Add initial un-delete support

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-12-12 22:43:22 +01:00
committed by Chris Morgan
parent 5a31b9d5c8
commit 8c7bd3a5e9
28 changed files with 345 additions and 96 deletions

View File

@@ -54,6 +54,11 @@ class appData
} }
} }
function purge()
{
return $this->delete();
}
function delete() function delete()
{ {
if(!$this->canEdit()) if(!$this->canEdit())
@@ -499,7 +504,7 @@ class appData
} else if($this->iAppId) } else if($this->iAppId)
{ {
$oApp = new application($this->iAppId); $oApp = new application($this->iAppId);
if($oApp->canEdit() && $oApp->objectGetQueueState() == 'accepted') if($oApp->canEdit() && $oApp->objectGetState() == 'accepted')
return FALSE; return FALSE;
else else
return TRUE; return TRUE;

View File

@@ -100,15 +100,20 @@ class Application {
} }
} }
private function _internal_retrieve_all_versions($bIncludeObsolete = TRUE) private function _internal_retrieve_all_versions($bIncludeObsolete = TRUE, $bIncludeDeleted = false)
{ {
if(!$bIncludeObsolete) if(!$bIncludeObsolete)
$sObsolete = " AND obsoleteBy = '0'"; $sObsolete = " AND obsoleteBy = '0'";
else else
$sObsolete = ""; $sObsolete = "";
if($bIncludeDeleted)
$sExcludeDeleted = "";
else
$sExcludeDeleted = " AND state != 'deleted'";
$sQuery = "SELECT versionId FROM appVersion WHERE $sQuery = "SELECT versionId FROM appVersion WHERE
appId = '?'$sObsolete ORDER by versionName"; appId = '?'$sObsolete$sExcludeDeleted ORDER by versionName";
$hResult = query_parameters($sQuery, $this->iAppId); $hResult = query_parameters($sQuery, $this->iAppId);
return $hResult; return $hResult;
} }
@@ -236,8 +241,37 @@ class Application {
return true; return true;
} }
/** /**
* Deletes the application from the database. * Deletes the application from the database.
* and request the deletion of linked elements.
*/
public function purge()
{
$bSuccess = true;
/* make sure the current user has the appropriate permission to delete
this application */
if(!$_SESSION['current']->canDeleteApplication($this))
return false;
foreach($this->objectGetChildren(true) as $oChild)
{
if(!$oChild->purge())
$bSuccess = FALSE;
}
/* Flag the entry as deleted */
$sQuery = "DELETE FROM appFamily
WHERE appId = '?'
LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iAppId)))
$bSuccess = false;
return $bSuccess;
}
/**
* Falgs the application as deleted
* and request the deletion of linked elements. * and request the deletion of linked elements.
*/ */
public function delete() public function delete()
@@ -255,7 +289,8 @@ class Application {
$bSuccess = FALSE; $bSuccess = FALSE;
} }
$sQuery = "DELETE FROM appFamily /* Flag the entry as deleted */
$sQuery = "UPDATE appFamily SET state = 'deleted'
WHERE appId = '?' WHERE appId = '?'
LIMIT 1"; LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iAppId))) if(!($hResult = query_parameters($sQuery, $this->iAppId)))
@@ -1090,7 +1125,7 @@ class Application {
return $oRow->count; return $oRow->count;
} }
public function getVersions($bIncludeObsolete = TRUE) public function getVersions($bIncludeObsolete = TRUE, $bIncludeDeleted = false)
{ {
/* If no id is set we cannot query for the versions, but perhaps objects are already cached? */ /* If no id is set we cannot query for the versions, but perhaps objects are already cached? */
if(!$this->iAppId) if(!$this->iAppId)
@@ -1098,7 +1133,7 @@ class Application {
$aVersions = array(); $aVersions = array();
$hResult = $this->_internal_retrieve_all_versions($bIncludeObsolete); $hResult = $this->_internal_retrieve_all_versions($bIncludeObsolete, $bIncludeDeleted);
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
$aVersions[] = new version($oRow->versionId); $aVersions[] = new version($oRow->versionId);
@@ -1129,14 +1164,14 @@ class Application {
return $sMsg; return $sMsg;
} }
public function objectGetChildren() public function objectGetChildren($bIncludeDeleted = false)
{ {
$aChildren = array(); $aChildren = array();
/* Get versions */ /* Get versions */
foreach($this->getVersions() as $oVersion) foreach($this->getVersions(true, $bIncludeDeleted) as $oVersion)
{ {
$aChildren += $oVersion->objectGetChildren(); $aChildren += $oVersion->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oVersion; $aChildren[] = $oVersion;
} }
@@ -1150,7 +1185,7 @@ class Application {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oUrl = new url(0, $oRow); $oUrl = new url(0, $oRow);
$aChildren += $oUrl->objectGetChildren(); $aChildren += $oUrl->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oUrl; $aChildren[] = $oUrl;
} }
@@ -1164,7 +1199,7 @@ class Application {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oMaintainer = new maintainer(0, $oRow); $oMaintainer = new maintainer(0, $oRow);
$aChildren += $oMaintainer->objectGetChildren(); $aChildren += $oMaintainer->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oMaintainer; $aChildren[] = $oMaintainer;
} }

View File

@@ -113,6 +113,25 @@ class application_queue
$this->oApp->reject(); $this->oApp->reject();
} }
function purge()
{
$bSuccess = TRUE;
if(!$this->oApp->purge())
$bSuccess = FALSE;
/* When deleting a duplicate app in the application queue, the version is moved
to another app and so when application_queue::delete() is called there is
no version child to delete, so check if the versionId is valid */
if($this->oVersionQueue->oVersion->iVersionId)
{
if(!$this->oVersionQueue->purge())
$bSuccess = FALSE;
}
return $bSuccess;
}
function delete() function delete()
{ {
$bSuccess = TRUE; $bSuccess = TRUE;
@@ -132,9 +151,9 @@ class application_queue
return $bSuccess; return $bSuccess;
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return $this->oApp->objectGetChildren(); return $this->oApp->objectGetChildren($bIncludeDeleted);
} }
function objectGetSubmitterId() function objectGetSubmitterId()

View File

@@ -145,6 +145,11 @@ class Bug
} }
} }
function purge()
{
return $this->delete();
}
/** /**
* Deletes the Bug from the database. * Deletes the Bug from the database.
* and request its deletion from the filesystem (including the thumbnail). * and request its deletion from the filesystem (including the thumbnail).
@@ -273,7 +278,7 @@ class Bug
return array(null, null, null); return array(null, null, null);
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return array(); return array();
} }

View File

@@ -171,6 +171,10 @@ class Comment {
return true; return true;
} }
function purge()
{
return $this->delete();
}
/** /**
* Removes the current comment from the database. * Removes the current comment from the database.
@@ -456,7 +460,7 @@ class Comment {
return array($sSubject, $sMessage, $aRecipients); return array($sSubject, $sMessage, $aRecipients);
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return array(); return array();
} }

View File

@@ -142,6 +142,38 @@ class distribution {
} }
} }
function purge()
{
/* Is the current user allowed to delete this distribution? We allow
everyone to delete a queued, empty distribution, because it should be
deleted along with the last testData associated with it */
if(!($this->canEdit() || (!sizeof($this->aTestingIds) &&
$this->sState != 'accepted')))
return false;
// if the distribution has test results only enable an admin to delete
// the distribution
if(sizeof($this->aTestingIds) && !$_SESSION['current']->hasPriv("admin"))
return FALSE;
$bSuccess = TRUE;
foreach($this->objectGetChildren(true) as $oChild)
{
if(!$oChild->purge())
$bSuccess = FALSE;
}
// now delete the Distribution
$sQuery = "DELETE FROM distributions
WHERE distributionId = '?'
LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iDistributionId)))
$bSuccess = FALSE;
return $bSuccess;
}
// Delete Distributution. // Delete Distributution.
function delete() function delete()
{ {
@@ -166,7 +198,7 @@ class distribution {
} }
// now delete the Distribution // now delete the Distribution
$sQuery = "DELETE FROM distributions $sQuery = "UPDATE distributions SET state = 'deleted'
WHERE distributionId = '?' WHERE distributionId = '?'
LIMIT 1"; LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iDistributionId))) if(!($hResult = query_parameters($sQuery, $this->iDistributionId)))
@@ -175,7 +207,6 @@ class distribution {
return $bSuccess; return $bSuccess;
} }
// Move Distribution out of the queue. // Move Distribution out of the queue.
function unQueue() function unQueue()
{ {
@@ -217,10 +248,15 @@ class distribution {
return $this->delete(); return $this->delete();
} }
function getTestResults() function getTestResults($bIncludeDeleted = false)
{ {
if($bIncludeDeleted)
$sExcludeDeleted = "";
else
$sExcludeDeleted = " AND state != 'deleted'";
$aTests = array(); $aTests = array();
$sQuery = "SELECT * FROM testResults WHERE distributionId = '?'"; $sQuery = "SELECT * FROM testResults WHERE distributionId = '?'$sExcludeDeleted";
$hResult = query_parameters($sQuery, $this->iDistributionId); $hResult = query_parameters($sQuery, $this->iDistributionId);
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
@@ -229,13 +265,13 @@ class distribution {
return $aTests; return $aTests;
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
$aChildren = array(); $aChildren = array();
foreach($this->getTestResults() as $oTest) foreach($this->getTestResults($bIncludeDeleted) as $oTest)
{ {
$aChildren += $oTest->objectGetChildren(); $aChildren += $oTest->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oTest; $aChildren[] = $oTest;
} }

View File

@@ -63,7 +63,7 @@ class downloadurl
return $sReturn; return $sReturn;
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We have none */ /* We have none */
return array(); return array();
@@ -395,6 +395,11 @@ class downloadurl
return TRUE; return TRUE;
} }
function purge()
{
return $this->delete();
}
function delete() function delete()
{ {
if(!downloadurl::canEdit($this->iVersionId)) if(!downloadurl::canEdit($this->iVersionId))

View File

@@ -334,6 +334,11 @@ class maintainer
return TRUE; return TRUE;
} }
function purge()
{
return $this->delete();
}
function delete() function delete()
{ {
$sQuery = "DELETE from appMaintainers where maintainerId = '?'"; $sQuery = "DELETE from appMaintainers where maintainerId = '?'";
@@ -875,7 +880,7 @@ class maintainer
return array($aItemsPerPage, $iDefaultPerPage); return array($aItemsPerPage, $iDefaultPerPage);
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We have none */ /* We have none */
return array(); return array();

View File

@@ -61,7 +61,7 @@ class Monitor {
} }
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We have none */ /* We have none */
return array(); return array();
@@ -169,6 +169,11 @@ class Monitor {
return array($sSubject, $sMsg, $aMailTo); return array($sSubject, $sMsg, $aMailTo);
} }
function purge()
{
return $this->delete();
}
/** /**
* Removes the current Monitor from the database. * Removes the current Monitor from the database.
* Informs interested people about the deletion. * Informs interested people about the deletion.

View File

@@ -119,6 +119,10 @@ class Note {
return true; return true;
} }
function purge()
{
return $this->delete();
}
/** /**
* Removes the current note from the database. * Removes the current note from the database.
@@ -355,7 +359,7 @@ class Note {
return array(null, null, null); return array(null, null, null);
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return array(); return array();
} }

View File

@@ -125,6 +125,10 @@ class screenshot
} }
} }
function purge()
{
return $this->delete();
}
/** /**
* Deletes the screenshot from the database. * Deletes the screenshot from the database.
@@ -290,7 +294,7 @@ class screenshot
return $this->oScreenshotImage->get_width(); return $this->oScreenshotImage->get_width();
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We have none */ /* We have none */
return array(); return array();

View File

@@ -223,7 +223,29 @@ class testData{
return false; return false;
} }
} }
// Purge test results from the database
function purge()
{
// is the current user allowed to delete this test result?
$oVersion = new Version($this->iVersionId);
if(!$_SESSION['current']->hasPriv("admin") &&
!$_SESSION['current']->hasAppVersionModifyPermission($oVersion) &&
!(($_SESSION['current']->iUserId == $this->iSubmitterId) && !($this->sState == 'accepted')))
{
return false;
}
// now we delete the data
$sQuery = "DELETE FROM testResults
WHERE testingId = '?'
LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iTestingId)))
return false;
return true;
}
// Delete test results. // Delete test results.
function delete() function delete()
{ {
@@ -236,8 +258,8 @@ class testData{
return false; return false;
} }
// now delete the test data // now we flag the data as deleted
$sQuery = "DELETE FROM testResults $sQuery = "UPDATE testResults SET state = 'deleted'
WHERE testingId = '?' WHERE testingId = '?'
LIMIT 1"; LIMIT 1";
if(!($hResult = query_parameters($sQuery, $this->iTestingId))) if(!($hResult = query_parameters($sQuery, $this->iTestingId)))
@@ -1163,7 +1185,7 @@ class testData{
return TRUE; return TRUE;
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We have none */ /* We have none */
return array(); return array();

View File

@@ -22,6 +22,21 @@ class testData_queue
return $this->oTestData->create(); return $this->oTestData->create();
} }
function purge()
{
$bSuccess = $this->oTestData->purge();
/* We delete the distribution if it has not been approved and is not associated
with any other testData. Otherwise we would have to have a distribution
queue for admins to clean up unused, queued entries */
$this->oDistribution = new distribution($this->oDistribution->iDistributionId);
if(!sizeof($this->oDistribution->aTestingIds) &&
$this->oDistribution->canEdit())
$this->oDistribution->purge();
return $bSuccess;
}
function delete() function delete()
{ {
$bSuccess = $this->oTestData->delete(); $bSuccess = $this->oTestData->delete();
@@ -198,9 +213,9 @@ class testData_queue
return $this->oTestData->objectGetSubmitterId(); return $this->oTestData->objectGetSubmitterId();
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return $this->oTestData->objectGetChildren(); return $this->oTestData->objectGetChildren($bIncludeDeleted);
} }
function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction) function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction)

View File

@@ -86,6 +86,10 @@ class Url {
return true; return true;
} }
function purge()
{
return $this->delete();
}
/** /**
* Deletes the url from the database. * Deletes the url from the database.
@@ -506,7 +510,7 @@ class Url {
return array(null, null, null); return array(null, null, null);
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return array(); return array();
} }

View File

@@ -144,9 +144,32 @@ class Vendor {
return true; return true;
} }
/**
* Remove the vendor from the database.
*/
function purge()
{
if(sizeof($this->aApplicationsIds)>0)
{
return FALSE;
} else
{
$sQuery = "DELETE FROM vendor
WHERE vendorId = '?'
LIMIT 1";
if(query_parameters($sQuery, $this->iVendorId))
{
return TRUE;
}
return FALSE;
}
return false;
}
/** /**
* Deletes the vendor from the database. * Flag the vendor as deleted
*/ */
function delete() function delete()
{ {
@@ -155,7 +178,7 @@ class Vendor {
return FALSE; return FALSE;
} else } else
{ {
$sQuery = "DELETE FROM vendor $sQuery = "UPDATE vendor SET state = 'deleted'
WHERE vendorId = '?' WHERE vendorId = '?'
LIMIT 1"; LIMIT 1";
if(query_parameters($sQuery, $this->iVendorId)) if(query_parameters($sQuery, $this->iVendorId))
@@ -307,7 +330,7 @@ class Vendor {
return new mailOptions(); return new mailOptions();
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
/* We don't have any */ /* We don't have any */
return array(); return array();

View File

@@ -251,9 +251,40 @@ class version {
return true; return true;
} }
/**
* Removes the version from the database and
* requests the same action for child entries
*/
public function purge()
{
/* We need the versionId to continue */
if(!$this->iVersionId)
return;
/** /* is the current user allowed to delete this version? */
* Deletes the version from the database. if(!$_SESSION['current']->canDeleteVersion($this))
return false;
$bSuccess = TRUE;
foreach($this->objectGetChildren(TRUE) as $oChild)
{
if(!$oChild->purge())
$bSuccess = FALSE;
}
/* now remove the version from the DB */
$hResult = query_parameters("DELETE FROM appVersion
WHERE versionId = '?'
LIMIT 1", $this->iVersionId);
if(!$hResult)
$bSuccess = FALSE;
return $bSuccess;
}
/**
* Flags the version as deleted
* and request the deletion of linked elements. * and request the deletion of linked elements.
*/ */
public function delete() public function delete()
@@ -274,8 +305,8 @@ class version {
$bSuccess = FALSE; $bSuccess = FALSE;
} }
/* now delete the version */ /* now flag the version as deleted */
$hResult = query_parameters("DELETE FROM appVersion $hResult = query_parameters("UPDATE appVersion SET state = 'deleted'
WHERE versionId = '?' WHERE versionId = '?'
LIMIT 1", $this->iVersionId); LIMIT 1", $this->iVersionId);
if(!$hResult) if(!$hResult)
@@ -1591,17 +1622,22 @@ class version {
"From that page you can edit, delete or approve it into the AppDB.</p>\n"; "From that page you can edit, delete or approve it into the AppDB.</p>\n";
} }
public function getTestResults() public function getTestResults($bIncludeDeleted = false)
{ {
/* If we don't have an id we can query the database, but perhaps we /* If we don't have an id we can't query the database, but perhaps we
have some cached entries? */ have some cached entries? */
if(!$this->iVersionId) if(!$this->iVersionId)
return $this->aTestResults; return $this->aTestResults;
$aTests = array(); $aTests = array();
if($bIncludeDeleted)
$sExcludeDeleted = "";
else
$sExcludeDeleted = " AND state != 'deleted'";
/* Find test results */ /* Find test results */
$sQuery = "SELECT * FROM testResults WHERE versionId = '?'"; $sQuery = "SELECT * FROM testResults WHERE versionId = '?'$sExcludeDeleted";
$hResult = query_parameters($sQuery, $this->iVersionId); $hResult = query_parameters($sQuery, $this->iVersionId);
if(!$hResult) if(!$hResult)
@@ -1613,13 +1649,13 @@ class version {
return $aTests; return $aTests;
} }
public function objectGetChildren() public function objectGetChildren($bIncludeDeleted = false)
{ {
$aChildren = array(); $aChildren = array();
foreach($this->getTestResults() as $oTest) foreach($this->getTestResults($bIncludeDeleted) as $oTest)
{ {
$aChildren += $oTest->objectGetChildren(); $aChildren += $oTest->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oTest; $aChildren[] = $oTest;
} }
@@ -1633,7 +1669,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oMaintainer = new maintainer(0, $oRow); $oMaintainer = new maintainer(0, $oRow);
$aChildren += $oMaintainer->objectGetChildren(); $aChildren += $oMaintainer->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oMaintainer; $aChildren[] = $oMaintainer;
} }
@@ -1647,7 +1683,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oMonitor = new monitor(0, $oRow); $oMonitor = new monitor(0, $oRow);
$aChildren += $oMonitor->objectGetChildren(); $aChildren += $oMonitor->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oMonitor; $aChildren[] = $oMonitor;
} }
@@ -1661,7 +1697,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oNote = new note(0, $oRow); $oNote = new note(0, $oRow);
$aChildren += $oNote->objectGetChildren(); $aChildren += $oNote->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oNote; $aChildren[] = $oNote;
} }
@@ -1675,7 +1711,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oScreenshot = new screenshot(0, $oRow); $oScreenshot = new screenshot(0, $oRow);
$aChildren += $oScreenshot->objectGetChildren(); $aChildren += $oScreenshot->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oScreenshot; $aChildren[] = $oScreenshot;
} }
@@ -1683,7 +1719,7 @@ class version {
foreach($this->get_buglink_ids() as $iBugId) foreach($this->get_buglink_ids() as $iBugId)
{ {
$oBug = new bug($iBugId); $oBug = new bug($iBugId);
$aChildren += $oBug->objectGetChildren(); $aChildren += $oBug->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oBug; $aChildren[] = $oBug;
} }
@@ -1697,7 +1733,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oComment = new comment(0, $oRow); $oComment = new comment(0, $oRow);
$aChildren += $oComment->objectGetChildren(); $aChildren += $oComment->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oComment; $aChildren[] = $oComment;
} }
@@ -1711,7 +1747,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oUrl = new url(0, $oRow); $oUrl = new url(0, $oRow);
$aChildren += $oUrl->objectGetChildren(); $aChildren += $oUrl->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oUrl; $aChildren[] = $oUrl;
} }
@@ -1725,7 +1761,7 @@ class version {
while($oRow = mysql_fetch_object($hResult)) while($oRow = mysql_fetch_object($hResult))
{ {
$oDownload = new downloadurl(0, $oRow); $oDownload = new downloadurl(0, $oRow);
$aChildren += $oDownload->objectGetChildren(); $aChildren += $oDownload->objectGetChildren($bIncludeDeleted);
$aChildren[] = $oDownload; $aChildren[] = $oDownload;
} }

View File

@@ -72,6 +72,22 @@ class version_queue
$this->oTestDataQueue->update(); $this->oTestDataQueue->update();
} }
function purge()
{
$bSuccess = TRUE;
if(!$this->oVersion->purge())
$bSuccess = FALSE;
if(!$this->oTestDataQueue->purge())
$bSuccess = FALSE;
if($this->oDownloadUrl->iId && !$this->oDownloadUrl->purge())
$bSuccess = FALSE;
return $bSuccess;
}
function delete() function delete()
{ {
$bSuccess = TRUE; $bSuccess = TRUE;
@@ -100,9 +116,9 @@ class version_queue
return $this->oVersion->objectGetSubmitterId(); return $this->oVersion->objectGetSubmitterId();
} }
function objectGetChildren() function objectGetChildren($bIncludeDeleted = false)
{ {
return $this->oVersion->objectGetChildren(); return $this->oVersion->objectGetChildren($bIncludeDeleted);
} }
function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction) function objectGetMailOptions($sAction, $bMailSubmitter, $bParentAction)

View File

@@ -147,6 +147,11 @@ class voteManager
return TRUE; return TRUE;
} }
function purge()
{
return $this->delete();
}
public function delete() public function delete()
{ {
$bSuccess = TRUE; $bSuccess = TRUE;

View File

@@ -23,7 +23,7 @@ create table vendor (
vendorId int not null auto_increment, vendorId int not null auto_increment,
vendorName varchar(100) not null, vendorName varchar(100) not null,
vendorURL varchar(200), vendorURL varchar(200),
state enum('accepted','queued') NOT NULL default 'accepted', state enum('accepted','queued','deleted') NOT NULL default 'accepted',
key(vendorId) key(vendorId)
); );
@@ -41,7 +41,7 @@ create table appFamily (
catId int, catId int,
submitTime datetime NOT NULL, submitTime datetime NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
state enum('accepted','queued','rejected') NOT NULL default 'accepted', state enum('accepted','queued','rejected','deleted') NOT NULL default 'accepted',
key(appId) key(appId)
); );
@@ -60,7 +60,7 @@ create table appVersion (
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
license enum('Retail','Open Source','Freeware','Demo','Shareware'), license enum('Retail','Open Source','Freeware','Demo','Shareware'),
obsoleteBy int(11) NOT NULL default '0', obsoleteBy int(11) NOT NULL default '0',
state enum('accepted','queued','rejected','pending') NOT NULL default 'accepted', state enum('accepted','queued','rejected','pending','deleted') NOT NULL default 'accepted',
key(versionId), key(versionId),
index(appId) index(appId)
); );

View File

@@ -11,7 +11,7 @@ create table distributions (
url varchar(255) default NULL, url varchar(255) default NULL,
submitTime datetime NOT NULL, submitTime datetime NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
state enum('accepted','queued') NOT NULL default 'accepted', state enum('accepted','queued','deleted') NOT NULL default 'accepted',
key(distributionId), key(distributionId),
index(name) index(name)
); );

View File

@@ -20,6 +20,6 @@ create table testResults (
comments text, comments text,
submitTime datetime NOT NULL, submitTime datetime NOT NULL,
submitterId int(11) NOT NULL default '0', submitterId int(11) NOT NULL default '0',
state enum('accepted','queued','rejected','pending') NOT NULL default 'accepted', state enum('accepted','queued','rejected','pending','deleted') NOT NULL default 'accepted',
key(testingId) key(testingId)
); );

View File

@@ -43,7 +43,7 @@ function test_appData_listSubmittedBy()
} }
/* Clean up */ /* Clean up */
if(!$oDownloadUrl->delete()) if(!$oDownloadUrl->purge())
{ {
$bSuccess = false; $bSuccess = false;
error("Failed to delete oDownloadUrl!"); error("Failed to delete oDownloadUrl!");

View File

@@ -7,7 +7,7 @@ require_once(BASE.'include/version.php');
require_once(BASE.'include/application.php'); require_once(BASE.'include/application.php');
require_once("test_common.php"); require_once("test_common.php");
/* test that Application::delete() properly deletes data dependent on */ /* test that Application::purge() properly deletes data dependent on */
/* having an application */ /* having an application */
//TODO: need to test that we delete all urls, maintainers and other things //TODO: need to test that we delete all urls, maintainers and other things
// tested under an application // tested under an application
@@ -210,9 +210,9 @@ function test_application_getWithRating()
function delete_app_and_user($oApp, $oUser) function delete_app_and_user($oApp, $oUser)
{ {
$bSuccess = true; $bSuccess = true;
if(!$oApp->delete()) if(!$oApp->purge())
{ {
echo __FUNCTION__."() oApp->delete() failed\n"; echo __FUNCTION__."() oApp->purge() failed\n";
$bSuccess = false; $bSuccess = false;
} }

View File

@@ -40,9 +40,9 @@ function delete_version_and_parent_app($iVersionId)
$oVersion = new version($iVersionId); $oVersion = new version($iVersionId);
$oApp = new application($oVersion->iAppId); $oApp = new application($oVersion->iAppId);
if(!$oApp->delete()) if(!$oApp->purge())
{ {
echo __FUNCTION__."() oApp->delete() failed, returned false!\n"; echo __FUNCTION__."() oApp->purge() failed, returned false!\n";
} }
// remove the admin privleges only if the user didn't // remove the admin privleges only if the user didn't

View File

@@ -200,7 +200,7 @@ function test_maintainer_getAppsMaintained()
/* remove this application */ /* remove this application */
$oApp = new Application($iAppId); $oApp = new Application($iAppId);
$oApp->delete(); $oApp->purge();
$oUser->delete(); $oUser->delete();
@@ -461,7 +461,7 @@ function test_superMaintainerOnAppSubmit()
Maintainer::deleteMaintainer($oUser, $iAppId); Maintainer::deleteMaintainer($oUser, $iAppId);
$oApp->delete(); $oApp->purge();
$oUser->delete(); $oUser->delete();
return true; return true;
@@ -549,7 +549,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Failed to get list of maintainers!"); error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -560,7 +560,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Got super maintainer count of $iReceived instead of $iExpected!"); error("Got super maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -569,7 +569,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Failed to get list of maintainers!"); error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -608,7 +608,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Failed to get list of maintainers!"); error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -619,7 +619,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Got maintainer count of $iReceived instead of $iExpected!"); error("Got maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -628,7 +628,7 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Failed to get list of maintainers!"); error("Failed to get list of maintainers!");
$oUser->delete(); // delete the user $oUser->delete(); // delete the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
@@ -639,12 +639,12 @@ function test_maintainer_getMaintainersForAppIdVersionId()
{ {
error("Got maintainer count of $iReceived instead of $iExpected!"); error("Got maintainer count of $iReceived instead of $iExpected!");
$oUser->delete(); // clean up the user $oUser->delete(); // clean up the user
$oApp->delete(); // cleanup the application and its versions we created $oApp->purge(); // cleanup the application and its versions we created
return FALSE; return FALSE;
} }
if(!$oApp->delete()) if(!$oApp->purge())
echo __FUNCTION__." oApp->delete() failed\n"; echo __FUNCTION__." oApp->purge() failed\n";
$oUser->delete(); // clean up the user $oUser->delete(); // clean up the user

View File

@@ -15,7 +15,7 @@ class notifyContainer
function cleanup() function cleanup()
{ {
$this->oTestData->delete(); // deleted the created testData $this->oTestData->purge(); // deleted the created testData
$this->oMaintainer->delete(); // delete the created maintainer entry $this->oMaintainer->delete(); // delete the created maintainer entry
// (Should be deleted when the user is deleted) // (Should be deleted when the user is deleted)

View File

@@ -51,7 +51,7 @@ function test_class($sClassName, $aTestMethods)
{ {
error("Got '$hResult' instead of a valid query handle"); error("Got '$hResult' instead of a valid query handle");
error("FAILED\t\t$sClassName::$sClassName"); error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete(); $oTestObject->purge();
return FALSE; return FALSE;
} }
@@ -59,7 +59,7 @@ function test_class($sClassName, $aTestMethods)
{ {
error("Failed to fetch query object"); error("Failed to fetch query object");
error("FAILED\t\t$sClassName::$sClassName"); error("FAILED\t\t$sClassName::$sClassName");
$oTestObject->delete(); $oTestObject->purge();
return FALSE; return FALSE;
} }
@@ -70,7 +70,7 @@ function test_class($sClassName, $aTestMethods)
{ {
error("Got '$iReceived' instead of a valid id"); error("Got '$iReceived' instead of a valid id");
error("FAILED\t\t$sClassName::$sClassName()"); error("FAILED\t\t$sClassName::$sClassName()");
$oTestObject->delete(); $oTestObject->purge();
return FALSE; return FALSE;
} }
@@ -83,9 +83,9 @@ function test_class($sClassName, $aTestMethods)
if(!$oUser->addPriv("admin")) if(!$oUser->addPriv("admin"))
error("oUser->addPriv('admin') failed"); error("oUser->addPriv('admin') failed");
if(!$oTestObject->delete()) if(!$oTestObject->purge())
{ {
error("sClassName of '".$sClassName."' oTestObject->delete() failed!"); error("sClassName of '".$sClassName."' oTestObject->purge() failed!");
$oUser->delete(); $oUser->delete();
return false; return false;
} }
@@ -111,13 +111,13 @@ function test_class($sClassName, $aTestMethods)
{ {
error("Got $iReceived instead of >= $iExpected"); error("Got $iReceived instead of >= $iExpected");
error("FAILED\t\t$sClassName::$sMethod"); error("FAILED\t\t$sClassName::$sMethod");
$oTestObject->delete(); $oTestObject->purge();
return FALSE; return FALSE;
} }
/* Class specific clean-up */ /* Class specific clean-up */
cleanup($oTestObject); cleanup($oTestObject);
$oTestObject->delete(); $oTestObject->purge();
echo "PASSED\t\t$sClassName::$sMethod\n"; echo "PASSED\t\t$sClassName::$sMethod\n";
break; break;
@@ -150,11 +150,11 @@ function cleanup($oObject)
break; break;
case "version": case "version":
$oApp = new application($oObject->iAppId); $oApp = new application($oObject->iAppId);
$oApp->delete(); $oApp->purge();
break; break;
case "version_queue": case "version_queue":
$oApp = new application($oObject->oVersion->iAppId); $oApp = new application($oObject->oVersion->iAppId);
$oApp->delete(); $oApp->purge();
break; break;
} }
} }
@@ -253,6 +253,7 @@ function test_object_methods()
"canEdit", "canEdit",
"display", "display",
"getOutputEditorValues", "getOutputEditorValues",
"mustBeQueued",
"objectGetChildren", "objectGetChildren",
"objectGetEntries", "objectGetEntries",
"objectGetHeader", "objectGetHeader",
@@ -264,7 +265,7 @@ function test_object_methods()
"objectMakeLink", "objectMakeLink",
"objectMakeUrl", "objectMakeUrl",
"outputEditor", "outputEditor",
"mustBeQueued" "purge"
); );
$aTestClasses = array("application", $aTestClasses = array("application",

View File

@@ -35,14 +35,14 @@ function test_testData_getNewestTestidFromVersionId()
if($iExpected != $iReceived) if($iExpected != $iReceived)
{ {
error("Got testData id of $iReceived instead of $iExpected!"); error("Got testData id of $iReceived instead of $iExpected!");
$oOldTestData->delete(); $oOldTestData->purge();
$oNewTestData->delete(); $oNewTestData->purge();
$oUser->delete(); $oUser->delete();
return FALSE; return FALSE;
} }
$oOldTestData->delete(); $oOldTestData->purge();
$oNewTestData->delete(); $oNewTestData->purge();
$oUser->delete(); $oUser->delete();
return TRUE; return TRUE;