TYPO3 CMS  TYPO3_6-2
SystemStatusUpdateTaskNotificationEmailField.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Reports\Task;
3 
23 
29  protected $fields = array('notificationEmail');
30 
36  protected $fieldPrefix = 'SystemStatusUpdate';
37 
46  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) {
47  $fields = array('notificationEmail' => 'textarea');
48  if ($schedulerModule->CMD == 'edit') {
49  $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail();
50  }
51  // build html for additional email field
52  $fieldName = $this->getFullFieldName('notificationEmail');
53  $fieldId = 'task_' . $fieldName;
54  $fieldHtml = '<textarea ' . 'rows="5" cols="50" name="tx_scheduler[' . $fieldName . ']" ' . 'id="' . $fieldId . '" ' . '>' . htmlspecialchars($taskInfo[$fieldName]) . '</textarea>';
55 
56  $additionalFields = array();
57  $additionalFields[$fieldId] = array(
58  'code' => $fieldHtml,
59  'label' => 'LLL:EXT:reports/reports/locallang.xlf:status_updateTaskField_notificationEmails',
60  'cshKey' => '',
61  'cshLabel' => $fieldId
62  );
63 
64  return $additionalFields;
65  }
66 
74  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule) {
75  $validInput = TRUE;
76  $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], TRUE);
77  foreach ($notificationEmails as $notificationEmail) {
78  if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
79  $validInput = FALSE;
80  break;
81  }
82  }
83  if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
84  $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/reports/locallang.xlf:status_updateTaskField_notificationEmails_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
85  $validInput = FALSE;
86  }
87  return $validInput;
88  }
89 
97  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task) {
98  if (!$task instanceof \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask) {
99  throw new \InvalidArgumentException('Expected a task of type TYPO3\\CMS\\Reports\\Task\\SystemStatusUpdateTask, but got ' . get_class($task), 1295012802);
100  }
101  $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']);
102  }
103 
110  protected function getFullFieldName($fieldName) {
111  return $this->fieldPrefix . ucfirst($fieldName);
112  }
113 
114 }
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]