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");
|
require("../common.inc.php");
|
||||||
auth_required('admin');
|
auth_required('admin');
|
||||||
|
include "communication.inc.php";
|
||||||
send_header("Communication");
|
send_header("Communication");
|
||||||
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>";
|
echo "<a href=\"index.php\"><< ".i18n("Back to Administration")."</a>";
|
||||||
echo "<br />";
|
echo "<br />";
|
||||||
@ -112,10 +112,12 @@
|
|||||||
echo "<tr><td><b>To:</b></td><td>";
|
echo "<tr><td><b>To:</b></td><td>";
|
||||||
echo "<select name=\"to\">";
|
echo "<select name=\"to\">";
|
||||||
echo " <option value=\"\">Choose Email Recipients</option>";
|
echo " <option value=\"\">Choose Email Recipients</option>";
|
||||||
echo " <option value=\"students_all\">All Registered Students</option>";
|
foreach($mailqueries AS $k=>$mq)
|
||||||
echo " <option value=\"judges_all\">All Judges</option>";
|
{
|
||||||
// echo " <option value=\"judges_active\">All Active Judges</option>";
|
$tq=mysql_query($mq['query']);
|
||||||
// echo " <option value=\"judges_deactive\">All Deactive Judges</option>";
|
$num=mysql_num_rows($tq);
|
||||||
|
echo " <option value=\"$k\">".i18n($mq['name'])." (".i18n("%1 recipients",array($num),array("number")).")</option>";
|
||||||
|
}
|
||||||
echo "</select>";
|
echo "</select>";
|
||||||
echo "</td></tr>";
|
echo "</td></tr>";
|
||||||
echo "<tr><td><b>Date:</b></td><td>".date("r")."</td></tr>";
|
echo "<tr><td><b>Date:</b></td><td>".date("r")."</td></tr>";
|
||||||
@ -150,47 +152,51 @@
|
|||||||
}
|
}
|
||||||
else
|
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("SELECT * FROM emails WHERE id='".$_GET['reallysend']."'");
|
$q=mysql_query($mailqueries[$to]['query']);
|
||||||
$r=mysql_fetch_object($q);
|
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
|
else
|
||||||
{
|
echo error(i18n("Unknown 'to' to send email communication to (%1)",array($_GET['to'])));
|
||||||
echo error(i18n("No recipients"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if($_GET['action']=="add" || $_GET['action']=="edit")
|
else if($_GET['action']=="add" || $_GET['action']=="edit")
|
||||||
@ -280,23 +286,3 @@
|
|||||||
|
|
||||||
send_footer();
|
send_footer();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
?>
|
?>
|
||||||
<?
|
<?
|
||||||
include "../common.inc.php";
|
include "../common.inc.php";
|
||||||
|
include "communication.inc.php";
|
||||||
|
|
||||||
$sleepmin=500000; // 0.5 seconds
|
$sleepmin=500000; // 0.5 seconds
|
||||||
$sleepmax=2000000; // 2.0 second
|
$sleepmax=2000000; // 2.0 second
|
||||||
@ -44,14 +45,10 @@ if(file_exists("../data/communication.lock"))
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch ($to)
|
if(array_key_exists($to,$mailqueries))
|
||||||
{
|
$q=mysql_query($mailqueries[$to]['query']);
|
||||||
case "judges_all":
|
else
|
||||||
$q=mysql_query("SELECT firstname, lastname, email FROM judges ORDER BY email");
|
echo i18n("Unknown 'to' to send email communication to (%1)",array($to));
|
||||||
break;
|
|
||||||
default:
|
|
||||||
echo i18n("Unknown 'to' to send email communication to (%1)",array($to));
|
|
||||||
}
|
|
||||||
|
|
||||||
while($r=mysql_fetch_object($q))
|
while($r=mysql_fetch_object($q))
|
||||||
{
|
{
|
||||||
|
@ -1 +1 @@
|
|||||||
1.0.4
|
1.0.4.2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user