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,44 +84,28 @@ 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";
|
||||
|
||||
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)
|
||||
{
|
||||
//success
|
||||
echo "<p>Maintainer application was successfully deleted from the Queue.</p>\n";
|
||||
}
|
||||
echo html_frame_end(" ");
|
||||
echo html_back_link(1,'adminMaintainerQueue.php');
|
||||
$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
|
||||
{
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user