diff --git a/admin/communication.inc.php b/admin/communication.inc.php
new file mode 100644
index 0000000..a4f217d
--- /dev/null
+++ b/admin/communication.inc.php
@@ -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"),
+ );
diff --git a/admin/communication.php b/admin/communication.php
index 43d77ae..b6b0e3c 100644
--- a/admin/communication.php
+++ b/admin/communication.php
@@ -24,7 +24,7 @@
require("../common.inc.php");
auth_required('admin');
-
+ include "communication.inc.php";
send_header("Communication");
echo "<< ".i18n("Back to Administration")."";
echo " ";
@@ -112,10 +112,12 @@
echo "
To:
";
echo "";
echo "
";
echo "
Date:
".date("r")."
";
@@ -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 " ";
+ echo happy("Email Communication sending has started!");
+ echo " ";
+ echo "Click here to see the sending progress";
+ }
+ 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 " ";
- echo happy("Email Communication sending has started!");
- echo " ";
- echo "Click here to see the sending progress";
}
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();
?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/admin/send_communication.php b/admin/send_communication.php
index 11de14a..5c68ce8 100644
--- a/admin/send_communication.php
+++ b/admin/send_communication.php
@@ -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))
{
diff --git a/version.txt b/version.txt
index ee90284..ac378a1 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.0.4
+1.0.4.2