ILIAS  Release_4_2_x_branch Revision 61807
 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  require_once('Services/Payment/classes/class.ilUserDefinedInvoiceNumber.php');
124 
125  $this->default_tasks = array(
126  'ilLDAPCronSynchronization::start',
127  'ilCronCheckUserAccounts::check',
128  'ilLuceneIndexer::index',
129  'ilCronLinkCheck::check',
130  'ilCronWebResourceCheck::check',
131  'ilCronForumNotification::sendNotifications',
132  'ilCronMailNotification::sendNotifications',
133  'ilCronValidator::check',
134  'ilCronDiskQuotaCheck::updateDiskUsageStatistics',
135  'ilCronDiskQuotaCheck::sendReminderMails',
136  // This entry refers to a task that is not completely implemented
137  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC',
138  'ilCronDeleteInactiveUserAccounts::run',
139  'ilCronPaymentNotification::sendNotifications',
140  'ilCronCourseGroupNotification::check',
141  'ilCronPaymentUDInvoiceNumberReset::check'
142  );
143 
144  $this->possible_tasks = array(
145 
146  'ilLDAPCronSynchronization::start' => array(
147  'classname' => 'ilLDAPCronSynchronization',
148  'method' => 'start',
149  'location' => 'Services/LDAP',
150  'condition' => true
151  ),
152 
153  // Check user accounts if enabled in settings
154  'ilCronCheckUserAccounts::check' => array(
155  'classname' => 'ilCronCheckUserAccounts',
156  'method' => 'check',
157  'location' => 'cron',
158  'condition' => $ilias->getSetting('cron_user_check')
159  ),
160 
161  // Start lucene indexer
162  'ilLuceneIndexer::index' => array(
163  'classname' => 'ilLuceneIndexer',
164  'method' => 'index',
165  'location' => 'Services/Search',
166  'sub_location' => 'Lucene',
167  'condition' => $ilias->getSetting("cron_lucene_index")
168  ),
169 
170  // Start Link check
171  'ilCronLinkCheck::check' => array(
172  'classname' => 'ilCronLinkCheck',
173  'method' => 'check',
174  'location' => 'cron',
175  'condition' => $ilias->getSetting("cron_link_check")
176  ),
177 
178  // Start web resource check
179  'ilCronWebResourceCheck::check' => array(
180  'classname' => 'ilCronWebResourceCheck',
181  'method' => 'check',
182  'location' => 'cron',
183  'condition' => $ilias->getSetting("cron_web_resource_check")
184  ),
185 
186  // Start sending forum notifications
187  'ilCronForumNotification::sendNotifications' => array(
188  'classname' => 'ilCronForumNotification',
189  'method' => 'sendNotifications',
190  'location' => 'cron',
191  'condition' => ($ilias->getSetting('forum_notification') == 2)
192  ),
193 
194  // Start sending mail notifications
195  'ilCronMailNotification::sendNotifications' => array(
196  'classname' => 'ilCronMailNotification',
197  'method' => 'sendNotifications',
198  'location' => 'cron',
199  'condition' => ($ilias->getSetting('mail_notification') == 1)
200  ),
201 
202  // Start System Check
203  'ilCronValidator::check' => array(
204  'classname' => 'ilCronValidator',
205  'method' => 'check',
206  'location' => 'cron',
207  'condition' => ($ilias->getSetting('systemcheck_cron') == 1)
208  ),
209 
210  // Start Disk Quota Usage Statistics
211  'ilCronDiskQuotaCheck::updateDiskUsageStatistics' => array(
212  'classname' => 'ilCronDiskQuotaCheck',
213  'method' => 'updateDiskUsageStatistics',
214  'location' => 'cron',
216  ),
217 
218  // Send Disk Quota Reminder Mails
219  'ilCronDiskQuotaCheck::sendReminderMails' => array(
220  'classname' => 'ilCronDiskQuotaCheck',
221  'method' => 'sendReminderMails',
222  'location' => 'cron',
224  ),
225 
226  // Send Disk Quota Summary Mails
227  'ilCronDiskQuotaCheck::sendSummaryMails' => array(
228  'classname' => 'ilCronDiskQuotaCheck',
229  'method' => 'sendSummaryMails',
230  'location' => 'cron',
232  ),
233 
238  #// Start Shopping Cart Check
239  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC' => array(
240  # 'classname' => 'ilPaymentShoppingCart',
241  # 'method' => '__deleteExpiredSessionsPSC',
242  # 'location' => 'Services/Payment',
243  # 'condition' => true
244  #),
245 
246  // Delete Inactive User Accounts
247  'ilCronDeleteInactiveUserAccounts::run' => array(
248  'classname' => 'ilCronDeleteInactiveUserAccounts',
249  'method' => 'run',
250  'location' => 'Services/User',
251  'condition' => $ilias->getSetting('cron_inactive_user_delete', 0)
252  ),
253 
254  // Start sending Payment "Buy Extension" Reminder
255  'ilCronPaymentNotification::sendNotifications' => array(
256  'classname' => 'ilCronPaymentNotification',
257  'method' => 'sendNotifications',
258  'location' => 'cron',
259  'condition' => ($ilias->getSetting('payment_notifications') == 1)
260  ),
261 
262  // Start course group notification check
263  'ilCronCourseGroupNotification::check' => array(
264  'classname' => 'ilCronCourseGroupNotification',
265  'method' => 'sendNotifications',
266  'location' => 'cron',
267  'condition' => $ilias->getSetting("crsgrp_ntf")
268  ),
269 
270  // Reset payment incremental invoice number
271  'ilCronPaymentUDInvoiceNumberReset::check' => array(
272  'classname' => 'ilCronPaymentUDInvoiceNumberReset',
273  'method' => 'check',
274  'location' => 'cron',
276  )
277  );
278  }
279 }
280 ?>