AccessRenderDecorator Class Reference
[Usermanagement]
Allow access only for logged in users (of given role). More...
Public Member Functions |
|
__construct ($role=null) | |
Constructor. |
|
initialize ($page_data) | |
Initialize this decorator and the data
passed. |
|
render_content ($page_data) | |
Render content. |
Detailed Description
Allow access only for logged in users (of given role).
If constructed with a user role or an array of roles, this render decorator will check, if the current user has the role assigned.
If constructed with an empty role, decorator only checks, if a user is logged in.
If access is denied, a 403 is returned, unless the constant APP_USER_403_BEHAVIOUR is set to 'REDIRECT_LOGIN', in which case the user is redirected to the login page.
This render decorates disables caching on the given route.
Definition at line 21 of file accessrenderdecorator.cls.php.
Constructor & Destructor Documentation
AccessRenderDecorator::__construct | ( | $ | role = null |
) |
Constructor.
- Parameters:
-
string $role Role user needs to have to access this page boolean $require_exact_role If TRUE, accewss checking is done for IsRole() else for hasAcessLevel()
- Returns:
- void
Definition at line 36 of file accessrenderdecorator.cls.php.
00036 { 00037 $allow_access = false; 00038 if (Users::is_logged_in()) { 00039 $allow_access = true; 00040 if (!empty($role)) { 00041 $allow_access = Users::current_has_role($role); 00042 } 00043 } 00044 $this->access_granted = $allow_access; 00045 }
Member Function Documentation
AccessRenderDecorator::initialize | ( | $ | page_data | ) |
Initialize this decorator and the data passed.
- Parameters:
-
PageData $page_data
- Returns:
- void
Reimplemented from RenderDecoratorBase.
Definition at line 53 of file accessrenderdecorator.cls.php.
00053 { 00054 $page_data->set_cache_manager(new NoCacheCacheManager()); // Do not cache 00055 if ($this->access_granted == false) { 00056 $page_data->status_code = ControllerBase::ACCESS_DENIED; 00057 // Kept for compatibility. Remove in 0.7 00058 if (!Users::is_logged_in()) { 00059 if (Config::get_value(ConfigUsermanagement::BEHAVIOUR_403) == 'REDIRECT_LOGIN') { 00060 Session::push('login_goto', Url::current()->build(Url::ABSOLUTE)); 00061 Url::create(ActionMapper::get_url('login'))->redirect(); 00062 exit; 00063 } 00064 } 00065 } 00066 else { 00067 parent::initialize($page_data); 00068 } 00069 }
AccessRenderDecorator::render_content | ( | $ | page_data | ) |
Render content.
- Parameters:
-
PageData $page_data
- Returns:
- void
Reimplemented from RenderDecoratorBase.
Definition at line 77 of file accessrenderdecorator.cls.php.
00077 { 00078 if ($this->access_granted == true) { 00079 parent::render_content($page_data); 00080 } 00081 }
The documentation for this class was generated from the following file:
- contributions/usermanagement/controller/base/renderdecorators/accessrenderdecorator.cls.php