From 2d40f3a5c88d75b41f1e30af76981ae19c89352d Mon Sep 17 00:00:00 2001 From: roberto Date: Fri, 21 Sep 2012 16:06:20 +0000 Subject: [PATCH] =?UTF-8?q?Preparaci=C3=B3n=20para=20subida=20a=20producci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@8 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d --- www/protected/config/main.php | 2 +- .../controllers/EmpresaController.php | 59 +------------- .../controllers/UsuarioController.php | 79 ++----------------- www/themes/profind/views/layouts/main.php | 4 +- 4 files changed, 10 insertions(+), 134 deletions(-) diff --git a/www/protected/config/main.php b/www/protected/config/main.php index 23be31e..965db80 100644 --- a/www/protected/config/main.php +++ b/www/protected/config/main.php @@ -13,7 +13,7 @@ $config = array( 'sourceLanguage' => 'en_US', 'language' => 'es', 'name' => 'PROFIND', - 'defaultController' => 'site', + 'defaultController' => 'usuario', // preloading 'log' component diff --git a/www/protected/controllers/EmpresaController.php b/www/protected/controllers/EmpresaController.php index 07ff91a..4e7a06e 100644 --- a/www/protected/controllers/EmpresaController.php +++ b/www/protected/controllers/EmpresaController.php @@ -18,55 +18,16 @@ class EmpresaController extends Controller { */ public function accessRules() { return array( - array('allow', // allow all users to perform 'index' and 'view' actions - 'actions' => array('index', 'view'), - 'users' => array('*'), - ), array('allow', // allow authenticated user to perform 'create' and 'update' actions - 'actions' => array('create', 'modificar'), + 'actions' => array('index', 'modificar'), 'users' => array('@'), ), - array('allow', // allow admin user to perform 'admin' and 'delete' actions - 'actions' => array('admin', 'delete'), - 'users' => array('admin'), - ), array('deny', // deny all users 'users' => array('*'), ), ); } - /** - * Displays a particular model. - * @param integer $id the ID of the model to be displayed - */ - public function actionView($id) { - $this->render('view', array( - 'model' => $this->loadModel($id), - )); - } - - /** - * Creates a new model. - * If creation is successful, the browser will be redirected to the 'view' page. - */ - public function actionCreate() { - $model = new Empresa; - - // Uncomment the following line if AJAX validation is needed - // $this->performAjaxValidation($model); - - if (isset($_POST['Empresa'])) { - $model->attributes = $_POST['Empresa']; - if ($model->save()) - $this->redirect(array('view', 'id' => $model->id)); - } - - $this->render('create', array( - 'model' => $model, - )); - } - /** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. @@ -94,27 +55,11 @@ class EmpresaController extends Controller { )); } - /** - * Deletes a particular model. - * If deletion is successful, the browser will be redirected to the 'admin' page. - * @param integer $id the ID of the model to be deleted - */ - public function actionDelete($id) { - $this->loadModel($id)->delete(); - - // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser - if (!isset($_GET['ajax'])) - $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); - } - /** * Lists all models. */ public function actionIndex() { - $dataProvider = new CActiveDataProvider('Empresa'); - $this->render('index', array( - 'dataProvider' => $dataProvider, - )); + $this->actionModificar(Yii::app()->user->id_empresa); } /** diff --git a/www/protected/controllers/UsuarioController.php b/www/protected/controllers/UsuarioController.php index cb590a9..1d3cde6 100644 --- a/www/protected/controllers/UsuarioController.php +++ b/www/protected/controllers/UsuarioController.php @@ -19,54 +19,24 @@ class UsuarioController extends Controller { public function accessRules() { return array( array('allow', // allow admin user to perform 'admin' and 'delete' actions - 'actions' => array('modificar'), + 'actions' => array('modificar', 'index'), 'users' => array('@'), ), - array('allow', // allow admin user to perform 'admin' and 'delete' actions - 'actions' => array('index', 'create', 'delete', 'indexEquipo'), - 'expression' => 'Usuario::model()->findByPk(Yii::app()->user->id)->id==2', //admin - ), array('deny', // deny all users 'users' => array('*'), ), ); } - /** - * Creates a new model. - * If creation is successful, the browser will be redirected to the 'view' page. - */ - public function actionCreate($tipo) { - //Yii::import('ext.multimodelform.MultiModelForm'); - - $model = new Usuario; - $model->tipo = $tipo; - if ($tipo = 'C') { - $model->empresa = new Empresa(); - } - - // Uncomment the following line if AJAX validation is needed - // $this->performAjaxValidation($model); - - if (isset($_POST['Usuario'])) { - $model->attributes = $_POST['Usuario']; - if ($model->save() && $model->empresa->save()) { - //$masterValues = array ('candidato_id'=>$model->id); - $this->redirect(array('view', 'id' => $model->id)); - } - } - - $this->render('create', array( - 'model' => $model, - )); - } - /** * Actualiza un usuario. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionModificar($id) { + if ($id != Yii::app()->user->id) + throw new CHttpException(404, 'The requested page does not exist.'); + $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed @@ -85,50 +55,11 @@ class UsuarioController extends Controller { )); } - /** - * Deletes a particular model. - * If deletion is successful, the browser will be redirected to the 'admin' page. - * @param integer $id the ID of the model to be deleted - */ - public function actionDelete($id) { - if (Yii::app()->request->isPostRequest) { - // we only allow deletion via POST request - $this->loadModel($id)->delete(); - - // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser - if (!isset($_GET['ajax'])) - $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); - } - else - throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); - } - /** * Lists all models. */ public function actionIndex() { - $model = new Usuario('search'); - $model->unsetAttributes(); // clear any default values - - if (isset($_GET['Usuario'])) - $model->attributes = $_GET['Usuario']; - - $this->render('index', array( - 'model' => $model, - )); - } - - public function actionIndexEquipo($id) { - $model = $this->loadModel($id); - - $agentes = new Usuario('search'); - $agentes->unsetAttributes(); // clear any default values - - $agentes->id_empresa = $model->id_empresa; - - $this->render('index', array( - 'model' => $agentes, - )); + $this->actionModificar(Yii::app()->user->id); } /** diff --git a/www/themes/profind/views/layouts/main.php b/www/themes/profind/views/layouts/main.php index 6476293..abec6dd 100644 --- a/www/themes/profind/views/layouts/main.php +++ b/www/themes/profind/views/layouts/main.php @@ -60,11 +60,11 @@ 'url' => array('/empresa/modificar', 'id' => Yii::app()->user->id_empresa), 'linkOptions' => array(), ), - array( + /*array( 'label' => CHtml::tag('i', array('class' => 'icon-user icon-white'), '') . ' ' . Yii::t('profind', 'Equipo'), 'url' => array('/equipo/index'), 'linkOptions' => array('class' => 'icon_block contacto'), - ), + ),*/ ), )); ?>