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

View File

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

View File

@@ -24,7 +24,7 @@ class application_queue
if($_SESSION['current']->hasPriv("admin"))
{
$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";
$hResult = query_parameters($sQuery, $this->oApp->iAppId);

View File

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

View File

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

View File

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

View File

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

View File

@@ -422,7 +422,7 @@ function searchForApplication($search_words)
$sQuery = "SELECT *
FROM appFamily
WHERE appName != 'NONAME'
AND appFamily.queued = 'false'
AND appFamily.state = 'accepted'
AND (appName 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 */
$sQuery = "SELECT appName, appId FROM appFamily WHERE queued = 'false'";
$sQuery = "SELECT appName, appId FROM appFamily WHERE state = 'accepted'";
foreach ($excludeAppIdArray as $key=>$value)
{
$sQuery.=" AND appId != '".query_escape_string($value)."'";

View File

@@ -93,7 +93,7 @@ class version {
return;
$oApp = new application($this->iAppId);
if($oApp->sQueued != "false")
if($oApp->objectGetState() != 'accepted')
$this->sState = 'pending';
else
$this->sState = $this->mustBeQueued() ? 'queued' : 'accepted';
@@ -1189,13 +1189,7 @@ class version {
{
$oApp = new application($oVersion->iAppId);
/* Temporary workaround */
$sAppState = $oApp->sQueued;
if($sAppState == 'true')
$sAppState = 'queued';
else if($sAppState == 'false')
$sAppState = 'accepted';
if ($oVersion->sState == $sAppState)
if ($oVersion->sState == $oApp->objectGetState())
{
// set row color
$bgcolor = ($c % 2 == 0) ? "color0" : "color1";
@@ -1284,7 +1278,7 @@ class version {
/* List the versions submitted by a user. Ignore versions for queued applications */
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))
return false;

View File

@@ -41,7 +41,7 @@ create table appFamily (
catId int,
submitTime datetime NOT NULL,
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)
);