• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

cron/classes/class.ilCronMailNotification.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 class ilCronMailNotification
00034 {
00035         function ilCronMailNotification()
00036         {
00037                 global $ilLog,$ilDB;
00038 
00039                 $this->log =& $ilLog;
00040                 $this->db =& $ilDB;
00041         }
00042 
00043         function sendMails($res)
00044         {
00045                 global $ilias, $rbacsystem;
00046 
00047         }
00048 
00049         function sendNotifications()
00050         {
00051                 global $ilias;
00052                 
00053                 include_once "Services/Mail/classes/class.ilMail.php";
00054                 include_once './Services/User/classes/class.ilObjUser.php';
00055                 include_once "./Services/Language/classes/class.ilLanguage.php";
00056 
00057                 $query = "SELECT mail.* " 
00058                                  ."FROM mail_options "
00059                                  ."INNER JOIN mail ON mail.user_id = mail_options.user_id "
00060                                  ."INNER JOIN mail_obj_data ON mail_obj_data.obj_id = mail.folder_id "
00061                                  ."WHERE 1 "
00062                                  ."AND cronjob_notification = '1' "
00063                                  ."AND send_time >= '" . date("Y-m-d H:i:s", time() - 60 * 60 * 24). "' "
00064                                  ."AND mail_obj_data.type = 'inbox' "
00065                                  ."AND m_status = 'unread' "
00066                                  ." ";
00067                                                 
00068                 $res = $this->db->query($query);
00069                 
00070                 $users = array();
00071                 
00072                 $user_id = 0;
00073                 while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
00074                 {
00075                         if ($user_id == 0 || $row['user_id'] != $user_id) $user_id = $row['user_id'];
00076 
00077                         $users[$user_id][] = $row;                               
00078                 }
00079                 
00080                 $numRows = 0;
00081                 foreach ($users as $user_id => $mail_data)
00082                 {
00083                         $tmp_mail_obj = new ilMail($user_id);                   
00084                         
00085                         include_once "Services/Mail/classes/class.ilMimeMail.php";
00086 
00087                         $mmail = new ilMimeMail();
00088                         $mmail->autoCheck(false);
00089                         $mmail->From('noreply');
00090                         $mmail->To(ilObjUser::_lookupEmail($user_id));                                  
00091                         $mmail->Subject($tmp_mail_obj->formatNotificationSubject());
00092                         $mmail->Body($tmp_mail_obj->formatNotificationMessage($user_id, $mail_data));
00093                         
00094                         $mmail->Send();
00095                         
00096                         unset($tmp_mail_obj);
00097                         
00098                         ++$numRows;
00099                 }
00100                 
00101                 $this->log->write(__METHOD__.': Send '.$numRows.' messages.');  
00102 
00103                 return true;
00104         }
00105 }
00106 ?>

Generated on Fri Dec 13 2013 17:56:49 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1