TYPO3 CMS  TYPO3_7-6
TestTaskAdditionalFieldProvider.php
Go to the documentation of this file.
1 <?php
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 
18 
23 {
33  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
34  {
35  // Initialize extra field value
36  if (empty($taskInfo['email'])) {
37  if ($parentObject->CMD === 'add') {
38  // In case of new task and if field is empty, set default email address
39  $taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
40  } elseif ($parentObject->CMD === 'edit') {
41  // In case of edit, and editing a test task, set to internal value if not data was submitted already
42  $taskInfo['email'] = $task->email;
43  } else {
44  // Otherwise set an empty value, as it will not be used anyway
45  $taskInfo['email'] = '';
46  }
47  }
48  // Write the code for the field
49  $fieldID = 'task_email';
50  $fieldCode = '<input type="text" class="form-control" name="tx_scheduler[email]" id="' . $fieldID . '" value="' . htmlspecialchars($taskInfo['email']) . '" size="30">';
51  $additionalFields = [];
52  $additionalFields[$fieldID] = [
53  'code' => $fieldCode,
54  'label' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.email',
55  'cshKey' => '_MOD_system_txschedulerM1',
56  'cshLabel' => $fieldID
57  ];
58  return $additionalFields;
59  }
60 
69  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
70  {
71  $submittedData['email'] = trim($submittedData['email']);
72  if (empty($submittedData['email'])) {
73  $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.noEmail'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
74  $result = false;
75  } else {
76  $result = true;
77  }
78  return $result;
79  }
80 
89  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
90  {
91  $task->email = $submittedData['email'];
92  }
93 }
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
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']