public function actionRegistration() { Yii::import('application.modules.profile.models.*'); $profile = new YumProfile(); if (isset($_POST['Profile'])) { $profile->attributes = $_POST['YumProfile']; if ($profile->save()) { $user = new YumUser(); } $password = YumUser::generatePassword(); // we generate a dummy username here, since yum requires one $user->register(md5($profile->email), $password, $profile); $this->sendRegistrationEmail($user, $password); Yum::setFlash('Thank you for your registration. Please check your email.'); $this->redirect(Yum::module()->loginUrl); } $this->render('/registration/registration', array('profile' => $profile)); }
/** * Creates a new User. */ public function actionCreate() { $model = new YumUser; if(Yum::hasModule('profile')) $profile = new YumProfile; $passwordform = new YumUserChangePassword; // When opening a empty user creation mask, we most probably want to // insert an _active_ user if(!isset($model->status)) $model->status = 1; if(isset($_POST['YumUser'])) { $model->attributes=$_POST['YumUser']; if(Yum::hasModule('role')) $model->roles = Relation::retrieveValues($_POST); if(Yum::hasModule('profile') && isset($_POST['YumProfile']) ) $profile->attributes = $_POST['YumProfile']; if(isset($_POST['YumUserChangePassword'])) { if($_POST['YumUserChangePassword']['password'] == '') { $password = YumUser::generatePassword(); $model->setPassword($password); Yum::setFlash(Yum::t('The generated Password is {password}', array( '{password}' => $password))); } else { $passwordform->attributes = $_POST['YumUserChangePassword']; if($passwordform->validate()) $model->setPassword($_POST['YumUserChangePassword']['password']); } } $model->activationKey = YumUser::encrypt(microtime() . $model->password); if($model->username == '' && isset($profile)) $model->username = $profile->email; $model->validate(); if(isset($profile)) $profile->validate(); if(!$model->hasErrors() && !$passwordform->hasErrors()) { $model->save(); if(isset($profile)) { $profile->user_id = $model->id; $profile->save(array('user_id'), false); } Yii::import('application.modules.registration.controllers.YumRegistrationController'); YumRegistrationController::sendRegistrationEmail($model); $this->redirect(array('view', 'id'=>$model->id)); } } $this->render('create',array( 'model' => $model, 'passwordform' => $passwordform, 'profile' => isset($profile) ? $profile : null, )); }