/** * Remove a single task from the database * * @param array Hash array with task properties * @param boolean Remove record irreversible * @return boolean True on success, False on error * @see tasklist_driver::delete_task() */ public function delete_task($prop, $force = true) { $prop = $this->_get_id($prop); $task = (array) parent::get_task($prop); $master = parent::get_master($prop); $task_id = (int) $task['id']; $cal_id = (int) ($prop['list'] ? $prop['list'] : $task['list']); $success = false; if ($prop['isclone'] && $prop['mode'] == 2) { // create EXCEPTION if ($success = parent::delete_task($prop, true)) { if ($props = $this->_get_caldav_props($task_id, self::OBJ_TYPE_VTODO)) { $success = $this->_edit_task($task_id, $cal_id); } } } else { if (!$prop['isclone'] && $prop['mode'] == 3) { // delete parent and remove relation from subtasks if (isset($this->sync_clients[$cal_id])) { $sync_client = $this->sync_clients[$cal_id]; $children = (array) parent::get_childs($prop, true); foreach ($children as $child_id) { // process childs $child_props = $this->_get_caldav_props($child_id, self::OBJ_TYPE_VTODO); if (is_array($child_props)) { if ($child = $this->get_master(array('id' => $child_id))) { unset($child['parent_id']); $child = $this->_save_preprocess($child); $sync_client->update_event($child, $child_props); } } } $props = $this->_get_caldav_props($task_id, self::OBJ_TYPE_VTODO); if ($success = parent::delete_task($prop, true)) { $success = $sync_client->remove_event($props); } } else { $success = parent::delete_task($prop, true); } } else { if (!$prop['isclone'] && $prop['mode'] == 4) { // delete parent and subtasks if (isset($this->sync_clients[$cal_id])) { $sync_client = $this->sync_clients[$cal_id]; $children = (array) parent::get_childs($prop, true); foreach ($children as $child_id) { // process childs $child_props = $this->_get_caldav_props($child_id, self::OBJ_TYPE_VTODO); if (is_array($child_props)) { $task = $this->_save_preprocess($child_props); $sync_client->remove_event($child_props); } } $props = $this->_get_caldav_props($task_id, self::OBJ_TYPE_VTODO); if ($success = parent::delete_task($prop, true)) { // process parent $success = $sync_client->remove_event($props); } } else { $success = parent::delete_task($prop, true); } } else { $props = $this->_get_caldav_props($task_id, self::OBJ_TYPE_VTODO); $props = $this->_get_caldav_props($task_id, self::OBJ_TYPE_VTODO); if ($success = parent::delete_task($task)) { if ($master['id'] != $prop['id']) { // delete EXCEPTION if (isset($this->sync_clients[$cal_id])) { $success = $this->_edit_task($master['id'], $cal_id); } $this->_reload_list(); } else { if (is_array($props)) { if (isset($this->sync_clients[$cal_id])) { $sync_client = $this->sync_clients[$cal_id]; $success = $sync_client->remove_event($props); } } } } } } } if ($success === true) { self::debug_log("Successfully removed task \"{$task_id}\"."); } else { self::debug_log("Unkown error while removing caldav task \"{$task_id}\", force sync of calendar \"{$task_id}\"!"); } // Trigger calendar sync to update ctags and etags. if (isset($this->sync_clients[$cal_id])) { $this->_sync_calendar($cal_id); } return $success; }