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