Welcome Guest, Not a member yet? Register   Sign In
Array global between Controllers - Problem.
#9

[eluser]Jinme[/eluser]
Yeah, ACL is a library loaded in config/autoload.php, not a Controller, well I'm come back to initial question: How make the Array global between all Controllers in my application or accesible to Acl Class library?

Use Session is not a good idea for a array (it can be long). Note from UserGuide: Cookies can only hold 4KB of data.

Important (for WanWizard) or anybody:
The test.php is that for now... a test, but the real code should be:
Code:
function Test()
{
    parent::Controller();
    $this->load->database();
    $this->load->model('test_model');
    if ($this->acl->isallowed($this->session->userdata('profile_id'))) {
        // Continue
    } else {
        // Not permissions for accesing Controller
        redirect('error');
    }
}
And in the Acl Class, exist a function:
Code:
function isallowed($profile = NULL, $resource = NULL) {
    $allowed = FALSE;
    if ($profile) {
        if (!$resource) {
            $resource = $this->resource();
        }
        foreach($this->permissions as $permission) {
            if (($permission["profile"] == $profile) && ($permission["resource"] == $resource)) {
                $allowed = TRUE;
                break;
            }
        }
    }
    return $allowed;
}

The intention is not call anytime functions accesing to database for read permissions, array is very fast.

I apreciated your new answers again.


Messages In This Thread
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 01:22 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 01:35 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 01:46 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 02:44 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 02:59 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 03:11 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 03:26 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 03:30 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 03:34 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 04:03 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 04:21 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 04:27 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 04:34 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 04:43 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 05:05 PM
Array global between Controllers - Problem. - by El Forum - 05-03-2010, 10:30 PM
Array global between Controllers - Problem. - by El Forum - 05-04-2010, 06:42 AM
Array global between Controllers - Problem. - by El Forum - 05-04-2010, 08:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB