summaryrefslogtreecommitdiffstats
path: root/include/functions.php
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2009-06-21 23:23:15 -0700
committerArun Persaud <arun@nubati.net>2009-06-23 00:17:00 -0700
commitc757506a0a598593115c377a6e4acf399f4d2b83 (patch)
treeae26d5aca8ae536e5754781a3341422bfa07b632 /include/functions.php
parent1a44bc0d058016a093a112f064bac63a570c400d (diff)
downloade-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.tar.gz
e-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.tar.bz2
e-DoKo-c757506a0a598593115c377a6e4acf399f4d2b83.zip
added option for email digest
you can now select to get emails only every N hours. They are saved in the database and a cron script will send them out.
Diffstat (limited to 'include/functions.php')
-rw-r--r--include/functions.php79
1 files changed, 42 insertions, 37 deletions
diff --git a/include/functions.php b/include/functions.php
index 3e21e6d..43fbb24 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -58,51 +58,56 @@ function mymail($uid,$subject,$message)
{
global $EmailName;
- /* check if user wants email right away or if we should save it in
- * the database for later delivery
- */
- if(0)
+ /* do we send the email right away or save it in the database? */
+ $send_now = 1;
+
+ /* add standard header and footer */
+ $subject = "$EmailName".$subject;
+
+ /* standard goodbye */
+ $footer = "\nHave a nice day\n".
+ " your E-Doko service department\n\n".
+ "-- \n".
+ "You can change your mail delivery mode in the preference menu.\n".
+ 'web: http://doko.nubati.net '.
+ 'help: http://wiki.nubati.net/EmailDoko '.
+ 'bugs: http://wiki.nubati.net/EmailDokoIssues';
+
+ if(is_array($uid))
{
- /* send to database (not yet implemented)*/
- }
- else
- {
- /* send email right away */
-
- /* add standard header and footer */
- $subject = "$EmailName".$subject;
+ /* send email to more than one person */
- /* standard goodbye */
- $footer = "\nHave a nice day\n".
- " your E-Doko service department\n\n".
- "-- \n".
- "You can change your mail delivery mode in the preference menu.\n".
- 'web: http://doko.nubati.net '.
- 'help: http://wiki.nubati.net/EmailDoko '.
- 'bugs: http://wiki.nubati.net/EmailDokoIssues';
+ $header = "Hello all\n\n";
- if(is_array($uid))
+ foreach($uid as $user)
{
- /* send email to more than one person */
+ $all[] = DB_get_email('userid',$user);
+ }
+ $To = implode(",",$all);
+ }
+ else
+ {
+ /* standard greeting */
+ $name = DB_get_name('userid',$uid);
+ $header = "Hello $name\n\n";
- $header = "Hello all\n\n";
+ $To = DB_get_email('userid',$uid);
- foreach($uid as $user)
- {
- $all[] = DB_get_email('userid',$user);
- }
- $To = implode(",",$all);
- }
- else
- {
- /* standard greeting */
- $name = DB_get_name('userid',$uid);
- $header = "Hello $name\n\n";
+ /* check if user wants email right away or if we should save it in
+ * the database for later delivery
+ */
- $To = DB_get_email('userid',$uid);
- }
+ $PREF = DB_get_PREF($uid);
+ if( $PREF['digest'] != 'digest-off' )
+ $send_now = 0;
+ }
- sendmail($To,$subject,$header.$message.$footer);
+ if($send_now)
+ sendmail($To,$subject,$header.$message.$footer);
+ else
+ {
+ /* store email in database */
+ DB_digest_insert_email($To,$message);
}
}