Project

General

Profile

Bug #4152 ยป 4152_example_task_hooks_do_not_keep_their_value.patch

Bastian Waidelich, 2009-08-05 12:31

View differences:

examples/class.tx_scheduler_sleeptask_hook.php (working copy)
*/
public function getAdditionalFields(&$taskInfo, $task, tx_scheduler_module1 $parentObject) {
if ($parentObject->CMD == 'add' && empty($taskInfo['sleepTime'])) {
// In case of new task and if field is empty, set default sleep time
$taskInfo['sleepTime'] = 30;
} else if ($parentObject->CMD == 'edit' && $task instanceof self::$class && empty($taskInfo['sleepTime'])) {
// In case of edit, and editing a test task, set to internal value if not data was submitted already
$taskInfo['sleepTime'] = $task->sleepTime;
} else {
// Otherwise set an empty value, as it will not be used anyway
$taskInfo['sleepTime'] = '';
if (empty($taskInfo['sleepTime'])) {
if ($parentObject->CMD == 'add') {
// In case of new task and if field is empty, set default sleep time
$taskInfo['sleepTime'] = 30;
} else if ($parentObject->CMD == 'edit' && $task instanceof self::$class) {
// In case of edit, and editing a test task, set to internal value if not data was submitted already
$taskInfo['sleepTime'] = $task->sleepTime;
} else {
// Otherwise set an empty value, as it will not be used anyway
$taskInfo['sleepTime'] = '';
}
}
// Write the code for the field
examples/class.tx_scheduler_testtask_hook.php (working copy)
* For each field it provides an associative sub-array with the following:
*/
public function getAdditionalFields(&$taskInfo, $task, tx_scheduler_module1 $parentObject) {
if (empty($taskInfo['email'])) {
if ($parentObject->CMD == 'add') {
// In case of new task and if field is empty, set default email address
$taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
if ($parentObject->CMD == 'add' && empty($taskInfo['email'])) {
// In case of new task and if field is empty, set default email address
$taskInfo['email'] = $GLOBALS['BE_USER']->user['email'];
} elseif ($parentObject->CMD == 'edit' && $task instanceof self::$class && empty($taskInfo['email'])) {
// In case of edit, and editing a test task, set to internal value if not data was submitted already
$taskInfo['email'] = $task->email;
} else {
// Otherwise set an empty value, as it will not be used anyway
$taskInfo['email'] = '';
} elseif ($parentObject->CMD == 'edit' && $task instanceof self::$class) {
// In case of edit, and editing a test task, set to internal value if not data was submitted already
$taskInfo['email'] = $task->email;
} else {
// Otherwise set an empty value, as it will not be used anyway
$taskInfo['email'] = '';
}
}
// Write the code for the field
    (1-1/1)