Search code examples
phpcakephpcakephp-1.3

CakePHP why does my appcontroller not work for admin?


For some reason beforefilter is not executed in appcontroller when I am in the admin section.

I test it with die(); and it still goes through. What could be the problem?

When I am logged out, it forwards to login, appcontroller is executed. When I log in, I get the problem.

Router:

Router::connect('/', array('controller' => 'static', 'action' => 'index'));
/**
 * ...and connect the rest of 'Pages' controller's urls.
 */
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
/**
 * PLUGIN MATCH
 */
if ($plugins = Configure::listObjects('plugin')) {
    $pluginMatch = implode('|', array_map(array('Inflector', 'underscore'), $plugins));
    Router::connect( "/:language/:plugin/:controller/:action/*",  array('action' => null),  array('plugin' => $pluginMatch)    );
}
/**
 *  ADMIN
 */
Router::connect('/:language/admin/:controller/:action/*', array('action' => null,   'admin'=> true),  array('language' => '[a-z]{3}'));
Router::connect('/:language/admin', array('controller' => 'admin', 'action' => 'index'),  array('language' => '[a-z]{3}')); //...and set the admin default page
/**
 * LANGUAGES
 */
Router::connect('/:language/home', array('controller' => 'static', 'action' => 'index'));
Router::connect('/:language/about', array('controller' => 'static', 'action' => 'about'));
// ...and more of those regular redirects here

Appcontroller beforeFilter:

function beforeFilter(){
    die();
    // LANGUAGES
    $this->_setLanguage();

    $this->Auth->authorize = 'actions'; //  CAN SOMEBODY EXPLAIN TO ME WHAT THIS DOES?
    $this->Auth->logoutRedirect = array( 'controller' => 'static', 'action' => 'index', 'language'=>$this->Session->read('Config.language'));
    $this->Auth->loginRedirect = array( 'controller' => 'galleries', 'action' => 'index', 'language'=>$this->Session->read('Config.language'));
    $this->Auth->loginAction = array( 'controller'=>'users', 'action'=>'login', 'plugin'=>null,'language'=>$this->Session->read('Config.language'));
    // ACO
    $this->Auth->actionPath = 'controllers/'; // The main ACO. Maybe we need to change something for languages?
    if($this->Auth->user()){
        $this->set('u', $this->Auth->user());
    }
}

Why is this?


Solution

  • does the specific controller have a beforeFilter? and does it call parent::beforeFilter?

    the simple stuff sometimes is overlooked.