Beispiel #1
0
 /**
  * Check User Permissions
  *
  * Check the user has the correct permissions to access the resource
  * If $redirect is TRUE then redirect to login page, otherwise return boolean
  *
  * @access public
  * @return bool
  */
 function check($resource, $action = NULL, $redirect = TRUE)
 {
     log_message('debug', 'BackendPro->Userlib->check : Checking if user has access to "' . $resource . '"');
     if ($this->CI->session) {
         // Get details from user
         $email = $this->CI->session->userdata('email');
         $group = $this->CI->session->userdata('group');
         if ($email !== FALSE && $group !== FALSE) {
             // There user has a session with values
             // Lets check there valid
             if (kh_acl_check($group, $resource, $action)) {
                 // They can access this resource
                 log_message('debug', 'BackendPro->Userlib->check : User has access to ' . $resource);
                 return TRUE;
             }
         }
     }
     // DENIED ACCESS
     log_message('debug', 'BackendPro->Userlib->check : Access is denied for user to ' . $resource);
     if ($redirect) {
         if (is_user()) {
             // They just don't have access
             flashMsg('warning', $this->CI->lang->line('userlib_status_restricted_access'));
             redirect('auth/login', 'location');
         } else {
             // They arn't logged in
             flashMsg('warning', $this->CI->lang->line('userlib_status_require_login'));
             // Save requested page
             $this->CI->session->set_flashdata('requested_page', $this->CI->uri->uri_string());
             redirect('auth/login', 'location');
         }
     }
     return FALSE;
 }
Beispiel #2
0
 /**
  * Check Access
  *
  * @param mixed $aro
  * @param mixed $aco
  * @param mixed $axo
  *
  * @return bool
  */
 function check($aro, $aco, $axo = null)
 {
     if (!function_exists('kh_acl_check')) {
         $this->_CI->load->helper('khacl');
     }
     return kh_acl_check($aro, $aco, $axo);
 }