Mejorado el sistema de mostrar mensajes y errores en la web
git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@20 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
This commit is contained in:
parent
72c55036e9
commit
69f172d869
@ -6,10 +6,7 @@
|
||||
class RegistroUsuarioController extends Controller {
|
||||
|
||||
public $defaultAction = 'registrar';
|
||||
|
||||
public function init() {
|
||||
$this->layout = '/layouts/mensajes';
|
||||
}
|
||||
public $layout = '//layouts/error';
|
||||
|
||||
public function filters() {
|
||||
return array('accessControl');
|
||||
@ -108,30 +105,42 @@ class RegistroUsuarioController extends Controller {
|
||||
$usuario = Usuario::model()->findByAttributes(array('email' => $email));
|
||||
|
||||
// Comprobamos si se ha encontrado un usuario con ese email
|
||||
if (!isset($usuario))
|
||||
//$this->render('/user/message', array('title' => Yii::t("User activation"), 'content' => Yii::t("Incorrect activation URL.")));
|
||||
Yii::log("Incorrect activation URL. 3");
|
||||
elseif ($usuario->estado == Usuario::ESTADO_ACTIVO)
|
||||
//$this->render('/user/message', array('title' => Yii::t("User activation"), 'content' => Yii::t("You account is active.")));
|
||||
Yii::log("You account is active.");
|
||||
elseif ($usuario->estado == Usuario::ESTADO_DENEGADO)
|
||||
//$this->render('/user/message', array('title' => Yii::t("User activation"), 'content' => Yii::t("You account is banned.")));
|
||||
Yii::log("You account is banned.");
|
||||
elseif (isset($usuario->clave_seguridad) && ($usuario->clave_seguridad == $clave_seguridad)) {
|
||||
if (!isset($usuario)) {
|
||||
$this->render('//site/error', array(
|
||||
'titulo' => Yii::t('profind', 'Error de activación'),
|
||||
'mensaje' => Yii::t('profind', 'No se puede activar la cuenta.<br>La URL de activación es incorrecta.'),
|
||||
));
|
||||
} elseif ($usuario->estado == Usuario::ESTADO_ACTIVO) {
|
||||
$this->render('//site/error', array(
|
||||
'titulo' => Yii::t('profind', 'Cuenta ya activada'),
|
||||
'mensaje' => Yii::t('profind', 'No se ha realizado ningún cambio.<br>La cuenta ya estaba activada.'),
|
||||
));
|
||||
} elseif ($usuario->estado == Usuario::ESTADO_DENEGADO) {
|
||||
$this->render('//site/error', array(
|
||||
'titulo' => Yii::t('profind', 'Cuenta bloqueada'),
|
||||
'mensaje' => Yii::t('profind', 'La cuenta ha sido bloqueada.<br>Contacte con el administrador del sitio para obtener más información.'),
|
||||
));
|
||||
} elseif (isset($usuario->clave_seguridad) && ($usuario->clave_seguridad == $clave_seguridad)) {
|
||||
// Hay que activar el usuario
|
||||
$usuario->estado = Usuario::ESTADO_ACTIVO;
|
||||
$usuario->clave_seguridad = $usuario->encrypt(microtime());
|
||||
$usuario->save();
|
||||
|
||||
$this->enviarMailConfirmacionActivacion($usuario);
|
||||
$this->render('confirmacion_usuario');
|
||||
Yii::log("You account is activated.");
|
||||
|
||||
$this->layout = '//layouts/mensaje';
|
||||
$this->render('confirmacion_usuario', array());
|
||||
} else {
|
||||
$this->render('error_confirmacion');
|
||||
Yii::log("Incorrect activation URL. 2 ");
|
||||
$this->render('//site/error', array(
|
||||
'titulo' => Yii::t('profind', 'Error de activación'),
|
||||
'mensaje' => Yii::t('profind', 'No se puede activar la cuenta.<br>La URL de activación es incorrecta.'),
|
||||
));
|
||||
}
|
||||
} else {
|
||||
$this->render('error_confirmacion');
|
||||
Yii::log("Incorrect activation URL. 1");
|
||||
$this->render('//site/error', array(
|
||||
'titulo' => Yii::t('profind', 'Error de activación'),
|
||||
'mensaje' => Yii::t('profind', 'No se puede activar la cuenta.<br>La URL de activación es incorrecta.'),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,9 +160,9 @@ class RegistroUsuarioController extends Controller {
|
||||
$mensaje->subject = Yii::t('profind', 'Complete su registro en PROFIND');
|
||||
$mensaje->view = 'registro_usuario';
|
||||
$mensaje->setBody(array(
|
||||
'url' => $url_activacion,
|
||||
'email' => $usuario->email
|
||||
), 'text/html'
|
||||
'url' => $url_activacion,
|
||||
'email' => $usuario->email
|
||||
), 'text/html'
|
||||
);
|
||||
|
||||
Yii::app()->mail->send($mensaje);
|
||||
@ -173,10 +182,11 @@ class RegistroUsuarioController extends Controller {
|
||||
$mensaje->subject = Yii::t('profind', 'Gracias por registrarse en PROFIND.');
|
||||
$mensaje->view = 'confirmacion_usuario';
|
||||
$mensaje->setBody(array(
|
||||
'email' => $usuario->email
|
||||
), 'text/html'
|
||||
'email' => $usuario->email
|
||||
), 'text/html'
|
||||
);
|
||||
|
||||
Yii::app()->mail->send($mensaje);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,102 +1,96 @@
|
||||
<?php
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
|
||||
public function filters()
|
||||
{
|
||||
return array( 'accessControl' );
|
||||
}
|
||||
|
||||
public function accessRules()
|
||||
{
|
||||
return array(
|
||||
array('allow',
|
||||
'actions'=>array('login'),
|
||||
'users' => array('*')
|
||||
),
|
||||
array('allow',
|
||||
'users' => array('@')
|
||||
),
|
||||
array('deny'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the default 'index' action that is invoked
|
||||
* when an action is not explicitly requested by users.
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
// renders the view file 'protected/views/site/index.php'
|
||||
// using the default layout 'protected/views/layouts/main.php'
|
||||
$this->render('index');
|
||||
}
|
||||
class SiteController extends Controller {
|
||||
|
||||
/**
|
||||
* This is the action to handle external exceptions.
|
||||
*/
|
||||
public function actionError()
|
||||
{
|
||||
if($error=Yii::app()->errorHandler->error)
|
||||
{
|
||||
if(Yii::app()->request->isAjaxRequest)
|
||||
echo $error['message'];
|
||||
else
|
||||
$this->render('error', $error);
|
||||
}
|
||||
}
|
||||
public function filters() {
|
||||
return array('accessControl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the login page
|
||||
*/
|
||||
public function actionLogin()
|
||||
{
|
||||
$formulario = new FormularioLogin;
|
||||
$resultado = array();
|
||||
public function accessRules() {
|
||||
return array(
|
||||
array('allow',
|
||||
'actions' => array('login'),
|
||||
'users' => array('*')
|
||||
),
|
||||
array('allow',
|
||||
'users' => array('@')
|
||||
),
|
||||
array('deny'),
|
||||
);
|
||||
}
|
||||
|
||||
// if it is ajax validation request
|
||||
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
|
||||
{
|
||||
$formulario->email = $_POST['FormularioLogin_email'];
|
||||
$formulario->password = $_POST['FormularioLogin_password'];
|
||||
|
||||
if(!$formulario->validate()) {
|
||||
foreach($formulario->getErrors() as $campo => $error) {
|
||||
$resultado[$campo] = $error;
|
||||
}
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
$identificacion = new IdentificacionUsuario($formulario->email, $formulario->password);
|
||||
$identificacion->authenticate();
|
||||
|
||||
if ($identificacion->errorCode != IdentificacionUsuario::ERROR_NONE) {
|
||||
$resultado['password'] = Yii::t('profind', 'Email o contraseña incorrectos');
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
/**
|
||||
* This is the default 'index' action that is invoked
|
||||
* when an action is not explicitly requested by users.
|
||||
*/
|
||||
public function actionIndex() {
|
||||
// renders the view file 'protected/views/site/index.php'
|
||||
// using the default layout 'protected/views/layouts/main.php'
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
$duracion = 0;
|
||||
Yii::app()->user->login($identificacion, $duracion);
|
||||
Yii::app()->user->setReturnUrl($this->createUrl('usuario/modificar', array('id' => $identificacion->id)));
|
||||
|
||||
$resultado['status'] = '200';
|
||||
$resultado['redirect'] = Yii::app()->user->returnUrl;
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
$this->redirect(Yii::app()->params['frontpage']);
|
||||
}
|
||||
/**
|
||||
* This is the action to handle external exceptions.
|
||||
*/
|
||||
public function actionError() {
|
||||
if ($error = Yii::app()->errorHandler->error) {
|
||||
if (Yii::app()->request->isAjaxRequest)
|
||||
echo $error['message'];
|
||||
else {
|
||||
$this->layout = '/layouts/error';
|
||||
$this->render('error_sistema', $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the login page
|
||||
*/
|
||||
public function actionLogin() {
|
||||
$formulario = new FormularioLogin;
|
||||
$resultado = array();
|
||||
|
||||
// if it is ajax validation request
|
||||
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
|
||||
$formulario->email = $_POST['FormularioLogin_email'];
|
||||
$formulario->password = $_POST['FormularioLogin_password'];
|
||||
|
||||
if (!$formulario->validate()) {
|
||||
foreach ($formulario->getErrors() as $campo => $error) {
|
||||
$resultado[$campo] = $error;
|
||||
}
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
$identificacion = new IdentificacionUsuario($formulario->email, $formulario->password);
|
||||
$identificacion->authenticate();
|
||||
|
||||
if ($identificacion->errorCode != IdentificacionUsuario::ERROR_NONE) {
|
||||
$resultado['password'] = Yii::t('profind', 'Email o contraseña incorrectos');
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
$duracion = 0;
|
||||
Yii::app()->user->login($identificacion, $duracion);
|
||||
Yii::app()->user->setReturnUrl($this->createUrl('usuario/modificar', array('id' => $identificacion->id)));
|
||||
|
||||
$resultado['status'] = '200';
|
||||
$resultado['redirect'] = Yii::app()->user->returnUrl;
|
||||
echo function_exists('json_encode') ? json_encode($resultado) : CJSON::encode($resultado);
|
||||
Yii::app()->end();
|
||||
}
|
||||
|
||||
$this->redirect(Yii::app()->params['frontpage']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the current user and redirect to homepage.
|
||||
*/
|
||||
public function actionLogout() {
|
||||
Yii::app()->user->logout();
|
||||
$this->redirect(Yii::app()->homeUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the current user and redirect to homepage.
|
||||
*/
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::app()->user->logout();
|
||||
$this->redirect(Yii::app()->homeUrl);
|
||||
}
|
||||
}
|
||||
@ -1334,4 +1334,57 @@ label, input, button, select, textarea, select, textarea, input[type="text"], in
|
||||
.nav .dropdown-toggle:hover .caret {
|
||||
opacity: 1;
|
||||
filter: alpha(opacity=100);
|
||||
}
|
||||
}
|
||||
|
||||
/* página de mensajes y errores */
|
||||
.message_page, .error_page {
|
||||
background:#eee
|
||||
}
|
||||
.message_page, .message_page body, .message_page .message_box,
|
||||
.error_page, .error_page body, .error_page .error_box {
|
||||
height:100%
|
||||
}
|
||||
.message_page h1, .message_page h2, .message_page h3, .message_page h4,
|
||||
.error_page h1, .error_page h2, .error_page h3, .error_page h4{
|
||||
font-family: helvetica, arial, sans-serif;
|
||||
line-height:1.1;
|
||||
color: #067ead;
|
||||
text-shadow: 2px 2px 0px rgba(255,255,255,.5), 4px 4px 0px rgba(0,0,0,.1);
|
||||
margin-bottom:10px;
|
||||
padding:40px 0 0 300px;
|
||||
}
|
||||
.message_page h1,
|
||||
.error_page h1 {
|
||||
font-size: 52px;
|
||||
}
|
||||
.message_page h2,
|
||||
.error_page h2 {
|
||||
font-size: 46px;
|
||||
}
|
||||
.message_page h3,
|
||||
.error_page h3 {
|
||||
font-size: 40px;
|
||||
}
|
||||
.message_page h4,
|
||||
.error_page h4 {
|
||||
font-size: 32px;
|
||||
}
|
||||
.message_page p,
|
||||
.error_page p {
|
||||
color:inherit;
|
||||
font-size:16px;
|
||||
line-height:24px;
|
||||
font-weight:200;
|
||||
margin-left:300px;
|
||||
}
|
||||
.message_page .back_link,
|
||||
.error_page .back_link {
|
||||
margin-left:300px;
|
||||
}
|
||||
.message_page .message_box,
|
||||
.error_page .error_box {
|
||||
padding:0;
|
||||
width:72%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
|
||||
36
www/themes/profind/views/layouts/error.php
Normal file
36
www/themes/profind/views/layouts/error.php
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo Yii::app()->language; ?>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap-responsive.min.css" />
|
||||
|
||||
<!-- Estilos -->
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/profind.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/media.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/azul.css" />
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body class="sidebar_hidden profind-fixed error_page">
|
||||
<div id="maincontainer" class="clearfix">
|
||||
<!-- contenido -->
|
||||
<div id="contentwrapper">
|
||||
<div class="main_content">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/js/bootstrap.min.js"></script>
|
||||
<!-- Arreglo orientación en iOS -->
|
||||
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/ios-orientationchange-fix.js"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
36
www/themes/profind/views/layouts/mensaje.php
Normal file
36
www/themes/profind/views/layouts/mensaje.php
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo Yii::app()->language; ?>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/css/bootstrap-responsive.min.css" />
|
||||
|
||||
<!-- Estilos -->
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/profind.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/media.css" />
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/azul.css" />
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
</head>
|
||||
<body class="sidebar_hidden profind-fixed message_page">
|
||||
<div id="maincontainer" class="clearfix">
|
||||
<!-- contenido -->
|
||||
<div id="contentwrapper">
|
||||
<div class="main_content">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bootstrap JS -->
|
||||
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/bootstrap/js/bootstrap.min.js"></script>
|
||||
<!-- Arreglo orientación en iOS -->
|
||||
<script src="<?php echo Yii::app()->theme->baseUrl; ?>/js/ios-orientationchange-fix.js"></script>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo Yii::app()->language; ?>">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
|
||||
<!-- notifications -->
|
||||
<link rel="stylesheet" href="<?php echo Yii::app()->theme->baseUrl; ?>/lib/sticky/sticky.css" />
|
||||
|
||||
</head>
|
||||
<body class="sidebar_right">
|
||||
|
||||
|
||||
<!-- main content -->
|
||||
<div id="contentwrapper">
|
||||
<div class="main_content">
|
||||
<?php echo $content; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h3>Gracias por registrarse en PROFIND</h3>
|
||||
<p>
|
||||
Gracias por registrarse en <a href="http://www.xxxxxxx.xxx/">PROFIND</a>.<br>
|
||||
Su cuenta ha sido confirmada.
|
||||
</p>
|
||||
<p>El equipo de <a href="http://www.xxxxxxx.xxx/">PROFIND</a></p>
|
||||
</body>
|
||||
</html>
|
||||
<?php $this->pageTitle = Yii::t('profind', 'Gracias por registrarse en PROFIND'); ?>
|
||||
|
||||
<div class="message_box">
|
||||
<h3>Gracias por registrarse en PROFIND</h3>
|
||||
<p>
|
||||
Gracias por registrarse en <a href="http://www.profindclub.com/">PROFIND</a>.<br>
|
||||
Su cuenta ha sido confirmada.
|
||||
</p>
|
||||
<p>El equipo de <a href="http://www.profindclub.com/">PROFIND</a></p>
|
||||
<a class="back_link btn btn-medium btn-primary" href="http://www.profindclub.com/">¡¡ Empezar !!</a>
|
||||
</div>
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php $this->pageTitle = "Error " . $code; ?>
|
||||
<?php $this->pageTitle = $titulo; ?>
|
||||
|
||||
<div class="error_box">
|
||||
<h1>Error <?php echo $code; ?></h1>
|
||||
<p><?php echo CHtml::encode($message); ?>.</p>
|
||||
<h4><?php echo $titulo; ?></h4>
|
||||
<p><?php echo $mensaje; ?>.</p>
|
||||
<a href="javascript:history.back()" class="back_link btn"><?php echo Yii::t('profind', 'Volver'); ?></a>
|
||||
</div>
|
||||
|
||||
7
www/themes/profind/views/site/error_sistema.php
Normal file
7
www/themes/profind/views/site/error_sistema.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php $this->pageTitle = "Error " . $code; ?>
|
||||
|
||||
<div class="error_box">
|
||||
<h1>Error <?php echo $code; ?></h1>
|
||||
<p><?php echo CHtml::encode($message); ?>.</p>
|
||||
<a href="javascript:history.back()" class="back_link btn"><?php echo Yii::t('profind', 'Volver'); ?></a>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user