From: Jan Schneider Date: Tue, 8 Jun 2010 14:17:23 +0000 (+0200) Subject: Implement individual alarms for tasks. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=dbb16d1b6ae16de3ad000aefbd91798a40e70909;p=horde.git Implement individual alarms for tasks. --- diff --git a/kronolith/index.php b/kronolith/index.php index 4213a2fd2..e8a94173c 100644 --- a/kronolith/index.php +++ b/kronolith/index.php @@ -36,45 +36,64 @@ $_SESSION['horde_notification']['override'] = array( 'Kronolith_Notification_Listener_AjaxStatus' ); -$alarm_methods = $alarm_params = ''; +$eventAlarmMethods = $eventAlarmParams = $taskAlarmMethods = $taskAlarmParams = ''; foreach ($injector->getInstance('Horde_Alarm')->handlers() as $method => $handler) { - $alarm_methods .= ' '; + $eventAlarmMethods .= ' '; + $taskAlarmMethods .= ' '; $params = $handler->getParameters(); if (!count($params)) { continue; } - $alarm_params .= ' '; } Kronolith::header(); diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index ce557a2e8..ea2c8b284 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -2370,6 +2370,7 @@ KronolithCore = { $('kronolithTaskDelete').show(); $('kronolithTaskForm').down('.kronolithFormActions .kronolithSeparator').show(); this.updateTasklistDropDown(); + this.disableAlarmMethods('Task'); if (id) { RedBox.loading(); this.doAction('getTask', { list: tasklist, id: id }, this.editTaskCallback.bind(this)); @@ -2429,8 +2430,37 @@ KronolithCore = { throw $break; } }); + if (task.m) { + $('kronolithTaskAlarmDefaultOff').checked = true; + $H(task.m).each(function(method) { + if (!$('kronolithTaskAlarm' + method.key)) { + return; + } + $('kronolithTaskAlarm' + method.key).setValue(1); + if ($('kronolithTaskAlarm' + method.key + 'Params')) { + $('kronolithTaskAlarm' + method.key + 'Params').show(); + } + $H(method.value).each(function(param) { + var input = $('kronolithTaskAlarmParam' + param.key); + if (!input) { + return; + } + if (input.type == 'radio') { + input.up('form').select('input[type=radio]').each(function(radio) { + if (radio.name == input.name && + radio.value == param.value) { + radio.setValue(1); + throw $break; + } + }); + } else { + input.setValue(param.value); + } + }); + }); + } } else { - $('kronolithEventAlarmOff').setValue(true); + $('kronolithTaskAlarmOff').setValue(true); } if (!task.pe) { @@ -2494,10 +2524,10 @@ KronolithCore = { removeTask: function(task, list) { this.deleteTasksCache(task, list); - $('kronolithViewTasksBody').select('tr').find(function(el) { + $('kronolithViewTasksBody').select('tr').findAll(function(el) { return el.retrieve('tasklist') == list && el.retrieve('taskid') == task; - }).remove(); + }).invoke('remove'); }, /** @@ -3699,7 +3729,11 @@ KronolithCore = { break; case 'kronolithEventAlarmDefaultOn': - this.disableAlarmMethods(); + this.disableAlarmMethods('Event'); + break; + + case 'kronolithTaskAlarmDefaultOn': + this.disableAlarmMethods('Task'); break; case 'kronolithEventAlarmPrefs': @@ -4288,8 +4322,14 @@ KronolithCore = { window.history.back(); e.stop(); break; - } else if (elt.tagName == 'INPUT' && elt.name == 'event_alarms[]') { - $('kronolithEventAlarmDefaultOff').setValue(1); + } else if (elt.tagName == 'INPUT' && + (elt.name == 'event_alarms[]' || + elt.name == 'task[alarm_methods][]')) { + if (elt.name == 'event_alarms[]') { + $('kronolithEventAlarmDefaultOff').setValue(1); + } else { + $('kronolithTaskAlarmDefaultOff').setValue(1); + } if ($(elt.id + 'Params')) { if (elt.getValue()) { $(elt.id + 'Params').show(); @@ -4526,7 +4566,7 @@ KronolithCore = { this.updateCalendarDropDown('kronolithEventTarget'); this.toggleAllDay(false); this.openTab($('kronolithEventForm').down('.tabset a.kronolithTabLink')); - this.disableAlarmMethods(); + this.disableAlarmMethods('Event'); $('kronolithEventForm').reset(); kronolithEAttendeesAc.reset(); kronolithETagAc.reset(); @@ -4993,9 +5033,9 @@ KronolithCore = { /** * Disables all custom alarm methods in the event form. */ - disableAlarmMethods: function() { - $('kronolithEventTabReminder').select('input').each(function(input) { - if (input.name == 'event_alarms[]') { + disableAlarmMethods: function(type) { + $('kronolith' + type + 'TabReminder').select('input').each(function(input) { + if (input.name == (type == 'Event' ? 'event_alarms[]' : 'task[alarm_methods][]')) { input.setValue(0); if ($(input.id + 'Params')) { $(input.id + 'Params').hide(); diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index 13f8190c9..6e621fa36 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -410,9 +410,25 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base $value = $unit = 1; } $task['alarm'] = $value * $unit; + if (isset($task['alarm_methods']) && isset($task['methods'])) { + foreach (array_keys($task['methods']) as $method) { + if (!in_array($method, $task['alarm_methods'])) { + unset($task['methods'][$method]); + } + } + foreach ($task['alarm_methods'] as $method) { + if (!isset($task['methods'][$method])) { + $task['methods'][$method] = array(); + } + } + } else { + $task['methods'] = array(); + } } else { $task['alarm'] = 0; + $task['methods'] = array(); } + unset($task['alarm_methods']); $result = new stdClass; try { diff --git a/kronolith/templates/index/edit.inc b/kronolith/templates/index/edit.inc index 25028a581..b2ad6c049 100644 --- a/kronolith/templates/index/edit.inc +++ b/kronolith/templates/index/edit.inc @@ -107,7 +107,7 @@ ' ', '') ?> - +