Welcome Guest, Not a member yet? Register   Sign In
check_uri_permissions() with subfolder/controller/action how to?
#1

[eluser]seonet[/eluser]
Hi,

I try to create a common dashboard/admin for some user permissions like admin, superadmin, moderation...
I choose dx_auth for users management...
I create admin folder for all admin controller files but unable check permission Sad


Code:
function check_uri_permissions($allow = TRUE)
{
....
// Get variable from current URI
$controller = '/'.$this->ci->uri->rsegment(1).'/';
if ($this->ci->uri->rsegment(2) != '')
{
    $action = $controller.$this->ci->uri->rsegment(2).'/';
}
else
{
    $action = $controller.'index/';
}

Please help me a/some solution(s)
Thanks
#2

[eluser]seonet[/eluser]
I have a solution:
Code:
$uri_string = $this->ci->uri->uri_string();
$all_allowed_uris = $this->get_permissions_value('uri');
foreach($all_allowed_uris as $allowed_uris)
{
    foreach($allowed_uris as $allowed_uri)
    {
        $strpos = strpos($uri_string, $allowed_uri);
        // log_message('debug', "uri_string: " . $uri_string ." - allowed_uri: ". $allowed_uri ." - strpos: ". $strpos."\n\n");
        if(is_int($strpos) && $strpos == 0)
        {
            $have_access = $allow;
            break;
        }
    }

    if ( isset($have_access) && $have_access)
    {
        break;
    }
}

// Trigger event
$this->ci->auth_event->checked_uri_permissions($this->get_user_id(), $have_access);

if ( ! $have_access)
{
    // User didn't have previlege to access current URI, so we show user 403 forbidden access
    // $this->deny_access();
    show_error('Acces Denied');
}




Theme © iAndrew 2016 - Forum software by © MyBB