Use sState for objectGetEntries[Count]()

This commit is contained in:
Alexander Nicolaysen Sørnes
2008-01-20 21:31:15 +01:00
committed by Chris Morgan
parent 4297db9786
commit 9b92c2221c
20 changed files with 190 additions and 226 deletions

View File

@@ -49,7 +49,7 @@ class appData
$this->iVersionId = $oRow->versionId;
$this->sSubmitTime = $oRow->submitTime;
$this->iId = $iId;
$this->bQueued = ($oRow->sQueued == "false") ? false : true;
$this->bQueued = ($oRow->sState == 'accepted') ? false : true;
$this->sDescription = $oRow->description;
}
}
@@ -79,8 +79,8 @@ class appData
if(!$this->canEdit())
return FALSE;
$sQuery = "UPDATE appData SET queued = '?' WHERE id = '?'";
$hResult = query_parameters($sQuery, "true", $this->iId);
$sQuery = "UPDATE appData SET state = '?' WHERE id = '?'";
$hResult = query_parameters($sQuery, 'queued', $this->iId);
if(!$hResult)
return FALSE;
@@ -93,8 +93,8 @@ class appData
if(!$this->canEdit())
return FALSE;
$sQuery = "UPDATE appData SET queued = '?' WHERE id = '?'";
$hResult = query_parameters($sQuery, "rejected", $this->iId);
$sQuery = "UPDATE appData SET state = '?' WHERE id = '?'";
$hResult = query_parameters($sQuery, 'rejected', $this->iId);
if(!$hResult)
return FALSE;
@@ -123,9 +123,9 @@ class appData
$hResult = query_parameters("SELECT * FROM appData WHERE
appData.submitterId = '?'
AND
appData.queued = '?'
appData.state = '?'
ORDER BY appData.id",
$iUserId, $bQueued ? "true" : "false");
$iUserId, $bQueued ? 'queued' : 'accepted');
if(!$hResult || !query_num_rows($hResult))
return false;
@@ -194,11 +194,11 @@ class appData
else
$iAppId = $iId;
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
$sState = objectManager::getStateString($bQueued, $bRejected);
$hResult = query_parameters("SELECT * FROM appData WHERE appId = '?' AND
versionId = '?' AND TYPE = '?' AND queued = '?'",
$iAppId, $iVersionId, $sType, $sQueued);
versionId = '?' AND TYPE = '?' AND state = '?'",
$iAppId, $iVersionId, $sType, $sState);
if(!$hResult || !query_num_rows($hResult))
return FALSE;
@@ -206,27 +206,23 @@ class appData
return $hResult;
}
function objectGetEntriesCount($sQueued, $bRejected, $sType = null)
function objectGetEntriesCount($sState, $sType = null)
{
/* Not implemented for appData */
if($bRejected)
if($sState == 'rejected')
return FALSE;
/* Compatibility with objectManager */
if($sQueued === true)
$sQueued = "true";
if($sQueued === false)
$sQueued = "false";
$sSelectType = "";
if(($sQueued == "true" || $sQueued == "all") &&
if(($sState != 'accepted') &&
!$_SESSION['current']->hasPriv("admin"))
{
$sQuery = "SELECT COUNT(DISTINCT appData.id) as count FROM appData,
appMaintainers, appVersion, appFamily WHERE
appFamily.appId = appVersion.appId
AND
appMaintainers.state = 'accepted'
AND
appMaintainers.userId = '?'
AND
(
@@ -261,8 +257,8 @@ class appData
AND
appFamily.state = 'accepted'";
if($sQueued == "true")
$sQuery .= " AND appData.queued = 'true'";
if($sState != 'all')
$sQuery .= " AND appData.state = 'true'";
if($sType)
{
@@ -275,8 +271,8 @@ class appData
}
} else
{
if($sQueued == "true" || $sQueued == "false")
$sAppDataQueued = " AND appData.queued = '$sQueued'";
if($sState != 'all')
$sAppDataQueued = " AND appData.state = '$sState'";
else
$sAppDataQueued = '';
@@ -330,21 +326,24 @@ class appData
return $oTableRow;
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sType)
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sType)
{
/* Not implemented for appData */
if($bRejected)
if($sState == 'rejected')
return FALSE;
$sSelectType = "";
$sLimit = "";
if($bQueued && !$_SESSION['current']->hasPriv("admin"))
if($sState != 'accepted' && !$_SESSION['current']->hasPriv("admin"))
{
$sQuery = "SELECT DISTINCT appData.* FROM appData, appMaintainers,
appVersion, appFamily WHERE
appFamily.appId = appVersion.appId
AND
AND
appMaintainers.state = 'accepted'
AND
appMaintainers.userId = '?'
AND
(
@@ -381,22 +380,21 @@ class appData
AND
appFamily.state = 'accepted'
AND
appData.queued = '?'
appData.state = '?'
AND
appData.type = '?'
ORDER BY appFamily.appName";
if(!$iRows && !$iStart)
{
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$bQueued ? "true" : "false", $sType);
$sState, $sType);
} else
{
if(!$iRows)
$iRows = appData::objectGetEntriesCount($bQueued ? "true" : "false",
$bRejected, $sType);
$iRows = appData::objectGetEntriesCount($sState, $sType);
$sQuery .= " LIMIT ?,?";
$hResult = query_parameters($sQuery, $_SESSION['current']->iUserId,
$bQueued ? "true" : "false", $sType,
$sState, $sType,
$iStart, $iRows);
}
} else
@@ -416,7 +414,7 @@ class appData
AND
appFamily.state = 'accepted'
AND
appData.queued = '?'
appData.state = '?'
AND
appData.type = '?' ORDER BY appFamily.appName $sLimit
)
@@ -434,22 +432,21 @@ class appData
AND
appFamily.state = 'accepted'
AND
appData.queued = '?'
appData.state = '?'
AND
appData.type = '?' ORDER BY appFamily.appName $sLimit
)";
if(!$iRows && !$iStart)
{
$hResult = query_parameters($sQuery, $bQueued ? "true" : "false", $sType,
$bQueued ? "true" : "false", $sType);
$hResult = query_parameters($sQuery, $sState, $sType,
$sState, $sType);
} else
{
if(!$iRows)
$iRows = appData::objectGetEntriesCount($bQueued ? "true" : "false",
$bRejected, $sType);
$hResult = query_parameters($sQuery, $bQueued ? "true" : "false", $sType,
$iRows = appData::objectGetEntriesCount($sState, $sType);
$hResult = query_parameters($sQuery, $sState, $sType,
$iStart, $iRows,
$bQueued ? "true" : "false", $sType,
$sState, $sType,
$iStart, $iRows);
}
}

View File

@@ -931,7 +931,7 @@ class Application {
return $sLink;
}
public static function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "appId", $bAscending = TRUE)
public static function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "appId", $bAscending = TRUE)
{
$sLimit = "";
$sOrdering = $bAscending ? "ASC" : "DESC";
@@ -944,7 +944,7 @@ class Application {
/* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = maintainer::objectGetEntriesCount($bQueued, $bRejected);
$iRows = application::objectGetEntriesCount($sState);
}
$sQuery = "SELECT appFamily.*, vendor.vendorName AS vendorName FROM appFamily, vendor WHERE
@@ -952,12 +952,10 @@ class Application {
AND
appFamily.state = '?'";
$sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !application::canEdit())
if($sState != 'accepted' && !application::canEdit())
{
/* Without global edit rights a user can only view his rejected apps */
if(!$bRejected)
if($sState != 'rejected')
return FALSE;
$sQuery .= " AND appFamily.submitterId = '?' ORDER BY ? ?$sLimit";
@@ -1106,11 +1104,9 @@ class Application {
}
}
public static function objectGetEntriesCount($bQueued, $bRejected)
public static function objectGetEntriesCount($sState)
{
$sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !application::canEdit())
if($sState != 'accepted' && !application::canEdit())
{
/* Without edit rights users can only resubmit their rejected entries */
if(!$bRejected)

View File

@@ -378,14 +378,14 @@ class application_queue
return $this->oApp->objectGetItemsPerPage($sState);
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
return $this->oApp->objectGetEntriesCount($bQueued, $bRejected);
return $this->oApp->objectGetEntriesCount($sState);
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "appId", $bAscending = TRUE)
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "appId", $bAscending = TRUE)
{
return $this->oApp->objectGetEntries($bQueued, $bRejected, $iRows, $iStart,
return $this->oApp->objectGetEntries($sState, $iRows, $iStart,
$sOrderBy, $bAscending);
}

View File

@@ -48,7 +48,7 @@ class Bug
$this->iLinkId = $oRow->linkId;
$this->iBug_id = $oRow->bug_id;
$this->iVersionId = $oRow->versionId;
$this->bQueued = ($oRow->queued=="true") ? true : false;
$this->bQueued = ($oRow->state=='queued') ? true : false;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
/* lets fill in some blanks */
@@ -125,12 +125,12 @@ class Bug
/* passed the checks so lets insert the puppy! */
$hResult = query_parameters("INSERT INTO buglinks (versionId, bug_id, ".
"submitTime, submitterId, queued) ".
"submitTime, submitterId, state) ".
"VALUES('?', '?', ?, '?', '?')",
$this->iVersionId, $this->iBug_id,
"NOW()",
$_SESSION['current']->iUserId,
$this->bQueued ? "true":"false");
$this->bQueued ? 'queued' : 'accepted');
if($hResult)
{
$this->iLinkId = query_appdb_insert_id();
@@ -286,7 +286,7 @@ class Bug
/* Get a list of bugs submitted by a given user */
function listSubmittedBy($iUserId, $bQueued = true)
{
$hResult = query_parameters("SELECT appFamily.appName, buglinks.versionId, appVersion.versionName, buglinks.submitTime, buglinks.bug_id, buglinks.linkId FROM buglinks, appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND buglinks.versionId = appVersion.versionId AND buglinks.queued = '?' AND buglinks.submitterId = '?' ORDER BY buglinks.versionId", $bQueued ? "true" : "false", $iUserId);
$hResult = query_parameters("SELECT appFamily.appName, buglinks.versionId, appVersion.versionName, buglinks.submitTime, buglinks.bug_id, buglinks.linkId FROM buglinks, appFamily, appVersion WHERE appFamily.appId = appVersion.appId AND buglinks.versionId = appVersion.versionId AND buglinks.state = '?' AND buglinks.submitterId = '?' ORDER BY buglinks.versionId", $bQueued ? 'queued' : 'accepted', $iUserId);
if(!$hResult || !query_num_rows($hResult))
return FALSE;
@@ -365,7 +365,7 @@ class Bug
return $this->iLinkId;
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
function objectGetEntries($sState, $iRows = 0, $iStart = 0)
{
$sLimit = "";
@@ -373,19 +373,17 @@ class Bug
wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = bug::objectGetEntriesCount($bQueued, $bRejected);
$iRows = bug::objectGetEntriesCount($sState);
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
$sQuery = "select * from buglinks where queued = '?' LIMIT ?, ?";
$hResult = query_parameters($sQuery, $sQueued, $iStart, $iRows);
$sQuery = "select * from buglinks where state = '?' LIMIT ?, ?";
$hResult = query_parameters($sQuery, $sState, $iStart, $iRows);
return $hResult;
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
$sQueued = objectManager::getQueueString($bQueued, $bRejected);
$sQuery = "select count(*) as cnt from buglinks where queued = '?'";
$hResult = query_parameters($sQuery, $sQueued);
$sQuery = "select count(*) as cnt from buglinks where state = '?'";
$hResult = query_parameters($sQuery, $sState);
$oRow = mysql_fetch_object($hResult);
return $oRow->cnt;
}

View File

@@ -360,7 +360,7 @@ class Comment {
} else
{
echo "<li><a href=\"commentview.php?iAppId={$oRow->appId}&amp;iVersionId=".
"{$oRow->versionId}&iThreadId={$oRow->parentId}\" ".
"{$oRow->versionId}&amp;iThreadId={$oRow->parentId}\" ".
"name=\"Comment-{$oRow->commentId}\"> ".
$oRow->subject.' </a> by '.forum_lookup_user($oRow->userId).' on '.$oRow->time.' </li>'."\n";
}

View File

@@ -496,15 +496,15 @@ class distribution {
}
/* Get the total number of Distributions in the database */
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
$hResult = query_parameters("SELECT count(distributionId) as num_dists FROM
distributions WHERE state='?'",
$bQueued ? 'queued' : 'accepted');
$sState);
if($hResult)
{
@@ -555,27 +555,27 @@ class distribution {
return array('name');
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "name", $bAscending = TRUE)
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "name", $bAscending = TRUE)
{
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
/* Only users with edit privileges are allowed to view queued
items, so return NULL in that case */
if($bQueued && !distribution::canEdit())
if($sState != 'accepted' && !distribution::canEdit())
return NULL;
$sOrder = $bAscending ? "ASC" : "DESC";
/* If row limit is 0 we want to fetch all rows */
if(!$iRows)
$iRows = distribution::objectGetEntriesCount($bQueued, $bRejected);
$iRows = distribution::objectGetEntriesCount($sState);
$sQuery = "SELECT * FROM distributions
WHERE state = '?' ORDER BY $sOrderBy $sOrder LIMIT ?,?";
return query_parameters($sQuery, $bQueued ? 'queued' : 'accepted',
return query_parameters($sQuery, $sState,
$iStart, $iRows);
}

View File

@@ -25,7 +25,7 @@ class downloadurl
if(!$oRow)
{
$hResult = query_parameters("SELECT id, versionId, description, url,
submitTime, submitterId, queued FROM appData WHERE id = '?'",
submitTime, submitterId, state FROM appData WHERE id = '?'",
$iId);
if($hResult && query_num_rows($hResult))
@@ -40,7 +40,7 @@ class downloadurl
$this->sUrl = $oRow->url;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
$this->bQueued = ($oRow->queued == "true") ? TRUE : FALSE;
$this->bQueued = ($oRow->state == 'queued') ? TRUE : FALSE;
}
}
@@ -321,11 +321,11 @@ class downloadurl
return FALSE;
$hResult = query_parameters("INSERT INTO appData (versionId, type,
description, url, queued, submitTime, submitterId)
description, url, state, submitTime, submitterId)
VALUES('?', '?', '?', '?', '?', ?, '?')",
$this->iVersionId, "downloadurl", $this->sDescription,
$this->sUrl,
downloadurl::canEdit($this->iVersionId) ? "false" : "true",
downloadurl::canEdit($this->iVersionId) ? 'accepted' : 'queued',
"NOW()",
$_SESSION['current']->iUserId);
@@ -427,10 +427,9 @@ class downloadurl
return $oAppData->reject();
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
function objectGetEntries($sState, $iRows = 0, $iStart = 0)
{
return appData::objectGetEntries($bQueued, $bRejected, $iRows, $iStart,
"downloadurl");
return appData::objectGetEntries($sState, $iRows, $iStart, 'downloadurl');
}
function objectGetHeader()

View File

@@ -114,8 +114,8 @@ class queuedEntries
////////////////////
// queued screenshots
$sQuery = "select * from appData where type = 'screenshot' and versionId = '?' and queued = '?'";
$hResult = query_parameters($sQuery, $iVersionId, "true");
$sQuery = "select * from appData where type = 'screenshot' and versionId = '?' and state = '?'";
$hResult = query_parameters($sQuery, $iVersionId, 'queued');
while($oScreenshotRow = query_fetch_object($hResult))
{
$oScreenshot = new Screenshot(null, $oScreenshotRow);
@@ -157,7 +157,7 @@ class maintainer
var $sMaintainReason;
var $bSuperMaintainer;
var $aSubmitTime; //FIXME: should be 'sSubmitTime'
var $bQueued; //FIXME: Should be sQueued
var $sState;
var $sReplyText;
// parameters used in the queued data notification system
@@ -191,7 +191,7 @@ class maintainer
$this->sMaintainReason = $oRow->maintainReason;
$this->bSuperMaintainer = $oRow->superMaintainer;
$this->aSubmitTime = $oRow->submitTime;
$this->bQueued = $oRow->queued;
$this->sState = $oRow->state;
$this->iNotificationLevel = $oRow->notificationLevel;
$this->sNotificationTime = $oRow->notificationTime;
@@ -215,16 +215,16 @@ class maintainer
if($oApp->objectGetState() != 'accepted' ||
(!$this->bSuperMaintainer && $oVersion->objectGetState() != 'accepted'))
$this->sQueued = "pending";
$this->sState = "pending";
else
$this->sQueued = $this->mustBeQueued() ? "true" : "false";
$this->sState = $this->mustBeQueued() ? 'queued' : 'accepted';
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
"userId, maintainReason, superMaintainer, submitTime, queued) ".
"userId, maintainReason, superMaintainer, submitTime, state) ".
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
$this->iAppId, $this->iVersionId,
$this->iUserId, $this->sMaintainReason,
$this->bSuperMaintainer, "NOW()", $this->sQueued);
$this->bSuperMaintainer, "NOW()", $this->sState);
/* this objects id is the insert id returned by the database */
$this->iMaintainerId = query_appdb_insert_id();
@@ -250,7 +250,7 @@ class maintainer
((!$this->bSuperMaintainer && !$oUser->isMaintainer($this->iVersionId)) || $this->bSuperMaintainer))
{
/* unqueue the maintainer entry */
$hResult = query_parameters("UPDATE appMaintainers SET queued='false' WHERE userId = '?' AND maintainerId = '?'",
$hResult = query_parameters("UPDATE appMaintainers SET state='accepted' WHERE userId = '?' AND maintainerId = '?'",
$this->iUserId, $this->iMaintainerId);
if($hResult)
@@ -285,7 +285,7 @@ class maintainer
} else
{
/* Delete entry, but only if queued */
query_parameters("DELETE from appMaintainers WHERE userId = '?' AND maintainerId = '?' AND queued = 'true'", $this->iUserId, $this->iMaintainerId);
query_parameters("DELETE from appMaintainers WHERE userId = '?' AND maintainerId = '?' AND state = 'queued'", $this->iUserId, $this->iMaintainerId);
if($oUser->isSuperMaintainer($this->iAppId) && !$this->bSuperMaintainer)
$sStatusMessage = "<p>User is already a super maintainer of this application</p>\n";
@@ -394,10 +394,10 @@ class maintainer
return $hResult;
}
function ObjectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
function ObjectGetEntries($sState, $iRows = 0, $iStart = 0)
{
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
$sLimit = "";
@@ -410,24 +410,24 @@ class maintainer
/* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = maintainer::objectGetEntriesCount($bQueued, $bRejected);
$iRows = maintainer::objectGetEntriesCount($sState);
}
/* Excluding requests for queued apps and versions, as these will be
handled automatically */
$sQuery = "SELECT * FROM appMaintainers WHERE
appMaintainers.queued = '?'$sLimit";
appMaintainers.state = '?'$sLimit";
if($bQueued)
if($sState != 'accepted')
{
if($_SESSION['current']->hasPriv("admin"))
{
if($sLimit)
{
return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
return query_parameters($sQuery, $sState, $iStart, $iRows);
} else
{
return query_parameters($sQuery, $bQueued ? "true" : "false");
return query_parameters($sQuery, $sState);
}
} else
{
@@ -437,10 +437,10 @@ class maintainer
{
if($sLimit)
{
return query_parameters($sQuery, $bQueued ? "true" : "false", $iStart, $iRows);
return query_parameters($sQuery, $sState, $iStart, $iRows);
} else
{
return query_parameters($sQuery, $bQueued ? "true" : "false");
return query_parameters($sQuery, $sState);
}
}
}
@@ -456,8 +456,8 @@ class maintainer
function getMaintainerCountForUser($oUser, $bSuperMaintainer)
{
$sQuery = "SELECT count(*) as cnt from appMaintainers WHERE userid = '?' AND superMaintainer = '?'".
" AND queued ='?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $bSuperMaintainer ? "1" : "0", "false");
" AND state ='?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $bSuperMaintainer ? "1" : "0", 'accepted');
if(!$hResult)
return 0;
$oRow = query_fetch_object($hResult);
@@ -472,8 +472,8 @@ class maintainer
/* retrieve the list of application and order them by application name */
$hResult = query_parameters("SELECT appMaintainers.appId, versionId, superMaintainer, appName FROM ".
"appFamily, appMaintainers WHERE appFamily.appId = appMaintainers.appId ".
"AND userId = '?' AND appMaintainers.queued = '?' ORDER BY appName",
$oUser->iUserId, "false");
"AND userId = '?' AND appMaintainers.state = '?' ORDER BY appName",
$oUser->iUserId, 'accepted');
if(!$hResult || query_num_rows($hResult) == 0)
return NULL;
@@ -488,18 +488,18 @@ class maintainer
return $aAppsMaintained;
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
/* Excluding requests for queued apps and versions, as these are handled
automatically. One SELECT for super maintainers, one for maintainers. */
$sQuery = "SELECT COUNT(maintainerId) as count FROM appMaintainers WHERE
appMaintainers.queued = '?'";
appMaintainers.state = '?'";
if(!($hResult = query_parameters($sQuery, $bQueued ? "true" : "false")))
if(!($hResult = query_parameters($sQuery, $sState)))
return FALSE;
if($oRow = query_fetch_object($hResult))
@@ -510,15 +510,6 @@ class maintainer
return $iCount;
}
/* see how many maintainer entries we have in the database */
function getMaintainerCount()
{
$sQuery = "SELECT count(*) as maintainers FROM appMaintainers where queued='false'";
$hResult = query_parameters($sQuery);
$oRow = query_fetch_object($hResult);
return $oRow->maintainers;
}
/* see how many unique maintainers we actually have */
function getNumberOfMaintainers()
{
@@ -536,12 +527,12 @@ class maintainer
/* otherwise check if we maintain this specific version */
if($iVersionId)
{
$sQuery = "SELECT * FROM appMaintainers WHERE userId = '?' AND versionId = '?' AND queued = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $iVersionId, "false");
$sQuery = "SELECT * FROM appMaintainers WHERE userId = '?' AND versionId = '?' AND state = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $iVersionId, 'accepted');
} else // are we maintaining any version ?
{
$sQuery = "SELECT * FROM appMaintainers WHERE userId = '?' AND queued = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, "false");
$sQuery = "SELECT * FROM appMaintainers WHERE userId = '?' AND state = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, 'accepted');
}
if(!$hResult)
return false;
@@ -553,12 +544,12 @@ class maintainer
{
if($iAppId)
{
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1' AND queued = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $iAppId, "false");
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1' AND state = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, $iAppId, 'accepted');
} else /* are we super maintainer of any applications? */
{
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND superMaintainer = '1' AND queued = '?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, "false");
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND superMaintainer = '1' AND state'?'";
$hResult = query_parameters($sQuery, $oUser->iUserId, 'accepted');
}
if(!$hResult)
return false;
@@ -575,7 +566,7 @@ class maintainer
{
$hResult = query_parameters("SELECT userId from appMaintainers, appVersion
WHERE
appMaintainers.queued = 'false'
appMaintainers.state = 'accepted'
AND
appVersion.versionId = '?'
AND
@@ -595,7 +586,7 @@ class maintainer
{
$hResult = query_parameters("SELECT userId
FROM appMaintainers
WHERE appId = '?' AND queued = 'false'",
WHERE appId = '?' AND state = 'accepted'",
$iAppId);
}
@@ -609,8 +600,8 @@ class maintainer
{
$sQuery = "SELECT userId FROM ".
"appMaintainers WHERE appId = '?' " .
"AND superMaintainer = '1' AND queued='?';";
$hResult = query_parameters($sQuery, $iAppId, "false");
"AND superMaintainer = '1' AND state='?';";
$hResult = query_parameters($sQuery, $iAppId, 'accepted');
$aUserIds = array();
$c = 0;
while($oRow = query_fetch_object($hResult))
@@ -909,7 +900,7 @@ class maintainer
{
$oSubmitter = new user($this->iSubmitterId);
$sVerb = $this->sQueued == "true" ? "rejected" : "removed";
$sVerb = $this->sState == 'queued' ? 'rejected' : 'removed';
if($this->bSuperMaintainer)
{
@@ -929,7 +920,7 @@ class maintainer
{
case "delete":
$sSubject = "Maintainership for $sFor $sVerb";
if($this->sQueued == "true")
if($this->sState == 'queued')
{
$sMsg = "Your request to be a maintainer of '$sFor'".
" has been denied.";
@@ -949,7 +940,7 @@ class maintainer
if(!$bParentAction)
{
$sSubject = "Maintainership for $sFor $sVerb";
if($this->bQueued == "false")
if($this->sState == 'accepted')
{
$sMsg = $oSubmitter->sRealName." has been removed as a ".
"maintainer of $sFor.";
@@ -1340,7 +1331,7 @@ class maintainer
function notifyMaintainersOfQueuedData()
{
// retrieve all of the maintainers
$hResult = maintainer::objectGetEntries(false, false);
$hResult = maintainer::objectGetEntries('accepted');
// echo "Processing ".query_num_rows($hResult)." maintainers\n";

View File

@@ -288,7 +288,7 @@ class Monitor {
return "";
}
function objectGetEntries($bQueued, $bRejected)
function objectGetEntries($sState)
{
$hResult = query_parameters("SELECT * FROM appMonitors");
@@ -298,7 +298,7 @@ class Monitor {
return $hResult;
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
$hResult = query_parameters("SELECT COUNT(DISTINCT monitorId) as count
FROM appMonitors");

View File

@@ -315,7 +315,7 @@ class Note {
// do not support queuing at this point
// TODO: we have no permissions scope on retrieving entries
// as notes are typically only added to unqueued versions
function objectGetEntries($bQueued, $bRejected)
function objectGetEntries($sState)
{
$sQuery = "select * from appNotes";
$hResult = query_parameters($sQuery);

View File

@@ -283,14 +283,14 @@ class ObjectManager
/* Has the user chosen a particular field to sort by? If not we want to use the default */
if($this->oSortInfo->sCurrentSort)
{
$hResult = $oObject->objectGetEntries($this->getIsQueue(), $this->sState == 'rejected',
$hResult = $oObject->objectGetEntries($this->sState,
$this->oMultiPage->iItemsPerPage,
$this->oMultiPage->iLowerLimit,
$this->oSortInfo->sCurrentSort,
$this->oSortInfo->bAscending);
} else
{
$hResult = $oObject->objectGetEntries($this->getIsQueue(), $this->sState == 'rejected',
$hResult = $oObject->objectGetEntries($this->sState,
$this->oMultiPage->iItemsPerPage,
$this->oMultiPage->iLowerLimit);
}
@@ -299,12 +299,12 @@ class ObjectManager
/* Has the user chosen a particular field to sort by? If not we want to use the default */
if($this->oSortInfo->sCurrentSort)
{
$hResult = $oObject->objectGetEntries($this->getIsQueue(), $this->sState == 'rejected',
$hResult = $oObject->objectGetEntries($this->sState,
$this->oSortInfo->sCurrentSort,
$this->oSortInfo->bAscending);
} else
{
$hResult = $oObject->objectGetEntries($this->getIsQueue(), $this->sState == 'rejected');
$hResult = $oObject->objectGetEntries($this->sState);
}
}
@@ -783,7 +783,7 @@ class ObjectManager
$oObject = $this->getObject();
$hResult = $oObject->objectGetEntries(true, true);
$hResult = $oObject->objectGetEntries('rejected');
if(!$hResult)
{
@@ -899,7 +899,7 @@ class ObjectManager
}
/* We only allow moving to non-queued objects */
if(!$hResult = $oObject->objectGetEntries(false, false))
if(!$hResult = $oObject->objectGetEntries('accepted'))
{
echo "Failed to get list of objects.<br />\n";
return FALSE;
@@ -1381,7 +1381,7 @@ class ObjectManager
$sControls .= "</form></p>";
}
$iTotalEntries = $oObject->objectGetEntriesCount($this->getIsQueue(), $this->sState == 'rejected');
$iTotalEntries = $oObject->objectGetEntriesCount($this->sState);
$iNumPages = ceil($iTotalEntries / $iItemsPerPage);
if($iNumPages == 0)
$iNumPages = 1;

View File

@@ -57,7 +57,7 @@ class screenshot
$this->iAppId = $oRow->appId;
$this->iVersionId = $oRow->versionId;
$this->sUrl = $oRow->url;
$this->bQueued = ($oRow->queued=="true")?true:false;
$this->bQueued = ($oRow->state=='queued')?true:false;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
$this->hFile = null;
@@ -71,11 +71,11 @@ class screenshot
function create()
{
$hResult = query_parameters("INSERT INTO appData
(versionId, type, description, queued, submitTime, submitterId)
(versionId, type, description, state, submitTime, submitterId)
VALUES('?', '?', '?', '?', ?, '?')",
$this->iVersionId, "screenshot",
$this->sDescription,
$this->mustBeQueued() ? "true" : "false",
$this->mustBeQueued() ? 'queued' : 'accepted',
"NOW()",
$_SESSION['current']->iUserId);
if($hResult)
@@ -173,8 +173,8 @@ class screenshot
if(!$this->bQueued)
return false;
if(query_parameters("UPDATE appData SET queued = '?' WHERE id='?'",
"false", $this->iScreenshotId))
if(query_parameters("UPDATE appData SET state = '?' WHERE id='?'",
'accepted', $this->iScreenshotId))
{
$this->bQueued = false;
// we send an e-mail to interested people
@@ -479,7 +479,7 @@ class screenshot
WHERE appData.versionId = appVersion.versionId
AND appVersion.appId = '?'
AND type = 'screenshot'
AND appData.queued = 'false'
AND appData.state = 'accepted'
ORDER BY rand", $iAppId);
} else if ($iVersionId) // we want a random screenshot for this version
{
@@ -487,7 +487,7 @@ class screenshot
FROM appData
WHERE versionId = '?'
AND type = 'screenshot'
AND queued = 'false'
AND state = 'accepted'
ORDER BY rand", $iVersionId);
}
@@ -545,7 +545,7 @@ class screenshot
WHERE appVersion.versionId = appData.versionId
AND type = 'screenshot'
AND appVersion.appId = '?'
AND appData.queued = '?'", $iAppId, $bQueued);
AND appData.state = '?'", $iAppId, ($bQueued == 'false') ? 'accepted' : 'queued');
}
/*
* We want all screenshots for this version.
@@ -557,7 +557,7 @@ class screenshot
WHERE appVersion.versionId = appData.versionId
AND type = 'screenshot'
AND appData.versionId = '?'
AND appData.queued = '?'", $iVersionId, $bQueued);
AND appData.state = '?'", $iVersionId, ($bQueued == 'false') ? 'accepted' : 'queued');
} else
{
return false;
@@ -649,16 +649,15 @@ class screenshot
echo "</tr></table></div><br />\n";
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0)
function objectGetEntries($sState, $iRows = 0, $iStart = 0)
{
return appData::objectGetEntries($bQueued, $bRejected, $iRows, $iStart,
return appData::objectGetEntries($sState, $iRows, $iStart,
"screenshot");
}
function objectGetEntriesCount($bQueued, $bRejected, $iRows = 0, $iStart = 0)
function objectGetEntriesCount($sState, $iRows = 0, $iStart = 0)
{
return appData::objectGetEntriesCount($bQueued, $bRejected,
'screenshot');
return appData::objectGetEntriesCount($sState, 'screenshot');
}
function objectGetHeader()

View File

@@ -9,34 +9,33 @@ function global_admin_menu() {
$g = new htmlmenu("Global Admin");
$g->add("App Queue (".application::objectGetEntriesCount(true, false).")",
$g->add("App Queue (".application::objectGetEntriesCount('queued').")",
BASE.'objectManager.php?sClass=application_queue&sState=queued&sTitle='.
'Application%20Queue');
$g->add("Version Queue (".version::objectGetEntriesCount(true, false).")",
$g->add("Version Queue (".version::objectGetEntriesCount('queued').")",
BASE.'objectManager.php?sClass=version_queue&sState=queued&sTitle='.
'Version%20Queue');
$g->add("Screenshot Queue (".appData::objectGetEntriesCount("true",
false, "screenshot").")",
$g->add("Screenshot Queue (".appData::objectGetEntriesCount('queued', "screenshot").")",
BASE.'objectManager.php?sClass=screenshot&sState=queued&sTitle='.
'Screenshot%20Queue');
$g->add("Maintainer Queue (".Maintainer::objectGetEntriesCount(true, false).")",
$g->add("Maintainer Queue (".Maintainer::objectGetEntriesCount('queued').")",
BASE.'objectManager.php?sClass=maintainer&sState=queued&sTitle='.
'Maintainer%20Queue');
$g->add("Test Results Queue (".testData::objectGetEntriesCount(true, false).")",
$g->add("Test Results Queue (".testData::objectGetEntriesCount('queued').")",
BASE.'objectManager.php?sClass=testData_queue&sState=queued&sTitle='.
'Test%20Results%20Queue');
$g->add("Bug Link Queue (".bug::objectGetEntriesCount(true, false).")",
$g->add("Bug Link Queue (".bug::objectGetEntriesCount('queued').")",
BASE.'objectManager.php?sClass=bug&sState=queued&sTitle='.
'Bug%20Link%20Queue');
$g->addmisc("&nbsp;");
$g->add("Maintainer Entries (".Maintainer::getMaintainerCount().")",
$g->add("Maintainer Entries (".Maintainer::objectGetEntriesCount('accepted').")",
BASE."admin/adminMaintainers.php");
$g->add("Bug Links (".bug::objectGetEntriesCount(false, false).")",
$g->add("Bug Links (".bug::objectGetEntriesCount('accepted').")",
BASE."objectManager.php?sClass=bug&sTitle=".
"Bug%20Links");
$g->add("Test Results (".testData::objectGetEntriesCount(false, false).")",
$g->add("Test Results (".testData::objectGetEntriesCount('accepted').")",
BASE."objectManager.php?sClass=testData&sTitle=".
"View%20Test%20Results");
$g->add("Users Management", BASE."admin/adminUsers.php");
@@ -45,15 +44,13 @@ function global_admin_menu() {
$g->addmisc("&nbsp;");
$g->add("Rejected Applications (".application::objectGetEntriesCount(true,
true).")",
$g->add("Rejected Applications (".application::objectGetEntriesCount('rejected').")",
BASE.'objectManager.php?sClass=application_queue&sState=rejected&'.
'sTitle=Rejected%20Applications');
$g->add("Rejected Versions (".version::objectGetEntriesCount(true, true).")",
$g->add("Rejected Versions (".version::objectGetEntriesCount('rejected').")",
BASE.'objectManager.php?sClass=version_queue&sState=rejected&'.
'sTitle=Rejected%20Versions');
$g->add("Rejected Test Results (".testData::objectGetEntriesCount(true,
true).")",
$g->add("Rejected Test Results (".testData::objectGetEntriesCount('rejected').")",
BASE.'objectManager.php?sClass=testData_queue&sState=rejected&'.
'sTitle=Rejected%20Test%20Results');

View File

@@ -1139,13 +1139,13 @@ class testData{
return $oRow->cnt;
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
$oTest = new testData();
$sState = objectManager::getStateString($bQueued, $bRejected);
if($bQueued && !$oTest->canEdit())
{
if($bRejected)
if($sState == 'rejected')
{
$sQuery = "SELECT COUNT(testingId) AS count FROM
testResults WHERE
@@ -1160,7 +1160,7 @@ class testData{
AND
appMaintainers.userId = '?'
AND
appMaintainers.queued = 'false'
appMaintainers.state = 'accepted'
AND
(
(
@@ -1197,10 +1197,9 @@ class testData{
return $oRow->count;
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "testingId")
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId")
{
$oTest = new testData();
$sState = objectManager::getStateString($bQueued, $bRejected);
$sLimit = "";
@@ -1212,12 +1211,12 @@ class testData{
/* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = testData::objectGetEntriesCount($bQueued, $bRejected);
$iRows = testData::objectGetEntriesCount($sState);
}
if($bQueued && !$oTest->canEdit())
if($sState != 'accepted' && !$oTest->canEdit())
{
if($bRejected)
if($sState == 'rejected')
{
$sQuery = "SELECT testResults.* FROM testResults WHERE
testResults.submitterId = '?'
@@ -1245,7 +1244,7 @@ class testData{
)
)
AND
appMaintainers.queued = 'false'
appMaintainers.state = 'accepted'
AND
testResults.state = '?' ORDER BY ?$sLimit";
}

View File

@@ -137,14 +137,14 @@ class testData_queue
$this->oTestData->objectDisplayAddItemHelp();
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "testingId")
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "testingId")
{
return $this->oTestData->objectGetEntries($bQueued, $bRejected, $iRows, $iStart, $sOrderBy);
return $this->oTestData->objectGetEntries($sState, $iRows, $iStart, $sOrderBy);
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
return testData::objectGetEntriesCount($bQueued, $bRejected);
return testData::objectGetEntriesCount($sState);
}
function objectGetHeader()

View File

@@ -44,7 +44,7 @@ class Url {
$this->iAppId = $oRow->appId;
$this->iVersionId = $oRow->versionId;
$this->sUrl = Url::normalize($oRow->url);
$this->bQueued = $oRow->queued;
$this->bQueued = ($oRow->state == 'accepted') ? false : true;
$this->sSubmitTime = $oRow->submitTime;
$this->iSubmitterId = $oRow->submitterId;
}
@@ -65,10 +65,10 @@ class Url {
$this->bQueued = true;
$hResult = query_parameters("INSERT INTO appData (appId, versionId, type,
description, queued, submitTime, submitterId, url)
description, state, submitTime, submitterId, url)
VALUES ('?', '?', '?', '?', '?', ?, '?', '?')",
$iAppId, $iVersionId, "url", $sDescription,
$this->bQueued ? "true" : "false",
$this->bQueued ? 'queued' : 'accepted',
"NOW()", $_SESSION['current']->iUserId, $sUrl);
if(!$hResult)
@@ -117,8 +117,8 @@ class Url {
if(!$this->bQueued)
return false;
if(query_parameters("UPDATE appData SET queued = '?' WHERE id='?'",
"false", $this->iUrlId))
if(query_parameters("UPDATE appData SET state '?' WHERE id='?'",
'accepted', $this->iUrlId))
{
// we send an e-mail to interested people
$this->mailSubmitter();

View File

@@ -240,20 +240,16 @@ class Vendor {
return array('vendorName');
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = 'vendorName', $bAscending = TRUE)
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = 'vendorName', $bAscending = TRUE)
{
/* Vendor queueing is not implemented yet */
if($bQueued)
return FALSE;
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
$sOrder = $bAscending ? 'ASC' : 'DESC';
if(!$iRows)
$iRows = Vendor::objectGetEntriesCount($bQueued, $bRejected);
$iRows = Vendor::objectGetEntriesCount($sState);
$hResult = query_parameters("SELECT * FROM vendor
ORDER BY $sOrderBy $sOrder LIMIT ?,?",
@@ -398,14 +394,10 @@ class Vendor {
return "<a href=\"".$this->objectMakeUrl()."\">$this->sName</a>";
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
/* Not implemented */
if($bQueued)
return FALSE;
/* Not implemented */
if($bRejected)
if($sState == 'rejected')
return FALSE;
$hResult = query_parameters("SELECT COUNT(vendorId) as count FROM vendor");

View File

@@ -1421,16 +1421,14 @@ class version {
return $sLink;
}
public static function objectGetEntriesCount($bQueued, $bRejected)
public static function objectGetEntriesCount($sState)
{
$sState = objectManager::getStateString($bQueued, $bRejected);
$oVersion = new version();
if($bQueued && !$oVersion->canEdit())
if($sState != 'accepted' && !$oVersion->canEdit())
{
/* Users should see their own rejected entries, but maintainers should
not be able to see rejected entries for versions they maintain */
if($bRejected)
if($sState == 'rejected')
$sQuery = "SELECT COUNT(DISTINCT appVersion.versionId) as count FROM
appVersion WHERE
appVersion.submitterId = '?'
@@ -1445,7 +1443,7 @@ class version {
AND
appMaintainers.userId = '?'
AND
appMaintainers.queued = 'false'
appMaintainers.state = 'accepted'
AND
appVersion.state = '?'";
@@ -1546,10 +1544,8 @@ class version {
return array($aItemsPerPage, $iDefaultPerPage);
}
public static function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "versionId")
public static function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "versionId")
{
$sState = objectManager::getStateString($bQueued, $bRejected);
$sLimit = "";
/* Should we add a limit clause to the query? */
@@ -1560,14 +1556,14 @@ class version {
/* Selecting 0 rows makes no sense, so we assume the user wants to select all of them
after an offset given by iStart */
if(!$iRows)
$iRows = maintainer::objectGetEntriesCount($bQueued, $bRejected);
$iRows = version::objectGetEntriesCount($sState);
}
if($bQueued && !version::canEdit())
if($sState != 'accepted' && !version::canEdit())
{
/* Users should see their own rejected entries, but maintainers should
not be able to see rejected entries for versions they maintain */
if($bRejected)
if($sState == 'rejected')
$sQuery = "SELECT * FROM appVersion WHERE
appVersion.submitterId = '?'
AND
@@ -1581,7 +1577,7 @@ class version {
AND
appMaintainers.userId = '?'
AND
appMaintainers.queued = 'false'
appMaintainers.state = 'accepted'
AND
appVersion.state = '?' ORDER BY ?$sLimit";

View File

@@ -225,14 +225,14 @@ class version_queue
return $this->oVersion->objectGetItemsPerPage($sState);
}
function objectGetEntriesCount($bQueued, $bRejected)
function objectGetEntriesCount($sState)
{
return $this->oVersion->objectGetEntriesCount($bQueued, $bRejected);
return $this->oVersion->objectGetEntriesCount($sState);
}
function objectGetEntries($bQueued, $bRejected, $iRows = 0, $iStart = 0, $sOrderBy = "versionId")
function objectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = "versionId")
{
return $this->oVersion->objectGetEntries($bQueued, $bRejected, $iRows, $iStart,
return $this->oVersion->objectGetEntries($sState, $iRows, $iStart,
$sOrderBy);
}

View File

@@ -45,7 +45,7 @@ function test_class($sClassName, $aTestMethods)
return FALSE;
/* Should return 1 or more, since there may be entries present already */
$hResult = $oTestObject->objectGetEntries(false, false);
$hResult = $oTestObject->objectGetEntries('accepted');
if(!$hResult)
{
@@ -105,7 +105,7 @@ function test_class($sClassName, $aTestMethods)
/* Should return 1 or more, since there may be entries present already */
$iExpected = 1;
$hResult = $oTestObject->objectGetEntries(false, false);
$hResult = $oTestObject->objectGetEntries('accepted');
$iReceived = query_num_rows($hResult);
if($iExpected > $iReceived)
{
@@ -230,9 +230,9 @@ function create_object($sClassName, $oUser)
} else
{
$sQuery = "INSERT INTO appData
(versionId, type, description, queued, submitterId)
(versionId, type, description, state, submitterId)
VALUES('?','?','?','?','?')";
$hResult = query_parameters($sQuery, $oTestObject->iVersionId, "screenshot", "", "false",
$hResult = query_parameters($sQuery, $oTestObject->iVersionId, 'screenshot', '', 'accepted',
$oUser->iUserId);
if(!$hResult)
{