/** * Check if the user can access a given element. * * The rights are: * - 'all' (default) * - 'none' * - 'login' * - 'members' * - 'owners' * * The order of the rights is such that a 'owner' is also a * 'member' and of course a logged in person. * * @param Pluf_HTTP_Request * @param string Control key * @return mixed */ public static function accessTabGeneric($request, $key) { switch ($request->conf->getVal($key, 'all')) { case 'none': return new Pluf_HTTP_Response_Forbidden($request); case 'login': return Pluf_Precondition::loginRequired($request); case 'members': return self::projectMemberOrOwner($request); case 'owners': return self::projectOwner($request); case 'all': default: return true; } }
/** * Check if the user has a given permission.. * * @param Pluf_HTTP_Request * @param string Permission * @return mixed */ public static function hasPerm($request, $permission) { $res = Pluf_Precondition::loginRequired($request); if (true !== $res) { return $res; } if ($request->user->hasPerm($permission)) { return true; } return new Pluf_HTTP_Response_Forbidden($request); }