コード例 #1
0
ファイル: Data.class.php プロジェクト: evilgeny/bob
 /**
  *	Check permission. If multiple permissions are specified, all of them are required.
  *
  *	@param		perm		string		Permission (see note in class description)
  *	@param		userId		int			User-ID. NULL - current user
  *	@param		psId		int			Password store ID
  *	@return		string
  */
 public function checkAccess($perm, $userId, $psId)
 {
     $userId = $this->_mapper->_realUserId($userId);
     // init check access vars
     $this->_sData =& $this->_mapper->_getPermData($this->_object->_accessId());
     $this->_sPassword = $this->_mapper->psGetPassword($psId, $this->_object->_accessId());
     $this->_sGroups = $this->_mapper->getUserGroups($userId);
     $this->_sPerms = $this->_mapper->permToIds($perm);
     $this->_sResult = PERM_UNDEF;
     $this->_sChecked = 0;
     $this->_sExtra = array(PERM_TARGET_ALL => 1, PERM_TARGET_OTHER => 1);
     if ($this->_object->_getOwnerId() == $userId) {
         $this->_sExtra[PERM_TARGET_OWNER] = 1;
     }
     $this->_sExtra[$userId ? PERM_TARGET_USERS : PERM_TARGET_GUESTS] = 1;
     //list($o,$m) = array($this->_object,$this->_mapper); unset($this->_object,$this->_mapper); var_dump($this); list($this->_object,$this->_mapper) = array($o,$m);
     // run check
     $hasOther = 0;
     foreach (array_keys($this->_sData) as $target) {
         if ($target == PERM_TARGET_OTHER) {
             $hasOther = 1;
         } else {
             $this->_checkPermRec($target);
         }
     }
     if ($hasOther and $this->_sChecked == 0) {
         $this->_checkPermRec(PERM_TARGET_OTHER);
     }
     // cleanup
     unset($this->_sData, $this->_sGroups, $this->_sPerms, $this->_sPassword);
     return $this->_sResult;
 }
コード例 #2
0
ファイル: Facade.class.php プロジェクト: evilgeny/bob
 /**
  *	Optimization hack: some fast way to get user ID
  */
 public function _userId()
 {
     return $this->_mapper->_realUserId(NULL);
 }