Start to move maintainer related functions into maintainer class and separate maintainer related queries and logic from
display code. Also move maintainer related code from the user class. Fix up unit tests to work with the new maintainer class.
This commit is contained in:
@@ -40,7 +40,7 @@ if ($aClean['sSub'])
|
||||
else
|
||||
{
|
||||
//error no Id!
|
||||
util_show_error_page_and_exit("<p><b>QueueId Not Found!</b></p>");
|
||||
util_show_error_page_and_exit("<p><b>MaintainerId Not Found!</b></p>");
|
||||
}
|
||||
|
||||
//process according to which request was submitted and optionally the sub flag
|
||||
@@ -52,110 +52,12 @@ if ($aClean['sSub'])
|
||||
$x = new TableVE("view");
|
||||
|
||||
//help
|
||||
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
||||
echo "Please enter an accurate and personalized reply anytime a maintainer request is rejected.\n";
|
||||
echo "Its not polite to reject someones attempt at trying to help out without explaining why.\n";
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
Maintainer::ObjectDisplayQueueProcessingHelp();
|
||||
|
||||
//view application details
|
||||
echo html_frame_start("New Maintainer Form",600,"",0);
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
$oMaintainer->OutputEditor();
|
||||
|
||||
// Show the other maintainers of this application, if there are any
|
||||
echo '<tr valign=top><td class=color0><b>Other maintainers of this app:</b></td>',"\n";
|
||||
|
||||
$bFoundMaintainers = false;
|
||||
|
||||
$bFirstDisplay = true; /* if false we need to fix up table rows appropriately */
|
||||
|
||||
$oVersion = new Version($oRow->versionId);
|
||||
$aOtherUsers = $oVersion->getMaintainersUserIds();
|
||||
if($aOtherUsers)
|
||||
{
|
||||
$bFoundMaintainers = true;
|
||||
while(list($index, $iUserId) = each($aOtherUsers))
|
||||
{
|
||||
$oUser = new User($iUserId);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
echo "<td>".$oUser->sRealname."</td></tr>\n";
|
||||
$bFirstDisplay = false;
|
||||
} else
|
||||
{
|
||||
echo "<tr><td class=\"color0\"></td><td>".$oUser->sRealname."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aOtherUsers = getSuperMaintainersUserIdsFromAppId($oRow->appId);
|
||||
if($aOtherUsers)
|
||||
{
|
||||
$bFoundMaintainers = true;
|
||||
while(list($index, $iUserId) = each($aOtherUsers))
|
||||
{
|
||||
$oUser = new User($iUserId);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
echo "<td>".$oUser->sRealname."*</td></tr>\n";
|
||||
$bFirstDisplay = false;
|
||||
} else
|
||||
{
|
||||
echo "<tr><td class=\"color0\"></td><td>".$oUser->sRealname."*</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$bFoundMaintainers)
|
||||
{
|
||||
echo "<td>No other maintainers</td></tr>\n";
|
||||
}
|
||||
|
||||
// Show which other apps the user maintains
|
||||
echo '<tr valign="top"><td class="color0"><b>This user also maintains these apps:</b></td>',"\n";
|
||||
|
||||
$bFirstDisplay = true;
|
||||
$oUser = new User($oRow->userId);
|
||||
$aOtherApps = $oUser->getAppsMaintained();
|
||||
if($aOtherApps)
|
||||
{
|
||||
while(list($index, list($iAppIdOther, $iVersionIdOther, $bSuperMaintainerOther)) = each($aOtherApps))
|
||||
{
|
||||
$oApp = new Application($iAppIdOther);
|
||||
$oVersion = new Version($iVersionIdOther);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
$bFirstDisplay = false;
|
||||
if($bSuperMaintainerOther)
|
||||
echo "<td>".$oApp->sName."*</td></tr>\n";
|
||||
else
|
||||
echo "<td>".$oApp->sName." ".$oVersion->sName."</td></tr>\n";
|
||||
} else
|
||||
{
|
||||
if($bSuperMaintainerOther)
|
||||
echo "<td class=color0></td><td>".$oApp->sName."*</td></tr>\n";
|
||||
else
|
||||
echo "<td class=color0></td><td>".$oApp->sName." ".$oVersion->sName."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
echo "<td>User maintains no other applications</td></tr>\n";
|
||||
}
|
||||
|
||||
$oApp = new Application($oRow->appId);
|
||||
$oVersion = new Version($oRow->versionId);
|
||||
|
||||
//app name
|
||||
echo '<tr valign=top><td class=color0><b>App Name</b></td>',"\n";
|
||||
echo "<td>".$oApp->sName."</td></tr>\n";
|
||||
|
||||
//version
|
||||
echo '<tr valign=top><td class=color0><b>App Version</b></td>',"\n";
|
||||
echo "<td>".$oVersion->sName."</td></tr>\n";
|
||||
|
||||
//maintainReason
|
||||
echo '<tr valign=top><td class=color0><b>Maintainer request reason</b></td>',"\n";
|
||||
echo '<td><textarea name="sMaintainReason" rows=10 cols=35>'.$oRow->maintainReason.'</textarea></td></tr>',"\n";
|
||||
echo "<table border=1 cellpadding=2 cellspacing=0 style='margin-left:auto; margin-right:auto'>\n";
|
||||
|
||||
//email response
|
||||
echo '<tr valign=top><td class=color0><b>Email reply</b></td>',"\n";
|
||||
@@ -169,11 +71,11 @@ if ($aClean['sSub'])
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
|
||||
echo '<input type=submit name=sReject value=" Reject this request " class=button /></td></tr>',"\n";
|
||||
|
||||
echo '</table>',"\n";
|
||||
echo '<input type=hidden name="sSub" value="inside_form" />',"\n";
|
||||
echo '<input type=hidden name="iMaintainerId" value="'.$aClean['iMaintainerId'].'" />',"\n";
|
||||
|
||||
echo html_frame_end(" ");
|
||||
echo '</table>';
|
||||
|
||||
echo html_back_link(1,'adminMaintainerQueue.php');
|
||||
echo "</form>";
|
||||
apidb_footer();
|
||||
@@ -182,35 +84,19 @@ if ($aClean['sSub'])
|
||||
}
|
||||
else if ($aClean['sAdd'] && $aClean['iMaintainerId'])
|
||||
{
|
||||
/* create a new user object for the maintainer */
|
||||
$oMaintainerUser = new User($oRow->userId);
|
||||
/* create this maintainer object */
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
|
||||
$sStatusMessage = $oMaintainer->unQueue($aClean['sReplyText']);
|
||||
|
||||
/* add the user as a maintainer and return the statusMessage */
|
||||
$sStatusMessage = $oMaintainerUser->addAsMaintainer($oRow->appId, $oRow->versionId,
|
||||
$oRow->superMaintainer,
|
||||
$aClean['iMaintainerId']);
|
||||
//done
|
||||
addmsg("<p><b>$sStatusMessage</b></p>", 'green');
|
||||
}
|
||||
else if (($aClean['sReject'] || ($aClean['sSub'] == 'sReject')) && $aClean['iMaintainerId'])
|
||||
{
|
||||
$sEmail = $oUser->sEmail;
|
||||
if ($sEmail)
|
||||
{
|
||||
$oApp = new Application($oRow->appId);
|
||||
$oVersion = new Version($oRow->versionId);
|
||||
$sSubject = "Application Maintainer Request Report";
|
||||
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." was rejected. ";
|
||||
$sMsg .= $aClean['sReplyText'];
|
||||
$sMsg .= "";
|
||||
$sMsg .= "-The AppDB admins\n";
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
$hResult = $oMaintainer->reject($aClean['sReplyText']);
|
||||
|
||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||
}
|
||||
|
||||
//delete main item
|
||||
$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)
|
||||
@@ -232,13 +118,8 @@ if ($aClean['sSub'])
|
||||
apidb_header("Admin Maintainer Queue");
|
||||
echo '<form name="sQform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
//get available maintainers
|
||||
$sQuery = "SELECT maintainerId, appId, versionId,".
|
||||
"userId, maintainReason,".
|
||||
"superMaintainer,".
|
||||
"submitTime as submitTime ".
|
||||
"FROM appMaintainers WHERE queued='true';";
|
||||
$hResult = query_parameters($sQuery);
|
||||
/* retrieve a list of queued entries */
|
||||
$hResult = Maintainer::ObjectGetEntries(true);
|
||||
|
||||
if(!$hResult || !mysql_num_rows($hResult))
|
||||
{
|
||||
@@ -251,46 +132,25 @@ if ($aClean['sSub'])
|
||||
else
|
||||
{
|
||||
//help
|
||||
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
||||
echo "<p>This is a list of users that are asking to become application maintainers.\n";
|
||||
echo "Please read carefully the reasons they give for wanting to be an application maintainer.\n";
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
maintainer::ObjectDisplayQueueProcessingHelp();
|
||||
|
||||
//show applist
|
||||
echo html_frame_start("","90%","",0);
|
||||
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
|
||||
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td>Submission Date</td>\n";
|
||||
echo " <td>Application Name</td>\n";
|
||||
echo " <td>Version</td>\n";
|
||||
echo " <td>Super maintainer?</td>\n";
|
||||
echo " <td>Submitter</td>\n";
|
||||
maintainer::ObjectOutputHeader();
|
||||
echo " <td>Action</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$iRowCount = 1;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$oUser = new User($oRow->userId);
|
||||
$oApp = new Application($oRow->appId);
|
||||
$oVersion = new Version($oRow->versionId);
|
||||
$oMaintainer = Maintainer::ObjectGetObjectFromObjectGetEntriesRow($oRow);
|
||||
|
||||
if ($iRowCount % 2 == 1) { $sBGColor = 'color0'; } else { $sBGColor = 'color1'; }
|
||||
echo "<tr class=$sBGColor>\n";
|
||||
echo " <td>".print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))." </td>\n";
|
||||
echo " <td>".$oApp->sName."</td>\n";
|
||||
|
||||
if($oRow->superMaintainer)
|
||||
{
|
||||
echo "<td>N/A</td>\n";
|
||||
echo "<td>Yes</td>\n";
|
||||
} else
|
||||
{
|
||||
echo "<td>".$oVersion->sName." </td>\n";
|
||||
echo "<td>No</td>\n";
|
||||
}
|
||||
|
||||
echo " <td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
|
||||
$oMaintainer->ObjectOutputTableRow();
|
||||
echo " <td>[<a href=\"adminMaintainerQueue.php?sSub=view&iMaintainerId=$oRow->maintainerId\">answer</a>]</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
$iRowCount++;
|
||||
|
||||
@@ -25,8 +25,8 @@ if ($aClean['sSub'])
|
||||
{
|
||||
if($aClean['sSub'] == 'delete')
|
||||
{
|
||||
$sQuery = "DELETE FROM appMaintainers WHERE maintainerId = '?'";
|
||||
$hResult = query_parameters($sQuery, $aClean['iMaintainerId']);
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
$oMaintainer->delete();
|
||||
echo html_frame_start("Delete maintainer: ".$aClean['iMaintainerId'],400,"",0);
|
||||
if($hResult)
|
||||
{
|
||||
@@ -84,7 +84,7 @@ if ($aClean['sSub'])
|
||||
else
|
||||
echo " <td style=\"$style\"><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
|
||||
|
||||
$count = $oUser->getMaintainerCount(true);
|
||||
$count = Maintainer::getMaintainerCountForUser($oUser, true);
|
||||
if($count == 0)
|
||||
echo " <td style=\"$style\"> </td>\n";
|
||||
else if($count <= 1)
|
||||
@@ -93,7 +93,7 @@ if ($aClean['sSub'])
|
||||
echo " <td style=\"$style\">".$count." apps</td>\n";
|
||||
|
||||
|
||||
$count = $oUser->getMaintainerCount(false);
|
||||
$count = Maintainer::getMaintainerCountForUser($oUser, false);
|
||||
if($count == 0)
|
||||
echo " <td style=\"$style\"> </td>\n";
|
||||
else if($count <= 1)
|
||||
|
||||
@@ -68,7 +68,7 @@ echo "</tr>\n\n";
|
||||
/* Display the number of application maintainers */
|
||||
echo "<tr class=color4>\n";
|
||||
echo " <td>Application maintainers:</td>\n";
|
||||
echo " <td>".getNumberOfMaintainers()."</td>\n";
|
||||
echo " <td>".Maintainer::getNumberOfMaintainers()."</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
/* Display the number of images */
|
||||
|
||||
@@ -59,7 +59,7 @@ if($hUsersToDelete)
|
||||
/* is the user a maintainer? if so remove their maintainer privilages */
|
||||
if($oUser->isMaintainer())
|
||||
{
|
||||
$oUser->deleteMaintainer();
|
||||
Maintainer::deleteMaintainer($oUser);
|
||||
}
|
||||
|
||||
$usersWithData++;
|
||||
|
||||
@@ -224,8 +224,8 @@ class Application {
|
||||
}
|
||||
|
||||
// remove any supermaintainers for this application so we don't orphan them
|
||||
$sQuery = "DELETE from appMaintainers WHERE appId='?'";
|
||||
if(!($hResult = query_parameters($sQuery, $this->iAppId)))
|
||||
$hResult = Maintainer::deleteMaintainersForApplication($this);
|
||||
if(!$hResult)
|
||||
{
|
||||
addmsg("Error removing app maintainers for the deleted application!", "red");
|
||||
}
|
||||
@@ -557,7 +557,7 @@ class Application {
|
||||
// Display all supermaintainers maintainers of this application
|
||||
echo " <table class=\"color4\" width=\"250\" border=\"1\">\n";
|
||||
echo " <tr><td align=\"left\"><b>Super maintainers:</b></td></tr>\n";
|
||||
$other_maintainers = getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
||||
$other_maintainers = Maintainer::getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
||||
if($other_maintainers)
|
||||
{
|
||||
echo " <tr><td align=\"left\"><ul>\n";
|
||||
|
||||
@@ -3,24 +3,493 @@
|
||||
/* functions for maintainers */
|
||||
/*****************************/
|
||||
|
||||
/*
|
||||
class maintainer
|
||||
{
|
||||
var $iMaintainerId;
|
||||
var $iAppId;
|
||||
var $iVersionId;
|
||||
var $iUserId;
|
||||
var $sMaintainReason;
|
||||
var $bSuperMaintainer;
|
||||
var $aSubmitTime;
|
||||
var $bQueued;
|
||||
|
||||
function maintainer($iMaintainerId = "")
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE maintainerId = '?'";
|
||||
$hResult = query_parameters($sQuery, $iMaintainerId);
|
||||
if($hResult)
|
||||
{
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
$this->iMaintainerId = $oRow->maintainerId;
|
||||
$this->iAppId = $oRow->appId;
|
||||
$this->iVersionId = $oRow->versionId;
|
||||
$this->iUserId = $oRow->userId;
|
||||
$this->sMaintainReason = $oRow->maintainReason;
|
||||
$this->bSuperMaintainer = $oRow->superMaintainer;
|
||||
$this->aSubmitTime = $oRow->submitTime;
|
||||
$this->bQueued = $oRow->queued;
|
||||
}
|
||||
}
|
||||
|
||||
function create()
|
||||
{
|
||||
/* user id, appid, and maintain reason must be valid to continue */
|
||||
if(!$this->iUserId || !$this->iAppId || !$this->sMaintainReason)
|
||||
return NULL;
|
||||
|
||||
$hResult = query_parameters("INSERT INTO appMaintainers (appId, versionId, ".
|
||||
"userId, maintainReason, superMaintainer, submitTime, queued) ".
|
||||
"VALUES ('?', '?', '?', '?', '?', ?, '?')",
|
||||
$this->iAppId, $this->iVersionId,
|
||||
$this->iUserId, $this->sMaintainReason,
|
||||
$this->bSuperMaintainer, "NOW()", 'true');
|
||||
|
||||
/* this objects id is the insert id returned by mysql */
|
||||
$this->iMaintainerId = mysql_insert_id();
|
||||
|
||||
return $hResult;
|
||||
}
|
||||
|
||||
function unQueue($sReplyText)
|
||||
{
|
||||
/* 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 */
|
||||
|
||||
$oUser = new User($this->iUserId);
|
||||
|
||||
if(!$oUser->isSuperMaintainer($this->iAppId) &&
|
||||
((!$this->bSuperMaintainer && !$oUser->isMaintainer($this->iVersionId)) | $this->bSuperMaintainer))
|
||||
{
|
||||
/* unqueue the maintainer entry */
|
||||
$hResult = query_parameters("UPDATE appMaintainers SET queued='false' WHERE userId = '?' AND maintainerId = '?'",
|
||||
$this->iUserId, $this->iMaintainerId);
|
||||
|
||||
if($hResult)
|
||||
{
|
||||
$sStatusMessage = "<p>The maintainer was successfully added into the database</p>\n";
|
||||
|
||||
$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 .= $sReplyText;
|
||||
$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_parameters("DELETE from appMaintainers WHERE userId = '?' AND maintainerId = '?'",
|
||||
$this->iUserId, $this->iMaintainerId);
|
||||
|
||||
if($oUser->isSuperMaintainer($this->iAppId) && !$this->bSuperMaintainer)
|
||||
$sStatusMessage = "<p>User is already a super maintainer of this application</p>\n";
|
||||
else
|
||||
$sStatusMessage = "<p>User is already a maintainer/super maintainer of this application/version</p>\n";
|
||||
}
|
||||
|
||||
return $sStatusMessage;
|
||||
}
|
||||
|
||||
function reject($sReplyText)
|
||||
{
|
||||
$oUser = new User($this->iUserId);
|
||||
$sEmail = $oUser->sEmail;
|
||||
if ($sEmail)
|
||||
{
|
||||
$oApp = new Application($oRow->appId);
|
||||
$oVersion = new Version($oRow->versionId);
|
||||
$sSubject = "Application Maintainer Request Report";
|
||||
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." was rejected. ";
|
||||
$sMsg .= $sReplyText;
|
||||
$sMsg .= "";
|
||||
$sMsg .= "-The AppDB admins\n";
|
||||
|
||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||
}
|
||||
|
||||
//delete main item
|
||||
$sQuery = "DELETE from appMaintainers where maintainerId = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iMaintainerId);
|
||||
|
||||
return $hResult;
|
||||
}
|
||||
|
||||
function delete()
|
||||
{
|
||||
$sQuery = "DELETE from appMaintainers where maintainerId = '?'";
|
||||
query_parameters($sQuery, $this->iMaintainerId);
|
||||
}
|
||||
|
||||
function deleteMaintainer($oUser, $iAppId = null, $iVersionId = null)
|
||||
{
|
||||
/* remove supermaintainer */
|
||||
if($iAppId && ($iVersionId == null))
|
||||
{
|
||||
$superMaintainer = 1;
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
||||
AND appId = '?' AND superMaintainer = '?'",
|
||||
$oUser->iUserId, $iAppId, $superMaintainer);
|
||||
} else if($iAppId && $iVersionId) /* remove a normal maintainer */
|
||||
{
|
||||
$superMaintainer = 0;
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
||||
AND appId = '?' AND versionId = '?' AND superMaintainer = '?'",
|
||||
$oUser->iUserId, $iAppId, $iVersionId, $superMaintainer);
|
||||
} else if(($iAppId == null) && ($iVersionId == null)) /* remove all maintainership by this user */
|
||||
{
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'",
|
||||
$oUser->iUserId);
|
||||
}
|
||||
|
||||
if($hResult)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function deleteMaintainersForVersion($oVersion)
|
||||
{
|
||||
$hResult = query_parameters("DELETE from appMaintainers WHERE versionId='?'",
|
||||
$oVersion->iVersionId);
|
||||
}
|
||||
|
||||
function deleteMaintainersForApplication($oApp)
|
||||
{
|
||||
$sQuery = "DELETE from appMaintainers WHERE appId='?'";
|
||||
$hResult = query_parameters($sQuery, $oApp->iAppId);
|
||||
return $hResult;
|
||||
}
|
||||
|
||||
function ObjectGetEntries($bQueued)
|
||||
{
|
||||
if($bQueued)
|
||||
$sQuery = "SELECT maintainerId FROM appMaintainers, user_list WHERE appMaintainers.userid = user_list.userid ".
|
||||
"AND queued = '?' ORDER by submitTime";
|
||||
else
|
||||
$sQuery = "SELECT maintainerId FROM appMaintainers, user_list WHERE appMaintainers.userid = user_list.userid ".
|
||||
"AND queued = '?' ORDER by realname";
|
||||
|
||||
if($bQueued)
|
||||
{
|
||||
if($_SESSION['current']->hasPriv("admin"))
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
||||
else
|
||||
return NULL;
|
||||
} else
|
||||
{
|
||||
return query_parameters($sQuery, $bQueued ? "true" : "false");
|
||||
}
|
||||
}
|
||||
|
||||
/* retrieve a maintainer object from a row returned by */
|
||||
/* ObjectGetEntries() */
|
||||
function ObjectGetObjectFromObjectGetEntriesRow($oRow)
|
||||
{
|
||||
return new maintainer($oRow->maintainerId);
|
||||
}
|
||||
|
||||
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");
|
||||
if(!$hResult)
|
||||
return 0;
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->cnt;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the applications and versions that this user maintains
|
||||
*/
|
||||
function getAppsMaintained($oUser)
|
||||
{
|
||||
/* 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");
|
||||
if(!$hResult || mysql_num_rows($hResult) == 0)
|
||||
return NULL;
|
||||
|
||||
$aAppsMaintained = array();
|
||||
$c = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$aAppsMaintained[$c] = array($oRow->appId, $oRow->versionId, $oRow->superMaintainer);
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $aAppsMaintained;
|
||||
}
|
||||
|
||||
function getQueuedMaintainerCount()
|
||||
{
|
||||
$sQuery = "SELECT count(*) as queued_maintainers FROM appMaintainers where queued='true'";
|
||||
$hResult = query_parameters($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->queued_maintainers;
|
||||
}
|
||||
|
||||
/* 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 = mysql_fetch_object($hResult);
|
||||
return $oRow->maintainers;
|
||||
}
|
||||
|
||||
/* see how many unique maintainers we actually have */
|
||||
function getNumberOfMaintainers()
|
||||
{
|
||||
$hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers WHERE queued='false';");
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
function isUserMaintainer($oUser, $iVersionId = null)
|
||||
{
|
||||
/* if we are a super maintainer, we are a maintainer of this version as well */
|
||||
$oVersion = new Version($iVersionId);
|
||||
if($oUser->isSuperMaintainer($oVersion->iAppId))
|
||||
return true;
|
||||
|
||||
/* 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");
|
||||
} else // are we maintaining any version ?
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $oUser->iUserId, "false");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
function isUserSuperMaintainer($oUser, $iAppId = null)
|
||||
{
|
||||
if($iAppId)
|
||||
{
|
||||
$sQuery = "SELECT * FROM appMaintainers WHERE userid = '?' AND appId = '?' AND superMaintainer = '1' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $oUser->iUserId, $iAppId, "false");
|
||||
} 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");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
/* if given an appid or a version id return a handle for a query that has */
|
||||
/* the user ids that are maintainers for this particular appid or version id */
|
||||
function getMaintainersForAppIdVersionId($iAppId = null, $iVersionId = null)
|
||||
{
|
||||
$hResult = null;
|
||||
|
||||
if($iVersionId)
|
||||
{
|
||||
$hResult = query_parameters("SELECT appMaintainers.userId
|
||||
FROM appMaintainers, appVersion
|
||||
WHERE appVersion.appId = appMaintainers.appId
|
||||
AND appVersion.versionId = '?' AND appMaintainers.queued = 'false'",
|
||||
$iVersionId);
|
||||
}
|
||||
/*
|
||||
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
||||
*/
|
||||
elseif($iAppId)
|
||||
{
|
||||
$hResult = query_parameters("SELECT userId
|
||||
FROM appMaintainers
|
||||
WHERE appId = '?' AND queued = 'false'",
|
||||
$iAppId);
|
||||
}
|
||||
|
||||
return $hResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* get the userIds of super maintainers for this appId
|
||||
*/
|
||||
function getSuperMaintainersUserIdsFromAppId($iAppId)
|
||||
{
|
||||
function getSuperMaintainersUserIdsFromAppId($iAppId)
|
||||
{
|
||||
$sQuery = "SELECT userId FROM ".
|
||||
"appMaintainers WHERE appId = '?' " .
|
||||
"AND superMaintainer = '1' AND queued='?';";
|
||||
$hResult = query_parameters($sQuery, $iAppId, "false");
|
||||
$retval = array();
|
||||
$aUserIds = array();
|
||||
$c = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$retval[$c] = $oRow->userId;
|
||||
$aUserIds[$c] = $oRow->userId;
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
return $aUserIds;
|
||||
}
|
||||
|
||||
function ObjectOutputHeader()
|
||||
{
|
||||
echo " <td>Submission Date</td>\n";
|
||||
echo " <td>Application Name</td>\n";
|
||||
echo " <td>Version</td>\n";
|
||||
echo " <td>Super maintainer?</td>\n";
|
||||
echo " <td>Submitter</td>\n";
|
||||
}
|
||||
|
||||
function ObjectOutputTableRow()
|
||||
{
|
||||
$oUser = new User($this->iUserId);
|
||||
$oApp = new Application($this->iAppId);
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
echo "<td>".print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime))." </td>\n";
|
||||
echo "<td>".$oApp->sName."</td>\n";
|
||||
|
||||
if($this->bSuperMaintainer)
|
||||
{
|
||||
echo "<td>N/A</td>\n";
|
||||
echo "<td>Yes</td>\n";
|
||||
} else
|
||||
{
|
||||
echo "<td>".$oVersion->sName." </td>\n";
|
||||
echo "<td>No</td>\n";
|
||||
}
|
||||
|
||||
echo "<td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
|
||||
}
|
||||
|
||||
function ObjectDisplayQueueProcessingHelp()
|
||||
{
|
||||
echo "<div align=center><table width='90%' border=0 cellpadding=3 cellspacing=0><tr><td>\n\n";
|
||||
echo "Please enter an accurate and personalized reply anytime a maintainer request is rejected.\n";
|
||||
echo "Its not polite to reject someones attempt at trying to help out without explaining why.\n";
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
}
|
||||
|
||||
function OutputEditor()
|
||||
{
|
||||
//view application details
|
||||
echo html_frame_start("New Maintainer Form",600,"",0);
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
|
||||
/**
|
||||
* Show the other maintainers of this application, if there are any
|
||||
*/
|
||||
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>Other maintainers of this app:</b></td>',"\n";
|
||||
|
||||
$bFoundMaintainers = false;
|
||||
|
||||
$bFirstDisplay = true; /* if false we need to fix up table rows appropriately */
|
||||
|
||||
/* display maintainers for the version */
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
$aOtherUsers = $oVersion->getMaintainersUserIds();
|
||||
if($aOtherUsers)
|
||||
{
|
||||
$bFoundMaintainers = true;
|
||||
while(list($index, $iUserId) = each($aOtherUsers))
|
||||
{
|
||||
$oUser = new User($iUserId);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
echo "<td>".$oUser->sRealname."</td></tr>\n";
|
||||
$bFirstDisplay = false;
|
||||
} else
|
||||
{
|
||||
echo "<tr><td class=\"color0\"></td><td>".$oUser->sRealname."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* display super maintainers for the given app */
|
||||
$aOtherUsers = Maintainer::getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
||||
if($aOtherUsers)
|
||||
{
|
||||
$bFoundMaintainers = true;
|
||||
while(list($index, $iUserId) = each($aOtherUsers))
|
||||
{
|
||||
$oUser = new User($iUserId);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
echo "<td>".$oUser->sRealname."*</td></tr>\n";
|
||||
$bFirstDisplay = false;
|
||||
} else
|
||||
{
|
||||
echo "<tr><td class=\"color0\"></td><td>".$oUser->sRealname."*</td></tr>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!$bFoundMaintainers)
|
||||
{
|
||||
echo "<td>No other maintainers</td></tr>\n";
|
||||
}
|
||||
|
||||
// Show which other apps the user maintains
|
||||
echo '<tr valign="top"><td class="color0" style=\'text-align:right\'><b>This user also maintains these apps:</b></td>',"\n";
|
||||
|
||||
$bFirstDisplay = true;
|
||||
$oUser = new User($this->iUserId);
|
||||
$aOtherApps = Maintainer::getAppsMaintained($oUser);
|
||||
if($aOtherApps)
|
||||
{
|
||||
while(list($index, list($iAppIdOther, $iVersionIdOther, $bSuperMaintainerOther)) = each($aOtherApps))
|
||||
{
|
||||
$oApp = new Application($iAppIdOther);
|
||||
$oVersion = new Version($iVersionIdOther);
|
||||
if($bFirstDisplay)
|
||||
{
|
||||
$bFirstDisplay = false;
|
||||
if($bSuperMaintainerOther)
|
||||
echo "<td>".$oApp->sName."*</td></tr>\n";
|
||||
else
|
||||
echo "<td>".$oApp->sName." ".$oVersion->sName."</td></tr>\n";
|
||||
} else
|
||||
{
|
||||
if($bSuperMaintainerOther)
|
||||
echo "<td class=color0></td><td>".$oApp->sName."*</td></tr>\n";
|
||||
else
|
||||
echo "<td class=color0></td><td>".$oApp->sName." ".$oVersion->sName."</td></tr>\n";
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
echo "<td>User maintains no other applications</td></tr>\n";
|
||||
}
|
||||
|
||||
$oApp = new Application($this->iAppId);
|
||||
$oVersion = new Version($this->iVersionId);
|
||||
|
||||
//app name
|
||||
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>App Name:</b></td>',"\n";
|
||||
echo "<td>".$oApp->sName."</td></tr>\n";
|
||||
|
||||
//version
|
||||
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>App Version:</b></td>',"\n";
|
||||
echo "<td>".$oVersion->sName."</td></tr>\n";
|
||||
|
||||
//maintainReason
|
||||
echo '<tr valign=top><td class=color0 style=\'text-align:right\'><b>Maintainer request reason:</b></td>',"\n";
|
||||
echo '<td><textarea name="sMaintainReason" rows=10 cols=35>'.$this->sMaintainReason.'</textarea></td></tr>',"\n";
|
||||
echo '</table>';
|
||||
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
};
|
||||
|
||||
?>
|
||||
|
||||
@@ -15,8 +15,8 @@ function global_admin_menu() {
|
||||
$g->addmisc(" ");
|
||||
$g->add("View App Queue (".$_SESSION['current']->getQueuedAppCount()."/".$_SESSION['current']->getQueuedVersionCount().")", BASE."admin/adminAppQueue.php");
|
||||
$g->add("View App Data Queue (".$_SESSION['current']->getQueuedAppDataCount().")", BASE."admin/adminAppDataQueue.php");
|
||||
$g->add("View Maintainer Queue (".getQueuedMaintainerCount().")", BASE."admin/adminMaintainerQueue.php");
|
||||
$g->add("View Maintainer Entries (".getMaintainerCount().")", BASE."admin/adminMaintainers.php");
|
||||
$g->add("View Maintainer Queue (".Maintainer::getQueuedMaintainerCount().")", BASE."admin/adminMaintainerQueue.php");
|
||||
$g->add("View Maintainer Entries (".Maintainer::getMaintainerCount().")", BASE."admin/adminMaintainers.php");
|
||||
$g->add("View Bug Links (".getNumberOfQueuedBugLinks()."/".getNumberOfBugLinks().")", BASE."admin/adminBugs.php");
|
||||
$g->add("View Test Results Queue (".testData::getNumberOfQueuedTests().")", BASE."admin/adminTestResults.php");
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ function global_sidebar_login() {
|
||||
|
||||
/* if this user maintains any applications list them */
|
||||
/* in their sidebar */
|
||||
$apps_user_maintains = $_SESSION['current']->getAppsMaintained();
|
||||
$apps_user_maintains = Maintainer::getAppsMaintained($_SESSION['current']);
|
||||
if($apps_user_maintains)
|
||||
{
|
||||
$g->addmisc("");
|
||||
|
||||
198
include/user.php
198
include/user.php
@@ -4,6 +4,7 @@
|
||||
/************************************/
|
||||
|
||||
require_once(BASE."include/version.php");
|
||||
require_once(BASE."include/maintainer.php");
|
||||
require_once(BASE."include/util.php");
|
||||
|
||||
define(SUCCESS, 0);
|
||||
@@ -187,11 +188,10 @@ class User {
|
||||
*/
|
||||
function delete()
|
||||
{
|
||||
if(!$this->isLoggedIn()) return false;
|
||||
$hResult2 = query_parameters("DELETE FROM user_privs WHERE userid = '?'", $this->iUserId);
|
||||
$hResult3 = query_parameters("DELETE FROM user_prefs WHERE userid = '?'", $this->iUserId);
|
||||
$hResult4 = query_parameters("DELETE FROM appVotes WHERE userid = '?'", $this->iUserId);
|
||||
$hResult5 = query_parameters("DELETE FROM appMaintainers WHERE userid = '?'", $this->iUserId);
|
||||
$hResult5 = Maintainer::deleteMaintainer($this);
|
||||
$hResult6 = query_parameters("DELETE FROM appComments WHERE userId = '?'", $this->iUserId);
|
||||
return($hResult = query_parameters("DELETE FROM user_list WHERE userid = '?'", $this->iUserId));
|
||||
}
|
||||
@@ -246,174 +246,16 @@ class User {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if this user is a maintainer of a given appId/versionId.
|
||||
*/
|
||||
/* Check if this user is a maintainer of a given appId/versionId */
|
||||
function isMaintainer($iVersionId=null)
|
||||
{
|
||||
if(!$this->isLoggedIn()) return false;
|
||||
|
||||
/* if we are a super maintainer, we are a maintainer of this version as well */
|
||||
$oVersion = new Version($iVersionId);
|
||||
if($this->isSuperMaintainer($oVersion->iAppId))
|
||||
return true;
|
||||
|
||||
/* otherwise check if we maintain this specific version */
|
||||
if($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 = '?' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, "false");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
|
||||
return mysql_num_rows($hResult);
|
||||
return Maintainer::isUserMaintainer($this, $iVersionId);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check if this user is a maintainer of a given appId/versionId.
|
||||
*/
|
||||
/* Check if this user is a maintainer of a given appId/versionId */
|
||||
function isSuperMaintainer($iAppId=null)
|
||||
{
|
||||
if(!$this->isLoggedIn()) return false;
|
||||
|
||||
if($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' AND queued = '?'";
|
||||
$hResult = query_parameters($sQuery, $this->iUserId, "false");
|
||||
}
|
||||
if(!$hResult)
|
||||
return false;
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the applications and versions that this user maintains
|
||||
*/
|
||||
function getAppsMaintained()
|
||||
{
|
||||
/* 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",
|
||||
$this->iUserId, "false");
|
||||
if(!$hResult || mysql_num_rows($hResult) == 0)
|
||||
return NULL;
|
||||
|
||||
$aAppsMaintained = array();
|
||||
$c = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$aAppsMaintained[$c] = array($oRow->appId, $oRow->versionId, $oRow->superMaintainer);
|
||||
$c++;
|
||||
}
|
||||
|
||||
return $aAppsMaintained;
|
||||
}
|
||||
|
||||
function getMaintainerCount($bSuperMaintainer)
|
||||
{
|
||||
if(!$this->isLoggedIn()) return 0;
|
||||
|
||||
$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);
|
||||
return $oRow->cnt;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the user as a maintainer
|
||||
*/
|
||||
//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();
|
||||
$aClean['sReplyText'] = makeSafe($_REQUEST['sReplyText']);
|
||||
|
||||
/* 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))
|
||||
{
|
||||
/* 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";
|
||||
|
||||
$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 .= $aClean['sReplyText'];
|
||||
$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_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";
|
||||
else
|
||||
$statusMessage = "<p>User is already a maintainer/super maintainer of this application/version</p>\n";
|
||||
}
|
||||
|
||||
return $statusMessage;
|
||||
}
|
||||
|
||||
/* remove maintainership */
|
||||
/* if $iAppId and $iVersionId are null, delete all maintainership for this user */
|
||||
function deleteMaintainer($iAppId = null, $iVersionId = null)
|
||||
{
|
||||
/* remove supermaintainer */
|
||||
if($iAppId && ($iVersionId == null))
|
||||
{
|
||||
$superMaintainer = 1;
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
||||
AND appId = '?' AND superMaintainer = '?'",
|
||||
$this->iUserId, $iAppId, $superMaintainer);
|
||||
} else if($iAppId && $iVersionId) /* remove a normal maintainer */
|
||||
{
|
||||
$superMaintainer = 0;
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'
|
||||
AND appId = '?' AND versionId = '?' AND superMaintainer = '?'",
|
||||
$this->iUserId, $iAppId, $iVersionId, $superMaintainer);
|
||||
} else if(($iAppId == null) && ($iVersionId == null)) /* remove all maintainership by this user */
|
||||
{
|
||||
$hResult = query_parameters("DELETE FROM appMaintainers WHERE userId = '?'", $this->iUserId);
|
||||
}
|
||||
|
||||
if($hResult)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return Maintainer::isUserSuperMaintainer($this, $iAppId);
|
||||
}
|
||||
|
||||
/* get the number of queued applications */
|
||||
@@ -717,10 +559,8 @@ class User {
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow->c != 0) return true;
|
||||
|
||||
$hResult = query_parameters("SELECT count(userId) as c FROM appMaintainers WHERE userId = '?'",
|
||||
$this->iUserId);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
if($oRow->c != 0) return true;
|
||||
if($this->isMaintainer() || $this->isSuperMaintainer())
|
||||
return true;
|
||||
|
||||
$hResult = query_parameters("SELECT count(userId) as c FROM appVotes WHERE userId = '?'",
|
||||
$this->iUserId);
|
||||
@@ -841,27 +681,7 @@ class User {
|
||||
/*
|
||||
* Retrieve version maintainers.
|
||||
*/
|
||||
/*
|
||||
* If versionId was supplied we fetch supermaintainers of application and maintainer of version.
|
||||
*/
|
||||
if($iVersionId)
|
||||
{
|
||||
$hResult = query_parameters("SELECT appMaintainers.userId
|
||||
FROM appMaintainers, appVersion
|
||||
WHERE appVersion.appId = appMaintainers.appId
|
||||
AND appVersion.versionId = '?' AND appMaintainers.queued = 'false'",
|
||||
$iVersionId);
|
||||
}
|
||||
/*
|
||||
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
||||
*/
|
||||
elseif($iAppId)
|
||||
{
|
||||
$hResult = query_parameters("SELECT userId
|
||||
FROM appMaintainers
|
||||
WHERE appId = '?' AND queued = 'false'",
|
||||
$iAppId);
|
||||
}
|
||||
$hResult = Maintainer::getMaintainersForAppIdVersionId($iAppId, $iVersionId);
|
||||
|
||||
if($hResult)
|
||||
{
|
||||
|
||||
@@ -184,24 +184,6 @@ function make_maintainer_rating_list($varname, $cvalue)
|
||||
echo "</select>\n";
|
||||
}
|
||||
|
||||
/* get the number of queued maintainers */
|
||||
function getQueuedMaintainerCount()
|
||||
{
|
||||
$sQuery = "SELECT count(*) as queued_maintainers FROM appMaintainers where queued='true'";
|
||||
$hResult = query_parameters($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->queued_maintainers;
|
||||
}
|
||||
|
||||
/* get the total number of maintainers and applications in the appMaintainers table */
|
||||
function getMaintainerCount()
|
||||
{
|
||||
$sQuery = "SELECT count(*) as maintainers FROM appMaintainers where queued='false'";
|
||||
$hResult = query_parameters($sQuery);
|
||||
$oRow = mysql_fetch_object($hResult);
|
||||
return $oRow->maintainers;
|
||||
}
|
||||
|
||||
/* get the total number of vendors from the vendor table */
|
||||
function getVendorCount()
|
||||
{
|
||||
@@ -227,13 +209,6 @@ function getNumberOfVersions()
|
||||
return $oRow->num_versions;
|
||||
}
|
||||
|
||||
/* Get the number of maintainers in the database */
|
||||
function getNumberOfMaintainers()
|
||||
{
|
||||
$hResult = query_parameters("SELECT DISTINCT userId FROM appMaintainers WHERE queued='false';");
|
||||
return mysql_num_rows($hResult);
|
||||
}
|
||||
|
||||
/* Get the number of app familes in the database */
|
||||
function getNumberOfAppFamilies()
|
||||
{
|
||||
|
||||
@@ -305,8 +305,8 @@ class Version {
|
||||
|
||||
|
||||
// remove any maintainers for this version so we don't orphan them
|
||||
$hResult = query_parameters("DELETE from appMaintainers WHERE versionId='?'", $this->iVersionId);
|
||||
if(!$hResult)
|
||||
$result = Maintainer::deleteMaintainersForVersion($this);
|
||||
if(!$result)
|
||||
{
|
||||
addmsg("Error removing version maintainers for the deleted version!", "red");
|
||||
}
|
||||
@@ -665,7 +665,7 @@ class Version {
|
||||
echo "<tr class=\"color0\"><td align=\"left\" colspan=\"2\"><b>Maintainers of this version:</b>\n";
|
||||
echo "<table width=\"250\" border=\"0\">";
|
||||
$aMaintainers = $this->getMaintainersUserIds();
|
||||
$aSupermaintainers = getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
||||
$aSupermaintainers = Maintainer::getSuperMaintainersUserIdsFromAppId($this->iAppId);
|
||||
$aAllMaintainers = array_merge($aMaintainers,$aSupermaintainers);
|
||||
$aAllMaintainers = array_unique($aAllMaintainers);
|
||||
if(sizeof($aAllMaintainers)>0)
|
||||
@@ -940,9 +940,7 @@ class Version {
|
||||
if($this->iVersionId == 0)
|
||||
return $aMaintainers;
|
||||
|
||||
$sQuery = "SELECT userId FROM ".
|
||||
"appMaintainers WHERE versionId = '?';";
|
||||
$hResult = query_parameters($sQuery, $this->iVersionId);
|
||||
$hResult = Maintainer::getMaintainersForAppIdVersionId(null, $this->iVersionId);
|
||||
$iCount = 0;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
|
||||
@@ -40,12 +40,12 @@ if($aClean['iConfirmed'])
|
||||
if($aClean['iSuperMaintainer'])
|
||||
{
|
||||
apidb_header("You have resigned as super maintainer of ".$oApp->sName);
|
||||
$result = $_SESSION['current']->deleteMaintainer($oApp->iAppId, null);
|
||||
$result = Maintainer::deleteMaintainer($_SESSION['current'], $aClean['iAppId'], null);
|
||||
} else
|
||||
{
|
||||
$oVersion = new Version($aClean['iVersionId']);
|
||||
apidb_header("You have resigned as maintainer of ".$oApp->sName." ".$oVersion->sName);
|
||||
$result = $_SESSION['current']->deleteMaintainer($oApp->iAppId, $oVersion->iVersionId);
|
||||
$result = Maintainer::deleteMaintainer($_SESSION['current'], $oApp->iAppId, $oVersion->iVersionId);
|
||||
}
|
||||
/* echo html_frame_start("Removing",400,"",0);
|
||||
*/
|
||||
|
||||
@@ -85,12 +85,14 @@ if( $aClean['sMaintainReason'] )
|
||||
apidb_header("Submit Maintainer Request");
|
||||
|
||||
// add to queue
|
||||
$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()", 'true');
|
||||
$oMaintainer = new Maintainer();
|
||||
$oMaintainer->iAppId = $aClean['iAppId'];
|
||||
$oMaintainer->iVersionId = $aClean['iVersionId'];
|
||||
$oMaintainer->iUserId = $_SESSION['current']->iUserId;
|
||||
$oMaintainer->sMaintainReason = $aClean['sMaintainReason'];
|
||||
$oMaintainer->bSuperMaintainer = $aClean['iSuperMaintainer'];
|
||||
|
||||
$hResult = $oMaintainer->create();
|
||||
|
||||
if ($hResult)
|
||||
{
|
||||
|
||||
206
unit_test/test_maintainer.php
Normal file
206
unit_test/test_maintainer.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
|
||||
require_once("path.php");
|
||||
require_once(BASE.'include/maintainer.php');
|
||||
|
||||
/* unit tests for maintainer class */
|
||||
|
||||
function test_maintainer_getMaintainerCountForUser()
|
||||
{
|
||||
test_start(__FUNCTION__);
|
||||
|
||||
global $test_email, $test_password;
|
||||
|
||||
/* login the user */
|
||||
$oUser = new User();
|
||||
$retval = $oUser->login($test_email, $test_password);
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* make the user a super maintatiner
|
||||
*/
|
||||
$iAppId = 655000;
|
||||
$iVersionId = 655200;
|
||||
|
||||
/* queue up this maintainer */
|
||||
$oMaintainer = new Maintainer();
|
||||
$oMaintainer->iAppId = $iAppId;
|
||||
$oMaintainer->iVersionId = $iVersionId;
|
||||
$oMaintainer->iUserId = $_SESSION['current']->iUserId;
|
||||
$oMaintainer->sMaintainReason = "Some crazy reason";
|
||||
$oMaintainer->bSuperMaintainer = TRUE;
|
||||
$oMaintainer->create();
|
||||
|
||||
/* and unqueue it to accept the user as a maintainer */
|
||||
$oMaintainer->unQueue("Some reply text");
|
||||
|
||||
/* 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 */
|
||||
$iSuperMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, TRUE);
|
||||
if($iSuperMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* maintainer count should be zero */
|
||||
$iExpected = 0;
|
||||
$iMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, FALSE);
|
||||
if($iMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
Maintainer::deleteMaintainer($oUser, $iAppId);
|
||||
|
||||
/**
|
||||
* make the user a maintainer
|
||||
*/
|
||||
|
||||
/* queue up this maintainer */
|
||||
$oMaintainer = new Maintainer();
|
||||
$oMaintainer->iAppId = $iAppId;
|
||||
$oMaintainer->iVersionId = $iVersionId;
|
||||
$oMaintainer->iUserId = $_SESSION['current']->iUserId;
|
||||
$oMaintainer->sMaintainReason = "Some crazy reason";
|
||||
$oMaintainer->bSuperMaintainer = FALSE;
|
||||
$oMaintainer->create();
|
||||
|
||||
/* and unqueue it to accept the user as a maintainer */
|
||||
$oMaintainer->unQueue("Some reply text");
|
||||
|
||||
/* see that the user is a super maintainer of no applications */
|
||||
$iExpected = 0; /* we expect 1 super maintainer for this user */
|
||||
$iSuperMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, TRUE);
|
||||
if($iSuperMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* maintainer count should be one */
|
||||
$iExpected = 1;
|
||||
$iMaintainerCount = Maintainer::getMaintainerCountForUser($oUser, FALSE);
|
||||
if($iMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
Maintainer::deleteMaintainer($oUser, $iAppId, $iVersionId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function test_maintainer_getAppsMaintained()
|
||||
{
|
||||
test_start(__FUNCTION__);
|
||||
|
||||
global $test_email, $test_password;
|
||||
|
||||
/* login the user */
|
||||
$oUser = new User();
|
||||
$retval = $oUser->login($test_email, $test_password);
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* make this user an admin so we can create applications without having them queued */
|
||||
$hResult = query_parameters("INSERT into user_privs values ('?', '?')",
|
||||
$oUser->iUserId, "admin");
|
||||
|
||||
/* create a application so we have a valid appFamily for the call to user::getAppsMaintained() */
|
||||
$oApp = new Application();
|
||||
$oApp->sName = "Some application";
|
||||
$oApp->sDescription = "some description";
|
||||
$oApp->submitterId = $oUser->iUserId;
|
||||
if(!$oApp->create())
|
||||
{
|
||||
echo "Failed to create application!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* make the user a super maintatiner
|
||||
*/
|
||||
$iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
|
||||
$iVersionId = 655200;
|
||||
$bSuperMaintainer = TRUE;
|
||||
|
||||
/* queue up the maintainership */
|
||||
// add to queue
|
||||
$oMaintainer = new Maintainer();
|
||||
$oMaintainer->iAppId = $iAppId;
|
||||
$oMaintainer->iVersionId = $iVersionId;
|
||||
$oMaintainer->iUserId = $oUser->iUserId;
|
||||
$oMaintainer->sMaintainReason = "Some crazy reason";
|
||||
$oMaintainer->bSuperMaintainer = $bSuperMaintainer;
|
||||
$oMaintainer->create();
|
||||
|
||||
$statusMessage = $oMaintainer->unQueue("Some reply text"); /* accept the maintainership */
|
||||
|
||||
/* get an array of the apps maintained */
|
||||
$aAppsMaintained = maintainer::getAppsMaintained($oUser);
|
||||
|
||||
if(!$aAppsMaintained)
|
||||
{
|
||||
echo "aAppsMaintained is null, we expected a non-null return value!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get only the first entry from the array of applications maintained */
|
||||
/* we only added the user as a maintainer of a single application */
|
||||
list($iAppId1, $iVersionId1, $bSuperMaintainer1) = $aAppsMaintained[0];
|
||||
|
||||
/* make sure all parameters match what we added as maintainer information */
|
||||
if($iAppId1 != $iAppId)
|
||||
{
|
||||
echo "Expected iAppid of ".$iAppId." but got ".$iAppId1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($iVersionId1 != $iVersionId)
|
||||
{
|
||||
echo "Expected iVersionId of ".$iVersionId." but got ".$iVersionId1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($bSuperMaintainer1 != $bSuperMaintainer)
|
||||
{
|
||||
echo "Expected bSuperMaintainer of ".$bSuperMaintainer." but got ".$bSuperMaintainer1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
Maintainer::deleteMaintainer($oUser, $iAppId);
|
||||
|
||||
/* remove this application */
|
||||
$oApp = new Application($iAppId);
|
||||
$oApp->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!test_maintainer_getMaintainerCountForUser())
|
||||
echo "test_maintainer_getMaintainerCountForUser() failed!\n";
|
||||
else
|
||||
echo "test_maintainer_getMaintainerCountForUser() passed\n";
|
||||
|
||||
|
||||
if(!test_maintainer_getAppsMaintained())
|
||||
echo "test_maintainer_getAppsMaintained() failed!\n";
|
||||
else
|
||||
echo "test_maintainer_getAppsMaintained() passed\n";
|
||||
|
||||
?>
|
||||
@@ -277,200 +277,6 @@ function test_user_update_password()
|
||||
return true;
|
||||
}
|
||||
|
||||
function test_user_getMaintainerCount()
|
||||
{
|
||||
test_start(__FUNCTION__);
|
||||
|
||||
global $test_email, $test_password;
|
||||
|
||||
/* login the user */
|
||||
$oUser = new User();
|
||||
$retval = $oUser->login($test_email, $test_password);
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* make the user a super maintatiner
|
||||
*/
|
||||
$iAppId = 655000;
|
||||
$iVersionId = 655200;
|
||||
|
||||
//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 */
|
||||
$iSuperMaintainerCount = $oUser->getMaintainerCount(TRUE);
|
||||
if($iSuperMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* maintainer count should be zero */
|
||||
$iExpected = 0;
|
||||
$iMaintainerCount = $oUser->getMaintainerCount(FALSE);
|
||||
if($iMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
$oUser->deleteMaintainer($iAppId);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* make the user a maintainer
|
||||
*/
|
||||
//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 */
|
||||
$iSuperMaintainerCount = $oUser->getMaintainerCount(TRUE);
|
||||
if($iSuperMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got super maintainer count of '".$iSuperMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* maintainer count should be one */
|
||||
$iExpected = 1;
|
||||
$iMaintainerCount = $oUser->getMaintainerCount(FALSE);
|
||||
if($iMaintainerCount != $iExpected)
|
||||
{
|
||||
echo "Got maintainer count of '".$iMaintainerCount."' instead of '".$iExpected."'\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
$oUser->deleteMaintainer($iAppId, $iVersionId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function test_user_getAppsMaintained()
|
||||
{
|
||||
test_start(__FUNCTION__);
|
||||
|
||||
global $test_email, $test_password;
|
||||
|
||||
/* login the user */
|
||||
$oUser = new User();
|
||||
$retval = $oUser->login($test_email, $test_password);
|
||||
if($retval != SUCCESS)
|
||||
{
|
||||
echo "Got '".$retval."' instead of SUCCESS(".SUCCESS.")\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* make this user an admin so we can create applications without having them queued */
|
||||
$hResult = query_parameters("INSERT into user_privs values ('?', '?')",
|
||||
$oUser->iUserId, "admin");
|
||||
|
||||
/* create a application so we have a valid appFamily for the call to user::getAppsMaintained() */
|
||||
$oApp = new Application();
|
||||
$oApp->sName = "Some application";
|
||||
$oApp->sDescription = "some description";
|
||||
$oApp->submitterId = $oUser->iUserId;
|
||||
if(!$oApp->create())
|
||||
{
|
||||
echo "Failed to create application!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* make the user a super maintatiner
|
||||
*/
|
||||
$iAppId = $oApp->iAppId; /* use the iAppId of the application we just created */
|
||||
$iVersionId = 655200;
|
||||
$bSuperMaintainer = TRUE;
|
||||
|
||||
//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();
|
||||
|
||||
if(!$aAppsMaintained)
|
||||
{
|
||||
echo "aAppsMaintained is null, we expected a non-null return value!\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get only the first entry from the array of applications maintained */
|
||||
/* we only added the user as a maintainer of a single application */
|
||||
list($iAppId1, $iVersionId1, $bSuperMaintainer1) = $aAppsMaintained[0];
|
||||
|
||||
/* make sure all parameters match what we added as maintainer information */
|
||||
if($iAppId1 != $iAppId)
|
||||
{
|
||||
echo "Expected iAppid of ".$iAppId." but got ".$iAppId1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($iVersionId1 != $iVersionId)
|
||||
{
|
||||
echo "Expected iVersionId of ".$iVersionId." but got ".$iVersionId1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if($bSuperMaintainer1 != $bSuperMaintainer)
|
||||
{
|
||||
echo "Expected bSuperMaintainer of ".$bSuperMaintainer." but got ".$bSuperMaintainer1."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/* remove maintainership for this user */
|
||||
$oUser->deleteMaintainer($iAppId);
|
||||
|
||||
/* remove this application */
|
||||
$oApp = new Application($iAppId);
|
||||
$oApp->delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*************************/
|
||||
/* Main testing routines */
|
||||
|
||||
@@ -504,20 +310,13 @@ if(!test_user_update_password())
|
||||
else
|
||||
echo "test_user_update_password() passed\n";
|
||||
|
||||
if(!test_user_getMaintainerCount())
|
||||
echo "test_user_getMaintainerCount() failed!\n";
|
||||
else
|
||||
echo "test_user_getMaintainerCount() passed\n";
|
||||
|
||||
if(!test_user_getAppsMaintained())
|
||||
echo "test_user_getAppsMaintained() failed!\n";
|
||||
else
|
||||
echo "test_user_getAppsMaintained() passed\n";
|
||||
/* Perform the maintainer tests here because they require that a user we can log into */
|
||||
/* and we want to save on having to clean up the user by duplicating the cleanup code below */
|
||||
include_once("test_maintainer.php");
|
||||
|
||||
/* TODO: the rest of the user member functions we don't currently test */
|
||||
|
||||
|
||||
|
||||
/* clean up the user we created during testing */
|
||||
/* so the unit test leaves no trace that it ran */
|
||||
$oUser = new User();
|
||||
|
||||
Reference in New Issue
Block a user