listNotepads() public static method

This method takes the $conf['share']['hidden'] setting into account. If this setting is enabled, even if requesting permissions different than SHOW, it will only return calendars that the user owns or has SHOW permissions for. For checking individual calendar's permissions, use hasPermission() instead.
public static listNotepads ( boolean $owneronly = false, integer $permission = Horde_Perms::SHOW ) : array
$owneronly boolean Only return memo lists that this user owns? Defaults to false.
$permission integer The permission to filter notepads by.
return array The memo lists.
Beispiel #1
0
 /**
  * Ensure the share system has a default notepad 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 notepad, create one. */
     if (!empty($this->_params['auto_create']) && $this->_user && !count(Mnemo::listNotepads(true))) {
         $share = $this->_shares->newShare($this->_user, strval(new Horde_Support_Randomid()), $this->_getDefaultShareName());
         $this->_prepareDefaultShare($share);
         $this->_shares->addShare($share);
         return $share->getName();
     }
 }
Beispiel #2
0
$view->title = $title;
$view->url = Horde::url('memo.php');
if (!$view->modify || !$view->passphrase) {
    $injector->getInstance('Horde_Core_Factory_Imple')->create('Mnemo_Ajax_Imple_TagAutoCompleter', array('id' => 'memo_tags'));
    $view->body = $memo_body;
    $view->count = sprintf(_("%s characters"), '<span id="mnemo-count">' . Horde_String::length(str_replace(array("\r", "\n"), '', $memo_body)) . '</span>');
    $view->encrypted = $memo_encrypted;
    $view->encryption = $storage->encryptionSupported();
    try {
        $view->help = Horde::callHook('description_help', array(), 'mnemo', '');
    } catch (Horde_Exception_HookNotSet $e) {
    }
    $view->loadingImg = Horde::img('loading.gif', _("Loading..."));
    $view->notepads = array();
    if (!$prefs->isLocked('default_notepad')) {
        foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $id => $notepad) {
            if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) {
                continue;
            }
            $view->notepads[] = array('id' => $id, 'selected' => $id == $memolist_id, 'label' => Mnemo::getLabel($notepad));
        }
    }
    $view->tags = implode(', ', $memo_tags);
    if ($memo_id && $mnemo_shares->getShare($memolist_id)->hasPermission($user, Horde_Perms::DELETE)) {
        $view->delete = Horde::url('memo.php')->add(array('memo' => $memo_id, 'memolist' => $memolist_id, 'actionID' => 'delete_memos'));
    }
}
$page_output->addScriptFile('memo.js');
$page_output->header(array('title' => $title));
$notification->notify();
echo $view->render('memo/memo');
Beispiel #3
0
            break;
        }
    }
    if (!$haveDefault) {
        $sync[] = $default;
        $GLOBALS['prefs']->setValue('sync_notepads', serialize($sync));
    }
});
// Sync
$_prefs['sync_notepads'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Select the notepads 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_notepads'));
    if (empty($sync)) {
        $GLOBALS['prefs']->setValue('sync_notepads', serialize(array(Mnemo::getDefaultNotepad(Horde_Perms::DELETE))));
    }
    foreach (Mnemo::listNotepads(false, Horde_Perms::DELETE) as $key => $list) {
        if ($list->getName() != Mnemo::getDefaultNotepad(Horde_Perms::DELETE)) {
            $enum[$key] = Mnemo::getLabel($list);
        }
    }
    $ui->prefs['sync_notepads']['enum'] = $enum;
}, 'on_change' => function () {
    $sync = @unserialize($GLOBALS['prefs']->getValue('sync_notepads'));
    $haveDefault = false;
    $default = Mnemo::getDefaultNotepad(Horde_Perms::DELETE);
    foreach ($sync as $cid) {
        if ($cid == $default) {
            $haveDefault = true;
            break;
        }
    }
Beispiel #4
0
 /**
  * Returns a list of available sources.
  *
  * @param boolean $writeable  If true, limits to writeable sources.
  * @param boolean $sync_only  Only include synchable notepads.
  *
  * @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 (Mnemo::listNotepads(false, $writeable ? Horde_Perms::EDIT : Horde_Perms::READ) as $key => $val) {
         $out[$key] = $val->get('name');
     }
     if ($sync_only) {
         $syncable = Mnemo::getSyncNotepads();
         $out = array_intersect_key($out, array_flip($syncable));
     }
     return $out;
 }
Beispiel #5
0
 /**
  */
 public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array())
 {
     global $registry;
     $add = Horde::url('memo.php', true)->add('actionID', 'add_memo');
     $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Note"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add)));
     $user = $registry->getAuth();
     foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $name => $notepad) {
         if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) {
             continue;
         }
         $tree->addNode(array('id' => $parent . $name . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), Mnemo::getLabel($notepad)), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add->copy()->add('memolist', $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'))));
 }
Beispiel #6
0
 /**
  * Retrieves one note from the backend by UID.
  *
  * @param string $uid         The UID of the note to retrieve.
  * @param string $passphrase  A passphrase with which this note was
  *                            supposed to be encrypted.
  *
  * @return array  The array of note attributes.
  * @throws Mnemo_Exception
  * @throws Horde_Exception_NotFound
  */
 public function getByUID($uid, $passphrase = null)
 {
     if (empty($this->_notepad)) {
         $notepads = Mnemo::listNotepads(false, Horde_Perms::READ);
     } else {
         $notepads = array($this->_notepad => true);
     }
     foreach (array_keys($notepads) as $notepad) {
         if ($notepad != $this->_notepad) {
             $this->_data = null;
         }
         $this->_notepad = $notepad;
         try {
             return $this->get(Horde_Url::uriB64Encode($uid), $passphrase);
         } catch (Horde_Exception_NotFound $e) {
         }
     }
 }