addTasklist() public static method

Creates a new share.
public static addTasklist ( array $info, boolean $display = true ) : Horde_Share
$info array Hash with tasklist information.
$display boolean Add the new tasklist to display_tasklists
return Horde_Share The new share.
示例#1
0
 public function execute()
 {
     $info = array();
     foreach (array('name', 'color', 'description', 'system') as $key) {
         $info[$key] = $this->_vars->get($key);
     }
     return Nag::addTasklist($info);
 }
示例#2
0
文件: Api.php 项目: Gomez/horde
 /**
  * Adds a new task list.
  *
  * @param string $name        Task list name.
  * @param string $description Task list description.
  * @param string $color       Task list color.
  * @param array  $params      Any addtional parameters needed. @since 4.2.1
  *     - synchronize:   (boolean) If true, add task list to the list of
  *                                task lists to syncronize.
  *                      DEFAULT: false (do not add to the list).
  *
  * @return string  The new tasklist's id.
  */
 public function addTasklist($name, $description = '', $color = '', array $params = array())
 {
     $tasklist = Nag::addTasklist(array('name' => $name, 'description' => $description, 'color' => $color));
     $name = $tasklist->getName();
     if (!empty($params['synchronize'])) {
         $sync = @unserialize($GLOBALS['prefs']->getValue('sync_lists'));
         $sync[] = $name;
         $GLOBALS['prefs']->setValue('sync_lists', serialize($sync));
     }
     return $name;
 }
示例#3
0
文件: List.php 项目: horde/horde
 /**
  * Performs a Task search. self::_tasks is populated with the results.
  *
  * @throws Nag_Exception
  */
 protected function _doSearch()
 {
     // Clear the tag browser in case we have an active browse set.
     $this->_browser->clearSearch();
     // Don't show the tag browser.
     $this->_showTagBrowser = false;
     $form = new Nag_Form_Search($this->_vars);
     if ($form->validate($this->_vars, true)) {
         $form->getInfo($this->_vars, $info);
     } else {
         throw new Nag_Exception(current($form->getErrors()));
     }
     // Text filter
     $search_pattern = $this->_vars->search_pattern;
     $search_in = empty($this->_vars->search_in) ? array() : $this->_vars->search_in;
     $search_name = in_array('search_name', $search_in) ? Nag_Search::MASK_NAME : 0;
     $search_desc = in_array('search_desc', $search_in) ? Nag_Search::MASK_DESC : 0;
     $search_tags = !empty($this->_vars->search_tags) ? Nag_Search::MASK_TAGS : 0;
     $search_completed = $this->_vars->search_completed;
     $this->_vars->set('show_completed', $search_completed);
     $mask = $search_name | $search_desc | $search_tags;
     // Date filter
     $date = $info['due_date'];
     if (empty($date)) {
         $date = array();
     }
     // Prepare the search
     $search = new Nag_Search($search_pattern, $mask, array('completed' => $search_completed, 'due' => $date, 'tags' => empty($this->_vars->search_tags) ? array() : $GLOBALS['injector']->getInstance('Nag_Tagger')->split($this->_vars->search_tags)));
     try {
         $tasks = $search->getSlice();
     } catch (Nag_Exception $e) {
         $GLOBALS['notification']->push($tasks, 'horde.error');
         $tasks = new Nag_Task();
     }
     // Save as a smart list?
     if ($id = $this->_vars->get('smart_id')) {
         // Existing list.
         $smartlist = $GLOBALS['nag_shares']->getShare($id);
         Nag::updateTasklist($smartlist, array('name' => $this->_vars->get('smartlist_name'), 'search' => serialize($search)));
         $this->_title = $smartlist->get('name');
         $this->_smartShare = $smartlist;
     } elseif ($this->_vars->get('save_smartlist')) {
         $this->_smartShare = Nag::addTasklist(array('name' => $this->_vars->get('smartlist_name'), 'search' => serialize($search)), false);
         $this->_title = $this->_vars->get('smartlist_name');
     } else {
         // Build a page title based on criteria.
         $this->_title = sprintf(_("Search: Results for"));
         $have_title = false;
         if (!empty($search_pattern)) {
             $have_title = true;
             $this->_title .= ' "' . $search_pattern . '" ';
         } else {
             $this->_title .= ' ' . _("tasks") . ' ';
         }
         if (!empty($date)) {
             if ($have_title) {
                 $this->_title .= _("and") . ' ';
             } else {
                 $this->_title .= _("with") . ' ';
                 $have_title = true;
             }
             $this->_title .= sprintf(_("due date within %d days of %s"), $date[0], $date[1]) . ' ';
         }
         if (!empty($search_tags)) {
             if ($have_title) {
                 $this->_title .= _("and") . ' ';
             } else {
                 $this->_title .= _("with") . ' ';
             }
             $this->_title .= sprintf(_("and tagged with %s"), $this->_vars->search_tags);
         }
     }
     $GLOBALS['session']->set('nag', 'search', $search, Horde_Session::TYPE_OBJECT);
     $this->_haveSearch = true;
     $this->_tasks = $tasks;
 }