[TASK] Scheduler: move 'Save' button to docHeader
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / class.tx_scheduler_module.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2011 Fran├žois Suter <francois@typo3.org>
6 * (c) 2005 Christian Jul Jensen <julle@typo3.org>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25
26 /**
27 * Module 'TYPO3 Scheduler administration module' for the 'scheduler' extension.
28 *
29 * @author Fran├žois Suter <francois@typo3.org>
30 * @author Christian Jul Jensen <julle@typo3.org>
31 * @author Ingo Renner <ingo@typo3.org>
32 * @package TYPO3
33 * @subpackage tx_scheduler
34 */
35 class tx_scheduler_Module extends t3lib_SCbase {
36
37 /**
38 * Back path to typo3 main dir
39 *
40 * @var string $backPath
41 */
42 public $backPath;
43
44 /**
45 * Array containing submitted data when editing or adding a task
46 *
47 * @var array $submittedData
48 */
49 protected $submittedData = array();
50
51 /**
52 * Array containing all messages issued by the application logic
53 * Contains the error's severity and the message itself
54 *
55 * @var array $messages
56 */
57 protected $messages = array();
58
59 /**
60 * @var string Key of the CSH file
61 */
62 protected $cshKey;
63
64 /**
65 *
66 * @var tx_scheduler Local scheduler instance
67 */
68 protected $scheduler;
69
70 /**
71 * Constructor
72 *
73 * @return tx_scheduler_Module
74 */
75 public function __construct() {
76 $this->backPath = $GLOBALS['BACK_PATH'];
77 // Set key for CSH
78 $this->cshKey = '_MOD_' . $GLOBALS['MCONF']['name'];
79 }
80
81 /**
82 * Initializes the backend module
83 *
84 * @return void
85 */
86 public function init() {
87 parent::init();
88
89 // Initialize document
90 $this->doc = t3lib_div::makeInstance('template');
91 $this->doc->setModuleTemplate(t3lib_extMgm::extPath('scheduler') . 'mod1/mod_template.html');
92 $this->doc->getPageRenderer()->addCssFile(t3lib_extMgm::extRelPath('scheduler') . 'res/tx_scheduler_be.css');
93 $this->doc->backPath = $this->backPath;
94 $this->doc->bodyTagId = 'typo3-mod-php';
95 $this->doc->bodyTagAdditions = 'class="tx_scheduler_mod1"';
96
97 // Create scheduler instance
98 $this->scheduler = t3lib_div::makeInstance('tx_scheduler');
99 }
100
101 /**
102 * Adds items to the ->MOD_MENU array. Used for the function menu selector.
103 *
104 * @return void
105 */
106 public function menuConfig() {
107 $this->MOD_MENU = array(
108 'function' => array(
109 'scheduler' => $GLOBALS['LANG']->getLL('function.scheduler'),
110 'check' => $GLOBALS['LANG']->getLL('function.check'),
111 'info' => $GLOBALS['LANG']->getLL('function.info'),
112 )
113 );
114
115 parent::menuConfig();
116 }
117
118 /**
119 * Main function of the module. Write the content to $this->content
120 *
121 * @return void
122 */
123 public function main() {
124 // Access check!
125 // The page will show only if user has admin rights
126 if ($GLOBALS['BE_USER']->user['admin']) {
127
128 // Set the form
129 $this->doc->form = '<form name="tx_scheduler_form" id="tx_scheduler_form" method="post" action="">';
130
131 // JavaScript for main function menu
132 $this->doc->JScode = '
133 <script language="javascript" type="text/javascript">
134 script_ended = 0;
135 function jumpToUrl(URL) {
136 document.location = URL;
137 }
138 </script>
139 ';
140 $this->doc->getPageRenderer()->addInlineSetting('scheduler', 'runningIcon', t3lib_extMgm::extRelPath('scheduler') . 'res/gfx/status_running.png');
141
142 // Prepare main content
143 $this->content = $this->doc->header(
144 $GLOBALS['LANG']->getLL('function.' . $this->MOD_SETTINGS['function'])
145 );
146 $this->content .= $this->doc->spacer(5);
147 $this->content .= $this->getModuleContent();
148 } else {
149 // If no access, only display the module's title
150 $this->content = $this->doc->header($GLOBALS['LANG']->getLL('title'));
151 $this->content .= $this->doc->spacer(5);
152 }
153
154 // Place content inside template
155 $content = $this->doc->moduleBody(
156 array(),
157 $this->getDocHeaderButtons(),
158 $this->getTemplateMarkers()
159 );
160
161 // Renders the module page
162 $this->content = $this->doc->render(
163 $GLOBALS['LANG']->getLL('title'),
164 $content
165 );
166 }
167
168 /**
169 * Generate the module's content
170 *
171 * @return string HTML of the module's main content
172 */
173 protected function getModuleContent() {
174 $content = '';
175 $sectionTitle = '';
176
177 // Get submitted data
178 $this->submittedData = t3lib_div::_GPmerged('tx_scheduler');
179 $this->submittedData['uid'] = intval($this->submittedData['uid']);
180
181 // If a save command was submitted, handle saving now
182 if ($this->CMD == 'save') {
183 $previousCMD = t3lib_div::_GP('previousCMD');
184 // First check the submitted data
185 $result = $this->preprocessData();
186
187 // If result is ok, proceed with saving
188 if ($result) {
189 $this->saveTask();
190 // Unset command, so that default screen gets displayed
191 unset($this->CMD);
192
193 // Errors occurred
194 // Go back to previous step
195 } else {
196 $this->CMD = $previousCMD;
197 }
198 }
199
200 // Handle chosen action
201 switch((string)$this->MOD_SETTINGS['function']) {
202 case 'scheduler':
203 // Scheduler's main screen
204 $content .= $this->executeTasks();
205
206 // Execute chosen action
207 switch ($this->CMD) {
208 case 'add':
209 case 'edit':
210 try {
211 // Try adding or editing
212 $content .= $this->editTask();
213 $sectionTitle = $GLOBALS['LANG']->getLL('action.' . $this->CMD);
214 } catch (Exception $e) {
215 // An exception may happen when the task to
216 // edit could not be found. In this case revert
217 // to displaying the list of tasks
218 // It can also happen when attempting to edit a running task
219 $content .= $this->listTasks();
220 }
221 break;
222 case 'delete':
223 $this->deleteTask();
224 $content .= $this->listTasks();
225 break;
226 case 'stop':
227 $this->stopTask();
228 $content .= $this->listTasks();
229 break;
230 case 'list':
231 default:
232 $content .= $this->listTasks();
233 break;
234 }
235 break;
236 case 'check':
237 // Setup check screen
238 // TODO: move check to the report module
239 $content .= $this->displayCheckScreen();
240 break;
241 case 'info':
242 // Information screen
243 $content .= $this->displayInfoScreen();
244 break;
245 }
246
247 // Wrap the content in a section
248 return $this->doc->section($sectionTitle, '<div class="tx_scheduler_mod1">' . $content . '</div>', 0, 1);
249 }
250
251 /**
252 * This method actually prints out the module's HTML content
253 *
254 * @return void
255 */
256 public function render() {
257 echo $this->content;
258 }
259
260 /**
261 * This method checks the status of the '_cli_scheduler' user
262 * It will differentiate between a non-existing user and an existing,
263 * but disabled user (as per enable fields)
264 *
265 * @return integer -1 if user doesn't exist
266 * 0 if user exists, but is disabled
267 * 1 if user exists and is not disabled
268 */
269 protected function checkSchedulerUser() {
270 $schedulerUserStatus = -1;
271 // Assemble base WHERE clause
272 $where = 'username = \'_cli_scheduler\' AND admin = 0' . t3lib_BEfunc::deleteClause('be_users');
273 // Check if user exists at all
274 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
275 '1',
276 'be_users',
277 $where
278 );
279 if ($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
280 $schedulerUserStatus = 0;
281 // Check if user exists and is enabled
282 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
283 '1',
284 'be_users',
285 $where . t3lib_BEfunc::BEenableFields('be_users')
286 );
287 if ($GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
288 $schedulerUserStatus = 1;
289 }
290 }
291 $GLOBALS['TYPO3_DB']->sql_free_result($res);
292
293 return $schedulerUserStatus;
294 }
295
296 /**
297 * This method creates the "cli_scheduler" BE user if it doesn't exist
298 *
299 * @return void
300 */
301 protected function createSchedulerUser() {
302 // Check _cli_scheduler user status
303 $checkUser = $this->checkSchedulerUser();
304 // Prepare default message
305 $message = $GLOBALS['LANG']->getLL('msg.userExists');
306 $severity = t3lib_FlashMessage::WARNING;
307 // If the user does not exist, try creating it
308 if ($checkUser == -1) {
309 // Prepare necessary data for _cli_scheduler user creation
310 $password = md5(uniqid('scheduler', TRUE));
311 $data = array('be_users' => array('NEW' => array('username' => '_cli_scheduler', 'password' => $password, 'pid' => 0)));
312 /** @var t3lib_TCEmain $tcemain */
313 $tcemain = t3lib_div::makeInstance('t3lib_TCEmain');
314 $tcemain->stripslashes_values = 0;
315 $tcemain->start($data, array());
316 $tcemain->process_datamap();
317 // Check if a new uid was indeed generated (i.e. a new record was created)
318 // (counting TCEmain errors doesn't work as some failures don't report errors)
319 $numberOfNewIDs = count($tcemain->substNEWwithIDs);
320 if ($numberOfNewIDs == 1) {
321 $message = $GLOBALS['LANG']->getLL('msg.userCreated');
322 $severity = t3lib_FlashMessage::OK;
323 } else {
324 $message = $GLOBALS['LANG']->getLL('msg.userNotCreated');
325 $severity = t3lib_FlashMessage::ERROR;
326 }
327 }
328 $this->addMessage($message, $severity);
329 }
330
331 /**
332 * This method displays the result of a number of checks
333 * on whether the Scheduler is ready to run or running properly
334 *
335 * @return string Further information
336 */
337 protected function displayCheckScreen() {
338 $message = '';
339 $severity = t3lib_FlashMessage::OK;
340
341 // First, check if _cli_scheduler user creation was requested
342 if ($this->CMD == 'user') {
343 $this->createSchedulerUser();
344 }
345
346 // Start generating the content
347 $content = $GLOBALS['LANG']->getLL('msg.schedulerSetupCheck');
348
349 // Display information about last automated run, as stored in the system registry
350 /** @var t3lib_Registry $registry */
351 $registry = t3lib_div::makeInstance('t3lib_Registry');
352 $lastRun = $registry->get('tx_scheduler', 'lastRun');
353 if (!is_array($lastRun)) {
354 $message = $GLOBALS['LANG']->getLL('msg.noLastRun');
355 $severity = t3lib_FlashMessage::WARNING;
356 } else {
357 if (empty($lastRun['end']) || empty($lastRun['start']) || empty($lastRun['type'])) {
358 $message = $GLOBALS['LANG']->getLL('msg.incompleteLastRun');
359 $severity = t3lib_FlashMessage::WARNING;
360 } else {
361 $startDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $lastRun['start']);
362 $startTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $lastRun['start']);
363 $endDate = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $lastRun['end']);
364 $endTime = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $lastRun['end']);
365 $label = 'automatically';
366 if ($lastRun['type'] == 'manual') {
367 $label = 'manually';
368 }
369 $type = $GLOBALS['LANG']->getLL('label.' . $label);
370 $message = sprintf($GLOBALS['LANG']->getLL('msg.lastRun'), $type, $startDate, $startTime, $endDate, $endTime);
371 $severity = t3lib_FlashMessage::INFO;
372 }
373 }
374 /** @var $flashMessage t3lib_FlashMessage */
375 $flashMessage = t3lib_div::makeInstance(
376 't3lib_FlashMessage',
377 $message,
378 '',
379 $severity
380 );
381 $content .= '<div class="info-block">';
382 $content .= '<h3>' . $GLOBALS['LANG']->getLL('hdg.lastRun') . '</h3>';
383 $content .= $flashMessage->render();
384 $content .= '</div>';
385
386 // Check CLI user
387 $content .= '<div class="info-block">';
388 $content .= '<h3>' . $GLOBALS['LANG']->getLL('hdg.schedulerUser') . '</h3>';
389 $content .= '<p>' . $GLOBALS['LANG']->getLL('msg.schedulerUser') . '</p>';
390
391 $checkUser = $this->checkSchedulerUser();
392 if ($checkUser == -1) {
393 $link = $GLOBALS['MCONF']['_'] . '&SET[function]=check&CMD=user';
394 $message = sprintf($GLOBALS['LANG']->getLL('msg.schedulerUserMissing'), htmlspecialchars($link));
395 $severity = t3lib_FlashMessage::ERROR;
396 } elseif ($checkUser == 0) {
397 $message = $GLOBALS['LANG']->getLL('msg.schedulerUserFoundButDisabled');
398 $severity = t3lib_FlashMessage::WARNING;
399 } else {
400 $message = $GLOBALS['LANG']->getLL('msg.schedulerUserFound');
401 $severity = t3lib_FlashMessage::OK;
402 }
403 $flashMessage = t3lib_div::makeInstance(
404 't3lib_FlashMessage',
405 $message,
406 '',
407 $severity
408 );
409 $content .= $flashMessage->render() . '</div>';
410
411 // Check if CLI script is executable or not
412 $script = PATH_typo3 . 'cli_dispatch.phpsh';
413 $isExecutable = FALSE;
414 // Skip this check if running Windows, as rights do not work the same way on this platform
415 // (i.e. the script will always appear as *not* executable)
416 if (TYPO3_OS === 'WIN') {
417 $isExecutable = TRUE;
418 } else {
419 $isExecutable = is_executable($script);
420 }
421 $content .= '<div class="info-block">';
422 $content .= '<h3>' . $GLOBALS['LANG']->getLL('hdg.cliScript') . '</h3>';
423 $content .= '<p>' . sprintf($GLOBALS['LANG']->getLL('msg.cliScript'), $script) . '</p>';
424
425 if ($isExecutable) {
426 $message = $GLOBALS['LANG']->getLL('msg.cliScriptExecutable');
427 $severity = t3lib_FlashMessage::OK;
428 } else {
429 $message = $GLOBALS['LANG']->getLL('msg.cliScriptNotExecutable');
430 $severity = t3lib_FlashMessage::ERROR;
431 }
432 $flashMessage = t3lib_div::makeInstance(
433 't3lib_FlashMessage',
434 $message,
435 '',
436 $severity
437 );
438 $content .= $flashMessage->render() . '</div>';
439
440 return $content;
441 }
442
443 /**
444 * This method gathers information about all available task classes and displays it
445 *
446 * @return string HTML content to display
447 */
448 protected function displayInfoScreen() {
449 $content = '';
450 $registeredClasses = self::getRegisteredClasses();
451
452 // No classes available, display information message
453 if (count($registeredClasses) == 0) {
454 /** @var t3lib_FlashMessage $flashMessage */
455 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage',
456 $GLOBALS['LANG']->getLL('msg.noTasksDefined'),
457 '',
458 t3lib_FlashMessage::INFO
459 );
460 $content .= $flashMessage->render();
461
462 // Display the list of all available classes
463 } else {
464 // Initialise table layout
465 $tableLayout = array (
466 'table' => array ('<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist">', '</table>'),
467 '0' => array (
468 'tr' => array('<tr class="t3-row-header" valign="top">', '</tr>'),
469 'defCol' => array('<td>', '</td>')
470 ),
471 'defRow' => array (
472 'tr' => array('<tr class="db_list_normal">', '</tr>'),
473 'defCol' => array('<td>', '</td>')
474 )
475 );
476 $table = array();
477 $tr = 0;
478
479 // Header row
480 $table[$tr][] = $GLOBALS['LANG']->getLL('label.name');
481 $table[$tr][] = $GLOBALS['LANG']->getLL('label.extension');
482 $table[$tr][] = $GLOBALS['LANG']->getLL('label.description');
483 $table[$tr][] = '';
484 $tr++;
485
486 // Display information about each service
487 foreach ($registeredClasses as $class => $classInfo) {
488 $table[$tr][] = $classInfo['title'];
489 $table[$tr][] = $classInfo['extension'];
490 $table[$tr][] = $classInfo['description'];
491 $link = $GLOBALS['MCONF']['_'] . '&SET[function]=list&CMD=add&tx_scheduler[class]=' . $class;
492 $table[$tr][] = '<a href="' . htmlspecialchars($link) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:new', TRUE) . '" class="icon">' . t3lib_iconWorks::getSpriteIcon('actions-document-new') . '</a>';
493 $tr++;
494 }
495
496 // Render the table and return it
497 $content = '<div>' . $GLOBALS['LANG']->getLL('msg.infoScreenIntro') . '</div>';
498 $content .= $this->doc->spacer(5);
499 $content .= $this->doc->table($table, $tableLayout);
500 }
501
502 return $content;
503 }
504
505 /**
506 * Display the current server's time along with a help text about server time
507 * usage in the Scheduler
508 *
509 * @return string HTML to display
510 */
511 protected function displayServerTime() {
512 // Get the current time, formatted
513 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ' T (e';
514 $now = date($dateFormat) . ', GMT ' . date('P') . ')';
515 // Display the help text
516 $serverTime = '<h4>' . $GLOBALS['LANG']->getLL('label.serverTime') . '</h4>';
517 $serverTime .= '<p>' . $GLOBALS['LANG']->getLL('msg.serverTimeHelp') . '</p>';
518 $serverTime .= '<p>' . sprintf($GLOBALS['LANG']->getLL('msg.serverTime'), $now) . '</p>';
519 return $serverTime;
520 }
521
522 /**
523 * Delete a task from the execution queue
524 *
525 * @return void
526 */
527 protected function deleteTask() {
528 try {
529 // Try to fetch the task and delete it
530 $task = $this->scheduler->fetchTask($this->submittedData['uid']);
531 // If the task is currently running, it may not be deleted
532 if ($task->isExecutionRunning()) {
533 $this->addMessage($GLOBALS['LANG']->getLL('msg.maynotDeleteRunningTask'), t3lib_FlashMessage::ERROR);
534 } else {
535 if ($this->scheduler->removeTask($task)) {
536 $GLOBALS['BE_USER']->writeLog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was deleted', array($task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()));
537 $this->addMessage($GLOBALS['LANG']->getLL('msg.deleteSuccess'));
538 } else {
539 $this->addMessage($GLOBALS['LANG']->getLL('msg.deleteError'), t3lib_FlashMessage::ERROR);
540 }
541 }
542 } catch (UnexpectedValueException $e) {
543 // The task could not be unserialized properly, simply delete the database record
544 $result = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_scheduler_task', 'uid = ' . intval($this->submittedData['uid']));
545 if ($result) {
546 $this->addMessage($GLOBALS['LANG']->getLL('msg.deleteSuccess'));
547 } else {
548 $this->addMessage($GLOBALS['LANG']->getLL('msg.deleteError'), t3lib_FlashMessage::ERROR);
549 }
550 } catch (OutOfBoundsException $e) {
551 // The task was not found, for some reason
552 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), t3lib_FlashMessage::ERROR);
553 }
554 }
555
556 /**
557 * Clears the registered running executions from the task
558 * Note that this doesn't actually stop the running script. It just unmarks
559 * all executions.
560 * TODO: find a way to really kill the running task
561 *
562 * @return void
563 */
564 protected function stopTask() {
565 try {
566 // Try to fetch the task and stop it
567 $task = $this->scheduler->fetchTask($this->submittedData['uid']);
568 if ($task->isExecutionRunning()) {
569 // If the task is indeed currently running, clear marked executions
570
571 $result = $task->unmarkAllExecutions();
572 if ($result) {
573 $this->addMessage($GLOBALS['LANG']->getLL('msg.stopSuccess'));
574 } else {
575 $this->addMessage($GLOBALS['LANG']->getLL('msg.stopError'), t3lib_FlashMessage::ERROR);
576 }
577 } else {
578 // The task is not running, nothing to unmark
579
580 $this->addMessage($GLOBALS['LANG']->getLL('msg.maynotStopNonRunningTask'), t3lib_FlashMessage::WARNING);
581 }
582 } catch (Exception $e) {
583 // The task was not found, for some reason
584 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), t3lib_FlashMessage::ERROR);
585 }
586 }
587
588 /**
589 * Return a form to add a new task or edit an existing one
590 *
591 * @return string HTML form to add or edit a task
592 */
593 protected function editTask() {
594 $registeredClasses = self::getRegisteredClasses();
595 $content = '';
596 $taskInfo = array();
597 $task = NULL;
598 $process = 'edit';
599
600 if ($this->submittedData['uid'] > 0) {
601 // If editing, retrieve data for existing task
602 try {
603 $taskRecord = $this->scheduler->fetchTaskRecord($this->submittedData['uid']);
604 // If there's a registered execution, the task should not be edited
605 if (!empty($taskRecord['serialized_executions'])) {
606 $this->addMessage($GLOBALS['LANG']->getLL('msg.maynotEditRunningTask'), t3lib_FlashMessage::ERROR);
607 throw new LogicException('Runnings tasks cannot not be edited', 1251232849);
608 }
609 // Get the task object
610 /** @var $task tx_scheduler_Task */
611 $task = unserialize($taskRecord['serialized_task_object']);
612
613 // Set some task information
614 $class = $taskRecord['classname'];
615 $taskInfo['disable'] = $taskRecord['disable'];
616
617 // Check that the task object is valid
618 if ($this->scheduler->isValidTaskObject($task)) {
619 // The task object is valid, process with fetching current data
620
621 $taskInfo['class'] = $class;
622
623 // Get execution information
624 $taskInfo['start'] = $task->getExecution()->getStart();
625 $taskInfo['end'] = $task->getExecution()->getEnd();
626 $taskInfo['interval'] = $task->getExecution()->getInterval();
627 $taskInfo['croncmd'] = $task->getExecution()->getCronCmd();
628 $taskInfo['multiple'] = $task->getExecution()->getMultiple();
629
630 if (!empty($taskInfo['interval']) || !empty($taskInfo['croncmd'])) {
631 // Guess task type from the existing information
632 // If an interval or a cron command is defined, it's a recurring task
633
634 // FIXME: remove magic numbers for the type, use class constants instead
635 $taskInfo['type'] = 2;
636 $taskInfo['frequency'] = (empty($taskInfo['interval'])) ? $taskInfo['croncmd'] : $taskInfo['interval'];
637 } else {
638 // It's not a recurring task
639 // Make sure interval and cron command are both empty
640 $taskInfo['type'] = 1;
641 $taskInfo['frequency'] = '';
642 $taskInfo['end'] = 0;
643 }
644 } else {
645 // The task object is not valid
646
647 // Issue error message
648 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.invalidTaskClassEdit'), $class), t3lib_FlashMessage::ERROR);
649 // Initialize empty values
650 $taskInfo['start'] = 0;
651 $taskInfo['end'] = 0;
652 $taskInfo['frequency'] = '';
653 $taskInfo['multiple'] = FALSE;
654 $taskInfo['type'] = 1;
655 }
656 } catch (OutOfBoundsException $e) {
657 // Add a message and continue throwing the exception
658 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), t3lib_FlashMessage::ERROR);
659 throw $e;
660 }
661 } else {
662 // If adding a new object, set some default values
663 $taskInfo['class'] = key($registeredClasses);
664 $taskInfo['type'] = 2;
665 $taskInfo['start'] = $GLOBALS['EXEC_TIME'];
666 $taskInfo['end'] = '';
667 $taskInfo['frequency'] = '';
668 $taskInfo['multiple'] = 0;
669 $process = 'add';
670 }
671
672 if (count($this->submittedData) > 0) {
673 // If some data was already submitted, use it to override
674 // existing data
675 $taskInfo = t3lib_div::array_merge_recursive_overrule($taskInfo, $this->submittedData);
676 }
677
678 // Get the extra fields to display for each task that needs some
679 $allAdditionalFields = array();
680 if ($process == 'add') {
681 foreach ($registeredClasses as $class => $registrationInfo) {
682 if (!empty($registrationInfo['provider'])) {
683 /** @var $providerObject tx_scheduler_AdditionalFieldProvider */
684 $providerObject = t3lib_div::getUserObj($registrationInfo['provider']);
685 if ($providerObject instanceof tx_scheduler_AdditionalFieldProvider) {
686 $additionalFields = $providerObject->getAdditionalFields($taskInfo, NULL, $this);
687 $allAdditionalFields = array_merge($allAdditionalFields, array($class => $additionalFields));
688 }
689 }
690 }
691
692 // In case of edit, get only the extra fields for the current task class
693 } else {
694 if (!empty($registeredClasses[$taskInfo['class']]['provider'])) {
695 $providerObject = t3lib_div::getUserObj($registeredClasses[$taskInfo['class']]['provider']);
696 if ($providerObject instanceof tx_scheduler_AdditionalFieldProvider) {
697 $allAdditionalFields[$taskInfo['class']] = $providerObject->getAdditionalFields($taskInfo, $task, $this);
698 }
699 }
700 }
701
702 // Load necessary JavaScript
703 /** @var $pageRenderer t3lib_PageRenderer */
704 $pageRenderer = $this->doc->getPageRenderer();
705 $pageRenderer->loadExtJS();
706 $pageRenderer->addJsFile(t3lib_extMgm::extRelPath('scheduler') . 'res/tx_scheduler_be.js');
707 $pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/tceforms.js');
708 $pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ux/Ext.ux.DateTimePicker.js');
709
710 // Define settings for Date Picker
711 $typo3Settings = array(
712 'datePickerUSmode' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['USdateFormat'] ? 1 : 0,
713 'dateFormat' => array('j-n-Y', 'G:i j-n-Y'),
714 'dateFormatUS' => array('n-j-Y', 'G:i n-j-Y'),
715 );
716 $pageRenderer->addInlineSettingArray('', $typo3Settings);
717
718 // Define table layout for add/edit form
719 $tableLayout = array (
720 'table' => array ('<table border="0" cellspacing="0" cellpadding="0" id="edit_form" class="typo3-usersettings">', '</table>'),
721 );
722
723 // Define a style for hiding
724 // Some fields will be hidden when the task is not recurring
725 $style = '';
726 if ($taskInfo['type'] == 1) {
727 $style = ' style="display: none"';
728 }
729
730 // Start rendering the add/edit form
731 $content .= '<input type="hidden" name="tx_scheduler[uid]" value="' . $this->submittedData['uid'] . '" />';
732 $content .= '<input type="hidden" name="previousCMD" value="' . $this->CMD . '" />';
733 $content .= '<input type="hidden" name="CMD" value="save" />';
734
735 $table = array();
736 $tr = 0;
737 $defaultCell = array('<td class="td-input">', '</td>');
738
739 // Disable checkbox
740 $label = '<label for="task_disable">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:disable') . '</label>';
741 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_disable', $label);
742 $table[$tr][] =
743 '<input type="hidden" name="tx_scheduler[disable]" value="0" />
744 <input type="checkbox" name="tx_scheduler[disable]" value="1" id="task_disable"' . ($taskInfo['disable'] == 1 ? ' checked="checked"' : '') . ' />';
745 $tableLayout[$tr] = array (
746 'tr' => array('<tr id="task_disable_row">', '</tr>'),
747 'defCol' => $defaultCell,
748 '0' => array('<td class="td-label">', '</td>')
749 );
750 $tr++;
751
752 // Task class selector
753 $label = '<label for="task_class">' . $GLOBALS['LANG']->getLL('label.class') . '</label>';
754 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_class', $label);
755 // On editing, don't allow changing of the task class, unless it was not valid
756 if ($this->submittedData['uid'] > 0 && !empty($taskInfo['class'])) {
757 $cell = $registeredClasses[$taskInfo['class']]['title'] . ' (' . $registeredClasses[$taskInfo['class']]['extension'] . ')';
758 $cell .= '<input type="hidden" name="tx_scheduler[class]" id="task_class" value="' . $taskInfo['class'] . '" />';
759 } else {
760 $cell = '<select name="tx_scheduler[class]" id="task_class" class="wide" onchange="actOnChangedTaskClass(this)">';
761
762 // Group registered classes by classname
763 $groupedClasses = array();
764 foreach ($registeredClasses as $class => $classInfo) {
765 $groupedClasses[$classInfo['extension']][$class] = $classInfo;
766 }
767 ksort($groupedClasses);
768 // Loop on all grouped classes to display a selector
769 foreach ($groupedClasses as $extension => $class) {
770 $cell .= '<optgroup label="' . $extension .'">';
771 foreach ($groupedClasses[$extension] as $class => $classInfo) {
772 $selected = ($class == $taskInfo['class']) ? ' selected="selected"' : '';
773 $cell .= '<option value="' . $class . '"'
774 . 'title="' . $classInfo['description'] . '"'
775 . $selected . '>' . $classInfo['title'] . '</option>';
776 }
777 $cell .= '</optgroup>';
778 }
779 $cell .= '</select>';
780 }
781 $table[$tr][] = $cell;
782 // Make sure each row has a unique id, for manipulation with JS
783 $tableLayout[$tr] = array (
784 'tr' => array('<tr id="task_class_row">', '</tr>'),
785 'defCol' => $defaultCell,
786 '0' => array('<td class="td-label">', '</td>')
787 );
788 $tr++;
789
790 // Task type selector
791 $label = '<label for="task_type">' . $GLOBALS['LANG']->getLL('label.type') . '</label>';
792 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_type', $label);
793 $table[$tr][] =
794 '<select name="tx_scheduler[type]" id="task_type" onchange="actOnChangedTaskType(this)">' .
795 '<option value="1"' . ($taskInfo['type'] == 1 ? ' selected="selected"' : '') . '>' . $GLOBALS['LANG']->getLL('label.type.single') . '</option>' .
796 '<option value="2"' . ($taskInfo['type'] == 2 ? ' selected="selected"' : '') . '>' . $GLOBALS['LANG']->getLL('label.type.recurring') . '</option>' .
797 '</select>';
798 $tableLayout[$tr] = array (
799 'tr' => array('<tr id="task_type_row">', '</tr>'),
800 'defCol' => $defaultCell,
801 '0' => array('<td class="td-label">', '</td>'),
802 );
803 $tr++;
804
805 // Start date/time field
806 // NOTE: datetime fields need a special id naming scheme
807 $label = '<label for="tceforms-datetimefield-task_start">' . $GLOBALS['LANG']->getLL('label.start') . '</label>';
808 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_start', $label);
809 $table[$tr][] = '<input name="tx_scheduler[start]" type="text" id="tceforms-datetimefield-task_start" value="' . ((empty($taskInfo['start'])) ? '' : strftime('%H:%M %d-%m-%Y', $taskInfo['start'])) . '" />' .
810 t3lib_iconWorks::getSpriteIcon(
811 'actions-edit-pick-date',
812 array(
813 'style' => 'cursor:pointer;',
814 'id' => 'picker-tceforms-datetimefield-task_start'
815 )
816 );
817 $tableLayout[$tr] = array (
818 'tr' => array('<tr id="task_start_row">', '</tr>'),
819 'defCol' => $defaultCell,
820 '0' => array('<td class="td-label">', '</td>')
821 );
822 $tr++;
823
824 // End date/time field
825 // NOTE: datetime fields need a special id naming scheme
826 $label = '<label for="tceforms-datetimefield-task_end">' . $GLOBALS['LANG']->getLL('label.end') . '</label>';
827 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_end', $label);
828 $table[$tr][] = '<input name="tx_scheduler[end]" type="text" id="tceforms-datetimefield-task_end" value="' . ((empty($taskInfo['end'])) ? '' : strftime('%H:%M %d-%m-%Y', $taskInfo['end'])) . '" />' .
829 t3lib_iconWorks::getSpriteIcon(
830 'actions-edit-pick-date',
831 array(
832 'style' => 'cursor:pointer;',
833 'id' => 'picker-tceforms-datetimefield-task_end'
834 )
835 );
836 $tableLayout[$tr] = array (
837 'tr' => array('<tr id="task_end_row"' . $style . '>', '</tr>'),
838 'defCol' => $defaultCell,
839 '0' => array('<td class="td-label">', '</td>'),
840 );
841 $tr++;
842
843 // Frequency input field
844 $label = '<label for="task_frequency">' . $GLOBALS['LANG']->getLL('label.frequency.long') . '</label>';
845 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_frequency', $label);
846 $cell = '<input type="text" name="tx_scheduler[frequency]" id="task_frequency" value="' . htmlspecialchars($taskInfo['frequency']) . '" />';
847 $table[$tr][] = $cell;
848 $tableLayout[$tr] = array (
849 'tr' => array('<tr id="task_frequency_row"' . $style . '>', '</tr>'),
850 'defCol' => $defaultCell,
851 '0' => array('<td class="td-label">', '</td>'),
852 );
853 $tr++;
854
855 // Multiple execution selector
856 $label = '<label for="task_multiple">' . $GLOBALS['LANG']->getLL('label.parallel.long') . '</label>';
857 $table[$tr][] = t3lib_BEfunc::wrapInHelp($this->cshKey, 'task_multiple', $label);
858 $table[$tr][] =
859 '<input type="hidden" name="tx_scheduler[multiple]" value="0" />
860 <input type="checkbox" name="tx_scheduler[multiple]" value="1" id="task_multiple"' . ($taskInfo['multiple'] == 1 ? ' checked="checked"' : '') . ' />';
861 $tableLayout[$tr] = array (
862 'tr' => array('<tr id="task_multiple_row"' . $style . '>', '</tr>'),
863 'defCol' => $defaultCell,
864 '0' => array('<td class="td-label">', '</td>')
865 );
866 $tr++;
867
868 // Display additional fields
869 foreach ($allAdditionalFields as $class => $fields) {
870 if ($class == $taskInfo['class']) {
871 $additionalFieldsStyle = '';
872 } else {
873 $additionalFieldsStyle = ' style="display: none"';
874 }
875
876 // Add each field to the display, if there are indeed any
877 if (isset($fields) && is_array($fields)) {
878 foreach ($fields as $fieldID => $fieldInfo) {
879 $label = '<label for="' . $fieldID . '">' . $GLOBALS['LANG']->sL($fieldInfo['label']) . '</label>';
880 $table[$tr][] = t3lib_BEfunc::wrapInHelp($fieldInfo['cshKey'], $fieldInfo['cshLabel'], $label);
881 $table[$tr][] = $fieldInfo['code'];
882 $tableLayout[$tr] = array (
883 'tr' => array('<tr id="' . $fieldID . '_row"' . $additionalFieldsStyle .' class="extraFields extra_fields_' . $class . '">', '</tr>'),
884 'defCol' => $defaultCell,
885 '0' => array('<td class="td-label">', '</td>')
886 );
887 $tr++;
888 }
889 }
890 }
891
892 // Render the add/edit task form
893 $content .= '<div style="float: left;"><div class="typo3-dyntabmenu-divs">';
894 $content .= $this->doc->table($table, $tableLayout);
895 $content .= '</div></div>';
896
897 $content .= '<div style="padding-top: 20px; clear: both;"></div>';
898
899 // Display information about server time usage
900 $content .= $this->displayServerTime();
901
902 return $content;
903 }
904
905 /**
906 * Execute all selected tasks
907 *
908 * @return void
909 */
910 protected function executeTasks() {
911 // Continue if some elements have been chosen for execution
912 if (isset($this->submittedData['execute']) && count($this->submittedData['execute']) > 0) {
913
914 // Get list of registered classes
915 $registeredClasses = self::getRegisteredClasses();
916
917 // Loop on all selected tasks
918 foreach ($this->submittedData['execute'] as $uid) {
919
920 try {
921 // Try fetching the task
922 $task = $this->scheduler->fetchTask($uid);
923 $class = get_class($task);
924 $name = $registeredClasses[$class]['title']. ' (' . $registeredClasses[$class]['extension'] . ')';
925 // Now try to execute it and report on outcome
926 try {
927 $result = $this->scheduler->executeTask($task);
928 if ($result) {
929 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.executed'), $name));
930 } else {
931 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.notExecuted'), $name), t3lib_FlashMessage::ERROR);
932 }
933 }
934 catch (Exception $e) {
935 // An exception was thrown, display its message as an error
936 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.executionFailed'), $name, $e->getMessage()), t3lib_FlashMessage::ERROR);
937 }
938 }
939 // The task was not found, for some reason
940 catch (OutOfBoundsException $e) {
941 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $uid), t3lib_FlashMessage::ERROR);
942 }
943 // The task object was not valid
944 catch (UnexpectedValueException $e) {
945 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.executionFailed'), $name, $e->getMessage()), t3lib_FlashMessage::ERROR);
946 }
947 }
948 // Record the run in the system registry
949 $this->scheduler->recordLastRun('manual');
950 // Make sure to switch to list view after execution
951 $this->CMD = 'list';
952 }
953 }
954
955 /**
956 * Assemble display of list of scheduled tasks
957 *
958 * @return string Table of pending tasks
959 */
960 protected function listTasks() {
961 // Define display format for dates
962 $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
963 $content = '';
964
965 // Get list of registered classes
966 $registeredClasses = self::getRegisteredClasses();
967
968 // Get all registered tasks
969 $query = array(
970 'SELECT' => '*',
971 'FROM' => 'tx_scheduler_task',
972 'WHERE' => '1=1',
973 'ORDERBY' => 'nextexecution'
974 );
975
976 $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($query);
977 $numRows = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
978 // No tasks defined, display information message
979 if ($numRows == 0) {
980 /** @var t3lib_FlashMessage $flashMessage */
981 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage',
982 $GLOBALS['LANG']->getLL('msg.noTasks'),
983 '',
984 t3lib_FlashMessage::INFO
985 );
986 $content .= $flashMessage->render();
987 } else {
988 // Load ExtJS framework and specific JS library
989 /** @var $pageRenderer t3lib_PageRenderer */
990 $pageRenderer = $this->doc->getPageRenderer();
991 $pageRenderer->loadExtJS();
992 $pageRenderer->addJsFile(t3lib_extMgm::extRelPath('scheduler') . 'res/tx_scheduler_be.js');
993
994 // Initialise table layout
995 $tableLayout = array(
996 'table' => array(
997 '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist">', '</table>'
998 ),
999 '0' => array(
1000 'tr' => array('<tr class="t3-row-header">', '</tr>'),
1001 'defCol' => array('<td>', '</td>'),
1002 '1' => array('<td style="width: 36px;">', '</td>'),
1003 '3' => array('<td colspan="2">', '</td>'),
1004 ),
1005 'defRow' => array(
1006 'tr' => array('<tr class="db_list_normal">', '</tr>'),
1007 'defCol' => array('<td>', '</td>'),
1008 '1' => array('<td class="right">', '</td>'),
1009 '2' => array('<td class="right">', '</td>'),
1010 )
1011 );
1012 $disabledTaskRow = array (
1013 'tr' => array('<tr class="db_list_normal disabled">', '</tr>'),
1014 'defCol' => array('<td>', '</td>'),
1015 '1' => array('<td class="right">', '</td>'),
1016 '2' => array('<td class="right">', '</td>'),
1017 );
1018 $rowWithSpan = array (
1019 'tr' => array('<tr class="db_list_normal">', '</tr>'),
1020 'defCol' => array('<td>', '</td>'),
1021 '1' => array('<td class="right">', '</td>'),
1022 '2' => array('<td class="right">', '</td>'),
1023 '3' => array('<td colspan="6">', '</td>'),
1024 );
1025 $table = array();
1026 $tr = 0;
1027
1028 // Header row
1029 $table[$tr][] = '<a href="#" onclick="toggleCheckboxes();" title="' . $GLOBALS['LANG']->getLL('label.checkAll', TRUE) . '" class="icon">' .
1030 t3lib_iconWorks::getSpriteIcon('actions-document-select') .
1031 '</a>';
1032 $table[$tr][] = '&nbsp;';
1033 $table[$tr][] = $GLOBALS['LANG']->getLL('label.id');
1034 $table[$tr][] = $GLOBALS['LANG']->getLL('task');
1035 $table[$tr][] = $GLOBALS['LANG']->getLL('label.type');
1036 $table[$tr][] = $GLOBALS['LANG']->getLL('label.frequency');
1037 $table[$tr][] = $GLOBALS['LANG']->getLL('label.parallel');
1038 $table[$tr][] = $GLOBALS['LANG']->getLL('label.lastExecution');
1039 $table[$tr][] = $GLOBALS['LANG']->getLL('label.nextExecution');
1040 $tr++;
1041
1042 // Loop on all tasks
1043 while (($schedulerRecord = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))) {
1044 // Define action icons
1045 $editAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=edit&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:edit', TRUE) . '" class="icon">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
1046 $deleteAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=delete&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.delete') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:delete', TRUE) . '" class="icon">' . t3lib_iconWorks::getSpriteIcon('actions-edit-delete') . '</a>';
1047 $stopAction = '<a href="' . $GLOBALS['MCONF']['_'] . '&CMD=stop&tx_scheduler[uid]=' . $schedulerRecord['uid'] . '" onclick="return confirm(\'' . $GLOBALS['LANG']->getLL('msg.stop') . '\');" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop', TRUE) . '" class="icon"><img ' . t3lib_iconWorks::skinImg($this->backPath, t3lib_extMgm::extRelPath('scheduler') . '/res/gfx/stop.png') . ' alt="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:stop') . '" /></a>';
1048 // Define some default values
1049 $lastExecution = '-';
1050 $isRunning = FALSE;
1051 $executionStatus = 'scheduled';
1052 $executionStatusOutput = '';
1053 $name = '';
1054 $nextDate = '-';
1055 $execType = '-';
1056 $frequency = '-';
1057 $multiple = '-';
1058 $startExecutionElement = '&nbsp;';
1059
1060 // Restore the serialized task and pass it a reference to the scheduler object
1061 /** @var $task tx_scheduler_Task */
1062 $task = unserialize($schedulerRecord['serialized_task_object']);
1063
1064 // Assemble information about last execution
1065 $context = '';
1066 if (!empty($schedulerRecord['lastexecution_time'])) {
1067 $lastExecution = date($dateFormat, $schedulerRecord['lastexecution_time']);
1068 if ($schedulerRecord['lastexecution_context'] == 'CLI') {
1069 $context = $GLOBALS['LANG']->getLL('label.cron');
1070 } else {
1071 $context = $GLOBALS['LANG']->getLL('label.manual');
1072 }
1073 $lastExecution .= ' (' . $context . ')';
1074 }
1075
1076 if ($this->scheduler->isValidTaskObject($task)) {
1077 // The task object is valid
1078
1079 $name = htmlspecialchars($registeredClasses[$schedulerRecord['classname']]['title']. ' (' . $registeredClasses[$schedulerRecord['classname']]['extension'] . ')');
1080 $additionalInformation = $task->getAdditionalInformation();
1081 if (!empty($additionalInformation)) {
1082 $name .= '<br />[' . htmlspecialchars($additionalInformation) . ']';
1083 }
1084
1085 // Check if task currently has a running execution
1086 if (!empty($schedulerRecord['serialized_executions'])) {
1087 $isRunning = TRUE;
1088 $executionStatus = 'running';
1089 }
1090
1091 // Prepare display of next execution date
1092 // If task is currently running, date is not displayed (as next hasn't been calculated yet)
1093 // Also hide the date if task is disabled (the information doesn't make sense, as it will not run anyway)
1094 if ($isRunning || $schedulerRecord['disable'] == 1) {
1095 $nextDate = '-';
1096 }
1097 else {
1098 $nextDate = date($dateFormat, $schedulerRecord['nextexecution']);
1099 if (empty($schedulerRecord['nextexecution'])) {
1100 $nextDate = $GLOBALS['LANG']->getLL('none');
1101 } elseif ($schedulerRecord['nextexecution'] < $GLOBALS['EXEC_TIME']) {
1102 // Next execution is overdue, highlight date
1103 $nextDate = '<span class="late" title="' . $GLOBALS['LANG']->getLL('status.legend.scheduled') . '">' . $nextDate . '</span>';
1104 $executionStatus = 'late';
1105 }
1106 }
1107
1108 // Get execution type
1109 if ($task->getExecution()->getInterval() == 0 && $task->getExecution()->getCronCmd() == '') {
1110 $execType = $GLOBALS['LANG']->getLL('label.type.single');
1111 $frequency = '-';
1112 } else {
1113 $execType = $GLOBALS['LANG']->getLL('label.type.recurring');
1114 if ($task->getExecution()->getCronCmd() == '') {
1115 $frequency = $task->getExecution()->getInterval();
1116 } else {
1117 $frequency = $task->getExecution()->getCronCmd();
1118 }
1119 }
1120
1121 // Get multiple executions setting
1122 if ($task->getExecution()->getMultiple()) {
1123 $multiple = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes');
1124 } else {
1125 $multiple = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
1126 }
1127
1128 // Define checkbox
1129 $startExecutionElement = '<input type="checkbox" name="tx_scheduler[execute][]" value="' . $schedulerRecord['uid'] . '" id="task_' . $schedulerRecord['uid'] . '" class="checkboxes" />';
1130
1131 // Show no action links (edit, delete) if task is running
1132 $actions = $editAction . $deleteAction;
1133 if ($isRunning) {
1134 $actions = $stopAction;
1135 }
1136
1137 // Check the disable status
1138 // Row is shown dimmed if task is disabled, unless it is still running
1139 if ($schedulerRecord['disable'] == 1 && !$isRunning) {
1140 $tableLayout[$tr] = $disabledTaskRow;
1141 $executionStatus = 'disabled';
1142 }
1143
1144 // Check if the last run failed
1145 $failureOutput = '';
1146 if (!empty($schedulerRecord['lastexecution_failure'])) {
1147 // Try to get the stored exception object
1148 /** @var $exception Exception */
1149 $exception = unserialize($schedulerRecord['lastexecution_failure']);
1150 // If the exception could not be unserialized, issue a default error message
1151 if ($exception === FALSE || ($exception instanceof __PHP_Incomplete_Class)) {
1152 $failureDetail = $GLOBALS['LANG']->getLL('msg.executionFailureDefault');
1153 } else {
1154 $failureDetail = sprintf($GLOBALS['LANG']->getLL('msg.executionFailureReport'), $exception->getCode(), $exception->getMessage());
1155 }
1156 $failureOutput = ' <img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_failure.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" title="' . htmlspecialchars($failureDetail) . '" />';
1157 }
1158
1159 // Format the execution status,
1160 // including failure feedback, if any
1161 $executionStatusOutput = '<img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_' . $executionStatus . '.png') . ' id="executionstatus_' . $schedulerRecord['uid'] . '" alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.' . $executionStatus)) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.legend.' . $executionStatus)) . '" />' . $failureOutput;
1162
1163 $table[$tr][] = $startExecutionElement;
1164 $table[$tr][] = $actions;
1165 $table[$tr][] = $schedulerRecord['uid'];
1166 $table[$tr][] = $executionStatusOutput;
1167 $table[$tr][] = $name;
1168 $table[$tr][] = $execType;
1169 $table[$tr][] = $frequency;
1170 $table[$tr][] = $multiple;
1171 $table[$tr][] = $lastExecution;
1172 $table[$tr][] = $nextDate;
1173
1174 } else {
1175 // The task object is not valid
1176 // Prepare to issue an error
1177
1178 /** @var t3lib_FlashMessage $flashMessage */
1179 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage',
1180 sprintf($GLOBALS['LANG']->getLL('msg.invalidTaskClass'), $schedulerRecord['classname']),
1181 '',
1182 t3lib_FlashMessage::ERROR
1183 );
1184 $executionStatusOutput = $flashMessage->render();
1185
1186 $tableLayout[$tr] = $rowWithSpan;
1187 $table[$tr][] = $startExecutionElement;
1188 $table[$tr][] = $deleteAction;
1189 $table[$tr][] = $schedulerRecord['uid'];
1190 $table[$tr][] = $executionStatusOutput;
1191 }
1192
1193 $tr++;
1194 }
1195 // Render table
1196 $content .= $this->doc->table($table, $tableLayout);
1197
1198 $content .= '<input type="submit" class="button" name="go" id="scheduler_executeselected" value="' . $GLOBALS['LANG']->getLL('label.executeSelected') . '" />';
1199 }
1200
1201 if (!count($registeredClasses) > 0) {
1202 /** @var t3lib_FlashMessage $flashMessage */
1203 $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage',
1204 $GLOBALS['LANG']->getLL('msg.noTasksDefined'),
1205 '',
1206 t3lib_FlashMessage::INFO
1207 );
1208 $content .= $flashMessage->render();
1209 }
1210
1211 // Display legend, if there's at least one registered task
1212 // Also display information about the usage of server time
1213 if ($numRows > 0) {
1214 $content .= $this->doc->spacer(20);
1215 $content .= '<h4>' . $GLOBALS['LANG']->getLL('status.legend') . '</h4>
1216 <ul>
1217 <li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_failure.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.failure')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.failure') . '</li>
1218 <li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_late.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.late')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.late')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.late') . '</li>
1219 <li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_running.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.running')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.running')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.running') . '</li>
1220 <li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_scheduled.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.scheduled')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.scheduled')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.scheduled') . '</li>
1221 <li><img ' . t3lib_iconWorks::skinImg(t3lib_extMgm::extRelPath('scheduler'), 'res/gfx/status_disabled.png') . ' alt="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.disabled')) . '" title="' . htmlspecialchars($GLOBALS['LANG']->getLL('status.disabled')) . '" /> ' . $GLOBALS['LANG']->getLL('status.legend.disabled') . '</li>
1222 </ul>';
1223 $content .= $this->doc->spacer(10);
1224 $content .= $this->displayServerTime();
1225 }
1226
1227
1228 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1229
1230 return $content;
1231 }
1232
1233 /**
1234 * Saves a task specified in the backend form to the database
1235 *
1236 * @return void
1237 */
1238 protected function saveTask() {
1239
1240 // If a task is being edited fetch old task data
1241 if (!empty($this->submittedData['uid'])) {
1242 try {
1243 $taskRecord = $this->scheduler->fetchTaskRecord($this->submittedData['uid']);
1244 /** @var tx_scheduler_Task $task */
1245 $task = unserialize($taskRecord['serialized_task_object']);
1246 } catch (OutOfBoundsException $e) {
1247 // If the task could not be fetched, issue an error message
1248 // and exit early
1249 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.taskNotFound'), $this->submittedData['uid']), t3lib_FlashMessage::ERROR);
1250 return;
1251 }
1252
1253 // Register single execution
1254 if ($this->submittedData['type'] == 1) {
1255 $task->registerSingleExecution($this->submittedData['start']);
1256
1257 // Else, it's a recurring task
1258 } else {
1259 if (!empty($this->submittedData['croncmd'])) {
1260 // Definition by cron-like syntax
1261
1262 $interval = 0;
1263 $cronCmd = $this->submittedData['croncmd'];
1264 } else {
1265 // Definition by interval
1266
1267 $interval = $this->submittedData['interval'];
1268 $cronCmd = '';
1269 }
1270
1271 // Register recurring execution
1272 $task->registerRecurringExecution($this->submittedData['start'], $interval, $this->submittedData['end'], $this->submittedData['multiple'], $cronCmd);
1273 }
1274
1275 // Set disable flag
1276 $task->setDisabled($this->submittedData['disable']);
1277
1278 // Save additional input values
1279 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields'])) {
1280 /** @var $providerObject tx_scheduler_AdditionalFieldProvider */
1281 $providerObject = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields']);
1282 if ($providerObject instanceof tx_scheduler_AdditionalFieldProvider) {
1283 $providerObject->saveAdditionalFields($this->submittedData, $task);
1284 }
1285 }
1286
1287 // Save to database
1288 $result = $this->scheduler->saveTask($task);
1289 if ($result) {
1290 $GLOBALS['BE_USER']->writeLog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was updated', array($task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()));
1291 $this->addMessage($GLOBALS['LANG']->getLL('msg.updateSuccess'));
1292 } else {
1293 $this->addMessage($GLOBALS['LANG']->getLL('msg.updateError'), t3lib_FlashMessage::ERROR);
1294 }
1295 } else {
1296 // A new task is being created
1297
1298 // Create an instance of chosen class
1299 $task = t3lib_div::makeInstance($this->submittedData['class']);
1300
1301 if ($this->submittedData['type'] == 1) {
1302 // Set up single execution
1303 $task->registerSingleExecution($this->submittedData['start']);
1304 } else {
1305 // Set up recurring execution
1306 $task->registerRecurringExecution($this->submittedData['start'], $this->submittedData['interval'], $this->submittedData['end'], $this->submittedData['multiple'], $this->submittedData['croncmd']);
1307 }
1308
1309 // Save additional input values
1310 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields'])) {
1311 /** @var $providerObject tx_scheduler_AdditionalFieldProvider */
1312 $providerObject = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields']);
1313 if ($providerObject instanceof tx_scheduler_AdditionalFieldProvider) {
1314 $providerObject->saveAdditionalFields($this->submittedData, $task);
1315 }
1316 }
1317
1318 // Set disable flag
1319 $task->setDisabled($this->submittedData['disable']);
1320
1321 // Add to database
1322 $result = $this->scheduler->addTask($task);
1323 if ($result) {
1324 $GLOBALS['BE_USER']->writeLog(4, 0, 0, 0, 'Scheduler task "%s" (UID: %s, Class: "%s") was added', array($task->getTaskTitle(), $task->getTaskUid(), $task->getTaskClassName()));
1325 $this->addMessage($GLOBALS['LANG']->getLL('msg.addSuccess'));
1326 } else {
1327 $this->addMessage($GLOBALS['LANG']->getLL('msg.addError'), t3lib_FlashMessage::ERROR);
1328 }
1329 }
1330 }
1331
1332
1333 /*************************
1334 *
1335 * INPUT PROCESSING UTILITIES
1336 *
1337 *************************/
1338
1339 /**
1340 * Checks the submitted data and performs some pre-processing on it
1341 *
1342 * @return boolean TRUE if everything was ok, FALSE otherwise
1343 */
1344 protected function preprocessData() {
1345 $result = TRUE;
1346
1347 // Validate id
1348 $this->submittedData['uid'] = (empty($this->submittedData['uid'])) ? 0 : intval($this->submittedData['uid']);
1349
1350 // Validate selected task class
1351 if (!class_exists($this->submittedData['class'])) {
1352 $this->addMessage($GLOBALS['LANG']->getLL('msg.noTaskClassFound'), t3lib_FlashMessage::ERROR);
1353 }
1354
1355 // Check start date
1356 if (empty($this->submittedData['start'])) {
1357 $this->addMessage($GLOBALS['LANG']->getLL('msg.noStartDate'), t3lib_FlashMessage::ERROR);
1358 $result = FALSE;
1359 } else {
1360 try {
1361 $timestamp = $this->checkDate($this->submittedData['start']);
1362 $this->submittedData['start'] = $timestamp;
1363 } catch (Exception $e) {
1364 $this->addMessage($GLOBALS['LANG']->getLL('msg.invalidStartDate'), t3lib_FlashMessage::ERROR);
1365 $result = FALSE;
1366 }
1367 }
1368
1369 // Check end date, if recurring task
1370 if ($this->submittedData['type'] == 2 && !empty($this->submittedData['end'])) {
1371 try {
1372 $timestamp = $this->checkDate($this->submittedData['end']);
1373 $this->submittedData['end'] = $timestamp;
1374
1375 if ($this->submittedData['end'] < $this->submittedData['start']) {
1376 $this->addMessage($GLOBALS['LANG']->getLL('msg.endDateSmallerThanStartDate'), t3lib_FlashMessage::ERROR);
1377 $result = FALSE;
1378 }
1379 } catch (Exception $e) {
1380 $this->addMessage($GLOBALS['LANG']->getLL('msg.invalidEndDate'), t3lib_FlashMessage::ERROR);
1381 $result = FALSE;
1382 }
1383 }
1384
1385 // Set default values for interval and cron command
1386 $this->submittedData['interval'] = 0;
1387 $this->submittedData['croncmd'] = '';
1388
1389 // Check type and validity of frequency, if recurring
1390 if ($this->submittedData['type'] == 2) {
1391 $frequency = trim($this->submittedData['frequency']);
1392
1393 if (empty($frequency)) {
1394 // Empty frequency, not valid
1395
1396 $this->addMessage($GLOBALS['LANG']->getLL('msg.noFrequency'), t3lib_FlashMessage::ERROR);
1397 $result = FALSE;
1398 } else {
1399 $cronErrorCode = 0;
1400 $cronErrorMessage = '';
1401
1402 // Try interpreting the cron command
1403 try {
1404 tx_scheduler_CronCmd_Normalize::normalize($frequency);
1405 $this->submittedData['croncmd'] = $frequency;
1406 }
1407 // If the cron command was invalid, we may still have a valid frequency in seconds
1408 catch (Exception $e) {
1409 // Store the exception's result
1410 $cronErrorMessage = $e->getMessage();
1411 $cronErrorCode = $e->getCode();
1412 // Check if the frequency is a valid number
1413 // If yes, assume it is a frequency in seconds, and unset cron error code
1414 if (is_numeric($frequency)) {
1415 $this->submittedData['interval'] = intval($frequency);
1416 unset($cronErrorCode);
1417 }
1418 }
1419 // If there's a cron error code, issue validation error message
1420 if (!empty($cronErrorCode)) {
1421 $this->addMessage(sprintf($GLOBALS['LANG']->getLL('msg.frequencyError'), $cronErrorMessage, $cronErrorCode), t3lib_FlashMessage::ERROR);
1422 $result = FALSE;
1423 }
1424 }
1425 }
1426
1427 // Validate additional input fields
1428 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields'])) {
1429 $providerObject = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][$this->submittedData['class']]['additionalFields']);
1430 if ($providerObject instanceof tx_scheduler_AdditionalFieldProvider) {
1431 // The validate method will return TRUE if all went well, but that must not
1432 // override previous FALSE values => AND the returned value with the existing one
1433 $result &= $providerObject->validateAdditionalFields($this->submittedData, $this);
1434 }
1435 }
1436
1437 return $result;
1438 }
1439
1440 /**
1441 * This method checks whether the given string can be considered a valid date or not
1442 * Allowed values are anything that matches natural language (see PHP function strtotime())
1443 * or TYPO3's date syntax: HH:ii yyyy-mm-dd
1444 * If the string is a valid date, the corresponding timestamp is returned.
1445 * Otherwise an exception is thrown
1446 *
1447 * @param string $string String to check
1448 * @return integer Unix timestamp
1449 */
1450 public function checkDate($string) {
1451 // Try with strtotime
1452 $timestamp = strtotime($string);
1453
1454 // That failed. Try TYPO3's standard date/time input format
1455 if ($timestamp === FALSE) {
1456 // Split time and date
1457 $dateParts = t3lib_div::trimExplode(' ', $string, TRUE);
1458 // Proceed if there are indeed two parts
1459 // Extract each component of date and time
1460 if (count($dateParts) == 2) {
1461 list($time, $date) = $dateParts;
1462 list($hour, $minutes) = t3lib_div::trimExplode(':', $time, TRUE);
1463 list($day, $month, $year) = t3lib_div::trimExplode('-', $date, TRUE);
1464 // Get a timestamp from all these parts
1465 $timestamp = @mktime($hour, $minutes, 0, $month, $day, $year);
1466 }
1467 // If the timestamp is still FALSE, throw an exception
1468 if ($timestamp === FALSE) {
1469 throw new InvalidArgumentException('"' . $string . '" seems not to be a correct date.', 1294587694);
1470 }
1471 }
1472 return $timestamp;
1473 }
1474
1475 /*************************
1476 *
1477 * APPLICATION LOGIC UTILITIES
1478 *
1479 *************************/
1480
1481 /**
1482 * This method is used to add a message to the internal queue
1483 *
1484 * @param string $message The message itself
1485 * @param integer $severity Message level (according to t3lib_FlashMessage class constants)
1486 * @return void
1487 */
1488 public function addMessage($message, $severity = t3lib_FlashMessage::OK) {
1489 $message = t3lib_div::makeInstance(
1490 't3lib_FlashMessage',
1491 $message,
1492 '',
1493 $severity
1494 );
1495
1496 t3lib_FlashMessageQueue::addMessage($message);
1497 }
1498
1499 /**
1500 * This method a list of all classes that have been registered with the Scheduler
1501 * For each item the following information is provided, as an associative array:
1502 *
1503 * ['extension'] => Key of the extension which provides the class
1504 * ['filename'] => Path to the file containing the class
1505 * ['title'] => String (possibly localized) containing a human-readable name for the class
1506 * ['provider'] => Name of class that implements the interface for additional fields, if necessary
1507 *
1508 * The name of the class itself is used as the key of the list array
1509 *
1510 * @return array List of registered classes
1511 */
1512 protected static function getRegisteredClasses() {
1513 $list = array();
1514 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'])) {
1515 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'] as $class => $registrationInformation) {
1516
1517 $title = isset($registrationInformation['title']) ? $GLOBALS['LANG']->sL($registrationInformation['title']) : '';
1518 $description = isset($registrationInformation['description']) ? $GLOBALS['LANG']->sL($registrationInformation['description']) : '';
1519
1520 $list[$class] = array(
1521 'extension' => $registrationInformation['extension'],
1522 'title' => $title,
1523 'description' => $description,
1524 'provider' => isset($registrationInformation['additionalFields']) ? $registrationInformation['additionalFields'] : ''
1525 );
1526 }
1527 }
1528
1529 return $list;
1530 }
1531
1532
1533 /*************************
1534 *
1535 * RENDERING UTILITIES
1536 *
1537 *************************/
1538
1539 /**
1540 * Gets the filled markers that are used in the HTML template.
1541 *
1542 * @return array The filled marker array
1543 */
1544 protected function getTemplateMarkers() {
1545 $markers = array(
1546 'CSH' => t3lib_BEfunc::wrapInHelp('_MOD_tools_txschedulerM1', ''),
1547 'FUNC_MENU' => $this->getFunctionMenu(),
1548 'CONTENT' => $this->content,
1549 'TITLE' => $GLOBALS['LANG']->getLL('title'),
1550 );
1551
1552 return $markers;
1553 }
1554
1555 /**
1556 * Gets the function menu selector for this backend module.
1557 *
1558 * @return string The HTML representation of the function menu selector
1559 */
1560 protected function getFunctionMenu() {
1561 $functionMenu = t3lib_BEfunc::getFuncMenu(
1562 0,
1563 'SET[function]',
1564 $this->MOD_SETTINGS['function'],
1565 $this->MOD_MENU['function']
1566 );
1567
1568 return $functionMenu;
1569 }
1570
1571 /**
1572 * Gets the buttons that shall be rendered in the docHeader.
1573 *
1574 * @return array Available buttons for the docHeader
1575 */
1576 protected function getDocHeaderButtons() {
1577 $buttons = array(
1578 'addtask' => '',
1579 'close' => '',
1580 'save' => '',
1581 'reload' => '',
1582 'shortcut' => $this->getShortcutButton(),
1583 );
1584
1585 if (empty($this->CMD) || $this->CMD == 'list') {
1586 $buttons['reload'] = '<a href="' . $GLOBALS['MCONF']['_'] . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.reload', TRUE) . '">' .
1587 t3lib_iconWorks::getSpriteIcon('actions-system-refresh') .
1588 '</a>';
1589 if ($this->MOD_SETTINGS['function'] === 'scheduler' && count(self::getRegisteredClasses())) {
1590 $link = $GLOBALS['MCONF']['_'] . '&CMD=add';
1591 $image = '<img ' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/new_el.gif') .
1592 ' alt="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:new', TRUE) . '" />';
1593 $buttons['addtask'] = '<a href="' . htmlspecialchars($link) . '" ' .
1594 'title="' . $GLOBALS['LANG']->getLL('action.add') . '">' . $image . '</a>';
1595 }
1596 }
1597
1598 if ($this->CMD === 'add' || $this->CMD === 'edit') {
1599 $buttons['close'] = '<a href="#" onclick="document.location=\'' . $GLOBALS['MCONF']['_'] . '\'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:cancel', TRUE) . '">' .
1600 t3lib_iconWorks::getSpriteIcon('actions-document-close') . '</a>';
1601
1602 $buttons['save'] = t3lib_iconWorks::getSpriteIcon(
1603 'actions-document-save',
1604 array('html' => '<input type="image" name="data[save]" class="c-inputButton" src="clear.gif" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:save', TRUE) . '" />')
1605 );
1606 }
1607
1608 return $buttons;
1609 }
1610
1611 /**
1612 * Gets the button to set a new shortcut in the backend (if current user is allowed to).
1613 *
1614 * @return string HTML representation of the shortcut button
1615 */
1616 protected function getShortcutButton() {
1617 $result = '';
1618 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
1619 $result = $this->doc->makeShortcutIcon('', 'function', $this->MCONF['name']);
1620 }
1621
1622 return $result;
1623 }
1624 }
1625
1626 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/class.tx_scheduler_module.php'])) {
1627 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/class.tx_scheduler_module.php']);
1628 }
1629 ?>