add reminder functionality

git-svn-id: http://svn.cacert.cl/Software/Voting/vote@58 d4452222-2f33-11de-9270-010000000000
This commit is contained in:
community.cacert.org 2009-06-12 05:01:29 +00:00
parent a66ba7060a
commit a159b44435
3 changed files with 51 additions and 1 deletions

View file

@ -9,7 +9,7 @@ php_value open_basedir /var/www/board
php_value safe_mode_exec_dir /var/empty php_value safe_mode_exec_dir /var/empty
</IfModule> </IfModule>
<FilesMatch "^database.*$"> <FilesMatch "^(database.*|remind.php)$">
Order Deny,Allow Order Deny,Allow
Deny from all Deny from all
</FilesMatch> </FilesMatch>

View file

@ -104,6 +104,11 @@ BODY;
$header = "References: <".$tag.">\r\nIn-reply-to: <".$tag.">\r\n"; $header = "References: <".$tag.">\r\nIn-reply-to: <".$tag.">\r\n";
mail($this->notices, mb_encode_mimeheader($subject,"UTF-8", "B", "\n"),$body,$header."From: Voting System <returns@cacert.org>"); mail($this->notices, mb_encode_mimeheader($subject,"UTF-8", "B", "\n"),$body,$header."From: Voting System <returns@cacert.org>");
} }
function remind_notify($email,$subject,$body)
{
$header = "Content-Type: text/plain; charset=UTF-8\r\n";
mail($email,$subject,$body,$header."From: Voting System <returns@cacert.org>");
}
function auth() function auth()
{ {
$stmt = $this->getStatement("get voter"); $stmt = $this->getStatement("get voter");

45
remind.php Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/php
<?
require_once("database.php");
$db = new DB();
$db->closeVotes();
$id = 0;
$page = 1;
$voters = $db->getStatement('get reminder voters');
$voters->execute();
$outstanding = $db->getStatement('list my unvoted decisions');
$outstanding->bindParam(':id',$id);
$outstanding->bindParam(':page',$page);
while ($v = $voters->fetch()) {
$id = $v['id'];
$outstanding->execute();
$msg ='';
while ($row=$outstanding->fetch()) {
$msg .= ($row['votetype'] ? 'vote ' : 'motion ') . $row['tag'] . ' ' . $row['title'] . "\nDue: " . $row['due'] . "\nhttps://community.cacert.org/board/motions.php?motion=" . $row['tag'] . "\n\n";
}
if ($msg) {
// form email
$name = $v['name'];
$body = <<<BODY
Dear $name,
You have not voted in the following CAcert Board vote(s)/motion(s):
$msg
To view all your outstanding motions: https://community.cacert.org/board/motions.php?unvoted=1
Kind regards,
the vote system
BODY;
$db->remind_notify($v['email'],"Outstanding CAcert board votes",$body);
}
}
?>