Sends email notifications that a task has been added, edited, or
deleted to users that want such notifications.
public static sendNotification ( string $action, Nag_Task $task, Nag_Task $old_task = null ) | ||
$action | string | The event action. One of "add", "edit", or "delete". |
$task | Nag_Task | The changed task. |
$old_task | Nag_Task | The original task if $action is "edit". |
/** * Deletes a task and handles notification. * * @param string $taskId The task to delete. */ public function delete($taskId) { /* Get the task's details for use later. */ $task = $this->get($taskId); $delete = $this->_delete($taskId); /* Log the deletion of this item in the history log. */ if (!empty($task->uid)) { try { $GLOBALS['injector']->getInstance('Horde_History')->log('nag:' . $this->_tasklist . ':' . $task->uid, array('action' => 'delete'), true); } catch (Exception $e) { Horde::log($e, 'ERR'); } } /* Notify users about the deleted event. */ try { $result = Nag::sendNotification('delete', $task); } catch (Nag_Exception $e) { Horde::log($e, 'ERR'); } /* Delete alarm if necessary. */ if (!empty($task->alarm)) { $GLOBALS['injector']->getInstance('Horde_Alarm')->delete($task->uid); } /* Remove any CalDAV mappings. */ try { $GLOBALS['injector']->getInstance('Horde_Dav_Storage')->deleteInternalObjectId($task->id, $task->tasklist); } catch (Horde_Exception $e) { Horde::log($e); } }
/** * Deletes a task and handles notification. * * @param string $taskId The task to delete. */ public function delete($taskId) { /* Get the task's details for use later. */ $task = $this->get($taskId); $task->loadChildren(); if ($task->hasSubTasks()) { throw new Nag_Exception(_("Sub tasks exist, delete them first")); } $delete = $this->_delete($taskId); /* Remove tags */ $task->tags = array(); $this->_updateTags($task->toHash()); /* Tell content we removed the object */ $GLOBALS['injector']->getInstance('Content_Objects_Manager')->delete(array($task->uid), 'task'); /* Log the deletion of this item in the history log. */ if (!empty($task->uid)) { try { $GLOBALS['injector']->getInstance('Horde_History')->log('nag:' . $this->_tasklist . ':' . $task->uid, array('action' => 'delete'), true); } catch (Exception $e) { Horde::log($e, 'ERR'); } } /* Notify users about the deleted event. */ try { $result = Nag::sendNotification('delete', $task); } catch (Nag_Exception $e) { Horde::log($e, 'ERR'); } /* Delete alarm if necessary. */ if (!empty($task->alarm)) { $GLOBALS['injector']->getInstance('Horde_Alarm')->delete($task->uid); } /* Remove any CalDAV mappings. */ try { $davStorage = $GLOBALS['injector']->getInstance('Horde_Dav_Storage'); try { $davStorage->deleteInternalObjectId($task->id, $task->tasklist); } catch (Horde_Exception $e) { Horde::log($e); } } catch (Horde_Exception $e) { } }