ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCronCheckUserAccounts.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
35 {
37  {
38  global $ilLog,$ilDB;
39 
40  $this->log =& $ilLog;
41  $this->db =& $ilDB;
42  }
43 
44  function check()
45  {
46  $two_weeks_in_seconds = 60 * 60 * 24 * 14;
47 
48  $this->log->write('Cron: Start ilCronCheckUserAccounts::check()');
49 
50  $query = "SELECT * FROM usr_data,usr_pref ".
51  "WHERE time_limit_message = '0' ".
52  "AND time_limit_unlimited = '0' ".
53  "AND time_limit_from < '".time()."' ".
54  "AND time_limit_until > '".$two_weeks_in_seconds."' ".
55  "AND usr_data.usr_id = usr_pref.usr_id ".
56  "AND keyword = 'language'";
57 
58  $res = $this->db->query($query);
59 
60  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
61  {
62  include_once 'Services/Mail/classes/class.ilMimeMail.php';
63 
64  $data['expires'] = $row->time_limit_until;
65  $data['email'] = $row->email;
66  $data['login'] = $row->login;
67  $data['usr_id'] = $row->usr_id;
68  $data['language'] = $row->value;
69  $data['owner'] = $row->time_limit_owner;
70 
71  // Send mail
72  $mail =& new ilMimeMail();
73 
74  $mail->From('noreply');
75  $mail->To($data['email']);
76  $mail->Subject($this->txt($data['language'],'account_expires_subject'));
77  $mail->Body($this->txt($data['language'],'account_expires_body')." ".strftime('%Y-%m-%d %R',$data['expires']));
78  $mail->send();
79 
80  // set status 'mail sent'
81  $query = "UPDATE usr_data SET time_limit_message = '1' WHERE usr_id = '".$data['usr_id']."'";
82  $this->db->query($query);
83 
84  // Send log message
85  $this->log->write('Cron: (checkUserAccounts()) sent message to '.$data['login'].'.');
86 
87 
88  }
89 
90  $this->log->write('Cron: End ilCronCheckUserAccounts::check()');
91  }
92  function txt($language,$key,$module = 'common')
93  {
94  $query = "SELECT value FROM lng_data ".
95  "WHERE module = '".$module."' ".
96  "AND identifier = '".$key."' ".
97  "AND lang_key = '".$language."'";
98 
99  $res = $this->db->query($query);
100  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
101  {
102  $value = $row->value;
103  }
104  return $value ? $value : $key;
105  }
106 }
107 
108 
109 
110 
111 ?>