TYPO3 CMS  TYPO3_6-2
BulkUpdateFieldProvider.php
Go to the documentation of this file.
1 <?php
3 
22 
28  protected $defaultCanDeactivateSelf = TRUE;
29 
35  protected $defaultNumberOfRecords = 250;
36 
46  public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
47  // Initialize selected fields
48  if (!isset($taskInfo['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf'])) {
49  $taskInfo['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf'] = $this->defaultCanDeactivateSelf;
50  if ($parentObject->CMD === 'edit') {
51  $taskInfo['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf'] = $task->getCanDeactivateSelf();
52  }
53  }
54  if (!isset($taskInfo['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'])) {
55  $taskInfo['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'] = $this->defaultNumberOfRecords;
56  if ($parentObject->CMD === 'edit') {
57  $taskInfo['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'] = $task->getNumberOfRecords();
58  }
59  }
60  // Configuration for canDeactivateSelf
61  $fieldName = 'tx_scheduler[scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf]';
62  $fieldId = 'task_saltedpasswordsBulkUpdateCanDeactivateSelf';
63  $fieldValue = 'IsChecked';
64  $fieldChecked = (bool) $taskInfo['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf'];
65  $fieldHtml = '<input type="checkbox"' . ' name="' . $fieldName . '"' . ' id="' . $fieldId . '"' . ' value="' . $fieldValue . '"' . ($fieldChecked ? ' checked="checked"' : '') . ' />';
66  $additionalFields[$fieldId] = array(
67  'code' => $fieldHtml,
68  'label' => 'LLL:EXT:saltedpasswords/locallang.xlf:ext.saltedpasswords.tasks.bulkupdate.label.canDeactivateSelf',
69  'cshKey' => '_txsaltedpasswords',
70  'cshLabel' => $fieldId
71  );
72  // Configuration for numberOfRecords
73  $fieldName = 'tx_scheduler[scheduler_saltedpasswordsBulkUpdateNumberOfRecords]';
74  $fieldId = 'task_saltedpasswordsBulkUpdateNumberOfRecords';
75  $fieldValue = (int)$taskInfo['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'];
76  $fieldHtml = '<input type="text" name="' . $fieldName . '" id="' . $fieldId . '" value="' . htmlspecialchars($fieldValue) . '" />';
77  $additionalFields[$fieldId] = array(
78  'code' => $fieldHtml,
79  'label' => 'LLL:EXT:saltedpasswords/locallang.xlf:ext.saltedpasswords.tasks.bulkupdate.label.numberOfRecords',
80  'cshKey' => '_txsaltedpasswords',
81  'cshLabel' => $fieldId
82  );
83  return $additionalFields;
84  }
85 
93  public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) {
94  $result = TRUE;
95  // Check if number of records is indeed a number and greater or equals to 0
96  // If not, fail validation and issue error message
97  if (!is_numeric($submittedData['scheduler_saltedpasswordsBulkUpdateNumberOfRecords']) || (int)$submittedData['scheduler_saltedpasswordsBulkUpdateNumberOfRecords'] < 0) {
98  $result = FALSE;
99  $parentObject->addMessage($GLOBALS['LANG']->sL('LLL:EXT:saltedpasswords/locallang.xlf:ext.saltedpasswords.tasks.bulkupdate.invalidNumberOfRecords'), \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
100  }
101  return $result;
102  }
103 
111  public function saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task) {
112  if (isset($submittedData['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf']) && $submittedData['scheduler_saltedpasswordsBulkUpdateCanDeactivateSelf'] === 'IsChecked') {
113  $task->setCanDeactivateSelf(TRUE);
114  } else {
115  $task->setCanDeactivateSelf(FALSE);
116  }
117  $task->setNumberOfRecords((int)$submittedData['scheduler_saltedpasswordsBulkUpdateNumberOfRecords']);
118  }
119 
120 }
saveAdditionalFields(array $submittedData, \TYPO3\CMS\Scheduler\Task\AbstractTask $task)
validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject)