Merge appMaintainerQueue table into appMaintainers table. This simplifies the handling of queued vs.
unqueued maintainers and removes a table from the database
This commit is contained in:
@@ -14,7 +14,7 @@ require_once(BASE."include/mail.php");
|
||||
$aClean = array(); //array of filtered user input
|
||||
|
||||
$aClean['sSub'] = makeSafe( $_REQUEST['sSub'] );
|
||||
$aClean['iQueueId'] = makeSafe( $_REQUEST['iQueueId'] );
|
||||
$aClean['iMaintainerId'] = makeSafe( $_REQUEST['iMaintainerId'] );
|
||||
$aClean['sAdd'] = makeSafe( $_REQUEST['sAdd'] );
|
||||
$aClean['sReject'] = makeSafe( $_REQUEST['sReject'] );
|
||||
$aClean['sReplyText'] = makeSafe( $_REQUEST['sReplyText'] );
|
||||
@@ -25,14 +25,14 @@ if(!$_SESSION['current']->hasPriv("admin"))
|
||||
|
||||
if ($aClean['sSub'])
|
||||
{
|
||||
if ($aClean['iQueueId'])
|
||||
if ($aClean['iMaintainerId'])
|
||||
{
|
||||
//get data
|
||||
$sQuery = "SELECT queueId, appId, versionId,".
|
||||
$sQuery = "SELECT maintainerId, appId, versionId,".
|
||||
"userId, maintainReason, superMaintainer,".
|
||||
"UNIX_TIMESTAMP(submitTime) as submitTime ".
|
||||
"FROM appMaintainerQueue WHERE queueId = '?'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iQueueId']);
|
||||
"FROM appMaintainers WHERE maintainerId = '?' AND queued = 'true'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iMaintainerId']);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
$oUser = new User($oRow->userId);
|
||||
mysql_free_result($hResult);
|
||||
@@ -44,7 +44,7 @@ if ($aClean['sSub'])
|
||||
}
|
||||
|
||||
//process according to which request was submitted and optionally the sub flag
|
||||
if (!$aClean['sAdd'] && !$aClean['sReject'] && $aClean['iQueueId'])
|
||||
if (!$aClean['sAdd'] && !$aClean['sReject'] && $aClean['iMaintainerId'])
|
||||
{
|
||||
apidb_header("Admin Maintainer Queue");
|
||||
echo '<form name="sQform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
@@ -171,7 +171,7 @@ if ($aClean['sSub'])
|
||||
|
||||
echo '</table>',"\n";
|
||||
echo '<input type=hidden name="sSub" value="inside_form" />',"\n";
|
||||
echo '<input type=hidden name="iQueueId" value="'.$aClean['iQueueId'].'" />',"\n";
|
||||
echo '<input type=hidden name="iMaintainerId" value="'.$aClean['iMaintainerId'].'" />',"\n";
|
||||
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminMaintainerQueue.php');
|
||||
@@ -180,7 +180,7 @@ if ($aClean['sSub'])
|
||||
exit;
|
||||
|
||||
}
|
||||
else if ($aClean['sAdd'] && $aClean['iQueueId'])
|
||||
else if ($aClean['sAdd'] && $aClean['iMaintainerId'])
|
||||
{
|
||||
/* create a new user object for the maintainer */
|
||||
$oMaintainerUser = new User($oRow->userId);
|
||||
@@ -188,11 +188,11 @@ if ($aClean['sSub'])
|
||||
/* add the user as a maintainer and return the statusMessage */
|
||||
$sStatusMessage = $oMaintainerUser->addAsMaintainer($oRow->appId, $oRow->versionId,
|
||||
$oRow->superMaintainer,
|
||||
$aClean['iQueueId']);
|
||||
$aClean['iMaintainerId']);
|
||||
//done
|
||||
addmsg("<p><b>$sStatusMessage</b></p>", 'green');
|
||||
}
|
||||
else if (($aClean['sReject'] || ($aClean['sSub'] == 'sReject')) && $aClean['iQueueId'])
|
||||
else if (($aClean['sReject'] || ($aClean['sSub'] == 'sReject')) && $aClean['iMaintainerId'])
|
||||
{
|
||||
$sEmail = $oUser->sEmail;
|
||||
if ($sEmail)
|
||||
@@ -209,8 +209,8 @@ if ($aClean['sSub'])
|
||||
}
|
||||
|
||||
//delete main item
|
||||
$sQuery = "DELETE from appMaintainerQueue where queueId = '?'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iQueueId']);
|
||||
$sQuery = "DELETE from appMaintainers where maintainerId = '?'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iMaintainerId']);
|
||||
if(!$hResult) addmsg("unable to delete selected maintainer application", "red");
|
||||
echo html_frame_start("Delete maintainer application",400,"",0);
|
||||
if($hResult)
|
||||
@@ -233,11 +233,11 @@ if ($aClean['sSub'])
|
||||
echo '<form name="sQform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
//get available maintainers
|
||||
$sQuery = "SELECT queueId, appId, versionId,".
|
||||
$sQuery = "SELECT maintainerId, appId, versionId,".
|
||||
"userId, maintainReason,".
|
||||
"superMaintainer,".
|
||||
"submitTime as submitTime ".
|
||||
"from appMaintainerQueue;";
|
||||
"FROM appMaintainers WHERE queued='true';";
|
||||
$hResult = query_parameters($sQuery);
|
||||
|
||||
if(!$hResult || !mysql_num_rows($hResult))
|
||||
@@ -291,7 +291,7 @@ if ($aClean['sSub'])
|
||||
}
|
||||
|
||||
echo " <td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
|
||||
echo " <td>[<a href=\"adminMaintainerQueue.php?sSub=view&iQueueId=$oRow->queueId\">answer</a>]</td>\n";
|
||||
echo " <td>[<a href=\"adminMaintainerQueue.php?sSub=view&iMaintainerId=$oRow->maintainerId\">answer</a>]</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
$iRowCount++;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ if ($aClean['sSub'])
|
||||
{
|
||||
// get available maintainers
|
||||
$sQuery = "SELECT * FROM appMaintainers, user_list where appMaintainers.userId = user_list.userid";
|
||||
$sQuery.= " ORDER BY realname;";
|
||||
$sQuery.= " AND queued='false' ORDER BY realname;";
|
||||
$hResult = query_parameters($sQuery);
|
||||
|
||||
if(!$hResult || !mysql_num_rows($hResult))
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
/*
|
||||
* get the userIds of super maintainers for this appId
|
||||
*/
|
||||
function getSuperMaintainersUserIdsFromAppId($appId)
|
||||
function getSuperMaintainersUserIdsFromAppId($iAppId)
|
||||
{
|
||||
$sQuery = "SELECT userId FROM ".
|
||||
"appMaintainers WHERE appId = '?' " .
|
||||
"AND superMaintainer = '1';";
|
||||
$hResult = query_parameters($sQuery, $appId);
|
||||
"AND superMaintainer = '1' AND queued='?';";
|
||||
$hResult = query_parameters($sQuery, $iAppId, "false");
|
||||
$retval = array();
|
||||
$c = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
|
||||
@@ -261,12 +261,12 @@ class User {
|
||||
/* otherwise check if we maintain this specific version */
|
||||
if($iVersionId)
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND versionId = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $iVersionId);
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND versionId = '?' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $iVersionId, "false");
|
||||
} else // are we maintaining any version ?
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId);
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, "false");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
@@ -284,12 +284,12 @@ class User {
|
||||
|
||||
if($iAppId)
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $iAppId);
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $iAppId, "false");
|
||||
} else /* are we super maintainer of any applications? */
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND superMaintainer = '1'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId);
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND superMaintainer = '1' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, "false");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
@@ -304,7 +304,8 @@ class User {
|
||||
/* 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 = '?' ORDER BY appName", $this->iUserId);
|
||||
"AND userId = '?' AND appMaintainers.queued = '?' ORDER BY appName",
|
||||
$this->iUserId, "false");
|
||||
if(!$hResult || mysql_num_rows($hResult) == 0)
|
||||
return NULL;
|
||||
|
||||
@@ -323,8 +324,9 @@ class User {
|
||||
{
|
||||
if(!$this->isLoggedIn()) return 0;
|
||||
|
||||
$sQuery = "SELECT count(*) as cnt from appMaintainers WHERE userid = '?' AND superMaintainer = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $bSuperMaintainer);
|
||||
$sQuery = "SELECT count(*) as cnt from appMaintainers WHERE userid = '?' AND superMaintainer = '?'".
|
||||
" AND queued ='?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, $bSuperMaintainer ? "1" : "0", "false");
|
||||
if(!$hResult)
|
||||
return 0;
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
@@ -335,7 +337,9 @@ class User {
|
||||
/**
|
||||
* Add the user as a maintainer
|
||||
*/
|
||||
function addAsMaintainer($iAppId, $iVersionId, $bSuperMaintainer, $iQueueId)
|
||||
//FIXME: we really don't need any parameter except $iMaintainerId here
|
||||
// we'll clean this up when we clean up maintainers
|
||||
function addAsMaintainer($iAppId, $iVersionId, $bSuperMaintainer, $iMaintainerId)
|
||||
{
|
||||
|
||||
$aClean = array();
|
||||
@@ -347,18 +351,14 @@ class User {
|
||||
if(!$this->isSuperMaintainer($iAppId) &&
|
||||
((!$bSuperMaintainer && !$this->isMaintainer($iVersionId)) | $bSuperMaintainer))
|
||||
{
|
||||
// insert the new entry into the maintainers list
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (maintainerId, appId,".
|
||||
"versionId, userId, superMaintainer, submitTime) ".
|
||||
"VALUES (?, '?', '?', '?', '?', ?)",
|
||||
"null", $iAppId, $iVersionId, $this->iUserId,
|
||||
$bSuperMaintainer, "NOW()");
|
||||
/* unqueue the maintainer entry */
|
||||
$hResult = query_parameters("UPDATE appMaintainers SET queued='false' WHERE userId = '?' AND maintainerId = '?'",
|
||||
$this->iUserId, $iMaintainerId);
|
||||
|
||||
if($hResult)
|
||||
{
|
||||
$statusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
||||
|
||||
//delete the item from the queue
|
||||
query_parameters("DELETE from appMaintainerQueue where queueId = '?'", $iQueueId);
|
||||
$oApp = new Application($iAppId);
|
||||
$oVersion = new Version($iVersionId);
|
||||
//Send Status Email
|
||||
@@ -376,7 +376,8 @@ class User {
|
||||
} else
|
||||
{
|
||||
//delete the item from the queue
|
||||
query_parameters("DELETE from appMaintainerQueue where queueId = '?'", $iQueueId);
|
||||
query_parameters("DELETE from appMaintainers WHERE userId = '?' AND maintainerId = '?'",
|
||||
$this->iUserId, $iMaintainerId);
|
||||
|
||||
if($this->isSuperMaintainer($iAppId) && !$bSuperMaintainer)
|
||||
$statusMessage = "<p>User is already a super maintainer of this application</p>\n";
|
||||
@@ -437,7 +438,7 @@ class User {
|
||||
{
|
||||
/* find all queued versions of applications that the user is a super maintainer of */
|
||||
$hResult = query_parameters("SELECT count(*) as queued_versions FROM appVersion, appMaintainers
|
||||
WHERE queued='true' AND appMaintainers.superMaintainer ='1'
|
||||
WHERE Appversion.queued='true' AND appMaintainers.superMaintainer ='1'
|
||||
AND appVersion.appId = appMaintainers.appId
|
||||
AND appMaintainers.userId ='?'", $this->iUserId);
|
||||
}
|
||||
@@ -606,7 +607,7 @@ class User {
|
||||
if($queryAppFamily)
|
||||
{
|
||||
$sQuery = "SELECT appFamily.appId FROM appFamily, appMaintainers
|
||||
WHERE queued = 'true'
|
||||
WHERE appFamily.queued = 'true'
|
||||
AND appFamily.appId = appMaintainers.appId
|
||||
AND appMaintainers.superMaintainer = '1'
|
||||
AND appMaintainers.userId = '".mysql_real_escape_string($this->iUserId)."';";
|
||||
@@ -848,7 +849,7 @@ class User {
|
||||
$hResult = query_parameters("SELECT appMaintainers.userId
|
||||
FROM appMaintainers, appVersion
|
||||
WHERE appVersion.appId = appMaintainers.appId
|
||||
AND appVersion.versionId = '?'",
|
||||
AND appVersion.versionId = '?' AND appMaintainers.queued = 'false'",
|
||||
$iVersionId);
|
||||
}
|
||||
/*
|
||||
@@ -858,7 +859,7 @@ class User {
|
||||
{
|
||||
$hResult = query_parameters("SELECT userId
|
||||
FROM appMaintainers
|
||||
WHERE appId = '?'",
|
||||
WHERE appId = '?' AND queued = 'false'",
|
||||
$iAppId);
|
||||
}
|
||||
|
||||
|
||||
@@ -187,7 +187,7 @@ function make_maintainer_rating_list($varname, $cvalue)
|
||||
/* get the number of queued maintainers */
|
||||
function getQueuedMaintainerCount()
|
||||
{
|
||||
$sQuery = "SELECT count(*) as queued_maintainers FROM appMaintainerQueue";
|
||||
$sQuery = "SELECT count(*) as queued_maintainers FROM appMaintainers where queued='true'";
|
||||
$hResult = query_parameters($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->queued_maintainers;
|
||||
@@ -196,7 +196,7 @@ function getQueuedMaintainerCount()
|
||||
/* get the total number of maintainers and applications in the appMaintainers table */
|
||||
function getMaintainerCount()
|
||||
{
|
||||
$sQuery = "SELECT count(*) as maintainers FROM appMaintainers";
|
||||
$sQuery = "SELECT count(*) as maintainers FROM appMaintainers where queued='false'";
|
||||
$hResult = query_parameters($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->maintainers;
|
||||
@@ -230,7 +230,7 @@ function getNumberOfVersions()
|
||||
/* Get the number of maintainers in the database */
|
||||
function getNumberOfMaintainers()
|
||||
{
|
||||
$hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers;");
|
||||
$hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers WHERE queued='false';");
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,17 +85,20 @@ if( $aClean['sMaintainReason'] )
|
||||
apidb_header("Submit Maintainer Request");
|
||||
|
||||
// add to queue
|
||||
$hResult = query_parameters("INSERT INTO appMaintainerQueue (queueId, appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime) ".
|
||||
"VALUES (?, '?', '?', '?', '?', '?', ?)",
|
||||
"null", $aClean['iAppId'], $aClean['iVersionId'],
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
||||
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
||||
$aClean['iAppId'], $aClean['iVersionId'],
|
||||
$_SESSION['current']->iUserId, $aClean['sMaintainReason'],
|
||||
$aClean['iSuperMaintainer'], "NOW()");
|
||||
$aClean['iSuperMaintainer'], "NOW()", 'true');
|
||||
|
||||
if ($hResult)
|
||||
{
|
||||
echo "<p>Your maintainer request has been submitted for review. You should hear back\n";
|
||||
echo "soon about the status of your submission</p>\n";
|
||||
} else
|
||||
{
|
||||
addmsg("Error submitting maintainer request. Please contact the appdb admins at appdb@winehq.org", "red");
|
||||
}
|
||||
} else
|
||||
{
|
||||
|
||||
@@ -7,28 +7,18 @@ drop table if exists appMaintainers;
|
||||
* List of the application maintainers. These users have the rights
|
||||
* to delete comments, edit the application description and otherwise
|
||||
* care for an application.
|
||||
*
|
||||
* We also store the reason they asked to be a maintainer since we use this table
|
||||
* for both queued and unqueued maintainers
|
||||
*/
|
||||
create table appMaintainers (
|
||||
maintainerId int not null auto_increment,
|
||||
appId int,
|
||||
versionId int,
|
||||
userId int,
|
||||
superMaintainer bool,
|
||||
submitTime datetime,
|
||||
key(maintainerId)
|
||||
);
|
||||
|
||||
/*
|
||||
* Queue where users names will go if they request to become an application
|
||||
* maintainer. This includes the reason they want to become a maintainer.
|
||||
*/
|
||||
create table appMaintainerQueue (
|
||||
queueId int not null auto_increment,
|
||||
appId int,
|
||||
versionId int,
|
||||
userId int,
|
||||
maintainReason text,
|
||||
superMaintainer bool,
|
||||
submitTime datetime,
|
||||
key(queueId)
|
||||
queued enum('true','false','rejected') NOT NULL default 'false';
|
||||
key(maintainerId)
|
||||
);
|
||||
|
||||
@@ -297,8 +297,20 @@ function test_user_getMaintainerCount()
|
||||
*/
|
||||
$iAppId = 655000;
|
||||
$iVersionId = 655200;
|
||||
$iQueueId = 655300;
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, TRUE, $iQueueId);
|
||||
|
||||
//FIXME: when we clean up maintainers we'll want to clean this code up as well
|
||||
/* queue up the maintainership */
|
||||
// add to queue
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
||||
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
||||
$iAppId, $iVersionId,
|
||||
$_SESSION['current']->iUserId, "Some crazy reason",
|
||||
TRUE ? "1" : "0", "NOW()", 'true');
|
||||
|
||||
$iMaintainerId = mysql_insert_id();
|
||||
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, TRUE, $iMaintainerId);
|
||||
|
||||
/* see that the user is a super maintainer of the one application we added them to be */
|
||||
$iExpected = 1; /* we expect 1 super maintainer for this user */
|
||||
@@ -327,7 +339,19 @@ function test_user_getMaintainerCount()
|
||||
/**
|
||||
* make the user a maintainer
|
||||
*/
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, FALSE, $iQueueId);
|
||||
//FIXME: when we clean up maintainers we'll want to clean this code up as well
|
||||
/* queue up the maintainership */
|
||||
// add to queue
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
||||
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
||||
$iAppId, $iVersionId,
|
||||
$_SESSION['current']->iUserId, "Some crazy reason",
|
||||
FALSE ? "1" : "0", "NOW()", 'true');
|
||||
|
||||
$iMaintainerId = mysql_insert_id();
|
||||
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, FALSE, $iMaintainerId);
|
||||
|
||||
/* see that the user is a super maintainer of no applications */
|
||||
$iExpected = 0; /* we expect 1 super maintainer for this user */
|
||||
@@ -388,9 +412,21 @@ function test_user_getAppsMaintained()
|
||||
*/
|
||||
$iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
|
||||
$iVersionId = 655200;
|
||||
$iQueueId = 655300;
|
||||
$bSuperMaintainer = TRUE;
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, $bSuperMaintainer, $iQueueId);
|
||||
|
||||
//FIXME: when we clean up maintainers we'll want to clean this code up as well
|
||||
/* queue up the maintainership */
|
||||
// add to queue
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
||||
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
||||
$iAppId, $iVersionId,
|
||||
$_SESSION['current']->iUserId, "Some crazy reason",
|
||||
$bSuperMaintainer ? "1" : "0", "NOW()", 'true');
|
||||
|
||||
$iMaintainerId = mysql_insert_id();
|
||||
|
||||
$statusMessage = $oUser->addAsMaintainer($iAppId, $iVersionId, $bSuperMaintainer, $iMaintainerId);
|
||||
|
||||
/* get an array of the apps maintained */
|
||||
$aAppsMaintained = $oUser->getAppsMaintained();
|
||||
|
||||
Reference in New Issue
Block a user