ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCronCheck.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 {
36  private $possible_tasks = array();
37  private $default_tasks = array();
38 
39  public function ilCronCheck()
40  {
41  global $ilLog;
42 
43  $this->log = $ilLog;
44 
45  $this->initTasks();
46  }
47 
48  public function start()
49  {
50  global $ilSetting;
51 
52  $ilSetting->set('last_cronjob_start_ts', time());
53 
54  if( $_SERVER['argc'] > 4 ) for($i = 4; $i < $_SERVER['argc']; $i++)
55  {
56  $arg = $_SERVER['argv'][$i];
57 
58  if( !isset($this->possible_tasks[$arg]) )
59  throw new ilException('cron-task "'.$arg.'" is not defined');
60 
61  $task = $this->possible_tasks[$arg];
62 
63  $this->runTask($task);
64  }
65  else foreach($this->default_tasks as $task)
66  {
67  $task = $this->possible_tasks[$task];
68 
69  $this->runTask($task);
70  }
71  }
72 
73  private function runTask($task)
74  {
79  $classlocation = $task['location'].'/classes';
80  if( isset($task['sub_location']) && strlen($task['sub_location']) )
81  {
82  $classlocation .= '/'.$task['sub_location'];
83  }
84  $classfile .= $classlocation.'/class.'.$task['classname'].'.php';
85 
86  $classname = $task['classname'];
87  $method = $task['method'];
88 
89  $condition = $task['condition'];
90 
95  if( !file_exists($classfile) )
96  throw new ilException('class file "'.$classfile.'" does not exist');
97 
98  require_once($classfile);
99 
100  if( !class_exists($classname) )
101  throw new ilException('class "'.$classname.'" does not exist');
102 
103  if( !method_exists($classname, $method) )
104  throw new ilException('method "'.$classname.'::'.$method.'()" does not exist');
105 
111  if($condition)
112  {
113  $task = new $classname;
114  $task->$method();
115  }
116  }
117 
118  private function initTasks()
119  {
120  global $ilias;
121 
122  require_once('Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php');
123 
124  $this->default_tasks = array(
125  'ilLDAPCronSynchronization::start',
126  'ilCronCheckUserAccounts::check',
127  'ilLuceneIndexer::index',
128  'ilCronLinkCheck::check',
129  'ilCronWebResourceCheck::check',
130  'ilCronForumNotification::sendNotifications',
131  'ilCronMailNotification::sendNotifications',
132  'ilCronValidator::check',
133  'ilCronDiskQuotaCheck::updateDiskUsageStatistics',
134  'ilCronDiskQuotaCheck::sendReminderMails',
135  // This entry refers to a task that is not completely implemented
136  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC',
137  'ilCronDeleteInactiveUserAccounts::run'
138  );
139 
140  $this->possible_tasks = array(
141 
142  'ilLDAPCronSynchronization::start' => array(
143  'classname' => 'ilLDAPCronSynchronization',
144  'method' => 'start',
145  'location' => 'Services/LDAP',
146  'condition' => true
147  ),
148 
149  // Check user accounts if enabled in settings
150  'ilCronCheckUserAccounts::check' => array(
151  'classname' => 'ilCronCheckUserAccounts',
152  'method' => 'check',
153  'location' => 'cron',
154  'condition' => $ilias->getSetting('cron_user_check')
155  ),
156 
157  // Start lucene indexer
158  'ilLuceneIndexer::index' => array(
159  'classname' => 'ilLuceneIndexer',
160  'method' => 'index',
161  'location' => 'Services/Search',
162  'sub_location' => 'Lucene',
163  'condition' => $ilias->getSetting("cron_lucene_index")
164  ),
165 
166  // Start Link check
167  'ilCronLinkCheck::check' => array(
168  'classname' => 'ilCronLinkCheck',
169  'method' => 'check',
170  'location' => 'cron',
171  'condition' => $ilias->getSetting("cron_link_check")
172  ),
173 
174  // Start web resource check
175  'ilCronWebResourceCheck::check' => array(
176  'classname' => 'ilCronWebResourceCheck',
177  'method' => 'check',
178  'location' => 'cron',
179  'condition' => $ilias->getSetting("cron_web_resource_check")
180  ),
181 
182  // Start sending forum notifications
183  'ilCronForumNotification::sendNotifications' => array(
184  'classname' => 'ilCronForumNotification',
185  'method' => 'sendNotifications',
186  'location' => 'cron',
187  'condition' => ($ilias->getSetting('forum_notification') == 2)
188  ),
189 
190  // Start sending mail notifications
191  'ilCronMailNotification::sendNotifications' => array(
192  'classname' => 'ilCronMailNotification',
193  'method' => 'sendNotifications',
194  'location' => 'cron',
195  'condition' => ($ilias->getSetting('mail_notification') == 1)
196  ),
197 
198  // Start System Check
199  'ilCronValidator::check' => array(
200  'classname' => 'ilCronValidator',
201  'method' => 'check',
202  'location' => 'cron',
203  'condition' => ($ilias->getSetting('systemcheck_cron') == 1)
204  ),
205 
206  // Start Disk Quota Usage Statistics
207  'ilCronDiskQuotaCheck::updateDiskUsageStatistics' => array(
208  'classname' => 'ilCronDiskQuotaCheck',
209  'method' => 'updateDiskUsageStatistics',
210  'location' => 'cron',
212  ),
213 
214  // Send Disk Quota Reminder Mails
215  'ilCronDiskQuotaCheck::sendReminderMails' => array(
216  'classname' => 'ilCronDiskQuotaCheck',
217  'method' => 'sendReminderMails',
218  'location' => 'cron',
220  ),
221 
222  // Send Disk Quota Summary Mails
223  'ilCronDiskQuotaCheck::sendSummaryMails' => array(
224  'classname' => 'ilCronDiskQuotaCheck',
225  'method' => 'sendSummaryMails',
226  'location' => 'cron',
228  ),
229 
234  #// Start Shopping Cart Check
235  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC' => array(
236  # 'classname' => 'ilPaymentShoppingCart',
237  # 'method' => '__deleteExpiredSessionsPSC',
238  # 'location' => 'Services/Payment',
239  # 'condition' => true
240  #),
241 
242  // Delete Inactive User Accounts
243  'ilCronDeleteInactiveUserAccounts::run' => array(
244  'classname' => 'ilCronDeleteInactiveUserAccounts',
245  'method' => 'run',
246  'location' => 'Services/User',
247  'condition' => $ilias->getSetting('cron_inactive_user_delete', 0)
248  )
249  );
250  }
251 
252 }
253 ?>