listTasklists() public static method

Lists all task lists a user has access to.
public static listTasklists ( boolean $owneronly = false, integer $permission = Horde_Perms::SHOW, boolean $smart = true ) : array
$owneronly boolean Only return task lists that this user owns? Defaults to false.
$permission integer The permission to filter task lists by.
$smart boolean Include SmartLists in the results.
return array The task lists.
Beispiel #1
0
 /**
  * Add base javascript variables to the page.
  */
 protected function _addBaseVars()
 {
     global $page_output, $prefs;
     // Nag::VIEW_* constant
     switch ($prefs->getValue('show_completed')) {
         case Nag::VIEW_INCOMPLETE:
             $show_completed = 'incomplete';
             break;
         case Nag::VIEW_ALL:
             $show_completed = 'all';
             break;
         case Nag::VIEW_COMPLETE:
             $show_completed = 'complete';
             break;
         case Nag::VIEW_FUTURE:
             $show_completed = 'future';
             break;
         case Nag::VIEW_FUTURE_INCOMPLETE:
             $show_completed = 'future-incomplete';
             break;
     }
     // Tasklists. Needed in case we deep link to an existing list.
     $lists = Nag::listTasklists();
     $tasklists = array();
     foreach ($lists as $name => $list) {
         $task = new Nag_Tasklist($list);
         $tasklists[$name] = $task->toHash();
     }
     $code = array('conf' => array('showCompleted' => $show_completed, 'icons' => array('completed' => strval(Horde_Themes::img('checked.png')), 'uncompleted' => strval(Horde_Themes::img('unchecked.png')), 'smartlist' => strval(Horde_Themes::img('smart.png')), 'tasklist' => strval(Horde_Themes::img('tasklists.png')))), 'strings' => array('all' => _("All Tasks"), 'newTask' => _("New Task")), 'tasklists' => $tasklists);
     $page_output->addInlineJsVars(array('var Nag' => $code), array('top' => true));
 }
Beispiel #2
0
 /**
  * Purge completed tasks that were completed before the configured date.
  *
  * @return boolean  Whether any messages were purged from the mailbox.
  */
 public function execute()
 {
     global $injector, $prefs;
     /* Get the current UNIX timestamp minus the number of days specified
      * in 'purge_completed_keep'.  If a task has a timestamp prior to
      * this value, it will be deleted. */
     $del_time = new Horde_Date($_SERVER['REQUEST_TIME'] - $prefs->getValue('purge_completed_keep') * 86400);
     $del_time = $del_time->timestamp();
     $tasklists = Nag::listTasklists(true, Horde_Perms::DELETE, false);
     $tasks = Nag::listTasks(array('completed' => Nag::VIEW_COMPLETE, 'tasklists' => array_keys($tasklists)));
     $factory = $GLOBALS['injector']->getInstance('Nag_Factory_Driver');
     $count = 0;
     $tasks->reset();
     while ($task = $tasks->each()) {
         if ($task->completed_date && $task->completed_date < $del_time || !$task->completed_date && $task->modified && $task->modified->timestamp() < $del_time) {
             try {
                 $factory->create($task->tasklist)->delete($task->id);
                 ++$count;
             } catch (Nag_Exception $e) {
                 Horde::log($e->getMessage(), 'ERR');
             }
         }
     }
     $GLOBALS['notification']->push(sprintf(ngettext("Purging %d completed task.", "Purging %d completed tasks.", $count), $count), 'horde.message');
     return true;
 }
Beispiel #3
0
 /**
  * Retrieves one or multiple tasks from the database by UID.
  *
  * @param string|array $uid  The UID(s) of the task to retrieve.
  * @param array $tasklists   An optional array of tasklists to search.
  * @param boolean $getall    If true, return all instances of the task,
  *                           otherwise only one. Attempts to find the
  *                           instance owned by the current user.
  *
  * @return Nag_Task  A Nag_Task object.
  * @throws Horde_Exception_NotFound
  * @throws Nag_Exception
  */
 public function getByUID($uids, array $tasklists = null, $getall = true)
 {
     $results = $this->_getBy($uids, 'task_uid', $tasklists);
     if ($getall) {
         return $results;
     }
     $owner_lists = Nag::listTasklists(true);
     $task = null;
     $results->reset();
     while ($row = $results->each()) {
         if (isset($owner_lists[$row->tasklist])) {
             $task = $row;
             break;
         }
     }
     if (empty($task)) {
         $readable_lists = Nag::listTasklists();
         foreach ($results as $row) {
             if (isset($readable_lists[$row->tasklist])) {
                 $task = $row;
                 break;
             }
         }
     }
     if (empty($task)) {
         throw new Horde_Exception_NotFound();
     }
     return $task;
 }
Beispiel #4
0
 /**
  * Ensure the share system has a default tasklist share for the current user
  * if the default share feature is activated.
  *
  * @return string|NULL The id of the new default share or NULL if no share
  *                     was created.
  */
 public function ensureDefaultShare()
 {
     /* If the user doesn't own a task list, create one. */
     if (!empty($this->_params['auto_create']) && $this->_user && !count(Nag::listTasklists(true))) {
         $share = $this->_shares->newShare($this->_user, strval(new Horde_Support_Randomid()), $this->_getDefaultShareName());
         $share->set('color', Nag::randomColor());
         $this->_prepareDefaultShare($share);
         $this->_shares->addShare($share);
         return $share->getName();
     }
 }
Beispiel #5
0
 public function getTaskLists()
 {
     $lists = Nag::listTasklists();
     $results = array();
     foreach ($lists as $name => $list) {
         $tasklist = new Nag_Tasklist($list);
         $results[$name] = $tasklist->toHash();
     }
     $return = new stdClass();
     $return->tasklists = $results;
     return $return;
 }
Beispiel #6
0
 /**
  * Const'r
  *
  * @param Horde_Form_Variables $vars  The form variables.
  * @param string $title               The form title.
  *
  * @return Nag_Form_Task
  */
 public function __construct($vars, $title = '')
 {
     global $injector, $nag_shares, $prefs, $registry;
     parent::__construct($vars, $title);
     $user = $registry->getAuth();
     $tasklist_enums = array();
     foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $tl_id => $tl) {
         if (!$tl->hasPermission($user, Horde_Perms::EDIT)) {
             continue;
         }
         $tasklist_enums[$tl_id] = Nag::getLabel($tl);
     }
     $tasklist = $vars->get('tasklist_id');
     if (empty($tasklist)) {
         reset($tasklist_enums);
         $tasklist = key($tasklist_enums);
     }
     $priorities = array(1 => '1 ' . _("(highest)"), 2 => 2, 3 => 3, 4 => 4, 5 => '5 ' . _("(lowest)"));
     $this->addHidden('', 'mobile', 'boolean', false);
     $this->addHidden('', 'task_id', 'text', false);
     $this->addHidden('', 'old_tasklist', 'text', false);
     $this->addHidden('', 'url', 'text', false);
     $this->addHidden('', 'uid', 'text', false);
     $this->addHidden('', 'owner', 'text', false);
     $this->addHidden('', 'list', 'text', false);
     $this->addHidden('', 'tab_name', 'text', false);
     $this->setSection(self::SECTION_GENERAL, _("General"));
     $this->addVariable(_("Name"), 'name', 'text', true);
     if (!$prefs->isLocked('default_tasklist') && count($tasklist_enums) > 1) {
         $v = $this->addVariable(_("Task List"), 'tasklist_id', 'enum', true, false, false, array($tasklist_enums));
         if (!$vars->get('mobile')) {
             $v->setAction(Horde_Form_Action::factory('reload'));
         }
     }
     if (!$vars->get('mobile')) {
         $tasks = Nag::listTasks(array('tasklists' => array($tasklist), 'complete' => Nag::VIEW_FUTURE_INCOMPLETE, 'include_history' => false));
         $task_enums = array('' => _("No parent task"));
         $tasks->reset();
         while ($task = $tasks->each()) {
             if ($vars->get('task_id') == $task->id) {
                 continue;
             }
             $task_enums[htmlspecialchars($task->id)] = str_repeat('&nbsp;', $task->indent * 4) . htmlspecialchars($task->name);
         }
         $v = $this->addVariable(_("Parent task"), 'parent', 'enum', false, false, false, array($task_enums));
         $v->setOption('htmlchars', true);
     }
     $this->addVariable(_("Tags"), 'tags', 'Nag:NagTags', false);
     // Only display the delete button if this is an existing task and the
     // user has HORDE_PERMS::DELETE
     $share = $nag_shares->getShare($tasklist);
     $delete = $share->hasPermission($registry->getAuth(), Horde_Perms::DELETE) && $vars->get('task_id');
     if (!$vars->get('mobile')) {
         $users = $share->listUsers(Horde_Perms::READ);
         $groups = $share->listGroups(Horde_Perms::READ);
         if (count($groups)) {
             $horde_group = $injector->getInstance('Horde_Group');
             foreach ($groups as $group) {
                 $users = array_merge($users, $horde_group->listUsers($group));
             }
         }
         if (empty($GLOBALS['conf']['assignees']['allow_external'])) {
             $users = array_flip($users);
             if (count($users)) {
                 foreach (array_keys($users) as $user) {
                     $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create($user);
                     $fullname = $identity->getValue('fullname');
                     $users[$user] = strlen($fullname) ? $fullname : $user;
                 }
             }
             $this->addVariable(_("Assignee"), 'assignee', 'enum', false, false, null, array($users, _("None")));
         } else {
             $this->addVariable(_("Assignee"), 'assignee', 'Nag:NagContact', false);
         }
     }
     $this->addVariable(_("Private?"), 'private', 'boolean', false);
     $this->addVariable(_("Due By"), 'due', 'Nag:NagDue', false);
     if (!$vars->get('mobile')) {
         $this->addVariable(_("Delay Start Until"), 'start', 'Nag:NagStart', false);
     }
     $this->addVariable(_("Alarm"), 'alarm', 'Nag:NagAlarm', false);
     if (!$vars->get('mobile')) {
         $v = $this->addVariable(_("Notification"), 'methods', 'Nag:NagMethod', false);
         $v->setAction(Horde_Form_Action::factory('reload'));
         $v = $this->addVariable(_("Priority"), 'priority', 'enum', false, false, false, array($priorities));
         $v->setDefault(3);
         $this->addVariable(_("Estimated Time"), 'estimate', 'number', false);
         $this->addVariable(_("Actual Time"), 'actual', 'number', false);
         $this->_completedVar = $this->addVariable(_("Completed?"), 'completed', 'boolean', false);
         $this->setSection(self::SECTION_RECUR, _("Recurrence"));
         $this->addVariable(_("Recurrence"), 'recurrence', 'Nag:NagRecurrence', false);
     }
     $this->setSection(self::SECTION_DESC, _("Description"));
     try {
         $description = Horde::callHook('description_help', array(), 'nag');
     } catch (Horde_Exception_HookNotSet $e) {
         $description = '';
     }
     $this->addVariable(_("Description"), 'desc', 'longtext', false, false, $description);
     $buttons = array(array('value' => _("Save")));
     if ($delete) {
         $buttons[] = array('value' => _("Delete"), 'name' => 'deletebutton', 'class' => 'horde-delete');
     }
     if (!$vars->get('task_id')) {
         $buttons[] = array('value' => _("Save and New"), 'name' => 'savenewbutton', 'class' => 'horde-create');
     }
     if (Horde_Util::getFormData('have_search')) {
         $buttons[] = array('value' => _("Return to Search Results"), 'name' => 'search_return', 'class' => 'horde-button');
     }
     $this->setButtons($buttons);
 }
Beispiel #7
0
 /**
  */
 protected function _content()
 {
     global $conf, $prefs, $registry;
     $html = '';
     if (!empty($this->_params['show_alarms'])) {
         $messages = array();
         try {
             $alarmList = Nag::listAlarms($_SERVER['REQUEST_TIME']);
         } catch (Nag_Exception $e) {
             return '<em>' . htmlspecialchars($e->getMessage()) . '</em>';
         }
         foreach ($alarmList as $task) {
             $differential = $task->getNextDue()->timestamp() - $_SERVER['REQUEST_TIME'];
             $key = $differential;
             while (isset($messages[$key])) {
                 $key++;
             }
             $viewurl = Horde::url('view.php', true)->add(array('task' => $task->id, 'tasklist' => $task->tasklist));
             $link = $viewurl->link() . (!empty($task->name) ? htmlspecialchars($task->name) : _("[none]")) . '</a>';
             if ($differential >= -60 && $differential < 60) {
                 $messages[$key] = sprintf(_("%s is due now."), $link);
             } elseif ($differential >= 60) {
                 $messages[$key] = sprintf(_("%s is due in %s"), $link, Nag::secondsToString($differential));
             }
         }
         ksort($messages);
         foreach ($messages as $message) {
             $html .= '<tr><td class="control">' . Horde::img('alarm_small.png') . '&nbsp;&nbsp;<strong>' . $message . '</strong></td></tr>';
         }
         if (!empty($messages)) {
             $html .= '</table><br /><table cellspacing="0" width="100%" class="linedRow">';
         }
     }
     $i = 0;
     try {
         $tasks = Nag::listTasks(array('tasklists' => isset($this->_params['show_tasklists']) ? $this->_params['show_tasklists'] : array_keys(Nag::listTasklists(false, Horde_Perms::READ)), 'completed' => empty($this->_params['show_completed']) ? Nag::VIEW_INCOMPLETE : Nag::VIEW_ALL, 'include_history' => false));
     } catch (Nag_Exception $e) {
         return '<em>' . htmlspecialchars($e->getMessage()) . '</em>';
     }
     $tasks->reset();
     while ($task = $tasks->each()) {
         $due = $task->due ? $task->getNextDue() : null;
         // Only print tasks due in the past if the show_overdue flag is on.
         if ($due && $due->before($_SERVER['REQUEST_TIME']) && empty($this->_params['show_overdue'])) {
             continue;
         }
         if ($task->completed) {
             $class = 'closed';
         } elseif ($due && $due->before($_SERVER['REQUEST_TIME'])) {
             $class = 'overdue';
         } else {
             $class = '';
         }
         $style = ' style="background-color:' . $task->backgroundColor() . ';color:' . $task->foregroundColor() . '"';
         $html .= '<tr class="' . $class . '">';
         if (!empty($this->_params['show_actions'])) {
             $taskurl = Horde::url('task.php', true)->add(array('task' => $task->id, 'tasklist' => $task->tasklist, 'url' => Horde::selfUrl(true)));
             $label = sprintf(_("Edit \"%s\""), $task->name);
             $html .= '<td width="1%"' . $style . '>' . $taskurl->copy()->add('actionID', 'modify_task')->link() . Horde::img('edit-sidebar-' . substr($task->foregroundColor(), 1) . '.png', $label) . '</a></td>';
             if ($task->completed) {
                 $html .= '<td width="1%">' . $style . '' . Horde::img('checked.png', _("Completed")) . '</td>';
             } else {
                 $label = sprintf(_("Complete \"%s\""), $task->name);
                 $html .= '<td width="1%"' . $style . '>' . Horde::url($conf['urls']['pretty'] == 'rewrite' ? 't/complete' : 'task/complete.php')->add(array('task' => $task->id, 'tasklist' => $task->tasklist, 'url' => Horde::selfUrl(true)))->link() . Horde::img('unchecked.png', $label) . '</a></td>';
             }
         }
         if (!empty($this->_params['show_pri'])) {
             $html .= '<td align="center"' . $style . '>&nbsp;' . Nag::formatPriority($task->priority) . '&nbsp;</td>';
         }
         if (!empty($this->_params['show_tasklist'])) {
             $html .= '<td width="1%" class="nowrap"' . $style . '>' . htmlspecialchars(Nag::getLabel($GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create()->getShare($task->tasklist))) . '&nbsp;</td>';
         }
         $html .= '<td' . $style . '>';
         $viewurl = Horde::url('view.php', true)->add(array('task' => $task->id, 'tasklist' => $task->tasklist));
         $html .= $task->treeIcons() . $viewurl->link(array('title' => $task->desc, 'style' => 'color:' . $task->foregroundColor())) . (!empty($task->name) ? htmlspecialchars($task->name) : _("[none]")) . '</a>';
         if ($due && empty($task->completed) && !empty($this->_params['show_due'])) {
             $html .= ' (' . $due->strftime($prefs->getValue('date_format')) . ')';
         }
         $html .= '</td>';
         $html .= "</tr>\n";
     }
     if (empty($html)) {
         return '<em>' . _("No tasks to display") . '</em>';
     }
     return '<table cellspacing="0" width="100%" class="linedRow">' . $html . '</table>';
 }
Beispiel #8
0
 /**
  * Retrieves one or multiple tasks from the database by UID.
  *
  * @param string|array $uid  The UID(s) of the task to retrieve.
  * @param array $tasklists   An optional array of tasklists to search.
  * @param boolean $getall    If true, return all instances of the task,
  *                           otherwise only one. Attempts to find the
  *                           instance owned by the current user.
  *
  * @return Nag_Task  A Nag_Task object.
  * @throws Horde_Exception_NotFound
  * @throws Nag_Exception
  */
 public function getByUID($uids, array $tasklists = null, $getall = true)
 {
     if (!is_array($tasklists)) {
         $tasklists = array_keys(Nag::listTasklists(false, Horde_Perms::READ, false));
     }
     $results = array();
     foreach ($tasklists as $tasklist) {
         $this->_tasklist = $tasklist;
         try {
             $results[] = $this->get(Horde_Url::uriB64Encode($uid));
         } catch (Horde_Exception_NotFound $e) {
         }
     }
     if ($getall && count($results) == 1) {
         return $results[0];
     } elseif ($getall) {
         $task = new Nag_Task();
         foreach ($results as $row) {
             $task->add($row);
         }
     } else {
         $ownerlists = Nag::listTasklists(true);
         $task = null;
         foreach ($results as $row) {
             if (isset($ownerlists[$row->tasklist])) {
                 $task = $row;
                 break;
             }
         }
         if (empty($task)) {
             $readablelists = Nag::listTasklists();
             foreach ($results as $row) {
                 if (isset($readablelists[$row->tasklist])) {
                     $task = $row;
                     break;
                 }
             }
         }
     }
     if (empty($task)) {
         throw new Horde_Exception_NotFound();
     }
     return $task;
 }
Beispiel #9
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     global $nag_shares, $prefs;
     $vars = Horde_Variables::getDefaultVariables();
     $registry = $this->getInjector()->getInstance('Horde_Registry');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     $form = new Nag_Form_Task($vars, $vars->get('task_id') ? sprintf(_("Edit: %s"), $vars->get('name')) : _("New Task"));
     if (!$form->validate($vars)) {
         // Hideous
         $_REQUEST['actionID'] = 'task_form';
         require NAG_BASE . '/task.php';
         exit;
     }
     $form->getInfo($vars, $info);
     // Check if we are here due to a search_return push.
     if ($vars->search_return) {
         Horde::url('list.php', true)->add(array('actionID' => 'search_return', 'list' => $vars->list, 'tab_name' => $vars->tab_name))->redirect();
     }
     // Check if we are here due to a deletebutton push
     if ($vars->deletebutton) {
         try {
             $share = $nag_shares->getShare($info['old_tasklist']);
         } catch (Horde_Share_Exception $e) {
             $notification->push(sprintf(_("Access denied deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
             $notification->push(_("Access denied deleting task"), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         try {
             $storage->delete($info['task_id']);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
         $notification->push(_("Task successfully deleted"), 'horde.success');
         Horde::url('list.php', true)->redirect();
     }
     if ($prefs->isLocked('default_tasklist') || count(Nag::listTasklists(false, Horde_Perms::EDIT, false)) <= 1) {
         $info['tasklist_id'] = $info['old_tasklist'] = Nag::getDefaultTasklist(Horde_Perms::EDIT);
     }
     try {
         $share = $nag_shares->getShare($info['tasklist_id']);
     } catch (Horde_Share_Exception $e) {
         $notification->push(sprintf(_("Access denied saving task: %s"), $e->getMessage()), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     if (!$share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
         $notification->push(_("Access denied saving task to this task list."), 'horde.error');
         Horde::url('list.php', true)->redirect();
     }
     /* If a task id is set, we're modifying an existing task.  Otherwise,
      * we're adding a new task with the provided attributes. */
     if (!empty($info['task_id']) && !empty($info['old_tasklist'])) {
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['old_tasklist']);
         $info['tasklist'] = $info['tasklist_id'];
         $result = $storage->modify($info['task_id'], $info);
     } else {
         /* Check permissions. */
         $perms = $this->getInjector()->getInstance('Horde_Core_Perms');
         if ($perms->hasAppPermission('max_tasks') !== true && $perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
             Horde::url('list.php', true)->redirect();
         }
         /* Creating a new task. */
         $storage = $this->getInjector()->getInstance('Nag_Factory_Driver')->create($info['tasklist_id']);
         // These must be unset since the form sets them to NULL
         unset($info['owner']);
         unset($info['uid']);
         try {
             $newid = $storage->add($info);
         } catch (Nag_Exception $e) {
             $notification->push(sprintf(_("There was a problem saving the task: %s."), $e->getMessage()), 'horde.error');
             Horde::url('list.php', true)->redirect();
         }
     }
     $notification->push(sprintf(_("Saved %s."), $info['name']), 'horde.success');
     /* Return to the last page or to the task list. */
     if ($vars->savenewbutton) {
         $url = Horde::url('task.php', true)->add(array('actionID' => 'add_task', 'tasklist_id' => $info['tasklist_id'], 'parent' => $info['parent']));
     } else {
         $url = Horde_Util::getFormData('url', (string) Horde::url('list.php', true));
         $url = Horde::url($url, true);
     }
     $response->setRedirectUrl($url);
 }
Beispiel #10
0
    }
    if (!$haveDefault) {
        $sync[] = $default;
        $GLOBALS['prefs']->setValue('sync_lists', serialize($sync));
    }
});
// store the task lists to diplay
$_prefs['display_tasklists'] = array('value' => 'a:0:{}');
// Tasklists use for synchronization
$_prefs['sync_lists'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Select the task lists that, in addition to the default, should be used for synchronization with external devices:"), 'on_init' => function ($ui) {
    $enum = array();
    $sync = @unserialize($GLOBALS['prefs']->getValue('sync_lists'));
    if (empty($sync)) {
        $GLOBALS['prefs']->setValue('sync_lists', serialize(array(Nag::getDefaultTasklist(Horde_Perms::DELETE))));
    }
    foreach (Nag::listTasklists(false, Horde_Perms::DELETE, false) as $key => $list) {
        if ($list->getName() != Nag::getDefaultTasklist(Horde_Perms::DELETE)) {
            $enum[$key] = Nag::getLabel($list);
        }
    }
    $ui->prefs['sync_lists']['enum'] = $enum;
}, 'on_change' => function () {
    $sync = @unserialize($GLOBALS['prefs']->getValue('sync_lists'));
    $haveDefault = false;
    $default = Nag::getDefaultTasklist(Horde_Perms::DELETE);
    foreach ($sync as $cid) {
        if ($cid == $default) {
            $haveDefault = true;
            break;
        }
    }
Beispiel #11
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     global $registry;
     switch ($params['id']) {
         case 'menu':
             $add = Horde::url('task.php', true)->add('actionID', 'add_task');
             $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Task"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add)));
             $user = $registry->getAuth();
             foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $name => $tasklist) {
                 if (!$tasklist->hasPermission($user, Horde_Perms::EDIT)) {
                     continue;
                 }
                 $tree->addNode(array('id' => $parent . $name . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), Nag::getLabel($tasklist)), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add->copy()->add('tasklist_id', $name))));
             }
             $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php'))));
             break;
     }
 }
Beispiel #12
0
 /**
  * Returns a list of available sources.
  *
  * @param boolean $writeable  If true, limits to writeable sources.
  * @param boolean $sync_only  Only include synchable address books.
  *
  * @return array  An array of the available sources. Keys are source IDs,
  *                values are source titles.
  * @since 4.2.0
  */
 public function sources($writeable = false, $sync_only = false)
 {
     $out = array();
     foreach (Nag::listTasklists(false, $writeable ? Horde_Perms::EDIT : Horde_Perms::READ, false) as $key => $val) {
         $out[$key] = $val->get('name');
     }
     if ($sync_only) {
         $syncable = Nag::getSyncLists();
         $out = array_intersect_key($out, array_flip($syncable));
     }
     return $out;
 }
Beispiel #13
0
                $row[$field] = 0;
            }
        }
        try {
            $nag_storage->add($row);
        } catch (Nag_Exception $e) {
            $haveError = true;
            $notification->push(sprintf(_("There was an error importing the data: %s"), $e->getMessage()), 'horde.error');
            break;
        }
        $num_tasks++;
    }
    if (!count($next_step)) {
        $notification->push(sprintf(_("The %s file didn't contain any tasks."), $file_types[$storage->get('format')]), 'horde.error');
    } elseif (empty($haveError)) {
        $notification->push(sprintf(_("%s successfully imported"), $file_types[$storage->get('format')]), 'horde.success');
    }
    $next_step = $data->cleanup();
}
$import_tasklists = $export_tasklists = array();
if ($GLOBALS['registry']->getAuth()) {
    $import_tasklists = Nag::listTasklists(false, Horde_Perms::EDIT);
}
$export_tasklists = Nag::listTasklists(false, Horde_Perms::READ);
$page_output->header(array('title' => _("Import/Export Tasks")));
Nag::status();
foreach ($templates[$next_step] as $template) {
    require $template;
    echo '<br />';
}
$page_output->footer();
Beispiel #14
0
 /**
  * Renders the view.
  *
  * @param Horde_PageOutput $output  The output object.
  *
  * @return string  The HTML needed to render the view.
  */
 public function render($output)
 {
     global $injector, $prefs;
     $output->addScriptFile('tooltips.js', 'horde');
     $output->addScriptFile('scriptaculous/effects.js', 'horde');
     $output->addScriptFile('quickfinder.js', 'horde');
     $output->header(array('title' => $this->_title));
     $tabs = new Horde_Core_Ui_Tabs('tab_name', $this->_vars);
     if (!$GLOBALS['prefs']->isLocked('show_completed')) {
         $listurl = Horde::url('list.php');
         $tabs->addTab(_("_All tasks"), $listurl->add('show_completed', Nag::VIEW_ALL), Nag::VIEW_ALL);
         $tabs->addTab(_("Incom_plete tasks"), $listurl->add('show_completed', Nag::VIEW_INCOMPLETE), Nag::VIEW_INCOMPLETE);
         $tabs->addTab(_("_Future tasks"), $listurl->add('show_completed', Nag::VIEW_FUTURE), Nag::VIEW_FUTURE);
         $tabs->addTab(_("_Completed tasks"), $listurl->add('show_completed', Nag::VIEW_COMPLETE), Nag::VIEW_COMPLETE);
     }
     foreach (Nag::listTasklists() as $list) {
         if ($list->get('issmart')) {
             $tabs->addTab($list->get('name'), $listurl->add(array('actionID' => 'smart', 'list' => $list->getName())), array('img' => 'search.png', 'tabname' => $list->getName()));
         }
     }
     // Set up the view
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addHelper(new Nag_View_Helper_List($view));
     $view->tasks = $this->_tasks;
     $view->tabs = $tabs->render($this->_vars->get('tab_name', $prefs->getValue('show_completed')));
     $view->browser = empty($this->_smartShare) && $this->_showTagBrowser ? $this->_getRelatedTags() . $this->_getTagTrail() : '';
     $view->title = $this->_title;
     $view->sortby = $prefs->getValue('sortby');
     $view->sortdir = $prefs->getValue('sortdir');
     $view->sortdirclass = $view->sortdir ? 'sortup' : 'sortdown';
     $view->dateFormat = $prefs->getValue('date_format');
     $view->columns = @unserialize($prefs->getValue('tasklist_columns'));
     $view->smartShare = $this->_smartShare;
     $view->haveSearch = $this->_haveSearch;
     $view->tab_name = $this->_vars->get('tab_name', $prefs->getValue('show_completed'));
     if (empty($view->columns)) {
         $view->columns = array();
     }
     $view->dynamic_sort = true;
     $view->baseurl = Horde::url('list.php');
     if ($this->_vars->actionID == 'search_tasks') {
         $view->baseurl->add(array('actionID' => 'search_tasks', 'search_pattern' => $search_pattern, 'search_name' => $search_name ? 'on' : 'off', 'search_desc' => $search_desc ? 'on' : 'off'));
     }
     $view->tasks->reset();
     Horde::startBuffer();
     Nag::status();
     echo $view->render('list');
     $output->footer();
     return Horde::endBuffer();
 }
Beispiel #15
0
 /**
  * Return tasklists the current user has PERMS_EDIT on.
  * See Bug: 13837.
  *
  * @return array  A hash of tasklist objects.
  */
 protected function _getTasklists()
 {
     $tasklist_enums = array();
     $user = $GLOBALS['registry']->getAuth();
     foreach (Nag::listTasklists(false, Horde_Perms::SHOW, false) as $tl_id => $tl) {
         if (!$tl->hasPermission($user, Horde_Perms::EDIT)) {
             continue;
         }
         $tasklist_enums[$tl_id] = Nag::getLabel($tl);
     }
     return $tasklist_enums;
 }
Beispiel #16
0
 /**
  * Retrieves one task from the database by UID.
  *
  * @param string $uid  The UID of the task to retrieve.
  *
  * @return array  The array of task attributes.
  */
 public function getByUID($uid)
 {
     foreach (array_keys(Nag::listTasklists(false, Horde_Perms::READ, false)) as $tasklist) {
         $this->_tasklist = $tasklist;
         try {
             return $this->get(Horde_Url::uriB64Encode($uid));
         } catch (Horde_Exception_NotFound $e) {
         }
     }
     throw new Horde_Exception_NotFound();
 }