Preparación para subida a producción

git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@8 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
This commit is contained in:
roberto 2012-09-21 16:06:20 +00:00
parent 7eba4415b5
commit 2d40f3a5c8
4 changed files with 10 additions and 134 deletions

View File

@ -13,7 +13,7 @@ $config = array(
'sourceLanguage' => 'en_US',
'language' => 'es',
'name' => 'PROFIND',
'defaultController' => 'site',
'defaultController' => 'usuario',
// preloading 'log' component

View File

@ -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);
}
/**

View File

@ -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);
}
/**

View File

@ -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'),
),
),*/
),
));
?>