Redirect from acp to frontend

  • Thread starter Thread starter ragtek
  • Start date Start date
R

ragtek

Guest
I'm showing the node edit page in the frontend.

The controller redirects to
PHP:
return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildAdminLink('nodes') . $this->getLastHash($nodeId)
        );

to stop this behaviour i coded this:

PHP:
        $comeFrom = $this->_request->get('_xfRequestUri');
        if(preg_match("/admin.php/",$comeFrom)){
               return $this->responseRedirect(
                XenForo_ControllerResponse_Redirect::SUCCESS,
                XenForo_Link::buildAdminLink('nodes') . $this->getLastHash($nodeId)
            );
        }
        else if ($this->_noRedirect()){

            return $this->responseRedirect(
            XenForo_ControllerResponse_Redirect::SUCCESS,
            XenForo_Link::buildPublicLink('pages', $pageData)
        );
       }

It's working fine on 2 testboards, but is it a clean way?
The only scenario where this could cause problems is that the user renamed his admin.php to something else, but could users using this add-on get other problems?
 
Are you using the same controller code for each behavior? That's rather... unexpected. You should probably split things out such that you can vary parts by simply instantiating different controllers. You could have helper methods that return what you need to do the redirects.
 
Are you using the same controller code for each behavior? That's rather... unexpected. You should probably split things out such that you can vary parts by simply instantiating different controllers.
Yes, it's the XenForo_ControllerAdmin_Page .
Until i finish my frontpage page editor, i'm showing the acp edit page as overlay ( i know this is a "dirty" way, but it's working, secure and a fast way^^
edit page.webp

With the original code, it redirects me from the page to the admin nodes overview ( XenForo_Link::buildAdminLink('nodes') . $this->getLastHash($nodeId) )

To stop this, i created the second redirect.
I analyzed the data from both requests and only xfRequestUri was usable to see wheres the form coming from.

I don't want to code an second controller doing the exact same thing, specially because it's hard to inject extradata from add-ons into both (for example if i have extrafields for pages & forums)
 
Top Bottom