Mnemo::listNotepads PHP Method

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.
    public static function listNotepads($owneronly = false, $permission = Horde_Perms::SHOW)
    {
        if ($owneronly && !$GLOBALS['registry']->getAuth()) {
            return array();
        }
        if ($owneronly || empty($GLOBALS['conf']['share']['hidden'])) {
            try {
                $notepads = $GLOBALS['mnemo_shares']->listShares($GLOBALS['registry']->getAuth(), array('perm' => $permission, 'attributes' => $owneronly ? $GLOBALS['registry']->getAuth() : null, 'sort_by' => 'name'));
            } catch (Horde_Share_Exception $e) {
                Horde::log($e->getMessage(), 'ERR');
                return array();
            }
        } else {
            try {
                $notepads = $GLOBALS['mnemo_shares']->listShares($GLOBALS['registry']->getAuth(), array('perm' => $permission, 'attributes' => $GLOBALS['registry']->getAuth(), 'sort_by' => 'name'));
            } catch (Horde_Share_Exception $e) {
                Horde::log($e);
                return array();
            }
            $display_notepads = @unserialize($GLOBALS['prefs']->getValue('display_notepads'));
            if (is_array($display_notepads)) {
                foreach ($display_notepads as $id) {
                    try {
                        $notepad = $GLOBALS['mnemo_shares']->getShare($id);
                        if ($notepad->hasPermission($GLOBALS['registry']->getAuth(), $permission)) {
                            $notepads[$id] = $notepad;
                        }
                    } catch (Horde_Exception_NotFound $e) {
                    } catch (Horde_Share_Exception $e) {
                        Horde::log($e);
                        return array();
                    }
                }
            }
        }
        return $notepads;
    }

Usage Example

コード例 #1
0
ファイル: Base.php プロジェクト: DSNS-LAB/Dmail
 /**
  * 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();
     }
 }
All Usage Examples Of Mnemo::listNotepads