What I want is that when a user submits a form (when clicked save), the system state should be checked and if it does not match, I need to interrupt data save and logout the user from the system. I tried this with beforeSave() and it works but the problem is that it does not work simultaneously.
i.e.- when the user click save button, data won’t insert and when user clicks save button again then the user logs out from the system.
This is my current code:
//protected/model/supplier.php
class Supplier extends CActiveRecord{
protected function beforeSave(){
if(Yii::app()->params->SYSTEM_STATE==3){
return false;
Yii::app()->session->destroy();
//Yii::app()->user->logout();
}
return parent::beforeSave();
}
}