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. |
public static function listMemos($sortby = self::SORT_DESC, $sortdir = self::SORT_ASCEND)
{
global $conf, $display_notepads;
$memos = array();
/* Sort the memo list. */
$sort_functions = array(self::SORT_DESC => 'ByDesc', self::SORT_NOTEPAD => 'ByNotepad', self::SORT_MOD_DATE => 'ByModDate');
foreach ($display_notepads as $notepad) {
$storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($notepad);
try {
$storage->retrieve();
} catch (Mnemo_Exception $e) {
$GLOBALS['notification']->push($e, 'horde.error');
}
$newmemos = $storage->listMemos();
$memos = array_merge($memos, $newmemos);
}
// Sort the array if we have a sort function defined
if (isset($sort_functions[$sortby])) {
$prefix = $sortdir == self::SORT_DESCEND ? '_rsort' : '_sort';
uasort($memos, array('Mnemo', $prefix . $sort_functions[$sortby]));
}
return $memos;
}
/** * 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; }