Skip to content

Commit

Permalink
Slight changes to API for CWebUser.
Browse files Browse the repository at this point in the history
  • Loading branch information
kahwee committed Mar 22, 2012
1 parent f351128 commit 98f5e42
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -37,15 +37,15 @@ return array(
'backstage' => array(
'class' => 'application.modules.backstage.BackstageModule',
#'autoloadModels' => false,
#'login_url' => '/site/login', // with support of CWebUser
#'login_required' => true, // with support of CWebUser
'name' => 'Backstage',
'copyright_name' => 'Backstage, Inc.'
'models' => array(
'Tag' => array(
'id' => array(
'control' => 'datetime',
'visible' => true,
'format'=>'M j, Y g:i A',
'format' => 'M j, Y g:i A',
),
),
'User' => false,
Expand Down
1 change: 1 addition & 0 deletions protected/config/main.php
Expand Up @@ -30,6 +30,7 @@
'class' => 'application.modules.backstage.BackstageModule',
#'autoloadModels' => false,
'name' => 'Backstage 2',
'login_required' => true, // with support of CWebUser
'copyright_name' => 'Backstage, Inc.',
'models' => array(
'Tag' => array(
Expand Down
12 changes: 6 additions & 6 deletions protected/modules/backstage/BackstageModule.php
Expand Up @@ -5,7 +5,7 @@ class BackstageModule extends CWebModule {
public $models = array();
public $name = null;
public $copyright_name = null;
public $login_url = false;
public $login_required = false;

/**
* @var models that are present in the ./protected/models directory
Expand All @@ -15,12 +15,12 @@ class BackstageModule extends CWebModule {
var $autoloadModels = true;

public function init() {
# if login url isset
if( $this->login_url && Yii::app()->user->isGuest ){
Yii::app()->request->redirect($login_url);

# if login url isset
if($this->login_required && Yii::app()->user->isGuest) {
Yii::app()->user->loginRequired();
}

Yii::setPathOfAlias('backstage', $this->getBasePath());
$this->setImport(array(
'application.models.*',
Expand Down

0 comments on commit 98f5e42

Please sign in to comment.