application: Rename 'queued' to 'state'

This commit is contained in:
Alexander Nicolaysen Sørnes
2007-12-12 22:25:01 +01:00
committed by Chris Morgan
parent aee69c1735
commit 176377f025
10 changed files with 63 additions and 64 deletions

View File

@@ -254,7 +254,7 @@ class appData
AND AND
appVersion.state = 'accepted' appVersion.state = 'accepted'
AND AND
appFamily.queued = 'false'"; appFamily.state = 'accepted'";
if($sQueued == "true") if($sQueued == "true")
$sQuery .= " AND appData.queued = 'true'"; $sQuery .= " AND appData.queued = 'true'";
@@ -286,7 +286,7 @@ class appData
appData.versionId = '0' appData.versionId = '0'
) )
AND AND
appFamily.queued = 'false'$sAppDataQueued$sSelectType) UNION appFamily.state = 'accepted'$sAppDataQueued$sSelectType) UNION
( (
SELECT COUNT(DISTINCT appData.id) as count FROM appData, SELECT COUNT(DISTINCT appData.id) as count FROM appData,
appFamily, appVersion WHERE appFamily, appVersion WHERE
@@ -298,7 +298,7 @@ class appData
AND AND
appVersion.state = 'accepted' appVersion.state = 'accepted'
AND AND
appFamily.queued = 'false'$sAppDataQueued$sSelectType)"; appFamily.state = 'accepted'$sAppDataQueued$sSelectType)";
if($sType) if($sType)
$hResult = query_parameters($sQuery, $sType, $sType); $hResult = query_parameters($sQuery, $sType, $sType);
@@ -374,7 +374,7 @@ class appData
AND AND
appVersion.state = 'accepted' appVersion.state = 'accepted'
AND AND
appFamily.queued = 'false' appFamily.state = 'accepted'
AND AND
appData.queued = '?' appData.queued = '?'
AND AND
@@ -409,7 +409,7 @@ class appData
appData.versionId = '0' appData.versionId = '0'
) )
AND AND
appFamily.queued = 'false' appFamily.state = 'accepted'
AND AND
appData.queued = '?' appData.queued = '?'
AND AND
@@ -427,7 +427,7 @@ class appData
AND AND
appVersion.state = 'accepted' appVersion.state = 'accepted'
AND AND
appFamily.queued = 'false' appFamily.state = 'accepted'
AND AND
appData.queued = '?' appData.queued = '?'
AND AND
@@ -499,7 +499,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->sQueued == "false") if($oApp->canEdit() && $oApp->objectGetQueueState() == 'accepted')
return FALSE; return FALSE;
else else
return TRUE; return TRUE;

View File

@@ -34,7 +34,7 @@ class Application {
var $sKeywords; var $sKeywords;
var $sDescription; var $sDescription;
var $sWebpage; var $sWebpage;
var $sQueued; private $sState;
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.
@@ -76,7 +76,7 @@ class Application {
//TODO: we should move the url to the appData table //TODO: we should move the url to the appData table
// and return an id into the appData table here // and return an id into the appData table here
$this->sWebpage = Url::normalize($oRow->webPage); $this->sWebpage = Url::normalize($oRow->webPage);
$this->sQueued = $oRow->queued; $this->sState = $oRow->state;
} }
/* fetch versions of this application, if there are any */ /* fetch versions of this application, if there are any */
@@ -133,12 +133,12 @@ class Application {
$hResult = query_parameters("INSERT INTO appFamily (appName, description, ". $hResult = query_parameters("INSERT INTO appFamily (appName, description, ".
"keywords, webPage, vendorId, catId, ". "keywords, webPage, vendorId, catId, ".
"submitTime, submitterId, ". "submitTime, submitterId, ".
"queued) VALUES (". "state) VALUES (".
"'?', '?', '?', '?', '?', '?', ?, '?', '?')", "'?', '?', '?', '?', '?', '?', ?, '?', '?')",
$this->sName, $this->sDescription, $this->sKeywords, $this->sName, $this->sDescription, $this->sKeywords,
$this->sWebpage, $this->iVendorId, $this->iCatId, $this->sWebpage, $this->iVendorId, $this->iCatId,
"NOW()", $_SESSION['current']->iUserId, "NOW()", $_SESSION['current']->iUserId,
$this->mustBeQueued() ? "true" : "false"); $this->mustBeQueued() ? 'queued' : 'accepted');
if($hResult) if($hResult)
{ {
$this->iAppId = query_appdb_insert_id(); $this->iAppId = query_appdb_insert_id();
@@ -273,10 +273,10 @@ class Application {
if(!$_SESSION['current']->canUnQueueApplication()) if(!$_SESSION['current']->canUnQueueApplication())
return; return;
if(query_parameters("UPDATE appFamily SET queued = '?', keywords = '?' WHERE appId = '?'", if(query_parameters("UPDATE appFamily SET state = '?', keywords = '?' WHERE appId = '?'",
"false", str_replace(" *** ","",$this->sKeywords), $this->iAppId)) 'accepted', str_replace(" *** ","",$this->sKeywords), $this->iAppId))
{ {
$this->sQueued = 'false'; $this->sState = 'accepted';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->mailSubmitter(); $this->mailSubmitter();
$this->SendNotificationMail(); $this->SendNotificationMail();
@@ -298,13 +298,13 @@ class Application {
return; return;
// If we are not in the queue, we can't move the application out of the queue. // If we are not in the queue, we can't move the application out of the queue.
if(!$this->sQueued == 'true') if($this->sState != 'queued')
return false; return false;
if(query_parameters("UPDATE appFamily SET queued = '?' WHERE appId = '?'", if(query_parameters("UPDATE appFamily SET state = '?' WHERE appId = '?'",
"rejected", $this->iAppId)) 'rejected', $this->iAppId))
{ {
$this->sQueued = 'rejected'; $this->sState = 'rejected';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->mailSubmitter("reject"); $this->mailSubmitter("reject");
$this->SendNotificationMail("reject"); $this->SendNotificationMail("reject");
@@ -326,10 +326,10 @@ class Application {
if(!$_SESSION['current']->canRequeueApplication($this)) if(!$_SESSION['current']->canRequeueApplication($this))
return false; return false;
if(query_parameters("UPDATE appFamily SET queued = '?' WHERE appId = '?'", if(query_parameters("UPDATE appFamily SET state = '?' WHERE appId = '?'",
"true", $this->iAppId)) 'queued', $this->iAppId))
{ {
$this->sQueued = 'true'; $this->sState = 'queued';
// we send an e-mail to interested people // we send an e-mail to interested people
$this->SendNotificationMail(); $this->SendNotificationMail();
@@ -416,7 +416,7 @@ class Application {
$sQuery = "SELECT DISTINCT count(appId) as total $sQuery = "SELECT DISTINCT count(appId) as total
FROM appVersion FROM appVersion
WHERE maintainer_rating = '?' WHERE maintainer_rating = '?'
AND queued='false'"; AND state = 'accepted'";
if($hResult = query_parameters($sQuery, $sRating)) if($hResult = query_parameters($sQuery, $sRating))
{ {
@@ -431,7 +431,7 @@ class Application {
$sQuery = "SELECT DISTINCT appId $sQuery = "SELECT DISTINCT appId
FROM appVersion FROM appVersion
WHERE maintainer_rating = '?' WHERE maintainer_rating = '?'
AND queued = 'false' AND state = 'accepted'
ORDER BY appId ASC LIMIT ?, ?"; ORDER BY appId ASC LIMIT ?, ?";
if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage)) if($hResult = query_parameters($sQuery, $sRating, $iOffset, $iItemsPerPage))
@@ -453,7 +453,7 @@ class Application {
switch($sAction) switch($sAction)
{ {
case "add": case "add":
if($this->sQueued == 'false') // Has been accepted. if($this->sState == 'accepted') // Has been accepted.
{ {
$sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname; $sSubject = $this->sName." has been added by ".$_SESSION['current']->sRealname;
$sMsg = $this->objectMakeUrl()."\n"; $sMsg = $this->objectMakeUrl()."\n";
@@ -533,7 +533,7 @@ class Application {
$oVendor = new vendor($this->iVendorId); $oVendor = new vendor($this->iVendorId);
$sVendorHelp = "The developer of the application. "; $sVendorHelp = "The developer of the application. ";
if(!$this->iAppId || $oVendor->sQueued != "false") if(!$this->iAppId || $oVendor->objectGetState() != 'accepted')
{ {
if(!$this->iAppId) if(!$this->iAppId)
{ {
@@ -555,7 +555,7 @@ class Application {
echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n"; echo '<tr valign=top><td class="color0">&nbsp;</td><td>',"\n";
echo $x->make_option_list("iAppVendorId", echo $x->make_option_list("iAppVendorId",
$this->iVendorId,"vendor","vendorId","vendorName", $this->iVendorId,"vendor","vendorId","vendorName",
array("vendor.queued", "false")); array('vendor.state', 'accepted'));
echo '</td></tr>',"\n"; echo '</td></tr>',"\n";
// url // url
@@ -644,7 +644,7 @@ class Application {
public function displayBundle() public function displayBundle()
{ {
$hResult = query_parameters("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ". $hResult = query_parameters("SELECT appFamily.appId, appName, description FROM appBundle, appFamily ".
"WHERE appFamily.queued='false' AND bundleId = '?' AND appBundle.appId = appFamily.appId", "WHERE appFamily.state = 'accepted' AND bundleId = '?' AND appBundle.appId = appFamily.appId",
$this->iAppId); $this->iAppId);
if(!$hResult || query_num_rows($hResult) == 0) if(!$hResult || query_num_rows($hResult) == 0)
{ {
@@ -834,8 +834,8 @@ class Application {
WHERE WHERE
submitterId = '?' submitterId = '?'
AND AND
queued = '?' state = '?'
ORDER BY appId", $iUserId, $bQueued ? "true" : "false"); ORDER BY appId", $iUserId, $bQueued ? 'queued' : 'accepted');
if(!$hResult || !query_num_rows($hResult)) if(!$hResult || !query_num_rows($hResult))
return false; return false;
@@ -903,9 +903,9 @@ class Application {
$sQuery = "SELECT appFamily.*, vendor.vendorName AS vendorName FROM appFamily, vendor WHERE $sQuery = "SELECT appFamily.*, vendor.vendorName AS vendorName FROM appFamily, vendor WHERE
appFamily.vendorId = vendor.vendorId appFamily.vendorId = vendor.vendorId
AND AND
appFamily.queued = '?'"; appFamily.state = '?'";
$sQueued = objectManager::getQueueString($bQueued, $bRejected); $sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !application::canEdit()) if($bQueued && !application::canEdit())
{ {
@@ -916,12 +916,12 @@ class Application {
$sQuery .= " AND appFamily.submitterId = '?' ORDER BY ? ?$sLimit"; $sQuery .= " AND appFamily.submitterId = '?' ORDER BY ? ?$sLimit";
if($sLimit) if($sLimit)
{ {
$hResult = query_parameters($sQuery, $sQueued, $hResult = query_parameters($sQuery, $sState,
$_SESSION['current']->iUserId, $sOrderBy, $_SESSION['current']->iUserId, $sOrderBy,
$sOrdering, $iStart, $iRows); $sOrdering, $iStart, $iRows);
} else } else
{ {
$hResult = query_parameters($sQuery, $sQueued, $hResult = query_parameters($sQuery, $sState,
$_SESSION['current']->iUserId, $sOrderBy, $_SESSION['current']->iUserId, $sOrderBy,
$sOrdering); $sOrdering);
} }
@@ -930,11 +930,11 @@ class Application {
$sQuery .= " ORDER BY ? ?$sLimit"; $sQuery .= " ORDER BY ? ?$sLimit";
if($sLimit) if($sLimit)
{ {
$hResult = query_parameters($sQuery, $sQueued, $sOrderBy, $sOrdering, $hResult = query_parameters($sQuery, $sState, $sOrderBy, $sOrdering,
$iStart, $iRows); $iStart, $iRows);
} else } else
{ {
$hResult = query_parameters($sQuery, $sQueued, $sOrderBy, $sOrdering); $hResult = query_parameters($sQuery, $sState, $sOrderBy, $sOrdering);
} }
} }
@@ -970,12 +970,17 @@ class Application {
$oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime))); $oTableRow->AddTextCell(print_date(mysqldatetime_to_unixtimestamp($this->sSubmitTime)));
$oTableRow->AddTextCell($oUser->objectMakeLink()); $oTableRow->AddTextCell($oUser->objectMakeLink());
$oTableRow->AddTextCell($sVendor); $oTableRow->AddTextCell($sVendor);
$oTableRow->AddTextCell(($this->sQueued == 'false') ? $this->objectMakeLink() : $this->sName); $oTableRow->AddTextCell(($this->sState == 'accepted') ? $this->objectMakeLink() : $this->sName);
$oOMTableRow = new OMTableRow($oTableRow); $oOMTableRow = new OMTableRow($oTableRow);
return $oOMTableRow; return $oOMTableRow;
} }
public function objectGetState()
{
return $this->sState;
}
public function canEdit() public function canEdit()
{ {
if($_SESSION['current']->hasPriv("admin")) if($_SESSION['current']->hasPriv("admin"))
@@ -987,7 +992,7 @@ class Application {
$this->iAppId)) $this->iAppId))
return TRUE; return TRUE;
if($this->sQueued != "false" && $this->iSubmitterId == if($this->sState != 'accepted' && $this->iSubmitterId ==
$_SESSION['current']->iUserId) $_SESSION['current']->iUserId)
{ {
return TRUE; return TRUE;
@@ -1056,7 +1061,7 @@ class Application {
public static function objectGetEntriesCount($bQueued, $bRejected) public static function objectGetEntriesCount($bQueued, $bRejected)
{ {
$sQueued = objectManager::getQueueString($bQueued, $bRejected); $sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !application::canEdit()) if($bQueued && !application::canEdit())
{ {
@@ -1067,13 +1072,13 @@ class Application {
$sQuery = "SELECT COUNT(appId) as count FROM appFamily WHERE $sQuery = "SELECT COUNT(appId) as count FROM appFamily WHERE
submitterId = '?' submitterId = '?'
AND AND
queued = '?'"; state = '?'";
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId, $hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$sQueued); $sState);
} else } else
{ {
$sQuery = "SELECT COUNT(appId) as count FROM appFamily WHERE queued = '?'"; $sQuery = "SELECT COUNT(appId) as count FROM appFamily WHERE state = '?'";
$hResult = query_parameters($sQuery, $sQueued); $hResult = query_parameters($sQuery, $sState);
} }
if(!$hResult) if(!$hResult)

View File

@@ -24,7 +24,7 @@ class application_queue
if($_SESSION['current']->hasPriv("admin")) if($_SESSION['current']->hasPriv("admin"))
{ {
$iVersionId = $this->oApp->aVersionsIds[0]; $iVersionId = $this->oApp->aVersionsIds[0];
} else if($this->oApp->sQueued == "rejected") } else if($this->oApp->objectGetState() == 'rejected')
{ {
$sQuery = "SELECT versionId FROM appVersion WHERE appId = '?' LIMIT 1"; $sQuery = "SELECT versionId FROM appVersion WHERE appId = '?' LIMIT 1";
$hResult = query_parameters($sQuery, $this->oApp->iAppId); $hResult = query_parameters($sQuery, $this->oApp->iAppId);

View File

@@ -47,7 +47,7 @@ class Category {
$sQuery = "SELECT appId $sQuery = "SELECT appId
FROM appFamily FROM appFamily
WHERE catId = '?' WHERE catId = '?'
AND queued = 'false' ORDER BY appName"; AND state = 'accepted' ORDER BY appName";
if($hResult = query_parameters($sQuery, $iCatId)) if($hResult = query_parameters($sQuery, $iCatId))
{ {
while($oRow = query_fetch_object($hResult)) while($oRow = query_fetch_object($hResult))

View File

@@ -62,7 +62,7 @@ class distribution {
WHERE testResults.state = 'accepted' AND WHERE testResults.state = 'accepted' AND
testResults.versionId = appVersion.versionId AND testResults.versionId = appVersion.versionId AND
appFamily.appId = appVersion.appId AND appFamily.appId = appVersion.appId AND
appFamily.queued = 'false' AND appFamily.state = 'accepted' AND
appVersion.state = 'accepted' AND appVersion.state = 'accepted' AND
distributionId = '?' distributionId = '?'
ORDER BY testedRating;"; ORDER BY testedRating;";

View File

@@ -213,7 +213,7 @@ class maintainer
if(!$this->bSuperMaintainer) if(!$this->bSuperMaintainer)
$oVersion = new version($this->iVersionId); $oVersion = new version($this->iVersionId);
if($oApp->sQueued != "false" || if($oApp->objectGetState() != 'accepted' ||
(!$this->bSuperMaintainer && $oVersion->objectGetState() != 'accepted')) (!$this->bSuperMaintainer && $oVersion->objectGetState() != 'accepted'))
$this->sQueued = "pending"; $this->sQueued = "pending";
else else

View File

@@ -629,7 +629,7 @@ class User {
return true; return true;
/* if the application isn't queued */ /* if the application isn't queued */
if($oApp->sQueued == 'false') if($oApp->objectGetState() == 'accepted')
return true; return true;
if($this->hasPriv("admin")) if($this->hasPriv("admin"))
@@ -637,7 +637,7 @@ class User {
/* if this user is the submitter and the application is queued */ /* if this user is the submitter and the application is queued */
if(($this->iUserId == $oApp->iSubmitterId) && if(($this->iUserId == $oApp->iSubmitterId) &&
($oApp->sQueued != 'false')) ($oApp->objectGetState() != 'accepted'))
return true; return true;
return false; return false;
@@ -659,7 +659,7 @@ class User {
/* and the application is still queued */ /* and the application is still queued */
/* the user can modify the app */ /* the user can modify the app */
if(($this->iUserId == $oApp->iSubmitterId) && if(($this->iUserId == $oApp->iSubmitterId) &&
($oApp->sQueued != 'false')) ($oApp->objectGetState() != 'accepted'))
return true; return true;
return false; return false;
@@ -683,7 +683,7 @@ class User {
return true; return true;
/* is this the user that submitted the application and is still queued */ /* is this the user that submitted the application and is still queued */
if(($oApp->sQueued != 'false') && ($oApp->iSubmitterId == $this->iUserId)) if(($oApp->objectGetState() != 'accepted') && ($oApp->iSubmitterId == $this->iUserId))
return true; return true;
return false; return false;
@@ -698,13 +698,13 @@ class User {
/* Can this user Requeue an application? */ /* Can this user Requeue an application? */
function canRequeueApplication($oApp) function canRequeueApplication($oApp)
{ {
if($oApp->sQueued == 'false') if($oApp->objectGetState() == 'accepted')
return false; return false;
if($this->hasPriv("admin")) if($this->hasPriv("admin"))
return true; return true;
if(($oApp->sQueued != 'false') && ($oApp->iSubmitterId == $this->iUserId)) if(($oApp->objectGetState() != 'accepted') && ($oApp->iSubmitterId == $this->iUserId))
return true; return true;
return false; return false;

View File

@@ -422,7 +422,7 @@ function searchForApplication($search_words)
$sQuery = "SELECT * $sQuery = "SELECT *
FROM appFamily FROM appFamily
WHERE appName != 'NONAME' WHERE appName != 'NONAME'
AND appFamily.queued = 'false' AND appFamily.state = 'accepted'
AND (appName LIKE '%" . $search_words . "%' AND (appName LIKE '%" . $search_words . "%'
OR keywords LIKE '%" . $search_words . "%'"; OR keywords LIKE '%" . $search_words . "%'";
@@ -449,7 +449,7 @@ function searchForApplicationFuzzy($search_words, $minMatchingPercent)
} }
/* add on all of the fuzzy matches we can find */ /* add on all of the fuzzy matches we can find */
$sQuery = "SELECT appName, appId FROM appFamily WHERE queued = 'false'"; $sQuery = "SELECT appName, appId FROM appFamily WHERE state = 'accepted'";
foreach ($excludeAppIdArray as $key=>$value) foreach ($excludeAppIdArray as $key=>$value)
{ {
$sQuery.=" AND appId != '".query_escape_string($value)."'"; $sQuery.=" AND appId != '".query_escape_string($value)."'";

View File

@@ -93,7 +93,7 @@ class version {
return; return;
$oApp = new application($this->iAppId); $oApp = new application($this->iAppId);
if($oApp->sQueued != "false") if($oApp->objectGetState() != 'accepted')
$this->sState = 'pending'; $this->sState = 'pending';
else else
$this->sState = $this->mustBeQueued() ? 'queued' : 'accepted'; $this->sState = $this->mustBeQueued() ? 'queued' : 'accepted';
@@ -1189,13 +1189,7 @@ class version {
{ {
$oApp = new application($oVersion->iAppId); $oApp = new application($oVersion->iAppId);
/* Temporary workaround */ if ($oVersion->sState == $oApp->objectGetState())
$sAppState = $oApp->sQueued;
if($sAppState == 'true')
$sAppState = 'queued';
else if($sAppState == 'false')
$sAppState = 'accepted';
if ($oVersion->sState == $sAppState)
{ {
// set row color // set row color
$bgcolor = ($c % 2 == 0) ? "color0" : "color1"; $bgcolor = ($c % 2 == 0) ? "color0" : "color1";
@@ -1284,7 +1278,7 @@ class version {
/* List the versions submitted by a user. Ignore versions for queued applications */ /* List the versions submitted by a user. Ignore versions for queued applications */
public static function listSubmittedBy($iUserId, $bQueued = true) public static function listSubmittedBy($iUserId, $bQueued = true)
{ {
$hResult = query_parameters("SELECT appFamily.appName, appVersion.versionName, appVersion.description, appVersion.versionId, appVersion.submitTime FROM appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND appVersion.submitterId = '?' AND appVersion.state = '?' AND appFamily.queued = '?'", $iUserId, $bQueued ? 'queued' : 'accepted', 'false'); $hResult = query_parameters("SELECT appFamily.appName, appVersion.versionName, appVersion.description, appVersion.versionId, appVersion.submitTime FROM appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND appVersion.submitterId = '?' AND appVersion.state = '?' AND appFamily.state = '?'", $iUserId, $bQueued ? 'queued' : 'accepted', 'accepted');
if(!$hResult || !query_num_rows($hResult)) if(!$hResult || !query_num_rows($hResult))
return false; return false;

View File

@@ -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',
queued enum('true','false','rejected') NOT NULL default 'false', state enum('accepted','queued','rejected') NOT NULL default 'accepted',
key(appId) key(appId)
); );