Add ability to see WHO the recipients of a communication will be

This commit is contained in:
james 2010-11-22 18:40:50 +00:00
parent 4f388734a9
commit d0d9fe4d60

View File

@ -24,6 +24,7 @@
<?
require_once("../common.inc.php");
require_once("../user.inc.php");
include "communication.inc.php";
user_auth_required('committee', 'admin');
function launchQueue() {
@ -643,9 +644,20 @@ case "email_get_list":
echo "ok";
}
exit;
case 'loadaddresses':
if($_GET['query'] && array_key_exists($_GET['query'],$mailqueries)) {
$q=mysql_query($mailqueries[$_GET['query']]['query']);
while($r=mysql_fetch_object($q)) {
if($r->organization) $s="($r->organization) ";
else $s="";
echo "$r->firstname $r->lastname {$s}&lt;$r->email&gt;<br />";
}
}
exit;
}
include "communication.inc.php";
if($_GET['action']=="sendqueue") {
$fcid=intval($_POST['fundraising_campaigns_id']);
@ -718,6 +730,23 @@ case "email_get_list":
"communication"
);
echo "<br />";
?>
<script type="text/javascript">
function toggleAddresses() {
if($("#toaddresses").is(":visible")) {
$("#toaddresses").hide();
$("#toaddresses-view").html("Show Recipients");
} else {
$("#toaddresses").show();
$("#toaddresses-view").html("Hide Recipients");
}
return false;
}
function loadAddresses() {
$("#toaddresses").load("communication.php?action=loadaddresses&query="+$("#to").val());
}
</script>
<?
if($_GET['action']=="delete" && $_GET['delete']) {
mysql_query("DELETE FROM emails WHERE id='".$_GET['delete']."' AND `type`='user'");
@ -725,6 +754,7 @@ case "email_get_list":
}
if($_GET['action']=="send" && $_GET['send']) {
echo mysql_error();
$q=mysql_query("SELECT * FROM emails WHERE id='".$_GET['send']."'");
$r=mysql_fetch_object($q);
@ -735,7 +765,7 @@ case "email_get_list":
echo "<table cellspacing=0 cellpadding=3 border=1>";
echo "<tr><td><b>From:</b></td><td>".htmlspecialchars($r->from)."</td></tr>";
echo "<tr><td><b>To:</b></td><td>";
echo "<select name=\"to\">";
echo "<select name=\"to\" id=\"to\" onchange=\"loadAddresses();\">";
echo " <option value=\"\">Choose Email Recipients</option>";
$str="";
foreach($mailqueries AS $k=>$mq) {
@ -752,6 +782,8 @@ case "email_get_list":
echo " <option value=\"$k\">".i18n($mq['name'])." (".i18n("%1 recipients",array($num),array("number")).")</option>";
}
echo "</select>";
echo "<div id=\"toaddresses-view-wrapper\"><a href=\"#\" onclick=\"return toggleAddresses()\"><span id=\"toaddresses-view\">View Recipients</span></a></div>";
echo "<div id=\"toaddresses\" style=\"width: 100%; height: 300px; overflow: auto; border: 1px solid grey; background-color: #FFFFFF; display: none;\">empty</div>";
echo "</td></tr>";
echo "<tr><td><b>Date:</b></td><td>".date("r")."</td></tr>";
echo "<tr><td><b>Subject:</b></td><td>".htmlspecialchars($r->subject)."</td></tr>";
@ -762,7 +794,7 @@ case "email_get_list":
$body=nl2br(htmlspecialchars($r->body));
}
echo "<tr><td colspan=2>".$body."</td></tr>";
echo "<tr><td colspan=2>".$body."<br />(".mb_detect_encoding($body).")</td></tr>";
echo "</table>";