示例#1
0
文件: common.php 项目: dasklney/traq
/**
 * Check if the user has permission to perform the action.
 *
 * @param integer $projectId
 * @param string  $action
 *
 * @return boolean
 */
function has_permission($action, $projectId = null, $fetchProjectRoles = false)
{
    if (!$projectId) {
        $currentProject = current_project();
        $projectId = $currentProject['id'];
    }
    if (!($user = current_user())) {
        $user = anonymous_user();
    }
    return $user->hasPermission($action, $projectId, $fetchProjectRoles);
}
示例#2
0
 /**
  * Check if the user has permisison to perform the action.
  *
  * @param integer $projectId
  * @param string  $action
  *
  * @return boolean
  */
 protected function hasPermission($action, $projectId = null)
 {
     if (!$projectId) {
         $projectId = $this->currentProject['id'];
     }
     if (!($user = current_user())) {
         $user = anonymous_user();
     }
     return $user->hasPermission($action, $projectId);
 }