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

cron/classes/class.ilCronCheckUserAccounts.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 
00034 class ilCronCheckUserAccounts
00035 {
00036         function ilCronCheckUserAccounts()
00037         {
00038                 global $ilLog,$ilDB;
00039 
00040                 $this->log =& $ilLog;
00041                 $this->db =& $ilDB;
00042         }
00043 
00044         function check()
00045         {
00046                 $two_weeks_in_seconds = 60 * 60 * 24 * 14;
00047 
00048                 $this->log->write('Cron: Start ilCronCheckUserAccounts::check()');
00049 
00050                 $query = "SELECT * FROM usr_data,usr_pref ".
00051                         "WHERE time_limit_message = '0' ".
00052                         "AND time_limit_unlimited = '0' ".
00053                         "AND time_limit_from < '".time()."' ".
00054                         "AND time_limit_until > '".$two_weeks_in_seconds."' ".
00055                         "AND usr_data.usr_id = usr_pref.usr_id ".
00056                         "AND keyword = 'language'";
00057 
00058                 $res = $this->db->query($query);
00059 
00060                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00061                 {
00062                         include_once './classes/class.ilMimeMail.php';
00063 
00064                         $data['expires'] = $row->time_limit_until;
00065                         $data['email'] = $row->email;
00066                         $data['login'] = $row->login;
00067                         $data['usr_id'] = $row->usr_id;
00068                         $data['language'] = $row->value;
00069                         $data['owner'] = $row->time_limit_owner;
00070 
00071                         // Send mail
00072                         $mail =& new ilMimeMail();
00073                         
00074                         $mail->From('noreply');
00075                         $mail->To($data['email']);
00076                         $mail->Subject($this->txt($data['language'],'account_expires_subject'));
00077                         $mail->Body($this->txt($data['language'],'account_expires_body')." ".strftime('%Y-%m-%d %R',$data['expires']));
00078                         $mail->send();
00079 
00080                         // set status 'mail sent'
00081                         $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '".$data['usr_id']."'";
00082                         $this->db->query($query);
00083                         
00084                         // Send log message
00085                         $this->log->write('Cron: (checkUserAccounts()) sent message to '.$data['login'].'.');
00086 
00087 
00088                 }
00089 
00090                 $this->log->write('Cron: End ilCronCheckUserAccounts::check()');
00091         }
00092         function txt($language,$key,$module = 'common')
00093         {
00094                 $query = "SELECT value FROM lng_data ".
00095                         "WHERE module = '".$module."' ".
00096                         "AND identifier = '".$key."' ".
00097                         "AND lang_key = '".$language."'";
00098 
00099                 $res = $this->db->query($query);
00100                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00101                 {
00102                         $value = $row->value;
00103                 }
00104                 return $value ? $value : $key;
00105         }
00106 }
00107 
00108 
00109 
00110 
00111 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1