CodeIgniter Forums
Is it possible to block certain functions within a controller classes? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Is it possible to block certain functions within a controller classes? (/showthread.php?tid=14357)



Is it possible to block certain functions within a controller classes? - El Forum - 12-30-2008

[eluser]mihu[/eluser]
I am trying to block certain functions within the controllers class base on user profile.
Is there a better way other than calling a check function within those functions.
Is it possible to do it within constructor?

Thanks,


Is it possible to block certain functions within a controller classes? - El Forum - 12-30-2008

[eluser]Colin Williams[/eluser]
You could do it in the constructor, but it seems better to do it in the functions to me. That way, if conditions need to be changed for the access checks, you don't find yourself muddying the constructor with more and more conditionals.


Is it possible to block certain functions within a controller classes? - El Forum - 12-30-2008

[eluser]mihu[/eluser]
I am thinking to do it via constructor + $this->uri->segment(2); instead of just within function.
Either way, I am calling a private function so I only need to take care 1 place.

Thanks for reply.


Is it possible to block certain functions within a controller classes? - El Forum - 12-30-2008

[eluser]Michael Wales[/eluser]
I would call a private function from my constructor (or a library, if you plan to implement this across multiple controllers) that will verify whether the user has the rights to access a particular URI.

Essentially, you are looking to build an ACL.


Is it possible to block certain functions within a controller classes? - El Forum - 12-31-2008

[eluser]mihu[/eluser]
Thanks a lot. Big Grin ... private function it is.