Let ObjectManager handle maintainer requests
This commit is contained in:
committed by
WineHQ
parent
47a4d3cf84
commit
bf7daaa789
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
/********************************************************/
|
||||
/* code to View and approve new application maintainers */
|
||||
/********************************************************/
|
||||
|
||||
require("path.php");
|
||||
require(BASE."include/incl.php");
|
||||
require_once(BASE."include/tableve.php");
|
||||
require_once(BASE."include/category.php");
|
||||
require_once(BASE."include/maintainer.php");
|
||||
require_once(BASE."include/application.php");
|
||||
require_once(BASE."include/mail.php");
|
||||
|
||||
/* The initial help text displayed in the admin's response field */
|
||||
$sReplyTextHelp = "Enter a personalized reason for accepting or rejecting the user's maintainer request here";
|
||||
|
||||
/* If the admin's response text has not been modified, it should not be included in the e-mail sent to the rejected/accepted maintainer */
|
||||
if($aClean['sReplyText'] == $sReplyTextHelp)
|
||||
$aClean['sReplyText'] = "";
|
||||
|
||||
if(!$_SESSION['current']->hasPriv("admin"))
|
||||
util_show_error_page_and_exit("Insufficient privileges.");
|
||||
|
||||
if ($aClean['sSub'])
|
||||
{
|
||||
if ($aClean['iMaintainerId'])
|
||||
{
|
||||
//get data
|
||||
$sQuery = "SELECT maintainerId, appId, versionId,".
|
||||
"userId, maintainReason, superMaintainer,".
|
||||
"UNIX_TIMESTAMP(submitTime) as submitTime ".
|
||||
"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);
|
||||
}
|
||||
else
|
||||
{
|
||||
//error no Id!
|
||||
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
|
||||
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";
|
||||
|
||||
$x = new TableVE("view");
|
||||
|
||||
//help
|
||||
Maintainer::ObjectDisplayQueueProcessingHelp();
|
||||
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
$oMaintainer->outputEditor();
|
||||
|
||||
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";
|
||||
echo "<td><textarea name='sReplyText' rows=10 cols=35>$sReplyTextHelp</textarea></td></tr>\n";
|
||||
|
||||
/* Add button */
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
|
||||
echo '<input type=submit name=sAdd value=" Add maintainer to this application " class=button /> </td></tr>',"\n";
|
||||
|
||||
/* Reject button */
|
||||
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 '<input type=hidden name="sSub" value="inside_form" />',"\n";
|
||||
echo '<input type=hidden name="iMaintainerId" value="'.$aClean['iMaintainerId'].'" />',"\n";
|
||||
|
||||
echo '</table>';
|
||||
|
||||
echo html_back_link(1,'adminMaintainerQueue.php');
|
||||
echo "</form>";
|
||||
apidb_footer();
|
||||
exit;
|
||||
|
||||
}
|
||||
else if ($aClean['sAdd'] && $aClean['iMaintainerId'])
|
||||
{
|
||||
/* create this maintainer object */
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
|
||||
$sStatusMessage = $oMaintainer->unQueue($aClean['sReplyText']);
|
||||
|
||||
//done
|
||||
addmsg("<p><b>$sStatusMessage</b></p>", 'green');
|
||||
}
|
||||
else if (($aClean['sReject'] || ($aClean['sSub'] == 'sReject')) && $aClean['iMaintainerId'])
|
||||
{
|
||||
$oMaintainer = new maintainer($aClean['iMaintainerId']);
|
||||
$hResult = $oMaintainer->reject($aClean['sReplyText']);
|
||||
|
||||
if(!$hResult) addmsg("unable to delete selected maintainer application", "red");
|
||||
echo html_frame_start("Delete maintainer application",400,"",0);
|
||||
if($hResult)
|
||||
{
|
||||
//success
|
||||
echo "<p>Maintainer application was successfully deleted from the Queue.</p>\n";
|
||||
}
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminMaintainerQueue.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
//error no sub!
|
||||
addmsg('<p><b>Internal Routine Not Found!</b></p>', 'red');
|
||||
}
|
||||
}
|
||||
/* display the list of all outstanding maintainer requests */
|
||||
{
|
||||
apidb_header("Admin Maintainer Queue");
|
||||
echo '<form name="sQform" action="adminMaintainerQueue.php" method="post" enctype="multipart/form-data">',"\n";
|
||||
|
||||
/* retrieve a list of queued entries */
|
||||
$hResult = Maintainer::ObjectGetEntries(true);
|
||||
|
||||
if(!$hResult || !mysql_num_rows($hResult))
|
||||
{
|
||||
//no apps in queue
|
||||
echo html_frame_start("","90%");
|
||||
echo '<p><b>The Maintainer Queue is empty.</b></p>',"\n";
|
||||
echo '<p>There is nothing for you to do. Check back later.</p>',"\n";
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
//help
|
||||
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";
|
||||
maintainer::ObjectOutputHeader();
|
||||
echo " <td>Action</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
|
||||
$iRowCount = 1;
|
||||
while($oRow = mysql_fetch_object($hResult))
|
||||
{
|
||||
$oMaintainer = Maintainer::ObjectGetObjectFromObjectGetEntriesRow($oRow);
|
||||
|
||||
if ($iRowCount % 2 == 1) { $sBGColor = 'color0'; } else { $sBGColor = 'color1'; }
|
||||
echo "<tr class=$sBGColor>\n";
|
||||
$oMaintainer->ObjectOutputTableRow();
|
||||
echo " <td>[<a href=\"adminMaintainerQueue.php?sSub=view&iMaintainerId=$oRow->maintainerId\">answer</a>]</td>\n";
|
||||
echo "</tr>\n\n";
|
||||
$iRowCount++;
|
||||
}
|
||||
echo "</table>\n\n";
|
||||
echo html_frame_end(" ");
|
||||
echo "</form>";
|
||||
apidb_footer();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -16,6 +16,7 @@ class maintainer
|
||||
var $bSuperMaintainer;
|
||||
var $aSubmitTime;
|
||||
var $bQueued;
|
||||
var $sReplyText;
|
||||
|
||||
function maintainer($iMaintainerId = "")
|
||||
{
|
||||
@@ -57,7 +58,7 @@ class maintainer
|
||||
return $hResult;
|
||||
}
|
||||
|
||||
function unQueue($sReplyText)
|
||||
function unQueue()
|
||||
{
|
||||
/* 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 */
|
||||
@@ -90,7 +91,7 @@ class maintainer
|
||||
$sSubject = "Application Maintainer Request Report";
|
||||
$sMsg = "Your application to be the maintainer of ".$oApp->sName." ".$oVersion->sName." has been accepted.\n";
|
||||
$sMsg .= "$sURL\n";
|
||||
$sMsg .= "$sReplyText\n";
|
||||
$sMsg .= "$this->sReplyText\n";
|
||||
$sMsg .= "We appreciate your help in making the Application Database better for all users.\n\n";
|
||||
|
||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||
@@ -110,7 +111,7 @@ class maintainer
|
||||
return $sStatusMessage;
|
||||
}
|
||||
|
||||
function reject($sReplyText)
|
||||
function reject()
|
||||
{
|
||||
$oUser = new User($this->iUserId);
|
||||
$sEmail = $oUser->sEmail;
|
||||
@@ -120,7 +121,7 @@ class maintainer
|
||||
$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 .= $this->sReplyText;
|
||||
$sMsg .= "";
|
||||
$sMsg .= "-The AppDB admins\n";
|
||||
|
||||
@@ -389,34 +390,40 @@ class maintainer
|
||||
return $aUserIds;
|
||||
}
|
||||
|
||||
function ObjectOutputHeader()
|
||||
function ObjectOutputHeader($sClass)
|
||||
{
|
||||
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";
|
||||
$aCells = array(
|
||||
"Submission Date",
|
||||
"Application Name",
|
||||
"Version",
|
||||
"Super maintainer?",
|
||||
"Submitter");
|
||||
|
||||
if(maintainer::canEdit())
|
||||
$aCells[sizeof($aCells)] = "Action";
|
||||
|
||||
echo html_tr($aCells, $sClass);
|
||||
}
|
||||
|
||||
function ObjectOutputTableRow()
|
||||
function ObjectOutputTableRow($oObject, $sClass)
|
||||
{
|
||||
$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";
|
||||
}
|
||||
$aCells = array(
|
||||
print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime)),
|
||||
$oApp->sName,
|
||||
($this->bSuperMaintainer) ? "N/A" : $oVersion->sName,
|
||||
($this->bSuperMaintainer) ? "Yes" : "No",
|
||||
"<a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a>");
|
||||
|
||||
echo "<td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
|
||||
if(maintainer::canEdit())
|
||||
$aCells[sizeof($aCells)] = "<a href=\"".$oObject->makeUrl("edit",
|
||||
$this->iMaintainerId)."\">answer</a>";
|
||||
|
||||
echo html_tr($aCells,
|
||||
$sClass);
|
||||
}
|
||||
|
||||
function ObjectDisplayQueueProcessingHelp()
|
||||
@@ -427,12 +434,26 @@ class maintainer
|
||||
echo "</td></tr></table></div>\n\n";
|
||||
}
|
||||
|
||||
function objectGetInstanceFromRow($oRow)
|
||||
{
|
||||
return new maintainer($oRow->maintainerId, $oRow);
|
||||
}
|
||||
|
||||
function canEdit()
|
||||
{
|
||||
if($_SESSION['current']->hasPriv("admin"))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"iMaintainerId\" ".
|
||||
"value=\"$this->iMaintainerId\" />";
|
||||
/**
|
||||
* Show the other maintainers of this application, if there are any
|
||||
*/
|
||||
@@ -536,6 +557,37 @@ class maintainer
|
||||
|
||||
echo html_frame_end(" ");
|
||||
}
|
||||
};
|
||||
|
||||
function ObjectGetId()
|
||||
{
|
||||
return $this->iMaintainerId;
|
||||
}
|
||||
|
||||
function getOutputEditorValues($aClean)
|
||||
{
|
||||
$this->sReplyText = $aClean['sReplyText'];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function update()
|
||||
{
|
||||
/* STUB: No updating possible at the moment */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function getDefaultReply()
|
||||
{
|
||||
$sReplyTextHelp = "Enter a personalized reason for accepting or rejecting the ".
|
||||
"user's maintainer request here";
|
||||
|
||||
return $sReplyTextHelp;
|
||||
}
|
||||
|
||||
function objectHideDelete()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -56,7 +56,7 @@ class ObjectManager
|
||||
function display_table()
|
||||
{
|
||||
$this->checkMethods(array("ObjectGetEntries", "ObjectOutputHeader",
|
||||
"ObjectGetInstanceFromRow", "ObjectOutputTableRow"));
|
||||
"ObjectGetInstanceFromRow", "ObjectOutputTableRow", "canEdit"));
|
||||
|
||||
|
||||
/* query the class for its entries */
|
||||
@@ -137,21 +137,28 @@ class ObjectManager
|
||||
queued entry */
|
||||
if($this->bIsQueue)
|
||||
{
|
||||
/* If it isn't implemented, that means there is no default text */
|
||||
if(method_exists(new $this->sClass, "getDefaultReply"))
|
||||
$sDefaultReply = $oObject->getDefaultReply();
|
||||
|
||||
echo html_frame_start("Reply text", "90%", "", 0);
|
||||
echo "<table width='100%' border=0 cellpadding=2 cellspacing=0>\n";
|
||||
echo '<tr valign=top><td class="color0"><b>email Text</b></td>',"\n";
|
||||
echo '<td><textarea name="sReplyText" style="width: 100%" cols="80" '.
|
||||
'rows="10"></textarea></td></tr>',"\n";
|
||||
'rows="10">'.$sDefaultReply.'</textarea></td></tr>',"\n";
|
||||
|
||||
/* buttons for operations we can perform on this entry */
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2>' ,"\n";
|
||||
echo '<input name="sSub" type="submit" value="Submit" class="button" '.
|
||||
echo '<input name="sSubmit" type="submit" value="Submit" class="button" '.
|
||||
'/>',"\n";
|
||||
echo '<input name="sSub" type="submit" value="Delete" class="button" '.
|
||||
if(!method_exists(new $this->sClass, "objectHideDelete"))
|
||||
{
|
||||
echo '<input name="sSubmit" type="submit" value="Delete" '.
|
||||
'class="button" />',"\n";
|
||||
}
|
||||
echo '<input name="sSubmit" type="submit" value="Reject" class="button" '.
|
||||
'/>',"\n";
|
||||
echo '<input name="sSub" type="submit" value="Reject" class="button" '.
|
||||
'/>',"\n";
|
||||
echo '<input name="sSub" type="submit" value="Cancel" class="button" '.
|
||||
echo '<input name="sSubmit" type="submit" value="Cancel" class="button" '.
|
||||
'/>',"\n";
|
||||
echo '</td></tr>',"\n";
|
||||
echo '</table>';
|
||||
@@ -159,7 +166,7 @@ class ObjectManager
|
||||
} else
|
||||
{
|
||||
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
|
||||
echo '<input name="sSubmit" type="submit" value="Save" class="button">'.
|
||||
echo '<input name="sSubmit" type="submit" value="Submit" class="button">'.
|
||||
' ',"\n";
|
||||
echo "</td></tr>\n";
|
||||
}
|
||||
@@ -243,21 +250,51 @@ class ObjectManager
|
||||
|
||||
$oObject = new $this->sClass($this->iId);
|
||||
|
||||
/* If it isn't implemented, that means there is no default text */
|
||||
if(method_exists(new $this->sClass, "getDefaultReply"))
|
||||
{
|
||||
/* Don't send the default reply text */
|
||||
if($oObject->getDefaultReply() == $aClean['sReplyText'])
|
||||
$aClean['sReplyText'] = "";
|
||||
}
|
||||
|
||||
$oObject->getOutputEditorValues($aClean);
|
||||
|
||||
if($this->iId)
|
||||
switch($aClean['sSubmit'])
|
||||
{
|
||||
if(!$oObject->canEdit())
|
||||
return FALSE;
|
||||
case "Submit":
|
||||
if($this->iId)
|
||||
{
|
||||
if(!$oObject->canEdit())
|
||||
return FALSE;
|
||||
|
||||
$oObject->update();
|
||||
if($this->bIsQueue)
|
||||
$oObject->unQueue();
|
||||
|
||||
$oObject->update();
|
||||
}
|
||||
else
|
||||
$oObject->create();
|
||||
break;
|
||||
|
||||
case "Reject":
|
||||
if(!$oObject->canEdit())
|
||||
return FALSE;
|
||||
|
||||
$oObject->reject();
|
||||
break;
|
||||
case "Delete":
|
||||
$this->delete_entry();
|
||||
}
|
||||
else
|
||||
$oObject->create();
|
||||
|
||||
$sIsQueue = $tihs->bIsQueue ? "true" : "false";
|
||||
|
||||
util_redirect_and_exit($this->makeUrl("view", false, "$this->sClass list"));
|
||||
if(!$this->bIsQueue)
|
||||
$sAction = "view";
|
||||
else
|
||||
$sAction = false;
|
||||
|
||||
util_redirect_and_exit($this->makeUrl($sAction, false, "$this->sClass list"));
|
||||
}
|
||||
|
||||
/* Make an objectManager URL based on the object and optional parameters */
|
||||
|
||||
@@ -15,11 +15,15 @@ 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 (".Maintainer::getQueuedMaintainerCount().")", BASE."admin/adminMaintainerQueue.php");
|
||||
$g->add("View App Data Queue (".$_SESSION['current']->getQueuedAppDataCount().")",
|
||||
BASE."admin/adminAppDataQueue.php");
|
||||
$g->add("View Maintainer Queue (".Maintainer::getQueuedMaintainerCount().")",
|
||||
BASE."objectManager.php?sClass=maintainer&bIsQueue=true&sTitle=Maintainer%20Queue");
|
||||
$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");
|
||||
$g->add("View Bug Links (".getNumberOfQueuedBugLinks()."/".getNumberOfBugLinks().")",
|
||||
BASE."admin/adminBugs.php");
|
||||
$g->add("View Test Results Queue (".testData::getNumberOfQueuedTests().")",
|
||||
BASE."admin/adminTestResults.php");
|
||||
|
||||
$g->addmisc(" ");
|
||||
$g->add("Users Management", BASE."admin/adminUsers.php");
|
||||
|
||||
Reference in New Issue
Block a user