Created
November 5, 2012 17:53
-
-
Save davialexandre/4019136 to your computer and use it in GitHub Desktop.
Exemplo de um controller dentro de um módulo com Login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DefaultController extends CController | |
{ | |
public $defaultAction = 'login'; | |
public function actionLogin() { | |
$this->layout = 'login'; | |
$model = new AdminLoginForm; | |
if(isset($_POST['AdminLoginForm'])) { | |
$model->attributes = $_POST['AdminLoginForm']; | |
if($model->validate() && $model->login()) { | |
$this->redirect($this->getModule()->user->returnUrl); | |
} | |
} | |
$this->render('login', array('model'=>$model)); | |
} | |
public function actionLogout() { | |
$this->getModule()->user->logout(); | |
$this->redirect('login'); | |
} | |
public function actionDashboard() { | |
$this->layout = 'main'; | |
$this->render('dashboard'); | |
} | |
public function actionError() { | |
$this->layout = 'main'; | |
if($error=Yii::app()->errorHandler->error) | |
{ | |
if(Yii::app()->request->isAjaxRequest) | |
echo $error['message']; | |
else | |
$this->render('error', $error); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment