/**
  * Returns the current users' principal uri.
  * 
  * If nobody is logged in, this will return null. 
  * 
  * @return string|null 
  */
 public function getCurrentUser()
 {
     $userInfo = $this->authBackend->getCurrentUser();
     if (!$userInfo) {
         return null;
     }
     return $userInfo;
 }
示例#2
0
文件: Plugin.php 项目: jtietema/Fizzy
 /**
  * This method intercepts calls to PROPFIND and similar lookups 
  * 
  * This is done to inject the current-user-principal if this is requested.
  *
  * @todo support for 'unauthenticated'
  * @return void  
  */
 public function afterGetProperties($href, &$properties)
 {
     if (array_key_exists('{DAV:}current-user-principal', $properties[404])) {
         if ($ui = $this->authBackend->getCurrentUser()) {
             $properties[200]['{DAV:}current-user-principal'] = new Sabre_DAV_Property_Principal(Sabre_DAV_Property_Principal::HREF, $ui['uri']);
         } else {
             $properties[200]['{DAV:}current-user-principal'] = new Sabre_DAV_Property_Principal(Sabre_DAV_Property_Principal::UNAUTHENTICATED);
         }
         unset($properties[404]['{DAV:}current-user-principal']);
     }
     if (array_key_exists('{DAV:}principal-collection-set', $properties[404])) {
         $properties[200]['{DAV:}principal-collection-set'] = new Sabre_DAV_Property_Href('principals');
         unset($properties[404]['{DAV:}principal-collection-set']);
     }
     if (array_key_exists('{DAV:}supported-report-set', $properties[200])) {
         $properties[200]['{DAV:}supported-report-set']->addReport(array('{DAV:}expand-property'));
     }
 }
示例#3
0
 /**
  * Check if user has access.
  *
  * This method does a check if the currently logged in user
  * has permission to access this calendar. There is only read-write
  * access, so you're in or you're out.
  * 
  * @return bool 
  */
 protected function hasPrivilege()
 {
     if (!($user = $this->authBackend->getCurrentUser())) {
         return false;
     }
     if ($user['uri'] !== $this->calendarInfo['principaluri']) {
         return false;
     }
     return true;
 }