forked from science-ation/science-ation
Update the communication module with a few more options
This commit is contained in:
parent
3a2186b5dd
commit
4bf5cb909f
29
admin/communication.inc.php
Normal file
29
admin/communication.inc.php
Normal 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"),
|
||||
);
|
@ -24,7 +24,7 @@
|
||||
<?
|
||||
require("../common.inc.php");
|
||||
auth_required('admin');
|
||||
|
||||
include "communication.inc.php";
|
||||
send_header("Communication");
|
||||
echo "<a href=\"index.php\"><< ".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,17 +152,14 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ($_GET['to'])
|
||||
if(array_key_exists($to,$mailqueries))
|
||||
{
|
||||
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)
|
||||
|
||||
$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']."'");
|
||||
@ -191,6 +190,13 @@
|
||||
{
|
||||
echo error(i18n("No recipients"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
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();
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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:
|
||||
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))
|
||||
{
|
||||
|
@ -1 +1 @@
|
||||
1.0.4
|
||||
1.0.4.2
|
||||
|
Loading…
Reference in New Issue
Block a user