コード例 #1
0
 /**
  * description: Hidrata el array $arguments con la informacion enviada desde el cliente dependiendo del
  * metodo que se trate.
  */
 public function actionProcessRequest()
 {
     $hU = new HttpUtils();
     $this->httpMethod = $hU->getHttpRequestMethod();
     switch ($this->httpMethod) {
         case HttpUtils::METHOD_GET:
             $this->arguments = $_GET;
             $this->processGet();
             break;
         case HttpUtils::METHOD_HEAD:
             $this->arguments = $_GET;
             $this->processHead();
             break;
         case HttpUtils::METHOD_POST:
             $json = file_get_contents('php://input');
             $this->arguments = CJSON::decode($json);
             if ($this->arguments == null) {
                 $this->arguments = $_POST;
             }
             $this->processPost();
             break;
         case HttpUtils::METHOD_PUT:
             $this->processPut();
             break;
         case HttpUtils::METHOD_DELETE:
             parse_str(file_get_contents('php://input'), $this->arguments);
             $this->processDelete();
             break;
     }
 }
コード例 #2
0
 public function actionUpdateState($id)
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $model = $this->loadModel($id);
         $hU = new HttpUtils();
         if (strcmp($hU->getHttpRequestMethod(), HttpUtils::METHOD_POST) == 0) {
             if ($model->enabled == 1) {
                 $model->enabled = 0;
             } else {
                 $model->enabled = 1;
             }
             if ($model->save()) {
                 $this->audit->logAudit(Yii::app()->user->id, new DateTime(), AppConstants::AUDIT_OBJECT_USER, AppConstants::AUDIT_OPERATION_EDIT, $model->nick);
                 $this->render('/site/successfullOperation', array('header' => 'Usuario modificado con éxito', 'message' => 'Haga click en volver para regresar a la gestión de usuarios', 'returnUrl' => Yii::app()->createUrl('user/admin'), 'viewUrl' => Yii::app()->createUrl("user/view", array("id" => $model->nick))));
                 $transaction->commit();
                 return;
             }
         }
         if ($model->enabled == 1) {
             $header = 'Bloquear usuario';
             $message = "¿Esta seguro que desea bloquear el usuario {$model->nick}?";
         } else {
             $header = 'Desbloquear usuario';
             $message = "¿Esta seguro que desea desbloquear el usuario {$model->nick}?";
         }
         $transaction->commit();
         $this->render('changeState', array('header' => $header, 'message' => $message));
     } catch (Exception $exc) {
         Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
         $transaction->rollback();
     }
 }
コード例 #3
0
 public function actionUpdateState($id)
 {
     $model = $this->loadModel($id);
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $hU = new HttpUtils();
     if (strcmp($hU->getHttpRequestMethod(), HttpUtils::METHOD_POST) == 0) {
         if ($model->enabled == 1) {
             $model->enabled = 0;
         } else {
             $model->enabled = 1;
         }
         if ($model->save()) {
             $this->audit->logAudit(Yii::app()->user->id, new DateTime(), Constants::AUDITORIA_OBJETO_USUARIO, Constants::AUDITORIA_OPERACION_MODIFICACION, $model->nick);
             $this->render('/site/successfullOperation', array('header' => 'Usuario modificado con éxito', 'message' => 'Haga click en volver para regresar a la gestión de usuarios', 'returnUrl' => Yii::app()->createUrl('user/admin'), 'viewUrl' => Yii::app()->createUrl("user/view", array("id" => $model->nick))));
             return;
         }
     }
     if ($model->enabled == 1) {
         $header = 'Bloquear usuario';
         $message = "¿Esta seguro que desea bloquear el usuario {$model->nick}?";
     } else {
         $header = 'Desbloquear usuario';
         $message = "¿Esta seguro que desea desbloquear el usuario {$model->nick}?";
     }
     $this->render('changeState', array('header' => $header, 'message' => $message));
 }