CodeIgniter Forums
Restrict some actions, _remap function - 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: Restrict some actions, _remap function (/showthread.php?tid=36494)



Restrict some actions, _remap function - El Forum - 12-03-2010

[eluser]SpaceCoder[/eluser]
I've tried to restrict some function by this construction:
Code:
function _remap($method)
    {
        $restricted = array('update_rating', 'delete_post');
        if( ! $this->session->userdata('logged_in') && in_array($method, $restricted))
        {
           echo 'Log in, please';
        }
        else {
           $this->$method();
        }
    }
But $this->$method(); didn't receive parameters which was sent in url. What to do?


Restrict some actions, _remap function - El Forum - 12-03-2010

[eluser]Twisted1919[/eluser]
When using _remap, if you have a method like :
Code:
public function something($uri1='',$uri2='')
{
    // code here .
}

You won't be able to use $uri1 and $uri2,
instead, use directly $this->uri->segment(1) and $this->uri->segment(2);