Improved version and applicaton class, deletes all linked elements

This commit is contained in:
Jonathan Ernst
2005-02-11 01:34:16 +00:00
committed by WineHQ
parent 36846376b4
commit d9bf5bc528
3 changed files with 35 additions and 11 deletions

2
TODO
View File

@@ -8,8 +8,6 @@ WineHQ Application Database TODO List
# 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 wineversion, distro, source/package fields to the user_list table.

View File

@@ -5,6 +5,7 @@
require_once(BASE."include/version.php");
require_once(BASE."include/vendor.php");
require_once(BASE."include/url.php");
/**
* Application class for handling applications.
@@ -22,6 +23,7 @@ class Application {
var $sSubmitTime;
var $iSubmitterId;
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.
@@ -37,7 +39,7 @@ class Application {
$sQuery = "SELECT appFamily.*, appVersion.versionId AS versionId
FROM appFamily, appVersion
WHERE appFamily.appId = appVersion.appId
AND appFamily.appId = ".$iAppId;
AND appFamily.appId = ".$iAppId." ORDER BY versionName";
if($hResult = query_appdb($sQuery))
{
$this->aVersionsIds = array();
@@ -85,6 +87,23 @@ class Application {
$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->delete($bSilent);
}
foreach($this->aUrlsIds as $iUrlId)
{
$oUrl = new Url($iUrlId);
$oUrl->delete($bSilent);
}
}
if(!$bSilent)
$this->mailSupermaintainers(true);

View File

@@ -5,6 +5,7 @@
require_once(BASE."include/note.php");
require_once(BASE."include/comment.php");
require_once(BASE."include/url.php");
/**
* Version class for handling versions.
@@ -77,6 +78,7 @@ class Version {
/*
* We fetch commentsIds.
*/
$this->aCommentsIds = array();
$sQuery = "SELECT commentId
FROM appComments
WHERE versionId = ".$iVersionId;
@@ -193,7 +195,7 @@ class Version {
if ($iAppId && $iAppId!=$this->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;
$oAppBefore = new Application($this->iAppId);
$oAppAfter = new Application($iAppId);
@@ -217,25 +219,25 @@ class Version {
LIMIT 1";
if($hResult = query_appdb($sQuery))
{
foreach($aNotesIds as $iNoteId)
foreach($this->aNotesIds as $iNoteId)
{
$oNote = new Note($iNoteId);
$oNote->delete($bSilent);
}
foreach($aCommentsIds as $iCommentId)
foreach($this->aCommentsIds as $iCommentId)
{
$oComment = new Note($iCommentId);
$oComment = new Comment($iCommentId);
$oComment->delete($bSilent);
}
foreach($aScreenshotsIds as $iScreenshotId)
foreach($this->aScreenshotsIds as $iScreenshotId)
{
$oScreenshot = new Screenshot($iScreenshotId);
$oScreenshot->delete($bSilent);
}
foreach($aUrlsIds as $iUrlId)
foreach($this->aUrlsIds as $iUrlId)
{
#FIXME: NOT IMPLEMENTED $oUrl = new Note($iUrlId);
#FIXME: NOT IMPLEMENTED $oUrl->delete($bSilent);
$oUrl = new Url($iUrlId);
$oUrl->delete($bSilent);
}
}
if(!$bSilent)