Update the communication module with a few more options

This commit is contained in:
james 2006-03-01 15:59:51 +00:00
parent 3a2186b5dd
commit 4bf5cb909f
4 changed files with 80 additions and 68 deletions

View File

@ -0,0 +1,29 @@
<?
$mailqueries=array(
"judges_all"=>array("name"=>"Judges from all years","query"=>
"SELECT firstname, lastname, email FROM judges ORDER BY email"),
"judges_active_thisyear"=>array("name"=>"Judges active for this year", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id ORDER BY email"),
"judges_active_complete_thisyear"=>array("name"=>"Judges active for this year and complete", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id AND judges.complete='yes' ORDER BY email"),
"judges_active_incomplete_thisyear"=>array("name"=>"Judges active for this year but not complete", "query"=>
"SELECT DISTINCT(judges.id), firstname, lastname, email FROM judges,judges_years WHERE judges_years.year='".$config['FAIRYEAR']."' AND judges.id=judges_years.judges_id AND judges.complete!='yes' ORDER BY email"),
"participants_complete_thisyear"=>array("name"=>"Participants complete this year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"),
"participants_complete_paymentpending_thisyear"=>array("name"=>"Participants complete this year but payment pending","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND registrations.status!='complete' AND registrations.status='paymentpending' ORDER BY students.email"),
"participants_notcomplete_thisyear"=>array("name"=>"Participants not complete this year","query"=>
"SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".$config['FAIRYEAR']."' AND registrations.status!='complete' AND registrations.status!='new' ORDER BY students.email"),
);

View File

@ -24,7 +24,7 @@
<?
require("../common.inc.php");
auth_required('admin');
include "communication.inc.php";
send_header("Communication");
echo "<a href=\"index.php\">&lt;&lt; ".i18n("Back to Administration")."</a>";
echo "<br />";
@ -112,10 +112,12 @@
echo "<tr><td><b>To:</b></td><td>";
echo "<select name=\"to\">";
echo " <option value=\"\">Choose Email Recipients</option>";
echo " <option value=\"students_all\">All Registered Students</option>";
echo " <option value=\"judges_all\">All Judges</option>";
// echo " <option value=\"judges_active\">All Active Judges</option>";
// echo " <option value=\"judges_deactive\">All Deactive Judges</option>";
foreach($mailqueries AS $k=>$mq)
{
$tq=mysql_query($mq['query']);
$num=mysql_num_rows($tq);
echo " <option value=\"$k\">".i18n($mq['name'])." (".i18n("%1 recipients",array($num),array("number")).")</option>";
}
echo "</select>";
echo "</td></tr>";
echo "<tr><td><b>Date:</b></td><td>".date("r")."</td></tr>";
@ -150,47 +152,51 @@
}
else
{
switch ($_GET['to'])
{
case "judges_all":
$q=mysql_query("SELECT count(id) AS num FROM judges");
break;
default:
echo error(i18n("Unknown 'to' to send email communication to (%1)",array($_GET['to'])));
}
$r=mysql_fetch_object($q);
$num_subscribed=$r->num;
if($r->num)
if(array_key_exists($to,$mailqueries))
{
$q=mysql_query("SELECT * FROM emails WHERE id='".$_GET['reallysend']."'");
$r=mysql_fetch_object($q);
$q=mysql_query($mailqueries[$to]['query']);
echo mysql_error();
$num_subscribed=mysql_num_rows($q);
if($num_subscribed)
{
$q=mysql_query("SELECT * FROM emails WHERE id='".$_GET['reallysend']."'");
$r=mysql_fetch_object($q);
//communcation lock file lines:
// 1: Email ID
// 2: Date it was started
// 3: Subject
// 4: Total Recipients
// 5: _GET['to']
$fp=fopen("../data/communication.lock","w");
fputs($fp,$r->id."\n");
fputs($fp,date("r")."\n");
fputs($fp,$r->subject."\n");
fputs($fp,$num_subscribed."\n");
fputs($fp,$_GET['to']."\n");
fclose($fp);
system("echo \"/usr/local/bin/php -q send_communication.php ".$_GET['reallysend']."\" | at now +1 minute");
echo "<br />";
echo happy("Email Communication sending has started!");
echo "<br>";
echo "<a href=\"communication_send_status.php\">Click here to see the sending progress</a>";
}
else
{
echo error(i18n("No recipients"));
}
//communcation lock file lines:
// 1: Email ID
// 2: Date it was started
// 3: Subject
// 4: Total Recipients
// 5: _GET['to']
$fp=fopen("../data/communication.lock","w");
fputs($fp,$r->id."\n");
fputs($fp,date("r")."\n");
fputs($fp,$r->subject."\n");
fputs($fp,$num_subscribed."\n");
fputs($fp,$_GET['to']."\n");
fclose($fp);
system("echo \"/usr/local/bin/php -q send_communication.php ".$_GET['reallysend']."\" | at now +1 minute");
echo "<br />";
echo happy("Email Communication sending has started!");
echo "<br>";
echo "<a href=\"communication_send_status.php\">Click here to see the sending progress</a>";
}
else
{
echo error(i18n("No recipients"));
}
echo error(i18n("Unknown 'to' to send email communication to (%1)",array($_GET['to'])));
}
}
else if($_GET['action']=="add" || $_GET['action']=="edit")
@ -280,23 +286,3 @@
send_footer();
?>

View File

@ -23,6 +23,7 @@
?>
<?
include "../common.inc.php";
include "communication.inc.php";
$sleepmin=500000; // 0.5 seconds
$sleepmax=2000000; // 2.0 second
@ -44,14 +45,10 @@ if(file_exists("../data/communication.lock"))
switch ($to)
{
case "judges_all":
$q=mysql_query("SELECT firstname, lastname, email FROM judges ORDER BY email");
break;
default:
echo i18n("Unknown 'to' to send email communication to (%1)",array($to));
}
if(array_key_exists($to,$mailqueries))
$q=mysql_query($mailqueries[$to]['query']);
else
echo i18n("Unknown 'to' to send email communication to (%1)",array($to));
while($r=mysql_fetch_object($q))
{

View File

@ -1 +1 @@
1.0.4
1.0.4.2