/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $transaction = Yii::app()->db->beginTransaction();
     try {
         $model = new User();
         if (isset($_POST['User'])) {
             $model->attributes = $_POST['User'];
             $model->password = crypt(Sysparam::model()->findByPk(AppConstants::RESET_PASSWORD_DEFAULT)->value);
             if ($model->save()) {
                 $authAssign = new AuthAssignment();
                 $authAssign->itemname = $model->role;
                 $authAssign->userid = $model->nick;
                 $authAssign->save();
                 $fsu = new FileSystemUtil();
                 $fsu->createUserTmpFoderIfNotExists($model->nick);
                 $this->audit->logAudit(Yii::app()->user->id, new DateTime(), AppConstants::AUDIT_OBJECT_USER, AppConstants::AUDIT_OPERATION_NEW, $model->nick);
                 $this->render('/site/successfullOperation', array('header' => 'Usuario creado 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;
             } else {
                 $transaction->rollback();
             }
         }
         $this->render('create', array('model' => $model));
     } catch (Exception $exc) {
         Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
         $transaction->rollback();
     }
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new User();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         $model->password = crypt(Sysparam::model()->findByPk(Constants::PARAMETRO_CONTRASENIA_REINICIO)->value);
         if ($model->save()) {
             $authAssign = new AuthAssignment();
             $authAssign->itemname = $model->role;
             $authAssign->userid = $model->nick;
             $authAssign->save();
             $fsu = new FileSystemUtil();
             $fsu->createUserTmpFoderIfNotExists($model->nick);
             $this->audit->logAudit(Yii::app()->user->id, new DateTime(), Constants::AUDITORIA_OBJETO_USUARIO, Constants::AUDITORIA_OPERACION_ALTA, $model->nick);
             $this->render('/site/successfullOperation', array('header' => 'Usuario creado 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;
         }
     }
     $this->render('create', 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 $id the ID of the model to be loaded
  * @return Sysparam the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Sysparam::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 public function resetPassword()
 {
     $defPassword = Sysparam::model()->findByPk(AppConstants::PARAMETRO_CONTRASENIA_REINICIO);
     $this->password = crypt($defPassword->value);
 }
 public function getPropertyFolder($idInmueble)
 {
     $rutaBase = Sysparam::model()->findByPk(Constants::PARAMETRO_RUTA_BASE)->value;
     return join(DIRECTORY_SEPARATOR, array($rutaBase, FileSystemUtil::IMAGES_FOLDER_NAME, $idInmueble));
 }