From bf7daaa789567e1dc0d07c163b2e08c3eec7d650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Sun, 4 Mar 2007 23:22:57 +0000 Subject: [PATCH] Let ObjectManager handle maintainer requests --- admin/adminMaintainerQueue.php | 164 --------------------------------- include/maintainer.php | 104 +++++++++++++++------ include/objectManager.php | 67 +++++++++++--- include/sidebar_admin.php | 12 ++- 4 files changed, 138 insertions(+), 209 deletions(-) delete mode 100644 admin/adminMaintainerQueue.php diff --git a/admin/adminMaintainerQueue.php b/admin/adminMaintainerQueue.php deleted file mode 100644 index 48cff2f..0000000 --- a/admin/adminMaintainerQueue.php +++ /dev/null @@ -1,164 +0,0 @@ -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("

MaintainerId Not Found!

"); - } - - //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 '
',"\n"; - - $x = new TableVE("view"); - - //help - Maintainer::ObjectDisplayQueueProcessingHelp(); - - $oMaintainer = new maintainer($aClean['iMaintainerId']); - $oMaintainer->outputEditor(); - - echo "\n"; - - //email response - echo '',"\n"; - echo "\n"; - - /* Add button */ - echo '',"\n"; - - /* Reject button */ - echo '',"\n"; - - echo '',"\n"; - echo '',"\n"; - - echo '
Email reply
' ,"\n"; - echo '
' ,"\n"; - echo '
'; - - echo html_back_link(1,'adminMaintainerQueue.php'); - echo "
"; - 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("

$sStatusMessage

", '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 "

Maintainer application was successfully deleted from the Queue.

\n"; - } - echo html_frame_end(" "); - echo html_back_link(1,'adminMaintainerQueue.php'); - } - else - { - //error no sub! - addmsg('

Internal Routine Not Found!

', 'red'); - } -} -/* display the list of all outstanding maintainer requests */ -{ - apidb_header("Admin Maintainer Queue"); - echo '
',"\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 '

The Maintainer Queue is empty.

',"\n"; - echo '

There is nothing for you to do. Check back later.

',"\n"; - echo html_frame_end(" "); - } - else - { - //help - maintainer::ObjectDisplayQueueProcessingHelp(); - - //show applist - echo html_frame_start("","90%","",0); - echo "\n\n"; - - echo "\n"; - maintainer::ObjectOutputHeader(); - echo " \n"; - echo "\n\n"; - - $iRowCount = 1; - while($oRow = mysql_fetch_object($hResult)) - { - $oMaintainer = Maintainer::ObjectGetObjectFromObjectGetEntriesRow($oRow); - - if ($iRowCount % 2 == 1) { $sBGColor = 'color0'; } else { $sBGColor = 'color1'; } - echo "\n"; - $oMaintainer->ObjectOutputTableRow(); - echo " \n"; - echo "\n\n"; - $iRowCount++; - } - echo "
Action
[maintainerId\">answer]
\n\n"; - echo html_frame_end(" "); - echo "
"; - apidb_footer(); - - } - -} -?> diff --git a/include/maintainer.php b/include/maintainer.php index ff978dd..a962f74 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -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,10 +121,10 @@ 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"; - + mail_appdb($sEmail, $sSubject ,$sMsg); } @@ -389,34 +390,40 @@ class maintainer return $aUserIds; } - function ObjectOutputHeader() + function ObjectOutputHeader($sClass) { - echo " Submission Date\n"; - echo " Application Name\n"; - echo " Version\n"; - echo " Super maintainer?\n"; - echo " Submitter\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 "".print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime))."  \n"; - echo "".$oApp->sName."\n"; - if($this->bSuperMaintainer) - { - echo "N/A\n"; - echo "Yes\n"; - } else - { - echo "".$oVersion->sName."  \n"; - echo "No\n"; - } + $aCells = array( + print_date(mysqldatetime_to_unixtimestamp($this->aSubmitTime)), + $oApp->sName, + ($this->bSuperMaintainer) ? "N/A" : $oVersion->sName, + ($this->bSuperMaintainer) ? "Yes" : "No", + "sEmail."\">".$oUser->sRealname.""); - echo "sEmail."\">".$oUser->sRealname."\n"; + if(maintainer::canEdit()) + $aCells[sizeof($aCells)] = "makeUrl("edit", + $this->iMaintainerId)."\">answer"; + + echo html_tr($aCells, + $sClass); } function ObjectDisplayQueueProcessingHelp() @@ -427,12 +434,26 @@ class maintainer echo "\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 "\n"; - + echo "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; + } +} ?> diff --git a/include/objectManager.php b/include/objectManager.php index 371543c..81a9ce0 100644 --- a/include/objectManager.php +++ b/include/objectManager.php @@ -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 "
\n"; echo '',"\n"; echo '',"\n"; + 'rows="10">'.$sDefaultReply.'',"\n"; /* buttons for operations we can perform on this entry */ echo '',"\n"; echo '
email Text
' ,"\n"; - echo '',"\n"; - echo 'sClass, "objectHideDelete")) + { + echo '',"\n"; + } + echo '',"\n"; - echo '',"\n"; - echo '',"\n"; echo '
'; @@ -159,7 +166,7 @@ class ObjectManager } else { echo '',"\n"; - echo ''. + echo ''. ' ',"\n"; echo "\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 */ diff --git a/include/sidebar_admin.php b/include/sidebar_admin.php index bdd7864..365ab7f 100644 --- a/include/sidebar_admin.php +++ b/include/sidebar_admin.php @@ -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");