[eluser]Unknown[/eluser]
Just found an issue with the _remap() method supplied - it was shifting my segments
if the controller was in a folder. The issue is the hardcoded 2 value...
For example,
http://example.com/controllerfolder/test/page/1/2/3 would render "page, 1, 2" instead of "1, 2, 3"
Code:
class Test extends Controller {
function __construct()
{
parent::__construct();
}
function page($id1='', $id2='', $id3='')
{
die($id1.', '.$id2.', '.$id3); //$id1 == "page" - wrong!
}
function _remap($method)
{
$auth = $this->ezauth->authorize($method, true);
if ($auth['authorize'] == 'yes') {
$segments = array_slice($this->uri->segment_array(),2); //redirect with method arguments by marlar on CodeIgniter forums
call_user_func_array(array(&$this, $method), $segments);
} else {
// user login information incorrect, so show login screen again
$this->login();
}
}
}
Here's my fix:
Code:
// remap for ezauth
function _remap($method)
{
$auth = $this->ezauth->authorize($method, true);
if ($auth['authorize'] == 'yes')
{
// find method in segment (fix)
$i=1;
foreach($this->uri->rsegment_array() as $segment)
{
if($segment == $method) break;
$i++;
}
$segments = array_slice($this->uri->rsegment_array(),$i); //redirect with method arguments
call_user_func_array(array(&$this, $method), $segments);
}
else
{
// user login information incorrect, so show login screen again
$this->login();
}
}