Пример #1
0
 /**
  * This method will be called after we route to the destinated method
  * 
  * @access	public
  */
 public function before()
 {
     $this->language = \Hybrid\Factory::get_language();
     $this->user = \Hybrid\Acl_User::get();
     \Event::trigger('controller_before');
     return parent::before();
 }
Пример #2
0
 /**
  * This method will be called after we route to the destinated method
  * 
  * @access	public
  */
 public function before()
 {
     $this->language = \Hybrid\Factory::get_language();
     $this->user = \Hybrid\Acl_User::get();
     \Event::trigger('controller_before');
     if (\Hybrid\Request::main() !== \Hybrid\Request::active()) {
         $this->set_content_type = false;
     }
     \Hybrid\Restful::auth();
     return parent::before();
 }
Пример #3
0
 /**
  * Check if user has any of provided roles (however this should be in \Hybrid\User IMHO)
  * 
  * @static
  * @access	public
  * @param	mixed	$check_roles
  * @return	bool 
  */
 public static function has_roles($check_roles)
 {
     $user = \Hybrid\Acl_User::get();
     if (!is_array($check_roles)) {
         $check_roles = array($check_roles);
     }
     foreach ($user->roles as $role) {
         $role = \Inflector::friendly_title($role, '-', TRUE);
         foreach ($check_roles as $check_against) {
             if ($role == $check_against) {
                 return true;
             }
         }
     }
     return false;
 }