Improved version and applicaton class, deletes all linked elements
This commit is contained in:
2
TODO
2
TODO
@@ -8,8 +8,6 @@ WineHQ Application Database TODO List
|
|||||||
|
|
||||||
# check for existing email when user is creating a new account
|
# check for existing email when user is creating a new account
|
||||||
|
|
||||||
# when deleting an application or version we should delete linked entries (screenshots, comments, etc.)
|
|
||||||
|
|
||||||
# add a system that will allow users to monitor an app without becoming a maintainer.
|
# add a system that will allow users to monitor an app without becoming a maintainer.
|
||||||
|
|
||||||
# add wineversion, distro, source/package fields to the user_list table.
|
# add wineversion, distro, source/package fields to the user_list table.
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
require_once(BASE."include/version.php");
|
require_once(BASE."include/version.php");
|
||||||
require_once(BASE."include/vendor.php");
|
require_once(BASE."include/vendor.php");
|
||||||
|
require_once(BASE."include/url.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application class for handling applications.
|
* Application class for handling applications.
|
||||||
@@ -22,6 +23,7 @@ class Application {
|
|||||||
var $sSubmitTime;
|
var $sSubmitTime;
|
||||||
var $iSubmitterId;
|
var $iSubmitterId;
|
||||||
var $aVersionsIds; // an array that contains the versionId of every version linked to this app.
|
var $aVersionsIds; // an array that contains the versionId of every version linked to this app.
|
||||||
|
var $aUrlsIds; // an array that contains the screenshotId of every url linked to this version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor, fetches the data.
|
* constructor, fetches the data.
|
||||||
@@ -37,7 +39,7 @@ class Application {
|
|||||||
$sQuery = "SELECT appFamily.*, appVersion.versionId AS versionId
|
$sQuery = "SELECT appFamily.*, appVersion.versionId AS versionId
|
||||||
FROM appFamily, appVersion
|
FROM appFamily, appVersion
|
||||||
WHERE appFamily.appId = appVersion.appId
|
WHERE appFamily.appId = appVersion.appId
|
||||||
AND appFamily.appId = ".$iAppId;
|
AND appFamily.appId = ".$iAppId." ORDER BY versionName";
|
||||||
if($hResult = query_appdb($sQuery))
|
if($hResult = query_appdb($sQuery))
|
||||||
{
|
{
|
||||||
$this->aVersionsIds = array();
|
$this->aVersionsIds = array();
|
||||||
@@ -85,6 +87,23 @@ class Application {
|
|||||||
$this->bQueued = $oRow->queued;
|
$this->bQueued = $oRow->queued;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We fetch urlsIds.
|
||||||
|
*/
|
||||||
|
$this->aUrlsIds = array();
|
||||||
|
$sQuery = "SELECT id
|
||||||
|
FROM appData
|
||||||
|
WHERE type = 'url'
|
||||||
|
AND appId = ".$iAppId;
|
||||||
|
|
||||||
|
if($hResult = query_appdb($sQuery))
|
||||||
|
{
|
||||||
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
$this->aUrlsIds[] = $oRow->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,6 +230,11 @@ class Application {
|
|||||||
$oVersion = new Version($iVersionId);
|
$oVersion = new Version($iVersionId);
|
||||||
$oVersion->delete($bSilent);
|
$oVersion->delete($bSilent);
|
||||||
}
|
}
|
||||||
|
foreach($this->aUrlsIds as $iUrlId)
|
||||||
|
{
|
||||||
|
$oUrl = new Url($iUrlId);
|
||||||
|
$oUrl->delete($bSilent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(!$bSilent)
|
if(!$bSilent)
|
||||||
$this->mailSupermaintainers(true);
|
$this->mailSupermaintainers(true);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
require_once(BASE."include/note.php");
|
require_once(BASE."include/note.php");
|
||||||
require_once(BASE."include/comment.php");
|
require_once(BASE."include/comment.php");
|
||||||
|
require_once(BASE."include/url.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version class for handling versions.
|
* Version class for handling versions.
|
||||||
@@ -77,6 +78,7 @@ class Version {
|
|||||||
/*
|
/*
|
||||||
* We fetch commentsIds.
|
* We fetch commentsIds.
|
||||||
*/
|
*/
|
||||||
|
$this->aCommentsIds = array();
|
||||||
$sQuery = "SELECT commentId
|
$sQuery = "SELECT commentId
|
||||||
FROM appComments
|
FROM appComments
|
||||||
WHERE versionId = ".$iVersionId;
|
WHERE versionId = ".$iVersionId;
|
||||||
@@ -193,7 +195,7 @@ class Version {
|
|||||||
if ($iAppId && $iAppId!=$this->iAppId)
|
if ($iAppId && $iAppId!=$this->iAppId)
|
||||||
{
|
{
|
||||||
$sUpdate = compile_update_string(array('appId' => $iAppId));
|
$sUpdate = compile_update_string(array('appId' => $iAppId));
|
||||||
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE appId = ".$this->iAppId))
|
if (!query_appdb("UPDATE appVersion SET ".$sUpdate." WHERE versionId = ".$this->iVersionId))
|
||||||
return false;
|
return false;
|
||||||
$oAppBefore = new Application($this->iAppId);
|
$oAppBefore = new Application($this->iAppId);
|
||||||
$oAppAfter = new Application($iAppId);
|
$oAppAfter = new Application($iAppId);
|
||||||
@@ -217,25 +219,25 @@ class Version {
|
|||||||
LIMIT 1";
|
LIMIT 1";
|
||||||
if($hResult = query_appdb($sQuery))
|
if($hResult = query_appdb($sQuery))
|
||||||
{
|
{
|
||||||
foreach($aNotesIds as $iNoteId)
|
foreach($this->aNotesIds as $iNoteId)
|
||||||
{
|
{
|
||||||
$oNote = new Note($iNoteId);
|
$oNote = new Note($iNoteId);
|
||||||
$oNote->delete($bSilent);
|
$oNote->delete($bSilent);
|
||||||
}
|
}
|
||||||
foreach($aCommentsIds as $iCommentId)
|
foreach($this->aCommentsIds as $iCommentId)
|
||||||
{
|
{
|
||||||
$oComment = new Note($iCommentId);
|
$oComment = new Comment($iCommentId);
|
||||||
$oComment->delete($bSilent);
|
$oComment->delete($bSilent);
|
||||||
}
|
}
|
||||||
foreach($aScreenshotsIds as $iScreenshotId)
|
foreach($this->aScreenshotsIds as $iScreenshotId)
|
||||||
{
|
{
|
||||||
$oScreenshot = new Screenshot($iScreenshotId);
|
$oScreenshot = new Screenshot($iScreenshotId);
|
||||||
$oScreenshot->delete($bSilent);
|
$oScreenshot->delete($bSilent);
|
||||||
}
|
}
|
||||||
foreach($aUrlsIds as $iUrlId)
|
foreach($this->aUrlsIds as $iUrlId)
|
||||||
{
|
{
|
||||||
#FIXME: NOT IMPLEMENTED $oUrl = new Note($iUrlId);
|
$oUrl = new Url($iUrlId);
|
||||||
#FIXME: NOT IMPLEMENTED $oUrl->delete($bSilent);
|
$oUrl->delete($bSilent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$bSilent)
|
if(!$bSilent)
|
||||||
|
|||||||
Reference in New Issue
Block a user