|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2008 Markus Friedrich (markus.friedrich@dkd.de) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Class "tx_scheduler_TestTask" provides testing procedures 00027 * 00028 * @author Markus Friedrich <markus.friedrich@dkd.de> 00029 * @package TYPO3 00030 * @subpackage tx_scheduler 00031 * 00032 * $Id: class.tx_scheduler_testtask.php 10130 2011-01-18 22:45:15Z lolli $ 00033 */ 00034 class tx_scheduler_TestTask extends tx_scheduler_Task { 00035 00036 /** 00037 * An email address to be used during the process 00038 * 00039 * @var string $email 00040 */ 00041 var $email; 00042 00043 /** 00044 * Function executed from the Scheduler. 00045 * Sends an email 00046 * 00047 * @return void 00048 */ 00049 public function execute() { 00050 $success = false; 00051 00052 if (!empty($this->email)) { 00053 // If an email address is defined, send a message to it 00054 00055 // NOTE: the TYPO3_DLOG constant is not used in this case, as this is a test task 00056 // and debugging is its main purpose anyway 00057 t3lib_div::devLog('[tx_scheduler_TestTask]: Test email sent to "' . $this->email . '"', 'scheduler', 0); 00058 00059 // Get execution information 00060 $exec = $this->getExecution(); 00061 00062 // Get call method 00063 if (basename(PATH_thisScript) == 'cli_dispatch.phpsh') { 00064 $calledBy = 'CLI module dispatcher'; 00065 $site = '-'; 00066 } else { 00067 $calledBy = 'TYPO3 backend'; 00068 $site = t3lib_div::getIndpEnv('TYPO3_SITE_URL'); 00069 } 00070 00071 $start = $exec->getStart(); 00072 $end = $exec->getEnd(); 00073 $interval = $exec->getInterval(); 00074 $multiple = $exec->getMultiple(); 00075 $cronCmd = $exec->getCronCmd(); 00076 $mailBody = 00077 'SCHEDULER TEST-TASK' . LF 00078 . '- - - - - - - - - - - - - - - -' . LF 00079 . 'UID: ' . $this->taskUid . LF 00080 . 'Sitename: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . LF 00081 . 'Site: ' . $site . LF 00082 . 'Called by: ' . $calledBy . LF 00083 . 'tstamp: ' . date('Y-m-d H:i:s') . ' [' . time() . ']' . LF 00084 . 'maxLifetime: ' . $this->scheduler->extConf['maxLifetime'] . LF 00085 . 'start: ' . date('Y-m-d H:i:s', $start) . ' [' . $start . ']' . LF 00086 . 'end: ' . ((empty($end)) ? '-' : (date('Y-m-d H:i:s', $end) . ' [' . $end . ']')) . LF 00087 . 'interval: ' . $interval . LF 00088 . 'multiple: ' . ($multiple ? 'yes' : 'no') . LF 00089 . 'cronCmd: ' . ($cronCmd ? $cronCmd : 'not used'); 00090 00091 // Prepare mailer and send the mail 00092 try { 00093 /** @var $mailer t3lib_mail_message */ 00094 $mailer = t3lib_div::makeInstance('t3lib_mail_message'); 00095 $mailer->setFrom(array($this->email => 'SCHEDULER TEST-TASK')); 00096 $mailer->setReplyTo(array($this->email => 'SCHEDULER TEST-TASK')); 00097 $mailer->setSubject('SCHEDULER TEST-TASK'); 00098 $mailer->setBody($mailBody); 00099 $mailer->setTo($this->email); 00100 $mailsSend = $mailer->send(); 00101 $success = ($mailsSend>0); 00102 } catch (Exception $e) { 00103 throw new t3lib_exception($e->getMessage()); 00104 } 00105 } else { 00106 // No email defined, just log the task 00107 t3lib_div::devLog('[tx_scheduler_TestTask]: No email address given', 'scheduler', 2); 00108 } 00109 00110 return $success; 00111 } 00112 00113 /** 00114 * This method returns the destination mail address as additional information 00115 * 00116 * @return string Information to display 00117 */ 00118 public function getAdditionalInformation() { 00119 return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xml:label.email') . ': ' . $this->email; 00120 } 00121 } 00122 00123 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_testtask.php'])) { 00124 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/examples/class.tx_scheduler_testtask.php']); 00125 } 00126 00127 ?>
1.8.0