Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
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
00081 $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '".$data['usr_id']."'";
00082 $this->db->query($query);
00083
00084
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 ?>