|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Ingo Renner <ingo@typo3.org> 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 /** 00027 * Additional field to set the notification email address(es) for system health 00028 * issue notifications. 00029 * 00030 * @author Ingo Renner <ingo@typo3.org> 00031 * @package TYPO3 00032 * @subpackage reports 00033 */ 00034 class tx_reports_tasks_SystemStatusUpdateTaskNotificationEmailField implements tx_scheduler_AdditionalFieldProvider { 00035 00036 00037 /** 00038 * Additional fields 00039 * 00040 * @var array 00041 */ 00042 protected $fields = array('notificationEmail'); 00043 00044 /** 00045 * Field prefix. 00046 * 00047 * @var string 00048 */ 00049 protected $fieldPrefix = 'SystemStatusUpdate'; 00050 00051 /** 00052 * Gets additional fields to render in the form to add/edit a task 00053 * 00054 * @param array $taskInfo Values of the fields from the add/edit task form 00055 * @param tx_scheduler_Task $task The task object being eddited. Null when adding a task! 00056 * @param tx_scheduler_Module $schedulerModule Reference to the scheduler backend module 00057 * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => '')) 00058 */ 00059 public function getAdditionalFields(array &$taskInfo, $task, tx_scheduler_Module $schedulerModule) { 00060 $fields = array('notificationEmail'); 00061 00062 if ($schedulerModule->CMD == 'edit') { 00063 $taskInfo[$this->fieldPrefix . 'NotificationEmail'] = $task->getNotificationEmail(); 00064 } 00065 00066 $additionalFields = array(); 00067 foreach ($fields as $field) { 00068 $fieldName = $this->getFullFieldName($field); 00069 $fieldId = 'task_' . $fieldName; 00070 $fieldHtml = '<input type="text" ' 00071 . 'name="tx_scheduler[' . $fieldName . ']" ' 00072 . 'id="' . $fieldId . '" ' 00073 . 'value="' . htmlspecialchars($taskInfo[$fieldName]) . '" />'; 00074 00075 $additionalFields[$fieldId] = array( 00076 'code' => $fieldHtml, 00077 'label' => 'LLL:EXT:reports/reports/locallang.xml:status_updateTaskField_' . $field, 00078 'cshKey' => '', 00079 'cshLabel' => $fieldId 00080 ); 00081 } 00082 00083 return $additionalFields; 00084 } 00085 00086 /** 00087 * Validates the additional fields' values 00088 * 00089 * @param array $submittedData An array containing the data submitted by the add/edit task form 00090 * @param tx_scheduler_Module $schedulerModule Reference to the scheduler backend module 00091 * @return boolean True if validation was ok (or selected class is not relevant), false otherwise 00092 */ 00093 public function validateAdditionalFields(array &$submittedData, tx_scheduler_Module $schedulerModule) { 00094 $validInput = TRUE; 00095 $submittedData[$this->fieldPrefix . 'NotificationEmail'] = trim($submittedData[$this->fieldPrefix . 'NotificationEmail']); 00096 00097 if ( 00098 empty($submittedData[$this->fieldPrefix . 'NotificationEmail']) 00099 || !filter_var($submittedData[$this->fieldPrefix . 'NotificationEmail'], FILTER_VALIDATE_EMAIL) 00100 ) { 00101 $schedulerModule->addMessage( 00102 $GLOBALS['LANG']->sL('LLL:EXT:reports/reports/locallang.xml:status_updateTaskField_notificationEmail_invalid'), 00103 t3lib_FlashMessage::ERROR 00104 ); 00105 $validInput = FALSE; 00106 } 00107 00108 return $validInput; 00109 } 00110 00111 /** 00112 * Takes care of saving the additional fields' values in the task's object 00113 * 00114 * @param array $submittedData An array containing the data submitted by the add/edit task form 00115 * @param tx_scheduler_Task $task Reference to the scheduler backend module 00116 * @return void 00117 */ 00118 public function saveAdditionalFields(array $submittedData, tx_scheduler_Task $task) { 00119 00120 if (!($task instanceof tx_reports_tasks_SystemStatusUpdateTask)) { 00121 throw new InvalidArgumentException( 00122 'Expected a task of type tx_reports_tasks_SystemStatusUpdateTask, but got ' . get_class($task), 00123 1295012802 00124 ); 00125 } 00126 00127 $task->setNotificationEmail($submittedData[$this->fieldPrefix . 'NotificationEmail']); 00128 } 00129 00130 /** 00131 * Constructs the full field name which can be used in HTML markup. 00132 * 00133 * @param string $fieldName A raw field name 00134 * @return string Field name ready to use in HTML markup 00135 */ 00136 protected function getFullFieldName($fieldName) { 00137 return $this->fieldPrefix . ucfirst($fieldName); 00138 } 00139 00140 } 00141 00142 00143 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reports/tasks/class.tx_reports_tasks_systemstatusupdatetasknotificationemailfield.php'])) { 00144 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/reports/tasks/class.tx_reports_tasks_systemstatusupdatetasknotificationemailfield.php']); 00145 } 00146 00147 ?>
1.8.0