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,99 +16,98 @@ if(!$_SESSION['current']->hasPriv("admin"))
apidb_header("Admin Maintainers");
echo '<form name="sQform" action="adminMaintainers.php" method="post" enctype="multipart/form-data">',"\n";
if (isset($aClean['sSub']))
// get available maintainers
$sQuery = "SELECT * FROM appMaintainers, user_list where appMaintainers.userId = user_list.userid";
$sQuery.= " AND state='accepted' ORDER BY realname;";
$hResult = query_parameters($sQuery);
if(!$hResult || !query_num_rows($hResult))
{
} else
// no apps
echo html_frame_start("","90%");
echo '<p><b>There are no application maintainers.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
// get available maintainers
$sQuery = "SELECT * FROM appMaintainers, user_list where appMaintainers.userId = user_list.userid";
$sQuery.= " AND state='accepted' ORDER BY realname;";
$hResult = query_parameters($sQuery);
echo '<div align="center"><a href="'.BASE.'contact.php?sRecipientGroup=maintainers">E-mail all maintainers</a></div>';
if(!$hResult || !query_num_rows($hResult))
// 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><font color=white>Submission Date</font></td>\n";
echo " <td><font color=white>Maintainer</font></td>\n";
echo " <td><font color=white>Application</font></td>\n";
echo " <td><font color=white>Version</font></td>\n";
echo " <td align=\"center\">Action</td>\n";
echo "</tr>\n\n";
$c = 1;
$oldUserId = 0;
while($oRow = query_fetch_object($hResult))
{
// no apps
echo html_frame_start("","90%");
echo '<p><b>There are no application maintainers.</b></p>',"\n";
echo html_frame_end("&nbsp;");
}
else
{
// show applist
echo html_frame_start("","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
$oUser = new User($oRow->userId);
$oApp = new application($oRow->appId);
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
echo "<tr class=color4>\n";
echo " <td><font color=white>Submission Date</font></td>\n";
echo " <td><font color=white>Maintainer</font></td>\n";
echo " <td><font color=white>Application</font></td>\n";
echo " <td><font color=white>Version</font></td>\n";
echo " <td align=\"center\">Action</td>\n";
echo "</tr>\n\n";
$c = 1;
$oldUserId = 0;
while($oRow = query_fetch_object($hResult))
/* if this is a new user we should print a header that has the aggregate of the applications */
/* the user super maintains and versions they maintain */
if($oRow->userId != $oldUserId)
{
$oUser = new User($oRow->userId);
$oApp = new application($oRow->appId);
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
$style = "border-top:thin solid;border-bottom:thin solid";
/* if this is a new user we should print a header that has the aggregate of the applications */
/* the user super maintains and versions they maintain */
if($oRow->userId != $oldUserId)
{
$style = "border-top:thin solid;border-bottom:thin solid";
echo "<tr class=color4>\n";
echo " <td style=\"$style;border-left:thin solid\">Maintainer summary</td>\n";
if($oUser->sRealname == "")
echo " <td style=\"$style\"><a href=\"mailto:".$oUser->sEmail."\">&nbsp;</a></td>\n";
else
echo " <td style=\"$style\"><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
echo "<tr class=color4>\n";
echo " <td style=\"$style;border-left:thin solid\">Maintainer summary</td>\n";
if($oUser->sRealname == "")
echo " <td style=\"$style\"><a href=\"mailto:".$oUser->sEmail."\">&nbsp;</a></td>\n";
else
echo " <td style=\"$style\"><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
$count = Maintainer::getMaintainerCountForUser($oUser, true);
if($count == 0)
echo " <td style=\"$style\">&nbsp;</td>\n";
else if($count <= 1)
echo " <td style=\"$style\">".$count." app</td>\n";
else
echo " <td style=\"$style\">".$count." apps</td>\n";
$count = Maintainer::getMaintainerCountForUser($oUser, true);
if($count == 0)
echo " <td style=\"$style\">&nbsp;</td>\n";
else if($count <= 1)
echo " <td style=\"$style\">".$count." app</td>\n";
else
echo " <td style=\"$style\">".$count." apps</td>\n";
$count = Maintainer::getMaintainerCountForUser($oUser, false);
if($count == 0)
echo " <td style=\"$style\">&nbsp;</td>\n";
else if($count <= 1)
echo " <td style=\"$style\">".$count." version</td>\n";
else
echo " <td style=\"$style\">".$count." versions</td>\n";
$count = Maintainer::getMaintainerCountForUser($oUser, false);
if($count == 0)
echo " <td style=\"$style\">&nbsp;</td>\n";
else if($count <= 1)
echo " <td style=\"$style\">".$count." version</td>\n";
else
echo " <td style=\"$style\">".$count." versions</td>\n";
echo " <td align=\"center\" style=\"$style;border-right:thin solid\">&nbsp;</td>\n";
echo "</tr>\n\n";
$oldUserId = $oRow->userId;
}
echo "<tr class=$bgcolor>\n";
echo " <td>".print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))." &nbsp;</td>\n";
echo " <td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
echo " <td>".$oApp->objectMakeLink()."</td>\n";
if($oRow->superMaintainer)
{
echo " <td>*</td>\n";
} else
{
$oVersion = new version($oRow->versionId);
echo " <td>".$oVersion->objectMakeLink()."</td>\n";
}
echo " <td align=\"center\">[<a href='".BASE."objectManager.php?sClass=maintainer&amp;iId=$oRow->maintainerId&amp;bIsQueue=false&amp;sTitle=Admin%20Maintainers&amp;sAction=delete&amp;sReturnTo=".APPDB_ROOT."admin/adminMaintainers.php'>delete</a>]</td>\n";
echo " <td align=\"center\" style=\"$style;border-right:thin solid\">&nbsp;</td>\n";
echo "</tr>\n\n";
$c++;
$oldUserId = $oRow->userId;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
echo "<tr class=$bgcolor>\n";
echo " <td>".print_date(mysqldatetime_to_unixtimestamp($oRow->submitTime))." &nbsp;</td>\n";
echo " <td><a href=\"mailto:".$oUser->sEmail."\">".$oUser->sRealname."</a></td>\n";
echo " <td>".$oApp->objectMakeLink()."</td>\n";
if($oRow->superMaintainer)
{
echo " <td>*</td>\n";
} else
{
$oVersion = new version($oRow->versionId);
echo " <td>".$oVersion->objectMakeLink()."</td>\n";
}
echo " <td align=\"center\">[<a href='".BASE."objectManager.php?sClass=maintainer&amp;iId=$oRow->maintainerId&amp;bIsQueue=false&amp;sTitle=Admin%20Maintainers&amp;sAction=delete&amp;sReturnTo=".APPDB_ROOT."admin/adminMaintainers.php'>delete</a>]</td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
echo "</form>";

View File

@@ -17,11 +17,40 @@ if(!$oUser->isLoggedIn())
exit;
}
$oRecipient = null;
$sRecipientText = '';
$iRecipientId = null;
$sRecipientGroup = getInput('sRecipientGroup', $aClean);
$sRecipients = '';
$oRecipient = new User($aClean['iRecipientId']);
if($sRecipientGroup)
{
if(!$oUser->hasPriv('admin'))
util_show_error_page_and_exit("Only admins can do this");
if(!User::exists($oRecipient->sEmail))
util_show_error_page_and_exit("User not found");
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']);
$iRecipientId = $oRecipient->iUserId;
$sRecipients = $oRecipient->sEmail;
if(!User::exists($oRecipient->sEmail))
util_show_error_page_and_exit("User not found");
$sRecipientText = $oRecipient->sRealname;
}
/* Check for errors */
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 */
if(!$aClean['sSubmit'])
{
apidb_header("E-mail $oRecipient->sRealname");
echo html_frame_start("Send us your suggestions",400,"",0);
apidb_header("E-mail $sRecipientText");
echo '&nbsp';
echo html_frame_start("Composer",400,"",0);
echo $error;
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
/* User manager */
if($_SESSION['current']->hasPriv("admin"))
if($_SESSION['current']->hasPriv("admin") && $oRecipient)
{
echo "<p><a href=\"".BASE."preferences.php?iUserId=".
$oRecipient->iUserId."&amp;sSearch=Administrator&amp;iLimit".
"=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->SetWidth("100%");
@@ -83,7 +113,10 @@ if(!$aClean['sSubmit'])
echo $oTable->GetString();
echo "<input type=\"hidden\" name=\"iRecipientId\" ".
"value=\"$oRecipient->iUserId\">";
"value=\"$iRecipientId\">";
echo "<input type=\"hidden\" name=\"sRecipientGroup\" ".
"value=\"$sRecipientGroup\">";
echo "</form>\n";
@@ -91,19 +124,26 @@ if(!$aClean['sSubmit'])
} else if ($aClean['sSubject'] && $aClean['sMessage'])
{
$sSubjectRe = $aClean['sSubject'];
if(substr($sSubjectRe, 0, 4) != "Re: ")
$sSubjectRe = "Re: $sSubjectRe";
if($oRecipient)
{
$sSubjectRe = $aClean['sSubject'];
if(substr($sSubjectRe, 0, 4) != "Re: ")
$sSubjectRe = "Re: $sSubjectRe";
$sSubjectRe = urlencode($sSubjectRe);
$sSubjectRe = urlencode($sSubjectRe);
$sMsg = "The following message was sent to you from $oUser->sRealname ";
$sMsg .= "through the Wine AppDB contact form.\nTo Reply, visit ";
$sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&amp;sSubject=";
$sMsg .= $sSubjectRe."\n\n";
$sMsg .= $aClean['sMessage'];
$sMsg = "The following message was sent to you from $oUser->sRealname ";
$sMsg .= "through the Wine AppDB contact form.\nTo Reply, visit ";
$sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&amp;sSubject=";
$sMsg .= $sSubjectRe."\n\n";
$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");
}

View File

@@ -395,6 +395,25 @@ class maintainer
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)
{
/* Not implemented */