git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_PROFIND_Web/trunk@52 3fe1ab16-cfe0-e34b-8c9f-7d8c168d430d
68 lines
2.0 KiB
PHP
68 lines
2.0 KiB
PHP
<?php
|
|
|
|
class SubscripcionController extends Controller
|
|
{
|
|
/**
|
|
* @return array action filters
|
|
*/
|
|
public function filters() {
|
|
return array(
|
|
'accessControl', // perform access control for CRUD operations
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Specifies the access control rules.
|
|
* This method is used by the 'accessControl' filter.
|
|
* @return array access control rules
|
|
*/
|
|
public function accessRules() {
|
|
return array(
|
|
array('allow',
|
|
'actions' => array('modificar'),
|
|
'users' => array('@'),
|
|
'expression' => 'Yii::app()->user->esCoordinador',
|
|
),
|
|
array('deny', // deny all users
|
|
'users' => array('*'),
|
|
),
|
|
);
|
|
}
|
|
|
|
public function actionModificar($id)
|
|
{
|
|
$model = $this->loadModel($id);
|
|
|
|
if (isset($_POST['Subscripcion'])) {
|
|
$model->attributes = $_POST['Subscripcion'];
|
|
|
|
if ($model->id_producto < 10)
|
|
$model->id_producto = 1;
|
|
else
|
|
$model->id_producto = 2;
|
|
|
|
if ($model->save()) {
|
|
Yii::app()->user->setFlash('success', Yii::t('profind', 'Se ha actualizado de producto'));
|
|
$this->redirect(array('modificar', 'id' => $model->id));
|
|
}
|
|
}
|
|
|
|
$this->render('modificar', array(
|
|
'model' => $model,
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Returns the data model based on the primary key given in the GET variable.
|
|
* If the data model is not found, an HTTP exception will be raised.
|
|
* @param integer the ID of the model to be loaded
|
|
*/
|
|
public function loadModel($id) {
|
|
$model = Subscripcion::model()->findByPk($id);
|
|
if ($model === null)
|
|
throw new CHttpException(404, Yii::t('profind', 'La página solicitada no existe.'));
|
|
|
|
return $model;
|
|
}
|
|
|
|
} |