Move some maintainer code into user class, don't let a user maintain
the same app more than once
This commit is contained in:
@@ -62,7 +62,7 @@ if ($_REQUEST['sub'])
|
|||||||
|
|
||||||
$firstDisplay = true; /* if false we need to fix up table rows appropriately */
|
$firstDisplay = true; /* if false we need to fix up table rows appropriately */
|
||||||
|
|
||||||
$other_users = getMaintainersUserIdsFromAppIdVersionId($ob->appId, $ob->versionId);
|
$other_users = getMaintainersUserIdsFromAppIdVersionId($ob->versionId);
|
||||||
if($other_users)
|
if($other_users)
|
||||||
{
|
{
|
||||||
$foundMaintainers = true;
|
$foundMaintainers = true;
|
||||||
@@ -174,37 +174,15 @@ if ($_REQUEST['sub'])
|
|||||||
}
|
}
|
||||||
else if ($_REQUEST['add'] && $_REQUEST['queueId'])
|
else if ($_REQUEST['add'] && $_REQUEST['queueId'])
|
||||||
{
|
{
|
||||||
// insert the new entry into the maintainers list
|
/* create a new user object for the maintainer */
|
||||||
$query = "INSERT into appMaintainers VALUES(null,".
|
$maintainerUser = new User($ob->userId);
|
||||||
"$ob->appId,".
|
|
||||||
"$ob->versionId,".
|
|
||||||
"$ob->userId,".
|
|
||||||
"$ob->superMaintainer,".
|
|
||||||
"NOW());";
|
|
||||||
|
|
||||||
if (query_appdb($query))
|
/* add the user as a maintainer and return the statusMessage */
|
||||||
{
|
$statusMessage = $maintainerUser->addAsMaintainer($ob->appId, $ob->versionId,
|
||||||
$statusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
$ob->superMaintainer,
|
||||||
|
$_REQUEST['queueId']);
|
||||||
//delete the item from the queue
|
//done
|
||||||
query_appdb("DELETE from appMaintainerQueue where queueId = ".$_REQUEST['queueId'].";");
|
addmsg("<p><b>$statusMessage</b></p>", 'green');
|
||||||
$oApp = new Application($ob->appId);
|
|
||||||
$oVersion = new Version($ob->versionId);
|
|
||||||
//Send Status Email
|
|
||||||
$sEmail = $oUser->sEmail;
|
|
||||||
if ($sEmail)
|
|
||||||
{
|
|
||||||
$sSubject = "Application Maintainer Request Report";
|
|
||||||
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." has been accepted. ";
|
|
||||||
$sMsg .= $_REQUEST['replyText'];
|
|
||||||
$sMsg .= "We appreciate your help in making the Application Database better for all users.\n\n";
|
|
||||||
|
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
//done
|
|
||||||
addmsg("<p><b>$statusMessage</b></p>", 'green');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId'])
|
else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId'])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -242,6 +242,58 @@ class User {
|
|||||||
return mysql_num_rows($hResult);
|
return mysql_num_rows($hResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the user as a maintainer
|
||||||
|
*/
|
||||||
|
function addAsMaintainer($iAppId, $iVersionId, $bSuperMaintainer, $iQueueId)
|
||||||
|
{
|
||||||
|
/* if the user isn't already a supermaintainer of the application and */
|
||||||
|
/* if they are trying to become a maintainer and aren't already a maintainer of */
|
||||||
|
/* the version, then continue processing the request */
|
||||||
|
if(!$this->isSuperMaintainer($iAppId) &&
|
||||||
|
((!$bSuperMaintainer && !$this->isMaintainer($iVersionId)) | $bSuperMaintainer))
|
||||||
|
{
|
||||||
|
// insert the new entry into the maintainers list
|
||||||
|
$sQuery = "INSERT into appMaintainers VALUES(null,".
|
||||||
|
"$iAppId,".
|
||||||
|
"$iVersionId,".
|
||||||
|
"$this->iUserId,".
|
||||||
|
"$bSuperMaintainer,".
|
||||||
|
"NOW());";
|
||||||
|
|
||||||
|
if (query_appdb($sQuery))
|
||||||
|
{
|
||||||
|
$statusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
||||||
|
|
||||||
|
//delete the item from the queue
|
||||||
|
query_appdb("DELETE from appMaintainerQueue where queueId = ".$iQueueId.";");
|
||||||
|
$oApp = new Application($iAppId);
|
||||||
|
$oVersion = new Version($iVersionId);
|
||||||
|
//Send Status Email
|
||||||
|
$sEmail = $oUser->sEmail;
|
||||||
|
if ($sEmail)
|
||||||
|
{
|
||||||
|
$sSubject = "Application Maintainer Request Report";
|
||||||
|
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." has been accepted. ";
|
||||||
|
$sMsg .= $_REQUEST['replyText'];
|
||||||
|
$sMsg .= "We appreciate your help in making the Application Database better for all users.\n\n";
|
||||||
|
|
||||||
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
//delete the item from the queue
|
||||||
|
query_appdb("DELETE from appMaintainerQueue where queueId = ".$iQueueId.";");
|
||||||
|
|
||||||
|
if($this->isSuperMaintainer($iAppId) && !$bSuperMaintainer)
|
||||||
|
$statusMessage = "<p>User is already a super maintainer of this application</p>\n";
|
||||||
|
else
|
||||||
|
$statusMessage = "<p>User is already a maintainer/super maintainer of this application/version</p>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $statusMessage;
|
||||||
|
}
|
||||||
|
|
||||||
function addPriv($sPriv)
|
function addPriv($sPriv)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user