TYPO3 CMS  TYPO3_7-6
SystemStatusUpdateTaskNotificationEmailField.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Reports\Task;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
22 {
28  protected $fields = ['notificationEmail'];
29 
35  protected $fieldPrefix = 'SystemStatusUpdate';
36 
45  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
46  {
47  $fields = ['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 class="form-control" ' . 'rows="5" cols="50" name="tx_scheduler[' . $fieldName . ']" ' . 'id="' . $fieldId . '" ' . '>' . htmlspecialchars($taskInfo[$fieldName]) . '</textarea>';
55 
56  $additionalFields = [];
57  $additionalFields[$fieldId] = [
58  'code' => $fieldHtml,
59  'label' => 'LLL:EXT:reports/Resources/Private/Language/locallang_reports.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  {
76  $validInput = true;
77  $notificationEmails = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $submittedData[$this->fieldPrefix . 'NotificationEmail'], true);
78  foreach ($notificationEmails as $notificationEmail) {
79  if (!\TYPO3\CMS\Core\Utility\GeneralUtility::validEmail($notificationEmail)) {
80  $validInput = false;
81  break;
82  }
83  }
84  if (empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) || !$validInput) {
85  $schedulerModule->addMessage($GLOBALS['LANG']->sL('LLL:EXT:reports/Resources/Private/Language/locallang_reports.xlf:status_updateTaskField_notificationEmails_invalid'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
86  $validInput = false;
87  }
88  return $validInput;
89  }
90 
98  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
99  {
100  if (!$task instanceof \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask) {
101  throw new \InvalidArgumentException('Expected a task of type ' . \TYPO3\CMS\Reports\Task\SystemStatusUpdateTask::class . ', but got ' . get_class($task), 1295012802);
102  }
103  $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']);
104  }
105 
112  protected function getFullFieldName($fieldName)
113  {
114  return $this->fieldPrefix . ucfirst($fieldName);
115  }
116 }
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(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']