TYPO3 CMS  TYPO3_6-2
TestTask.php
Go to the documentation of this file.
1 <?php
3 
22 
29  public $email;
30 
37  public function execute() {
38  $success = FALSE;
39  if (!empty($this->email)) {
40  // If an email address is defined, send a message to it
41  // NOTE: the TYPO3_DLOG constant is not used in this case, as this is a test task
42  // and debugging is its main purpose anyway
43  \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[TYPO3\\CMS\\Scheduler\\Example\\TestTask]: Test email sent to "' . $this->email . '"', 'scheduler', 0);
44  // Get execution information
45  $exec = $this->getExecution();
46  // Get call method
47  if (basename(PATH_thisScript) == 'cli_dispatch.phpsh') {
48  $calledBy = 'CLI module dispatcher';
49  $site = '-';
50  } else {
51  $calledBy = 'TYPO3 backend';
53  }
54  $start = $exec->getStart();
55  $end = $exec->getEnd();
56  $interval = $exec->getInterval();
57  $multiple = $exec->getMultiple();
58  $cronCmd = $exec->getCronCmd();
59  $mailBody = 'SCHEDULER TEST-TASK' . LF . '- - - - - - - - - - - - - - - -' . LF . 'UID: ' . $this->taskUid . LF . 'Sitename: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . LF . 'Site: ' . $site . LF . 'Called by: ' . $calledBy . LF . 'tstamp: ' . date('Y-m-d H:i:s') . ' [' . time() . ']' . LF . 'maxLifetime: ' . $this->scheduler->extConf['maxLifetime'] . LF . 'start: ' . date('Y-m-d H:i:s', $start) . ' [' . $start . ']' . LF . 'end: ' . (empty($end) ? '-' : date('Y-m-d H:i:s', $end) . ' [' . $end . ']') . LF . 'interval: ' . $interval . LF . 'multiple: ' . ($multiple ? 'yes' : 'no') . LF . 'cronCmd: ' . ($cronCmd ? $cronCmd : 'not used');
60  // Prepare mailer and send the mail
61  try {
63  $mailer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
64  $mailer->setFrom(array($this->email => 'SCHEDULER TEST-TASK'));
65  $mailer->setReplyTo(array($this->email => 'SCHEDULER TEST-TASK'));
66  $mailer->setSubject('SCHEDULER TEST-TASK');
67  $mailer->setBody($mailBody);
68  $mailer->setTo($this->email);
69  $mailsSend = $mailer->send();
70  $success = $mailsSend > 0;
71  } catch (\Exception $e) {
72  throw new \TYPO3\CMS\Core\Exception($e->getMessage());
73  }
74  } else {
75  // No email defined, just log the task
76  \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[TYPO3\\CMS\\Scheduler\\Example\\TestTask]: No email address given', 'scheduler', 2);
77  }
78  return $success;
79  }
80 
86  public function getAdditionalInformation() {
87  return $GLOBALS['LANG']->sL('LLL:EXT:scheduler/mod1/locallang.xlf:label.email') . ': ' . $this->email;
88  }
89 
90 }
static devLog($msg, $extKey, $severity=0, $dataVar=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]