getDefaultNotepad() public static method

Returns the default notepad for the current user at the specified permissions level.
public static getDefaultNotepad ( integer $permission = Horde_Perms::SHOW ) : string
$permission integer Horde_Perms constant for permission level required.
return string The notepad identifier, or null if none.
Esempio n. 1
0
 /**
  * Add additional items to the sidebar.
  *
  * @param Horde_View_Sidebar $sidebar  The sidebar object.
  */
 public function sidebar($sidebar)
 {
     $perms = $GLOBALS['injector']->getInstance('Horde_Core_Perms');
     if (Mnemo::getDefaultNotepad(Horde_Perms::EDIT) && ($perms->hasAppPermission('max_notes') === true || $perms->hasAppPermission('max_notes') > Mnemo::countMemos())) {
         $sidebar->addNewButton(_("_New Note"), Horde::url('memo.php')->add('actionID', 'add_memo'));
     }
     $url = Horde::url('');
     $edit = Horde::url('notepads/edit.php');
     $user = $GLOBALS['registry']->getAuth();
     $sidebar->containers['my'] = array('header' => array('id' => 'mnemo-toggle-my', 'label' => _("My Notepads"), 'collapsed' => false));
     if (!$GLOBALS['prefs']->isLocked('default_notepad')) {
         $sidebar->containers['my']['header']['add'] = array('url' => Horde::url('notepads/create.php'), 'label' => _("Create a new Notepad"));
     }
     $sidebar->containers['shared'] = array('header' => array('id' => 'mnemo-toggle-shared', 'label' => _("Shared Notepads"), 'collapsed' => true));
     foreach (Mnemo::listNotepads() as $name => $notepad) {
         $url->add(array('display_notepad' => $name, 'actionID' => in_array($name, $GLOBALS['display_notepads']) ? 'remove_displaylist' : 'add_displaylist'));
         $row = array('selected' => in_array($name, $GLOBALS['display_notepads']), 'url' => $url, 'label' => Mnemo::getLabel($notepad), 'color' => $notepad->get('color') ?: '#dddddd', 'edit' => $edit->add('n', $notepad->getName()), 'type' => 'checkbox');
         if ($notepad->get('owner') == $user) {
             $sidebar->addRow($row, 'my');
         } else {
             $sidebar->addRow($row, 'shared');
         }
     }
 }
Esempio n. 2
0
File: memo.php Progetto: horde/horde
$actionID = Horde_Util::getFormData('actionID');
if (is_null($actionID)) {
    Horde::url('list.php', true)->redirect();
}
/* Run through the action handlers. */
switch ($actionID) {
    case 'add_memo':
        /* Check permissions. */
        if ($injector->getInstance('Horde_Core_Perms')->hasAppPermission('max_notes') !== true && $injector->getInstance('Horde_Core_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
            Horde::permissionDeniedError('mnemo', 'max_notes', sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Core_Perms')->hasAppPermission('max_notes')));
            Horde::url('list.php', true)->redirect();
        }
        /* Set up the note attributes. */
        if (empty($memolist_id)) {
            try {
                $memolist_id = Mnemo::getDefaultNotepad();
            } catch (Mnemo_Exception $e) {
                $notification->push($e);
                Horde::url('list.php', true)->redirect();
            }
        }
        if (!getShare($memolist_id)->hasPermission($user, Horde_Perms::EDIT)) {
            $notification->push(_("Access denied addings notes to this notepad."), 'horde.error');
            Horde::url('list.php', true)->redirect();
        }
        $memo_id = null;
        $memo_body = '';
        $memo_encrypted = $show_passphrase = false;
        $storage = $injector->getInstance('Mnemo_Factory_Driver')->create();
        $memo_tags = array();
        $title = _("New Note");
Esempio n. 3
0
$_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;
        }
    }
    if (!$haveDefault) {
        $sync[] = $default;
        $GLOBALS['prefs']->setValue('sync_notepads', serialize($sync));
    }
    if ($GLOBALS['conf']['activesync']['enabled'] && !$GLOBALS['prefs']->getValue('activesync_no_multiplex')) {
        try {
            $sm = $GLOBALS['injector']->getInstance('Horde_ActiveSyncState');
            $sm->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger'));
            $devices = $sm->listDevices($GLOBALS['registry']->getAuth());
Esempio n. 4
0
 /**
  * Retrieve the UID for the current user's default notepad.
  *
  * @return string  UID.
  * @since 4.2.0
  */
 public function getDefaultShare()
 {
     return Mnemo::getDefaultNotepad(Horde_Perms::EDIT);
 }
Esempio n. 5
0
$_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())));
    }
    foreach (Mnemo::listNotepads(false, Horde_Perms::EDIT) as $key => $list) {
        if ($list->getName() != Mnemo::getDefaultNotepad(Horde_Perms::EDIT)) {
            $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::EDIT);
    foreach ($sync as $cid) {
        if ($cid == $default) {
            $haveDefault = true;
            break;
        }
    }
    if (!$haveDefault) {
        $sync[] = $default;
        $GLOBALS['prefs']->setValue('sync_notepads', serialize($sync));
    }
    if ($GLOBALS['conf']['activesync']['enabled'] && !$GLOBALS['prefs']->getValue('activesync_no_multiplex')) {
        try {
            $sm = $GLOBALS['injector']->getInstance('Horde_ActiveSyncState');
            $sm->setLogger($GLOBALS['injector']->getInstance('Horde_Log_Logger'));
            $devices = $sm->listDevices($GLOBALS['registry']->getAuth());
Esempio n. 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)
 {
     //@todo: search across notepads
     // HACK: Use default notepad if no notepad is set.
     //       ActiveSync does not work without this
     //       as we don't search across all notepads yet.
     if (empty($this->_notepad)) {
         $this->_notepad = Mnemo::getDefaultNotepad();
     }
     return $this->get(Horde_Url::uriB64Encode($uid), $passphrase);
 }