Exemplo n.º 1
0
	/**
	* Retrieves all permissions this user has in the current project.
	* Notes:
	* - this method returns the names of all groups with type='permission'
	*   this user is a member of
	* - there's no way to explicitly ask for the global permissions.
	*   If the user hasn't selected a project, you get the global permissions
	*   only. If the user has selected a project, you get the global
	*   permissions AND the local permissions mangled together.
	*
	* @return array indexed array of permission names
	*/
	function getAllPermissions($projectID=0,$userID=0)
	{
		$userID=$this->defaultID($userID);
		$projectID=$this->defaultProject($projectID)->id;

		$cache=LPC_Cache::getCurrent();
		$groups=$cache->getUPf(self::P_KEY,$userID,$projectID);
		if ($groups!==false && $this->validatePermissionsCache($projectID,$userID))
			return $groups;

		self::ensureCacheExpiration($userID,$projectID);
		$cache->setUPf(self::PD_KEY,self::getNow(),$userID,$projectID);
		$groupIDs=$this->getAllGroupIDs($projectID,$userID);
		if (!$groupIDs) {
			$cache->setUPf(self::P_KEY,array(),$userID,$projectID);
			return array();
		}

		$group=new LPC_Group();
		$cache->setUPf(
			self::P_KEY,
			$groups=$group->filterGroupsByType($groupIDs,'permission','name'),
			$userID,
			$projectID
		);

		return $groups;
	}