From 095d228296329186c0274a41e04a4bf8a65d99e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Sat, 9 Jun 2007 15:44:46 +0000 Subject: [PATCH] Fix app/version rejection. Version queue requeue wasn't requeueing its downloadurl, downloadurl class was missing objectManager functionality. Rejected appData wasn't being accounted for. --- include/appData.php | 34 ++++++++++++++++++++++++++++++++-- include/downloadurl.php | 23 +++++++++++++++++++++-- include/version_queue.php | 9 ++++++++- tables/appdb_tables.sql | 2 +- 4 files changed, 62 insertions(+), 6 deletions(-) diff --git a/include/appData.php b/include/appData.php index 58c51ce..aa768f0 100644 --- a/include/appData.php +++ b/include/appData.php @@ -52,6 +52,34 @@ class appData return $hResult; } + function reQueue() + { + if(!$this->canEdit()) + return FALSE; + + $sQuery = "UPDATE appData SET queued = '?' WHERE id = '?'"; + $hResult = query_parameters($sQuery, "true", $this->iId); + + if(!$hResult) + return FALSE; + else + return TRUE; + } + + function reject() + { + if(!$this->canEdit()) + return FALSE; + + $sQuery = "UPDATE appData SET queued = '?' WHERE id = '?'"; + $hResult = query_parameters($sQuery, "rejected", $this->iId); + + if(!$hResult) + return FALSE; + else + return TRUE; + } + function update($bSilent = FALSE) { if(!$this->canEdit()) @@ -122,7 +150,7 @@ class appData } /* Get appData for a given version/application, optionally filter by type */ - function getData($iId, $sType, $bIsVersion = TRUE, $bQueued = FALSE) + function getData($iId, $sType, $bIsVersion = TRUE, $bQueued = FALSE, $bRejected = FALSE) { $iAppId = 0; $iVersionId = 0; @@ -132,9 +160,11 @@ class appData else $iAppId = $iId; + $sQueued = objectManager::getQueueString($bQueued, $bRejected); + $hResult = query_parameters("SELECT * FROM appData WHERE appId = '?' AND versionId = '?' AND TYPE = '?' AND queued = '?'", - $iAppId, $iVersionId, $sType, $bQueued ? "true" : "false"); + $iAppId, $iVersionId, $sType, $sQueued); if(!$hResult || !mysql_num_rows($hResult)) return FALSE; diff --git a/include/downloadurl.php b/include/downloadurl.php index 741cd4b..1ea345a 100644 --- a/include/downloadurl.php +++ b/include/downloadurl.php @@ -244,8 +244,13 @@ class downloadurl $sDownloadUrlDescription = $aValues["sDownloadUrlDescription"]; } else if($iVersionId) { - if($hResult = appData::getData($iVersionId, "downloadurl", - TRUE, TRUE)) + /* This illustrates the importance of converting downloadurl completely + to the objectManager model. If we don't get a match searching for + a queued entry, try finding a rejected one. */ + if(($hResult = appData::getData($iVersionId, "downloadurl", + TRUE, TRUE, FALSE)) || + $hResult = appData::getData($iVersionId, "downloadurl", + TRUE, TRUE, TRUE)) { $oRow = mysql_fetch_object($hResult); $sDownloadUrlUrl = $oRow->url; @@ -370,6 +375,20 @@ class downloadurl return TRUE; } + function reQueue() + { + $oAppData = new AppData($this->iId); + + return $oAppData->reQueue(); + } + + function reject() + { + $oAppData = new AppData($this->iId); + + return $oAppData->reject(); + } + function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0) { return appData::objectGetEntries($bQueued, $bRejected, $iRows, $iStart, diff --git a/include/version_queue.php b/include/version_queue.php index 9ac1c86..a338ddd 100644 --- a/include/version_queue.php +++ b/include/version_queue.php @@ -16,7 +16,13 @@ class version_queue { $iTestingId = testData::getNewestTestIdFromVersionId($iVersionId, $this->oVersion->sQueued); - if($hResult = appData::getData($iVersionId, "downloadurl", TRUE, TRUE)) + /* This illustrates the importance of converting downloadurl completely + to the objectManager model. If we don't get a match searching for + a queued entry, try finding a rejected one. */ + if(($hResult = appData::getData($iVersionId, "downloadurl", + TRUE, TRUE, FALSE)) || + $hResult = appData::getData($iVersionId, "downloadurl", + TRUE, TRUE, TRUE)) { if($oRow = mysql_fetch_object($hResult)) $iDownloadUrlId = $oRow->id; @@ -46,6 +52,7 @@ class version_queue { $this->oVersion->reQueue(); $this->oTestDataQueue->reQueue(); + $this->oDownloadUrl->reQueue(); } function reject() diff --git a/tables/appdb_tables.sql b/tables/appdb_tables.sql index 699a0b7..a527ebc 100644 --- a/tables/appdb_tables.sql +++ b/tables/appdb_tables.sql @@ -140,7 +140,7 @@ create table appData ( url varchar(255) default NULL, submitTime timestamp(14) NOT NULL, submitterId int(11) NOT NULL default '0', - queued enum('true','false') NOT NULL default 'false', + queued enum('true','false','rejected') NOT NULL default 'false', KEY id (id), KEY versionId (versionId) );