From c757506a0a598593115c377a6e4acf399f4d2b83 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sun, 21 Jun 2009 23:23:15 -0700 Subject: 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. --- include/functions.php | 79 +++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 37 deletions(-) (limited to 'include/functions.php') 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); } } -- cgit v1.2.3-18-g5258