checkPermissions() 공개 정적인 메소드

Checks if a user has the specified permissions on a resource.
public static checkPermissions ( string $filter, integer $permission = Horde_Perms::READ, string $resource = null ) : boolean
$filter string What are we checking for. Either 'backend' or 'directory'.
$permission integer The permission to check for. One of the Horde_Perms constants.
$resource string The resource to check. If empty, check the current backend/directory.
리턴 boolean Returns true if the user has permission.
예제 #1
0
파일: Api.php 프로젝트: raz0rsdge/horde
 /**
  * @throws Gollem_Exception
  */
 protected function _getBackend($path)
 {
     // A file or directory has been requested.
     // Locate the backend_key in the path.
     $backend_key = strchr($path, '/') ? substr($path, 0, strpos($path, '/')) : $path;
     throw new Gollem_Exception('Not implemented');
     // Validate and perform permissions checks on the requested backend
     if (!$GLOBALS['session']->exists('gollem', 'backends/' . $backend_key)) {
         throw new Gollem_Exception(sprintf(_("Invalid backend requested: %s"), $backend_key));
     }
     if (!Gollem_Session::createSession($backend_key)) {
         throw new Gollem_Exception(_("Unable to create Gollem session"));
     }
     if (!Gollem::checkPermissions('backend', Horde_Perms::READ)) {
         throw new Gollem_Exception(_("Permission denied to this backend."));
     }
     return $backend_key;
 }
예제 #2
0
 /**
  */
 public function menu($menu)
 {
     $backend_key = Gollem_Auth::getPreferredBackend();
     $menu->add(Horde::url('manager.php')->add('dir', Gollem::$backend['home']), _("Start Folder"), 'gollem-home', null, null, null, '__noselection');
     if (Gollem::checkPermissions('backend', Horde_Perms::EDIT) && Gollem::checkPermissions('directory', Horde_Perms::EDIT, Gollem::$backend['dir']) && $GLOBALS['session']->get('gollem', 'clipboard', Horde_Session::TYPE_ARRAY)) {
         $menu->add(Horde::url('clipboard.php')->add('dir', Gollem::$backend['dir']), _("Clipboard"), 'gollem-clipboard');
     }
     if (!empty(Gollem::$backend['quota'])) {
         if ($GLOBALS['browser']->hasFeature('javascript')) {
             $quota_url = 'javascript:' . Horde::popupJs(Horde::url('quota.php'), array('params' => array('backend' => $backend_key), 'height' => 300, 'width' => 300, 'urlencode' => true));
         } else {
             $quota_url = Horde::url('quota.php')->add('backend', $backend_key);
         }
         $menu->add($quota_url, _("Check Quota"), 'gollem-quota');
     }
     if ($GLOBALS['registry']->isAdmin() && !$GLOBALS['injector']->getInstance('Horde_Perms') instanceof Horde_Perms_Null) {
         $menu->add(Horde::url('permissions.php')->add('backend', $backend_key), _("_Permissions"), 'horde-perms');
     }
 }
예제 #3
0
$info['title'] = htmlspecialchars(Gollem::$backend['label']);
/* Commonly used URLs. */
$self_url = Horde::url('selectlist.php');
/* Set up the template object. */
$view = $injector->createInstance('Horde_View');
$view->self_url = $self_url;
$view->forminput = Horde_Util::formInput();
$view->cacheid = $cacheid;
$view->currdir = htmlspecialchars(Gollem::$backend['dir']);
$view->formid = htmlspecialchars($vars->formid);
$view->navlink = Gollem::directoryNavLink(Gollem::$backend['dir'], $self_url->copy()->add(array('cacheid' => $cacheid, 'formid' => $vars->formid)));
if ($GLOBALS['conf']['backend']['backend_list'] == 'shown') {
    // TODO
    //$view->changeserver = Horde::link(htmlspecialchars(Horde_Auth::addLogoutParameters(Horde::url('login.php')->add(array('url' => Horde::url('selectlist.php')->add(array('formid' => $vars->formid)))), Horde_Auth::REASON_LOGOUT)), _("Change Server")) . Horde::img('logout.png', _("Change Server")) . '</a>', true;
}
if (is_array($info['list']) && count($info['list']) && Gollem::checkPermissions('backend', Horde_Perms::READ)) {
    $entry = $icon_cache = array();
    $rowct = 0;
    foreach ($info['list'] as $key => $val) {
        $item = array('dir' => false, 'name' => htmlspecialchars($val['name']), 'selected' => false, 'type' => $val['type']);
        $name = str_replace(' ', '&nbsp;', $item['name']);
        /* Determine graphic to use. */
        if (!empty($val['link'])) {
            $item['graphic'] = '<span class="iconImg gollem-symlink"></span>';
        } elseif ($val['type'] == '**dir') {
            $item['graphic'] = '<span class="iconImg gollem-folder"></span>';
        } else {
            if (empty($icon_cache[$val['type']])) {
                $icon_cache[$val['type']] = Horde::img($injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon($val['type']));
            }
            $item['graphic'] = $icon_cache[$val['type']];
예제 #4
0
파일: Auth.php 프로젝트: DSNS-LAB/Dmail
 /**
  * Loads the Gollem backend configuration from backends.php.
  *
  * @param string $backend  Returns this labeled entry only.
  *
  * @return mixed  If $backend is set return this entry; else, return the
  *                entire backends array. Returns false on error.
  */
 public static function getBackend($backend = null)
 {
     if (!($backends = self::_getBackends())) {
         try {
             $backends = Horde::loadConfiguration('backends.php', 'backends', 'gollem');
             if (is_null($backends)) {
                 return false;
             }
         } catch (Horde_Exception $e) {
             Horde::log($e, 'ERR');
             return false;
         }
         foreach (array_keys($backends) as $key) {
             if (!empty($backends[$key]['disabled']) || !Gollem::checkPermissions('backend', Horde_Perms::SHOW, $key)) {
                 unset($backends[$key]);
             }
         }
         self::_setBackends($backends);
     }
     if (is_null($backend)) {
         return $backends;
     }
     /* Check for the existence of the backend in the config file. */
     if (empty($backends[$backend]) || !is_array($backends[$backend])) {
         $entry = sprintf('Invalid backend key "%s" from client [%s]', $backend, $_SERVER['REMOTE_ADDR']);
         Horde::log($entry, 'ERR');
         return false;
     }
     return $backends[$backend];
 }
예제 #5
0
파일: manager.php 프로젝트: horde/horde
 /* Determine graphic to use. */
 if (!empty($val['link'])) {
     $item['graphic'] = '<span class="iconImg gollem-symlink"></span>';
 } elseif ($val['type'] == '**dir') {
     $item['graphic'] = '<span class="iconImg gollem-folder"></span>';
 } else {
     if (empty($icon_cache[$val['type']])) {
         $icon_cache[$val['type']] = Horde::img($injector->getInstance('Horde_Core_Factory_MimeViewer')->getIcon(Horde_Mime_Magic::extToMime($val['type'])), '', '', '');
     }
     $item['graphic'] = $icon_cache[$val['type']];
 }
 /* Create proper link. */
 switch ($val['type']) {
     case '**dir':
         $subdir = Gollem::subdirectory(Gollem::$backend['dir'], $val['name']);
         if (!Gollem::checkPermissions('directory', Horde_Perms::SHOW, $subdir)) {
             continue 2;
         }
         $item['link'] = $manager_url->copy()->add('dir', $subdir)->link() . $name . '</a>';
         if ($shares_enabled) {
             $share = $backkey . '|' . $subdir;
             $item['share'] = $perms_url_base->add('share', $share)->link(array('title' => $shares->exists($share) ? _("Shared Folder") : _("Share Folder"), 'target' => '_blank', 'onclick' => Horde::popupJs($perms_url_base, array('params' => array('share' => $share), 'urlencode' => true)) . 'return false;'));
             $item['share_disabled'] = !$shares->exists($share);
         }
         break;
     case '**broken':
         $item['link'] = $name;
         break;
     case '**sym':
         if ($val['linktype'] === '**dir') {
             if (substr($val['link'], 0, 1) == '/') {