Move some maintainer code into user class, don't let a user maintain

the same app more than once
This commit is contained in:
Chris Morgan
2005-07-31 17:53:11 +00:00
committed by WineHQ
parent 16e28b37a3
commit cc912964d6
2 changed files with 61 additions and 31 deletions

View File

@@ -62,7 +62,7 @@ if ($_REQUEST['sub'])
$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)
{
$foundMaintainers = true;
@@ -174,38 +174,16 @@ if ($_REQUEST['sub'])
}
else if ($_REQUEST['add'] && $_REQUEST['queueId'])
{
// insert the new entry into the maintainers list
$query = "INSERT into appMaintainers VALUES(null,".
"$ob->appId,".
"$ob->versionId,".
"$ob->userId,".
"$ob->superMaintainer,".
"NOW());";
if (query_appdb($query))
{
$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 = ".$_REQUEST['queueId'].";");
$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);
}
/* create a new user object for the maintainer */
$maintainerUser = new User($ob->userId);
/* add the user as a maintainer and return the statusMessage */
$statusMessage = $maintainerUser->addAsMaintainer($ob->appId, $ob->versionId,
$ob->superMaintainer,
$_REQUEST['queueId']);
//done
addmsg("<p><b>$statusMessage</b></p>", 'green');
}
}
else if (($_REQUEST['reject'] || ($_REQUEST['sub'] == 'reject')) && $_REQUEST['queueId'])
{
$sEmail = $oUser->sEmail;

View File

@@ -242,6 +242,58 @@ class User {
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)
{