add reminder query + fix UTF-8 on email
authorcommunity.cacert.org <community.cacert.org@d4452222-2f33-11de-9270-010000000000>
Fri, 12 Jun 2009 05:06:03 +0000 (05:06 +0000)
committercommunity.cacert.org <community.cacert.org@d4452222-2f33-11de-9270-010000000000>
Fri, 12 Jun 2009 05:06:03 +0000 (05:06 +0000)
git-svn-id: http://svn.cacert.cl/Software/Voting/vote@59 d4452222-2f33-11de-9270-010000000000

database.php

index 83aec29..a4063f8 100644 (file)
@@ -15,6 +15,7 @@
                        $this->statement['get voter'] = $this->dbh->prepare("SELECT voters.id, voters.name FROM voters, emails WHERE voters.id=emails.voter AND emails.address=? AND voters.enabled=1");
                        $this->statement['get voter by id'] = $this->dbh->prepare("SELECT voters.id, voters.name FROM voters WHERE id=:id;");
                        $this->statement['get voters'] = $this->dbh->prepare("SELECT voters.id, voters.name FROM voters WHERE voters.enabled=1 ORDER BY name ASC;");
+                       $this->statement['get reminder voters'] = $this->dbh->prepare("SELECT voters.id, voters.name, voters.reminder AS email FROM voters WHERE voters.enabled=1 AND voters.reminder!='' ORDER BY name ASC;");
                        $this->statement['del vote'] = $this->dbh->prepare("DELETE FROM votes WHERE decision=:decision AND voter=:voter;");
                        $this->statement['do vote'] = $this->dbh->prepare("INSERT INTO votes (decision, voter, vote, voted, notes) VALUES (:decision, :voter, :vote, datetime('now','utc'), :notes);");
                        $this->statement['stats'] = $this->dbh->prepare("SELECT COUNT(*) AS voters FROM voters WHERE enabled=1;");
@@ -23,6 +24,7 @@
                        $this->statement['post create'] = $this->dbh->prepare(" UPDATE decisions SET tag='m' || strftime('%Y%m%d','now') || '.' || id WHERE id=last_insert_rowid();");
                        $this->statement['update decision'] = $this->dbh->prepare("UPDATE decisions SET proposed=datetime('now','utc'), proponent=:proponent, title=:title, content=:content, votetype=:votetype, status=0, due=datetime('now','utc',:due), modified=datetime('now','utc') WHERE id=:id;");
                        $this->statement['close decision'] = $this->dbh->prepare("UPDATE decisions SET status=:status, modified=datetime('now','utc') WHERE id=:decision");
+                       ini_set('mbstring.internal_encoding', 'UTF-8');
                }
                function getStatement($name) {
                        return $this->statement[$name];
@@ -91,17 +93,18 @@ BODY;
                }
                function notify($subject,$body,$tag,$first=FALSE)
                {
+                       $header = "Content-Type: text/plain; charset=UTF-8\r\n";
                        if ($first) {
-                               $header = "Message-id: <".$tag.">\r\n";
+                               $header .= "Message-id: <".$tag.">\r\n";
                        } else {
-                               $header = "References: <".$tag.">\r\nIn-reply-to: <".$tag.">\r\n";
+                               $header .= "References: <".$tag.">\r\nIn-reply-to: <".$tag.">\r\n";
                        }
                        mail($this->board, mb_encode_mimeheader($subject,"UTF-8", "B", "\n"),$body,$header."From: Voting System <returns@cacert.org>");
-                       //mail("testsympa@lists.cacert.org",$subject,$body,"From: Voting System <returns@cacert.org>");
                }
                function vote_notify($subject,$body,$tag)
                {
-                       $header = "References: <".$tag.">\r\nIn-reply-to: <".$tag.">\r\n";
+                       $header = "Content-Type: text/plain; charset=UTF-8\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>");
                }
                function remind_notify($email,$subject,$body)