*/
public static function updateTasklist($id, $info)
{
- $tasklist = $GLOBALS['nag_shares']->getShare($id);
- if (is_a($tasklist, 'PEAR_Error')) {
- return $tasklist;
+ try {
+ $tasklist = $GLOBALS['nag_shares']->getShare($id);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
+
return Nag::updateTasklist($tasklist, $info);
}
} else {
// Remove share and all groups/permissions.
$share = $GLOBALS['nag_shares']->getShare($tasklistID);
- $result = $GLOBALS['nag_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
- $result->code = 500;
- return $result;
+ try {
+ $GLOBALS['nag_shares']->removeShare($share);
+ } catch (Horde_Share_Exception $e) {
+ throw new Nag_Exception($e->getMessage());
}
}
}
return PEAR::raiseError(_("Permission Denied"));
}
- $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
- if (is_a($share, 'PEAR_Error')) {
- return $share;
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
-
$task = Nag::getTask($tasklist_id, $task_id);
- if (is_a($task, 'PEAR_Error')) {
+ if ($task instanceof PEAR_Error) {
return $task;
}
$tasklists = is_null($user) ? array_keys($GLOBALS['nag_shares']->listAllShares()) : $GLOBALS['display_tasklists'];
$alarms = Nag::listAlarms($time, $tasklists);
- if (is_a($alarms, 'PEAR_Error')) {
+ if (is_a($alarms instanceof PEAR_Error) {
return $alarms;
}
foreach ($alarms as $alarm) {
- $share = $GLOBALS['nag_shares']->getShare($alarm->tasklist);
- if (is_a($share, 'PEAR_Error')) {
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($alarm->tasklist);
+ } catch (Horde_Share_Exception $e) {
continue;
}
if (empty($user)) {
$hasError = false;
/* Get the share for later deletion */
- $share = $GLOBALS['nag_shares']->getShare($user);
- if(is_a($share, 'PEAR_Error')) {
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($user);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ }
+
+ /* Get the list of all tasks */
+ $tasks = Nag::listTasks(null, null, null, $user, 1);
+ if ($tasks instanceof PEAR_Error) {
+ $hasError = true;
Horde::logMessage($share, 'ERR');
- unset($share);
} else {
- /* Get the list of all tasks */
- $tasks = Nag::listTasks(null, null, null, $user, 1);
- if (is_a($tasks, 'PEAR_Error')) {
- $hasError = true;
- Horde::logMessage($share, 'ERR');
- } else {
- $uids = array();
- $tasks->reset();
- while ($task = $tasks->each()) {
- $uids[] = $task->uid;
- }
+ $uids = array();
+ $tasks->reset();
+ while ($task = $tasks->each()) {
+ $uids[] = $task->uid;
+ }
- /* ... and delete them. */
- foreach ($uids as $uid) {
- $this->delete($uid);
- }
+ /* ... and delete them. */
+ foreach ($uids as $uid) {
+ $this->delete($uid);
}
}
+
/* ...and finally, delete the actual share */
if (!empty($share)) {
- $result = $GLOBALS['nag_shares']->removeShare($share);
- if (is_a($result, 'PEAR_Error')) {
+ try {
+ $GLOBALS['nag_shares']->removeShare($share);
+ } catch (Horde_Share_Exception $e) {
$hasError = true;
Horde::logMessage($result, 'ERR');
}
}
/* Now remove perms for this user from all other shares */
- $shares = $GLOBALS['nag_shares']->listShares($user);
- if (is_a($shares, 'PEAR_Error')) {
+ try {
+ $shares = $GLOBALS['nag_shares']->listShares($user);
+ foreach ($shares as $share) {
+ $share->removeUser($user);
+ }
+ } catch (Horde_Share_Exception $e) {
$hasError = true;
Horde::logMessage($shares, 'ERR');
}
- foreach ($shares as $share) {
- $share->removeUser($user);
- }
if ($hasError) {
return PEAR::raiseError(sprintf(_("There was an error removing tasks for %s. Details have been logged."), $user));
$owner = $task->tasklist;
$shares = $GLOBALS['injector']->getInstance('Horde_Share')->getScope();
$share = $shares->getShare($owner);
- if (!is_a($share, 'PEAR_Error')) {
- $owner = $share->get('name');
- }
+ $owner = $share->get('name');
$html .= '<td width="1%" class="nowrap">'
. htmlspecialchars($owner) . ' </td>';
}
$log_tasklist = $this->_tasklist;
if (!is_null($tasklist) && $task->tasklist != $tasklist) {
/* Moving the task to another tasklist. */
- $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
- if (is_a($share, 'PEAR_Error')) {
- return $share;
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
return false;
}
- $share = $GLOBALS['nag_shares']->getShare($tasklist);
- if (is_a($share, 'PEAR_Error')) {
- return $share;
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($tasklist);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
}
$moved = $this->_move($task->id, $tasklist);
- if (is_a($moved, 'PEAR_Error')) {
+ if ($moved instanceof PEAR_Error) {
return $moved;
}
$new_storage = Nag_Driver::singleton($tasklist);
function listAlarms($date)
{
$task_list = $this->_store->getObjects();
- if (is_a($task_list, 'PEAR_Error')) {
+ if ($task_list instanceof PEAR_Error) {
return $task_list;
}
--- /dev/null
+<?php
+/**
+ * Base exception class for Nag.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package Nag
+ */
+class Nag_Exception extends Horde_Exception_Prior
+{
+}
$task_enums[htmlspecialchars($task->id)] = str_repeat(' ', $task->indent * 4) . htmlentities($task->name, ENT_COMPAT, Horde_Nls::getCharset());
}
$users = array();
- $share = &$GLOBALS['nag_shares']->getShare($tasklist);
- if (!is_a($share, 'PEAR_Error')) {
- $users = $share->listUsers(Horde_Perms::READ);
- $groups = $share->listGroups(Horde_Perms::READ);
- if (count($groups)) {
- require_once 'Horde/Group.php';
- $horde_group = Group::singleton();
- foreach ($groups as $group) {
- $users = array_merge($users,
- $horde_group->listAllUsers($group));
- }
+ $share = $GLOBALS['nag_shares']->getShare($tasklist);
+ $users = $share->listUsers(Horde_Perms::READ);
+ $groups = $share->listGroups(Horde_Perms::READ);
+ if (count($groups)) {
+ require_once 'Horde/Group.php';
+ $horde_group = Group::singleton();
+ foreach ($groups as $group) {
+ $users = array_merge($users,
+ $horde_group->listAllUsers($group));
}
- $users = array_flip($users);
}
+ $users = array_flip($users);
+
if (count($users)) {
foreach (array_keys($users) as $user) {
$identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getIdentity($user);
if ($owneronly && !Horde_Auth::getAuth()) {
return array();
}
- $tasklists = $GLOBALS['nag_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
- if (is_a($tasklists, 'PEAR_Error')) {
- Horde::logMessage($tasklists, 'ERR');
+ try {
+ $tasklists = $GLOBALS['nag_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
return array();
}
*/
public static function addTasklist($info)
{
- $tasklist = $GLOBALS['nag_shares']->newShare(md5(microtime()));
- if (is_a($tasklist, 'PEAR_Error')) {
- return $tasklist;
- }
- $tasklist->set('name', $info['name']);
- $tasklist->set('color', $info['color']);
- $tasklist->set('desc', $info['description']);
- if (!empty($info['system'])) {
- $tasklist->set('owner', null);
- }
+ try {
+ $tasklist = $GLOBALS['nag_shares']->newShare(md5(microtime()));
+ $tasklist->set('name', $info['name']);
+ $tasklist->set('color', $info['color']);
+ $tasklist->set('desc', $info['description']);
+ if (!empty($info['system'])) {
+ $tasklist->set('owner', null);
+ }
- $result = $GLOBALS['nag_shares']->addShare($tasklist);
- if (is_a($result, 'PEAR_Error')) {
- return $result;
+ $GLOBALS['nag_shares']->addShare($tasklist);
+ } catch (Horde_Share_Exception $e) {
+ throw new Nag_Exception($e);
}
$GLOBALS['display_tasklists'][] = $tasklist->getName();
// Delete the task list.
$storage = &Nag_Driver::singleton($tasklist->getName());
$result = $storage->deleteAll();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
return PEAR::raiseError(sprintf(_("Unable to delete \"%s\": %s"), $tasklist->get('name'), $result->getMessage()));
}
return PEAR::raiseError('Unknown event action: ' . $action);
}
- $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
- if (is_a($share, 'PEAR_Error')) {
- return $share;
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
+ } catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
require_once 'Horde/Group.php';
}
if ($old_task->parent_id != $task->parent_id) {
$old_parent = $old_task->getParent();
- if (!is_a($old_parent, 'PEAR_Error')) {
- $parent = $task->getParent();
- if (!is_a($parent, 'PEAR_Error')) {
- $notification_message .= "\n - "
- . sprintf(_("Changed parent task from \"%s\" to \"%s\""),
- $old_parent ? $old_parent->name : _("no parent"),
- $parent ? $parent->name : _("no parent"));
- }
+ $parent = $task->getParent();
+ if (!is_a($parent, 'PEAR_Error')) {
+ $notification_message .= "\n - "
+ . sprintf(_("Changed parent task from \"%s\" to \"%s\""),
+ $old_parent ? $old_parent->name : _("no parent"),
+ $parent ? $parent->name : _("no parent"));
}
+
}
if ($old_task->category != $task->category) {
$notification_message .= "\n - "
$aowner = $a->tasklist;
$bowner = $b->tasklist;
- if (!is_a($ashare, 'PEAR_Error') && $aowner != $ashare->get('owner')) {
+ if ($aowner != $ashare->get('owner')) {
$aowner = $ashare->get('name');
}
- if (!is_a($bshare, 'PEAR_Error') && $bowner != $bshare->get('owner')) {
+ if ($bowner != $bshare->get('owner')) {
$bowner = $bshare->get('name');
}
$aowner = $a->tasklist;
$bowner = $b->tasklist;
- if (!is_a($ashare, 'PEAR_Error') && $aowner != $ashare->get('owner')) {
+ if ($aowner != $ashare->get('owner')) {
$aowner = $ashare->get('name');
}
- if (!is_a($bshare, 'PEAR_Error') && $bowner != $bshare->get('owner')) {
+ if ($bowner != $bshare->get('owner')) {
$bowner = $bshare->get('name');
}
$json->m = $this->methods;
//$json->pv = (boolean)$this->private;
- $share = $GLOBALS['nag_shares']->getShare($this->tasklist);
- if (is_a($share, 'PEAR_Error')) {
- return $share;
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($this->tasklist);
+ } catch (Horde_Share_exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
}
$json->pe = $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT);
$json->pd = $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE);
{
if (!empty($task_id)) {
$task = Nag::getTask($tasklist_id, $task_id);
- if (is_a($task, 'PEAR_Error')) {
+ if ($task instanceof PEAR_Error) {
$GLOBALS['notification']->push(
sprintf(_("Error deleting task: %s"),
$task->getMessage()), 'horde.error');
} else {
- $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
- if (is_a($share, 'PEAR_Error') ||
- !$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
- $GLOBALS['notification']->push(
- _("Access denied deleting task."), 'horde.error');
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
+ } catch (Horde_Share_Exception $e) {
+ throw new Nag_Exception($e);
+ }
+ if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
+ $GLOBALS['notification']->push(_("Access denied deleting task."), 'horde.error');
} else {
$storage = Nag_Driver::singleton($tasklist_id);
- $result = $storage->delete($task_id);
- if (is_a($result, 'PEAR_Error')) {
+ try {
+ $storage->delete($task_id);
+ } catch (Horde_Share_Exception $e) {
$GLOBALS['notification']->push(
sprintf(_("There was a problem deleting %s: %s"),
- $task->name, $result->getMessage()),
+ $task->name, $e->getMessage()),
'horde.error');
- } else {
- $GLOBALS['notification']->push(sprintf(_("Deleted %s."),
- $task->name),
- 'horde.success');
}
+ $GLOBALS['notification']->push(sprintf(_("Deleted %s."), $task->name),
+ 'horde.success');
}
}
}
case 'modify_task':
$task_id = $vars->get('task');
$tasklist_id = $vars->get('tasklist');
- $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
- if (is_a($share, 'PEAR_Error')) {
- $notification->push(sprintf(_("Access denied editing task: %s"), $share->getMessage()), 'horde.error');
- } elseif (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($tasklist_id);s
+ } catch (Horde_Share_Exception $e) {
+ $notification->push(sprintf(_("Access denied editing task: %s"), $e->getMessage()), 'horde.error');
+ }
+ if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
$notification->push(_("Access denied editing task."), 'horde.error');
} else {
$task = Nag::getTask($tasklist_id, $task_id);
count(Nag::listTasklists(false, Horde_Perms::EDIT)) <= 1) {
$info['tasklist_id'] = $info['old_tasklist'] = Nag::getDefaultTasklist(Horde_Perms::EDIT);
}
- $share = $GLOBALS['nag_shares']->getShare($info['tasklist_id']);
- if (is_a($share, 'PEAR_Error')) {
- $notification->push(sprintf(_("Access denied saving task: %s"), $share->getMessage()), 'horde.error');
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($info['tasklist_id']);
+ } catch (Horde_Share_Exception $e) {
+ $notification->push(sprintf(_("Access denied saving task: %s"), $e->getMessage()), 'horde.error');
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
- } elseif (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+ }
+ if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
$notification->push(sprintf(_("Access denied saving task to %s."), $share->get('name')), 'horde.error');
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
}
/* Check our results. */
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push(sprintf(_("There was a problem saving the task: %s."), $result->getMessage()), 'horde.error');
} else {
$notification->push(sprintf(_("Saved %s."), $info['name']), 'horde.success');
if (isset($task_id)) {
$share = $GLOBALS['nag_shares']->getShare($tasklist_id);
$task = Nag::getTask($tasklist_id, $task_id);
- if (is_a($share, 'PEAR_Error') || !$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+ if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
$notification->push(sprintf(_("Access denied completing task %s."), $task->name), 'horde.error');
} else {
$task->completed = !$task->completed;
$task->completed_date = null;
}
$result = $task->save();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push(sprintf(_("There was a problem completing %s: %s"),
$task->name, $result->getMessage()), 'horde.error');
} else {
header('Location: ' . Horde::applicationUrl('tasklists/', true));
exit;
}
-$tasklist = $nag_shares->getShare($tasklist_id);
-if (is_a($tasklist, 'PEAR_Error')) {
+try {
+ $tasklist = $nag_shares->getShare($tasklist_id);
+} catch (Horde_Share_Exception $e) {
$notification->push($tasklist, 'horde.error');
header('Location: ' . Horde::applicationUrl('tasklists/', true));
exit;
-} elseif ($tasklist->get('owner') != Horde_Auth::getAuth() &&
- (!is_null($tasklist->get('owner')) || !Horde_Auth::isAdmin())) {
+}
+if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+ (!is_null($tasklist->get('owner')) || !Horde_Auth::isAdmin())) {
$notification->push(_("You are not allowed to delete this task list."), 'horde.error');
header('Location: ' . Horde::applicationUrl('tasklists/', true));
exit;
// Execute if the form is valid (must pass with POST variables only).
if ($form->validate(new Horde_Variables($_POST))) {
$result = $form->execute();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push($result, 'horde.error');
} elseif ($result) {
$notification->push(sprintf(_("The task list \"%s\" has been deleted."), $tasklist->get('name')), 'horde.success');
}
$vars = Horde_Variables::getDefaultVariables();
-$tasklist = $nag_shares->getShare($vars->get('t'));
-if (is_a($tasklist, 'PEAR_Error')) {
- $notification->push($tasklist, 'horde.error');
+try {
+ $tasklist = $nag_shares->getShare($vars->get('t'));
+} catch (Horde_Share_Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
header('Location: ' . Horde::applicationUrl('tasklists/', true));
exit;
-} elseif ($tasklist->get('owner') != Horde_Auth::getAuth() &&
- (!is_null($tasklist->get('owner')) || !Horde_Auth::isAdmin())) {
+}
+if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+ (!is_null($tasklist->get('owner')) || !Horde_Auth::isAdmin())) {
$notification->push(_("You are not allowed to change this task list."), 'horde.error');
header('Location: ' . Horde::applicationUrl('tasklists/', true));
exit;
if ($form->validate($vars)) {
$original_name = $tasklist->get('name');
$result = $form->execute();
- if (is_a($result, 'PEAR_Error')) {
+ if ($result instanceof PEAR_Error) {
$notification->push($result, 'horde.error');
} else {
if ($tasklist->get('name') != $original_name) {
exit;
}
-$tasklist = $nag_shares->getShare(Horde_Util::getFormData('t'));
-if (is_a($tasklist, 'PEAR_Error')) {
+try {
+ $tasklist = $nag_shares->getShare(Horde_Util::getFormData('t'));
+} catch (Horde_Share_Exception $e) {
exit;
}
$share = $GLOBALS['nag_shares']->newShare('**EXTERNAL**');
$owner = $task->tasklist_name;
} else {
- $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
- $owner = is_a($share, 'PEAR_Error') ? $task->tasklist : $share->get('name');
+ try {
+ $share = $GLOBALS['nag_shares']->getShare($task->tasklist);
+ $owner = $share->get('name');
+ } catch (Horde_Share_Exception $e) {
+ $owner = $task->tasklist;
+ }
}
require NAG_TEMPLATES . '/list/task_summaries.inc';
<tr class="<?php echo $style ?>">
<td>
<?php
-if (!is_a($share, 'PEAR_Error') &&
- $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
if (!$task->completed) {
if (!$task->childrenCompleted()) {
$label = _("Incomplete sub tasks, complete them first");
<?php endif; ?>
<td>
<?php
- if (!is_a($share, 'PEAR_Error') &&
- $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT) &&
+ if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT) &&
(!$task->private || $task->owner == Horde_Auth::getAuth())) {
$label = sprintf(_("Edit \"%s\""), $task->name);
echo Horde::link($task->edit_link, $label) . Horde::img('edit.png', $label) . '</a>';
$task_name = strlen($task->name)
? htmlspecialchars($task->name)
: _("[none]");
- if (!is_a($share, 'PEAR_Error') &&
- $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
+ if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
echo Horde::link($task->view_link, '', '', '', '', $task->desc)
. $task_name . '</a>';
} else {
<tr>
<td class="rightAlign" valign="top"><strong><?php echo _("Completed?") ?></strong></td>
<td>
- <?php if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+ <?php if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
if (empty($task->completed)) {
echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'complete_task')), _("Complete Task"), 'widget') . Horde::img('unchecked.png', _("Complete Task")) . '</a>';
} else {
if ($uid = Horde_Util::getFormData('uid')) {
$storage = Nag_Driver::singleton();
$task = $storage->getByUID($uid);
- if (is_a($task, 'PEAR_Error')) {
+ if ($task instanceof PEAR_Error) {
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
}
/* Check permissions on $tasklist_id. */
$share = $GLOBALS['nag_shares']->getShare($tasklist_id);
-if (is_a($share, 'PEAR_Error') || !$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
+if (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::READ)) {
$notification->push(_("You do not have permission to view this tasklist."), 'horde.error');
header('Location: ' . Horde::applicationUrl('list.php', true));
exit;
$taskurl = Horde_Util::addParameter('task.php',
array('task' => $task_id,
'tasklist' => $tasklist_id));
-$share = $GLOBALS['nag_shares']->getShare($tasklist_id);
-
-if (!is_a($share, 'PEAR_Error')) {
- if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
- if (!$task->completed) {
- $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'complete_task')), _("Complete"), 'smallheader', '', '', _("_Complete"));
- }
- if (!$task->private || $task->owner == Horde_Auth::getAuth()) {
- $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'modify_task')), _("Edit"), 'smallheader', '', '', _("_Edit"));
- }
+try {
+ $share = $GLOBALS['nag_shares']->getShare($tasklist_id);
+} catch (Horde_Share_Exception $e) {
+ Horde::logMessage($e->getMessage(), 'ERR');
+ throw new Nag_Exception($e);
+}
+if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
+ if (!$task->completed) {
+ $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'complete_task')), _("Complete"), 'smallheader', '', '', _("_Complete"));
}
- if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
- $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'delete_tasks')), _("Delete"), 'smallheader', '', $prefs->getValue('delete_opt') ? 'return window.confirm(\'' . addslashes(_("Really delete this task?")) . '\');' : '', _("_Delete"));
+ if (!$task->private || $task->owner == Horde_Auth::getAuth()) {
+ $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'modify_task')), _("Edit"), 'smallheader', '', '', _("_Edit"));
}
}
+if ($share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
+ $links[] = Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($taskurl, 'actionID', 'delete_tasks')), _("Delete"), 'smallheader', '', $prefs->getValue('delete_opt') ? 'return window.confirm(\'' . addslashes(_("Really delete this task?")) . '\');' : '', _("_Delete"));
+}
+
require NAG_TEMPLATES . '/common-header.inc';
require NAG_TEMPLATES . '/menu.inc';