Welcome Guest, Not a member yet? Register   Sign In
Building global permissions.
#1

[eluser]Young Caveman[/eluser]
As usual, i apologize cause i can't speak english very well, but i'll try to explain as well as i can.
I'm new with CI, i would like to know if i can do this thing without coding too much.

Suppose i have to restrict the controller "admin", only the administrator can access to this area. Sure, he's the only who can access also admin/some, admin/somethingelse etc.

I have to code a if in each 'index', 'some' and 'somethingelse' function, or i can do something here? :
Code:
function Admin()
    {
        parent::Controller();
            
    }
Something here would help me in every function of the controller?

Thanks in advance.

Don ~ Alberto.
#2

[eluser]Pascal Kriete[/eluser]
How are you checking if he's an admin? You can just put that check in the constructor.
#3

[eluser]Young Caveman[/eluser]
[quote author="inparo" date="1207865009"]How are you checking if he's an admin? You can just put that check in the constructor.[/quote]
Code:
function Admin()
    {
        parent::Controller();

        if($this->some->isadmin() == '0') { redirect('error_page_that_tells_him_that_he_is_not_admin'); }
    
    }

Something like this?
#4

[eluser]Pascal Kriete[/eluser]
If you have a library called some with a function called isadmin, and it's loaded then that will work Tongue .
#5

[eluser]Young Caveman[/eluser]
[quote author="inparo" date="1207865970"]If you have a library called some with a function called isadmin, and it's loaded then that will work Tongue .[/quote]

It was so easy -.-

Thank you. Smile




Theme © iAndrew 2016 - Forum software by © MyBB