Skip to content

Instantly share code, notes, and snippets.

@ruliarmando
Created April 13, 2014 12:46
Show Gist options
  • Select an option

  • Save ruliarmando/10582633 to your computer and use it in GitHub Desktop.

Select an option

Save ruliarmando/10582633 to your computer and use it in GitHub Desktop.
AdminModule
<?php
class AdminModule extends CWebModule
{
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'admin.models.*',
'admin.components.*',
));
Yii::app()->theme = 'shadow_dancer';
}
public function beforeControllerAction($controller, $action)
{
if(parent::beforeControllerAction($controller, $action))
{
if(!Yii::app()->authManager->checkAccess('Admin', Yii::app()->user->id)){
Yii::app()->theme = 'yourblog';
throw new CHttpException(403,Yii::t('yii','You are not authorized to perform this action.'));
}else{
return true;
}
}
else
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment