Kronolith::hasPermission PHP 메소드

hasPermission() 공개 정적인 메소드

Returns whether the current user has certain permissions on a calendar.
public static hasPermission ( string $calendar, integer $perm ) : boolean
$calendar string A calendar id.
$perm integer A Horde_Perms permission mask.
리턴 boolean True if the current user has the requested permissions.
    public static function hasPermission($calendar, $perm)
    {
        try {
            $share = $GLOBALS['injector']->getInstance('Kronolith_Shares')->getShare($calendar);
            if (!$share->hasPermission($GLOBALS['registry']->getAuth(), $perm)) {
                if ($share->get('owner') == null && $GLOBALS['registry']->isAdmin()) {
                    return true;
                }
                throw new Horde_Exception_NotFound();
            }
        } catch (Horde_Exception_NotFound $e) {
            return false;
        }
        return true;
    }

Usage Example

예제 #1
0
파일: Handler.php 프로젝트: kossamums/horde
 /**
  * Returns the driver object for a calendar.
  *
  * @param string $cal  A calendar string in the format "type|name".
  *
  * @return Kronolith_Driver|boolean  A driver instance or false on failure.
  */
 protected function _getDriver($cal)
 {
     list($driver, $calendar) = explode('|', $cal);
     if ($driver == 'internal' && !Kronolith::hasPermission($calendar, Horde_Perms::SHOW)) {
         $GLOBALS['notification']->push(_("Permission Denied"), 'horde.error');
         return false;
     }
     try {
         $kronolith_driver = Kronolith::getDriver($driver, $calendar);
     } catch (Exception $e) {
         $GLOBALS['notification']->push($e, 'horde.error');
         return false;
     }
     if ($driver == 'remote') {
         $kronolith_driver->setParam('timeout', 15);
     }
     return $kronolith_driver;
 }
All Usage Examples Of Kronolith::hasPermission