Skip to content

Instantly share code, notes, and snippets.

@davialexandre
Created November 5, 2012 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davialexandre/4019136 to your computer and use it in GitHub Desktop.
Save davialexandre/4019136 to your computer and use it in GitHub Desktop.
Exemplo de um controller dentro de um módulo com Login
<?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