function check_my_access($permission_code = '') { //if am an admin allow all $ci =& get_instance(); $ci->load->model('role_m'); //if its admin logged in if ($ci->session->userdata('isadmin') == 'Y') { return TRUE; } else { //echo $permission_code; //if no permission id is passed if (!$permission_code) { return FALSE; } else { //echo $permission_code; //echo 'foo'; //get all current user's groups $my_groups = $ci->role_m->get_my_roles(); //print_array($my_groups); if ($my_groups) { //todo based on assumption that a user can not be in 2 groups with conflicting permissions foreach ($my_groups as $group) { //echo $group; //get_permissions basket $permission_basket = get_permissions_by_group($group); } //if there are no permissions if (!$permission_basket) { //echo 'foo'; return FALSE; } else { //if the permission_code is in basket then return true if (in_array($permission_code, $permission_basket)) { //print_array($permission_basket); return $permission_basket; } else { //echo 'foo'; return FALSE; } } } else { //if user has no group return FALSE; } } } }
function check_my_access($permission_code = '') { //if am an admin allow all $ci =& get_instance(); $ci->load->model('role_m'); //$ci->load->model('permission_m'); // $where=array( // 'code'=>$permission_code, // 'trash'=>'n' // ); // if(!$ci->permission_m->get_where($where)){ // //create the permission // $pieces=explode('_',$permission_code); // // $section=ucfirst($pieces[1]); // $code=$permission_code; // } // //if its admin logged in //if its a new code add it if ($ci->session->userdata('logged_in_usertype') == '1') { return TRUE; } else { //echo $permission_code; //if no permission id is passed if (!$permission_code) { return FALSE; } else { //get all current user's groups $my_groups = $ci->role_m->get_my_roles(); //print_array($my_groups); if ($my_groups) { //todo based on assumption that a user can not be in 2 groups with conflicting permissions foreach ($my_groups as $group) { //get_permissions basket $permission_basket = get_permissions_by_group($group); } //if there are no permissions if (!$permission_basket) { return FALSE; } else { //if the permission_code is in basket then return true if (in_array($permission_code, $permission_basket)) { //print_array($permission_basket); return $permission_basket; } else { return FALSE; } } } else { //if user has no group return FALSE; } } } }