Hi,
i wanna to make a maintance page. But i have any probleme.
is it my init, from the Controller
public function init() {
$model = Maintance::model()->findByPk(1);
if($model->aktiv == 1 && !Yii::app()->getModule('user')->isAdmin()) {
if($this->id->action != 'maintance') {
Yii::app()->user->logout();
$this->redirect(array('/site/maintance'));
}
}
}
If i write to the if $this->action already drop error:
Trying to get property of non-object
Or is use $this->route, not write the action, only the controller.
abennouna
(Abennouna)
2
what is this?
$this->id->action
Is it supposed to be this?
$this->getAction()->getId()
or
$this->action->id
If i use $this->action->id, drop error.
Trying to get property of non-object
What is the best idea, for excluding login,maintance action? 
Y11
(Y!!)
4
$this->action is not available within init() because it was not created/initialized at that point.
You can use beforeAction():
public function beforeAction($action)
{
// $action->id
}
Don’t forget to return true if you don’t redirect.
I have a little probleme with the mainteance page.
I use 2 domain with 1 yii "motor".
The 1. domain is correct with this beforeaction, but the 2. domain is always drop, when i go to another controller/action. 
public function beforeAction($action) {
$model = Maintance::model()->findByPk(1);
if($model->aktiv == 1 && !Yii::app()->getModule('user')->isAdmin()) {
if($this->id != 'admin' && $this->route != 'admin/login' && $action->id != 'maintance') {
Yii::app()->user->logout();
$this->redirect(array('/site/maintance'));
} else {
return true;
}
} else {
return true;
}
}
Y11
(Y!!)
7
What you mean with “drop”? What exactly doesn’t work on the domain #2?
The #2 always logged out, when i click to another controller/action.
Edit: Yii::app()->getModule(‘user’)->isAdmin() show false, when is clicked.
Y11
(Y!!)
9
Maybe it has something to do with the session cookie? Are these 2 different domains or 1 domain + 1 subdomain?
redguy
(Maciej Lizewski)
10
Also - there is a ‘catchAllRequests’ config entry which does maintenance mode redirection, however by default you have to switch it on/off in config file: http://www.yiiframework.com/doc/api/1.1/CWebApplication#catchAllRequest-detail
I use session, not cookies. 2 differend domains.
But i dont use the mainteace works fine the login in the 2 domain.
Yes, but i use db to the on/off mainteance and not edit the file. And this beforeAction() allow to admin anyone in the page and deny all other.
I’m happy! 
In the main i use this ->
'preload'=>array('log', 'user'),
It’s works. Thanks for all. 