/** * Update an task entry with the given data * * @param array Hash array with task properties * @return boolean True on success, False on error * @see tasklist_driver::edit_task() */ public function edit_task($task, $old_task = null) { if ($task['_savemode'] == 'new') { $task['uid'] = $this->plugin->generate_uid(); return $this->create_task($task); } else { $sync_enforced = $old_task != null; $task_id = (int) $task['id']; $cal_id = $task['list']; if (isset($task['_fromlist'])) { $delete = $task; $delete['list'] = $task['_fromlist']; if ($success = $this->delete_task($delete)) { unset($task['id']); unset($task['changed']); unset($task['_fromlist']); $task['raw'] = $task['title']; foreach ($task as $prop => $val) { if (!$val) { unset($task[$prop]); } } return $this->create_task($task) ? true : false; } else { return false; } } else { if ($old_task == null) { $old_task = parent::get_master($task); } if ($success = parent::edit_task($task)) { if (isset($this->sync_clients[$cal_id])) { $success = $this->_edit_task($task_id, $cal_id); if ($success === true) { self::debug_log("Successfully updated task \"{$task_id}\"."); // Trigger calendar sync to update ctags and etags. $this->_sync_calendar($cal_id); $this->_reload_list($task, $old_task); return true; } else { if ($success < 0 && $sync_enforced == false) { self::debug_log("Task \"{$task_id}\", tag \"" . $props['tag'] . "\" not up to date, will update calendar first ..."); $this->_sync_calendar($cal_id); return $this->edit_task($task, $old_task); // Re-try after re-sync } else { self::debug_log("Unkown error while updating caldav task, undo updating local task \"{$task_id}\"!"); parent::edit_task($old_task); return false; } } } else { return $success; } } } } return false; }