Dear Zugluk
Kindly checkout whether the following would serve the purpose.
We are going to create two actions in SiteController.You can impose appropriate permissions on these two actions.
SiteController.php
public function actionMassLogout()
{
Yii::app()->setGlobalState('massLogout',true);
$this->redirect(array('site/index'));
}
public function actionAllowLogin()
{
Yii::app()->setGlobalState('massLogout',false);
$this->redirect(array('site/index'));
}
You can paste the following code in header section in main layout file to know the current status.
if(Yii::app()->getGlobalState('massLogout') && (Yii::app()->user->name=='admin'))
echo "Site is on Mass Logout Mode";
Create a file maintanance.php in views/site/pages folder.
maintanance.php
<h2>The site is under active maintanance.Please login with your credentials later.</h2>
Now we have to create a behavior for our application.
applicationBehavior.php in components folder.
<?php
class applicationBehavior extends CBehavior
{ private $_owner;
public function events()
{
return array(
'onBeginRequest'=>'massLogout',
);
}
public function massLogout()
{
$owner=$this->_owner=$this->getOwner();
if($owner->getGlobalState('massLogout') && ($owner->user->name!=='admin'))
{
$owner->user->clearStates();
$owner->catchAllRequest=array('site/page','view'=>'maintanance');
}
}
}
Attach this behavior as a property in main configuration file.
main.php
'behaviors'=>array(
'class'=>'application.components.applicationBehavior',
),
If the admin sets the state as massLogout, he is going to logout all the users excluding him.
After that every request is going to the default page.
The effect will not be perceived unless user registers a fresh request.
Here we have used runtime directory to save the massLogout status.
We can also use database tables to store the values
Regards.