Add ability to e-mail all maintainers

This commit is contained in:
Alexander Nicolaysen Sørnes
2008-05-12 21:36:51 +02:00
committed by Chris Morgan
parent ef64981a1b
commit c547b5532d
3 changed files with 160 additions and 102 deletions

View File

@@ -16,10 +16,8 @@ if(!$_SESSION['current']->hasPriv("admin"))
apidb_header("Admin Maintainers"); apidb_header("Admin Maintainers");
echo '<form name="sQform" action="adminMaintainers.php" method="post" enctype="multipart/form-data">',"\n"; echo '<form name="sQform" action="adminMaintainers.php" method="post" enctype="multipart/form-data">',"\n";
if (isset($aClean['sSub']))
{
} else
{
// get available maintainers // get available maintainers
$sQuery = "SELECT * FROM appMaintainers, user_list where appMaintainers.userId = user_list.userid"; $sQuery = "SELECT * FROM appMaintainers, user_list where appMaintainers.userId = user_list.userid";
$sQuery.= " AND state='accepted' ORDER BY realname;"; $sQuery.= " AND state='accepted' ORDER BY realname;";
@@ -34,6 +32,8 @@ if (isset($aClean['sSub']))
} }
else else
{ {
echo '<div align="center"><a href="'.BASE.'contact.php?sRecipientGroup=maintainers">E-mail all maintainers</a></div>';
// show applist // show applist
echo html_frame_start("","90%","",0); echo html_frame_start("","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n"; echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
@@ -109,7 +109,6 @@ if (isset($aClean['sSub']))
echo "</table>\n\n"; echo "</table>\n\n";
echo html_frame_end("&nbsp;"); echo html_frame_end("&nbsp;");
} }
}
echo "</form>"; echo "</form>";
apidb_footer(); apidb_footer();

View File

@@ -17,12 +17,41 @@ if(!$oUser->isLoggedIn())
exit; exit;
} }
$oRecipient = null;
$sRecipientText = '';
$iRecipientId = null;
$sRecipientGroup = getInput('sRecipientGroup', $aClean);
$sRecipients = '';
if($sRecipientGroup)
{
if(!$oUser->hasPriv('admin'))
util_show_error_page_and_exit("Only admins can do this");
switch($sRecipientGroup)
{
case 'maintainers':
$sRecipientText = 'all maintainers';
$sRecipients = maintainer::getSubmitterEmails();
if($sRecipients === FALSE)
util_show_error_page_and_exit("Failed to get list of maintainers");
break;
default:
util_show_error_page_and_exit("Invalid recipient group");
}
} else
{
$oRecipient = new User($aClean['iRecipientId']); $oRecipient = new User($aClean['iRecipientId']);
$iRecipientId = $oRecipient->iUserId;
$sRecipients = $oRecipient->sEmail;
if(!User::exists($oRecipient->sEmail)) if(!User::exists($oRecipient->sEmail))
util_show_error_page_and_exit("User not found"); util_show_error_page_and_exit("User not found");
$sRecipientText = $oRecipient->sRealname;
}
/* Check for errors */ /* Check for errors */
if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit']) if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit'])
{ {
@@ -34,21 +63,22 @@ if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit'])
/* Display the feedback form if nothing else is specified */ /* Display the feedback form if nothing else is specified */
if(!$aClean['sSubmit']) if(!$aClean['sSubmit'])
{ {
apidb_header("E-mail $oRecipient->sRealname"); apidb_header("E-mail $sRecipientText");
echo html_frame_start("Send us your suggestions",400,"",0); echo '&nbsp';
echo html_frame_start("Composer",400,"",0);
echo $error; echo $error;
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">"; echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
/* User manager */ /* User manager */
if($_SESSION['current']->hasPriv("admin")) if($_SESSION['current']->hasPriv("admin") && $oRecipient)
{ {
echo "<p><a href=\"".BASE."preferences.php?iUserId=". echo "<p><a href=\"".BASE."preferences.php?iUserId=".
$oRecipient->iUserId."&amp;sSearch=Administrator&amp;iLimit". $oRecipient->iUserId."&amp;sSearch=Administrator&amp;iLimit".
"=100&amp;sOrderBy=email\">User manager</a></p>"; "=100&amp;sOrderBy=email\">User manager</a></p>";
} }
echo "<p>E-mail $oRecipient->sRealname.</p>"; echo "<p>E-mail $sRecipientText.</p>";
$oTable = new Table(); $oTable = new Table();
$oTable->SetWidth("100%"); $oTable->SetWidth("100%");
@@ -83,13 +113,18 @@ if(!$aClean['sSubmit'])
echo $oTable->GetString(); echo $oTable->GetString();
echo "<input type=\"hidden\" name=\"iRecipientId\" ". echo "<input type=\"hidden\" name=\"iRecipientId\" ".
"value=\"$oRecipient->iUserId\">"; "value=\"$iRecipientId\">";
echo "<input type=\"hidden\" name=\"sRecipientGroup\" ".
"value=\"$sRecipientGroup\">";
echo "</form>\n"; echo "</form>\n";
echo html_frame_end("&nbsp;"); echo html_frame_end("&nbsp;");
} else if ($aClean['sSubject'] && $aClean['sMessage']) } else if ($aClean['sSubject'] && $aClean['sMessage'])
{
if($oRecipient)
{ {
$sSubjectRe = $aClean['sSubject']; $sSubjectRe = $aClean['sSubject'];
if(substr($sSubjectRe, 0, 4) != "Re: ") if(substr($sSubjectRe, 0, 4) != "Re: ")
@@ -102,8 +137,13 @@ if(!$aClean['sSubmit'])
$sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&amp;sSubject="; $sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&amp;sSubject=";
$sMsg .= $sSubjectRe."\n\n"; $sMsg .= $sSubjectRe."\n\n";
$sMsg .= $aClean['sMessage']; $sMsg .= $aClean['sMessage'];
} else
{
$sMsg = "The following message was sent to you by the AppDB admins:\n\n";
$sMsg .= $aClean['sMessage'];
}
mail_appdb($oRecipient->sEmail, $aClean['sSubject'], $sMsg); mail_appdb($sRecipients, $aClean['sSubject'], $sMsg);
util_redirect_and_exit(BASE."index.php"); util_redirect_and_exit(BASE."index.php");
} }

View File

@@ -395,6 +395,25 @@ class maintainer
return $hResult; return $hResult;
} }
function getSubmitterEmails()
{
$sRecipients = '';
$sQuery = "SELECT DISTINCT(user_list.email) FROM appMaintainers, user_list WHERE
appMaintainers.userId = user_list.userId
AND
appMaintainers.state = 'accepted'";
$hResult = query_parameters($sQuery);
if(!$hResult)
return FALSE;
for($i = 0; $oRow = query_fetch_object($hResult); $i++)
{
if($i)
$sRecipients .= ' ';
$sRecipients = $oRow->email;
}
return $sRecipients;
}
function ObjectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = '', $bAscending = true) function ObjectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = '', $bAscending = true)
{ {
/* Not implemented */ /* Not implemented */