php - not redirecting correct if user has permission -
in user group have set can check or unchecked each controller name , click on submit , send names database. in text/array format. , controllers have access otherwise should if seek access controller unchecked redirected 'admin/error_permission'
each user has user grouping id next user id.
how able names of controllers database , have them redirect error page so
table name: user_group: columns: user_group_id, name, permission
the name of column controller names stored permission , controller names stored permission a:2:{s:6:"access";a:1:{i:0;s:11:"column_left";}s:6:"modify";a:1:{i:0;s:11:"column_left";}}
rather write each controller name in array how can ones database.
function __construct() { parent::__construct(); if ( ! $this->session->userdata('logged_in')) { // allow methods names database permission? $allowed = array( ); if ( ! in_array($this->router->fetch_method(), $allowed) { // not allowed access redirect('admin/error_permission'); } } }
$permissions = 'a:2:{s:6:"access";a:1:{i:0;s:11:"column_left";}s:6:"modify";a:1:{i:0;s:11:"column_left";}}'; $permissions_array = unserialize($permissions); var_dump($permissions_array);
outputs:
array(2) { 'access' => array(1) { [0] => string(11) "column_left" } 'modify' => array(1) { [0] => string(11) "column_left" } }
if (false === array_key_exists($this->router->fetch_method(), $permissions_array)) { // not allowed access redirect('admin/error_permission'); }
php codeigniter
No comments:
Post a Comment