ILIAS  eassessment Revision 61809
 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 
110  if($condition)
111  {
112  $task = new $classname;
113  $task->$method();
114  }
115  }
116 
117  private function initTasks()
118  {
119  global $ilias;
120 
121  require_once('Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php');
122 
123  $this->default_tasks = array(
124  'ilLDAPCronSynchronization::start',
125  'ilCronCheckUserAccounts::check',
126  'ilLuceneIndexer::index',
127  'ilCronLinkCheck::check',
128  'ilCronWebResourceCheck::check',
129  'ilCronForumNotification::sendNotifications',
130  'ilCronMailNotification::sendNotifications',
131  'ilCronValidator::check',
132  'ilCronDiskQuotaCheck::updateDiskUsageStatistics',
133  'ilCronDiskQuotaCheck::sendReminderMails',
134  // This entry refers to a task that is not completely implemented
135  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC',
136  'ilCronDeleteInactiveUserAccounts::run'
137  );
138 
139  $this->possible_tasks = array(
140 
141  'ilLDAPCronSynchronization::start' => array(
142  'classname' => 'ilLDAPCronSynchronization',
143  'method' => 'start',
144  'location' => 'Services/LDAP',
145  'condition' => true
146  ),
147 
148  // Check user accounts if enabled in settings
149  'ilCronCheckUserAccounts::check' => array(
150  'classname' => 'ilCronCheckUserAccounts',
151  'method' => 'check',
152  'location' => 'cron',
153  'condition' => $ilias->getSetting('cron_user_check')
154  ),
155 
156  // Start lucene indexer
157  'ilLuceneIndexer::index' => array(
158  'classname' => 'ilLuceneIndexer',
159  'method' => 'index',
160  'location' => 'Services/Search',
161  'sub_location' => 'Lucene',
162  'condition' => $ilias->getSetting("cron_lucene_index")
163  ),
164 
165  // Start Link check
166  'ilCronLinkCheck::check' => array(
167  'classname' => 'ilCronLinkCheck',
168  'method' => 'check',
169  'location' => 'cron',
170  'condition' => $ilias->getSetting("cron_link_check")
171  ),
172 
173  // Start web resource check
174  'ilCronWebResourceCheck::check' => array(
175  'classname' => 'ilCronWebResourceCheck',
176  'method' => 'check',
177  'location' => 'cron',
178  'condition' => $ilias->getSetting("cron_web_resource_check")
179  ),
180 
181  // Start sending forum notifications
182  'ilCronForumNotification::sendNotifications' => array(
183  'classname' => 'ilCronForumNotification',
184  'method' => 'sendNotifications',
185  'location' => 'cron',
186  'condition' => ($ilias->getSetting('forum_notification') == 2)
187  ),
188 
189  // Start sending mail notifications
190  'ilCronMailNotification::sendNotifications' => array(
191  'classname' => 'ilCronMailNotification',
192  'method' => 'sendNotifications',
193  'location' => 'cron',
194  'condition' => ($ilias->getSetting('mail_notification') == 1)
195  ),
196 
197  // Start System Check
198  'ilCronValidator::check' => array(
199  'classname' => 'ilCronValidator',
200  'method' => 'check',
201  'location' => 'cron',
202  'condition' => ($ilias->getSetting('systemcheck_cron') == 1)
203  ),
204 
205  // Start Disk Quota Usage Statistics
206  'ilCronDiskQuotaCheck::updateDiskUsageStatistics' => array(
207  'classname' => 'ilCronDiskQuotaCheck',
208  'method' => 'updateDiskUsageStatistics',
209  'location' => 'cron',
211  ),
212 
213  // Send Disk Quota Reminder Mails
214  'ilCronDiskQuotaCheck::sendReminderMails' => array(
215  'classname' => 'ilCronDiskQuotaCheck',
216  'method' => 'sendReminderMails',
217  'location' => 'cron',
219  ),
220 
221  // Send Disk Quota Summary Mails
222  'ilCronDiskQuotaCheck::sendSummaryMails' => array(
223  'classname' => 'ilCronDiskQuotaCheck',
224  'method' => 'sendSummaryMails',
225  'location' => 'cron',
227  ),
228 
233  #// Start Shopping Cart Check
234  #'ilPaymentShoppingCart::__deleteExpiredSessionsPSC' => array(
235  # 'classname' => 'ilPaymentShoppingCart',
236  # 'method' => '__deleteExpiredSessionsPSC',
237  # 'location' => 'Services/Payment',
238  # 'condition' => true
239  #),
240 
241  // Delete Inactive User Accounts
242  'ilCronDeleteInactiveUserAccounts::run' => array(
243  'classname' => 'ilCronDeleteInactiveUserAccounts',
244  'method' => 'run',
245  'location' => 'Services/User',
246  'condition' => $ilias->getSetting('cron_inactive_user_delete', 0)
247  )
248  );
249  }
250 
251 }
252 ?>