listMemos() public static method

Retrieves the current user's note list from storage. This function will also sort the resulting list, if requested.
See also: Mnemo_Driver::listMemos()
public static listMemos ( constant $sortby = self::SORT_DESC, constant $sortdir = self::SORT_ASCEND ) : array
$sortby constant The field by which to sort. (self::SORT_DESC, self::SORT_NOTEPAD, self::SORT_MOD_DATE)
$sortdir constant The direction by which to sort. (self::SORT_ASC, self::SORT_DESC)
return array A list of the requested notes.
Exemplo n.º 1
0
 /**
  * Returns an array of UIDs for all notes that the current user is authorized
  * to see.
  *
  * @param array|string $notepads  The notepad(s) to list notes from.
  *
  * @return array  An array of UIDs for all notes the user can access.
  * @throws Mnemo_Exception
  * @throws Horde_Exception_PermissionDenied
  */
 public function listUids($notepads = null)
 {
     global $conf;
     if (!isset($conf['storage']['driver'])) {
         throw new RuntimeException('Not configured');
     }
     // Make sure we have a valid notepad.
     if (empty($notepads)) {
         $notepads = Mnemo::getSyncNotepads();
     } else {
         if (!is_array($notepads)) {
             $notepads = array($notepads);
         }
         foreach ($notepads as $notepad) {
             if (!Mnemo::hasPermission($notepad, Horde_Perms::READ)) {
                 throw new Horde_Exception_PermissionDenied();
             }
         }
     }
     // Set notepad for listMemos.
     $GLOBALS['display_notepads'] = $notepads;
     $memos = Mnemo::listMemos();
     $uids = array();
     foreach ($memos as $memo) {
         $uids[] = $memo['uid'];
     }
     return $uids;
 }
Exemplo n.º 2
0
 /**
  */
 protected function _content()
 {
     global $registry, $prefs;
     if (!empty($this->_params['show_notepad'])) {
         $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create();
     }
     $html = '';
     $memos = Mnemo::listMemos($prefs->getValue('sortby'), $prefs->getValue('sortdir'));
     foreach ($memos as $id => $memo) {
         $html .= '<tr>';
         if (!empty($this->_params['show_actions'])) {
             $editImg = Horde_Themes::img('edit.png');
             $editurl = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id']));
             $html .= '<td width="1%">' . Horde::link(htmlspecialchars(Horde::url($editurl, true)->add('actionID', 'modify_memo')), _("Edit Note")) . Horde::img($editImg, _("Edit Note")) . '</a></td>';
         }
         if (!empty($this->_params['show_notepad'])) {
             $html .= '<td>' . htmlspecialchars(Mnemo::getLabel($shares->getShare($memo['memolist_id']))) . '</td>';
         }
         $viewurl = Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id']));
         $html .= '<td>' . Horde::linkTooltip(htmlspecialchars(Horde::url($viewurl, true)), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a> <ul class="horde-tags">';
         foreach ($memo['tags'] as $tag) {
             $html .= '<li>' . htmlspecialchars($tag) . '</li>';
         }
         $html .= '</ul></td></tr>';
     }
     if (!$memos) {
         return '<p><em>' . _("No notes to display") . '</em></p>';
     }
     return '<table cellspacing="0" width="100%" class="linedRow">' . $html . '</table>';
 }
Exemplo n.º 3
0
 /**
  */
 protected function _params()
 {
     global $prefs;
     $memos = Mnemo::listMemos($prefs->getValue('sortby'), $prefs->getValue('sortdir'));
     $notes = array();
     foreach ($memos as $memo) {
         $notes[$memo['uid']] = $memo['desc'];
     }
     return array('note_uid' => array('type' => 'enum', 'name' => _("Show this note"), 'values' => $notes));
 }
Exemplo n.º 4
0
 *
 * @package Mnemo
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('mnemo');
/* Get the current action ID. */
$actionID = Horde_Util::getFormData('actionID');
/* Sort out the sorting values. */
if (Horde_Util::getFormData('sortby') !== null) {
    $prefs->setValue('sortby', Horde_Util::getFormData('sortby'));
}
if (Horde_Util::getFormData('sortdir') !== null) {
    $prefs->setValue('sortdir', Horde_Util::getFormData('sortdir'));
}
/* Get the full, sorted notepad. */
$memos = Mnemo::listMemos($prefs->getValue('sortby'), $prefs->getValue('sortdir'));
/* Page variables. */
$title = _("My Notes");
switch ($actionID) {
    case 'search_memos':
        /* If we're searching, only list those notes that match the search
         * result. */
        $search_pattern = Horde_Util::getFormData('search_pattern');
        $search_type = Horde_Util::getFormData('search_type');
        $search_desc = $search_type == 'desc';
        $search_body = $search_type == 'body';
        if (!empty($search_pattern) && ($search_body || $search_desc)) {
            $search_pattern = '/' . preg_quote($search_pattern, '/') . '/i';
            $search_result = array();
            foreach ($memos as $memo_id => $memo) {
                if ($search_desc && preg_match($search_pattern, $memo['desc']) || $search_body && preg_match($search_pattern, $memo['body'])) {
Exemplo n.º 5
0
Arquivo: List.php Projeto: horde/horde
 /**
  * Load the full, sorted task list.
  */
 protected function _loadNotes()
 {
     global $prefs;
     $this->_notes = Mnemo::listMemos($prefs->getValue('sortby'), $prefs->getValue('sortdir'));
 }
Exemplo n.º 6
0
 /**
  * @throws Mnemo_Exception
  */
 public function download(Horde_Variables $vars)
 {
     global $injector, $registry;
     switch ($vars->actionID) {
         case 'export':
             /* Get the full, sorted memo list. */
             $notes = Mnemo::listMemos();
             switch ($vars->exportID) {
                 case Horde_Data::EXPORT_CSV:
                     $data = array();
                     foreach ($notes as $note) {
                         unset($note['desc'], $note['memo_id'], $note['memolist_id'], $nore['uid']);
                         $note['tags'] = implode(',', $note['tags']);
                         if ($note['body'] instanceof Mnemo_Exception) {
                             $note['body'] = $note['body']->getMessage();
                         }
                         $data[] = $note;
                     }
                     $injector->getInstance('Horde_Core_Factory_Data')->create('Csv', array('cleanup' => array($this, 'cleanupData')))->exportFile(_("notes.csv"), $data, true);
                     exit;
             }
     }
 }