register() public méthode

Registers a user
public register ( $username = null, $password = null, $profile = null )
 public function actionRegistration()
 {
     // When we override the registrationUrl, this one should not be accessible
     // anymore
     if (Yum::module('registration')->registrationUrl != array('//registration/registration/registration')) {
         throw new CHttpException(403);
     }
     Yii::import('user.profile.models.*');
     $form = new YumRegistrationForm();
     $profile = new YumProfile();
     $this->performAjaxValidation('YumRegistrationForm', $form);
     if (isset($_POST['YumRegistrationForm'])) {
         $form->attributes = $_POST['YumRegistrationForm'];
         $profile->attributes = $_POST['YumProfile'];
         if (Yum::module('registration')->registration_by_email) {
             $form->username = $profile->email;
         }
         $form->validate();
         $profile->validate();
         if (!$form->hasErrors() && !$profile->hasErrors()) {
             $user = new YumUser();
             $user->register($form->username, $form->password, $profile);
             $user->profile = $profile;
             $this->sendRegistrationEmail($user);
             Yum::setFlash('Thank you for your registration. Please check your email.');
             $this->redirect(Yum::module()->loginUrl);
         }
     }
     $this->render(Yum::module('registration')->registrationView, array('form' => $form, 'profile' => $profile));
 }
 public function actionCreate()
 {
     // if some data has been entered before or the user is already logged in,
     // take the already existing data and prefill the input form
     if ($model = Shop::getCustomer()) {
         $address = $model->address;
     } else {
         $model = new Customer();
     }
     if (isset($_POST['Customer'])) {
         $model->attributes = $_POST['Customer'];
         if (isset($_POST['Address'])) {
             $address = new Address();
             $address->attributes = $_POST['Address'];
             if ($address->save()) {
                 $model->address_id = $address->id;
             }
         }
         if (!Yii::app()->user->isGuest) {
             $model->user_id = Yii::app()->user->id;
         }
         $model->validate();
         if (Shop::module()->useWithYum && isset($_POST['register']) && ($_POST['register'] = true)) {
             if (isset($_POST['Customer']['password']) && isset($_POST['Customer']['passwordRepeat'])) {
                 if ($_POST['Customer']['password'] != $_POST['Customer']['passwordRepeat']) {
                     $model->addError('password', Shop::t('Passwords do not match'));
                 } else {
                     if ($_POST['Customer']['password'] == '') {
                         $model->addError('password', Shop::t('Password is empty'));
                     } else {
                         $user = new YumUser();
                         $profile = new YumProfile();
                         $profile->attributes = $_POST['Customer'];
                         $profile->attributes = $_POST['Address'];
                         if ($user->register(strtr($model->email, array('@' => '_', '.' => '_')), $_POST['Customer']['password'], $profile)) {
                             $user->status = YumUser::STATUS_ACTIVE;
                             $user->save(false, array('status'));
                             $model->user_id = $user->id;
                             Shop::setFlash(Shop::t('Successfully registered user'));
                         } else {
                             $model->addErrors($user->getErrors());
                             $model->addErrors($profile->getErrors());
                             Shop::setFlash(Shop::t('Error while registering user'));
                         }
                     }
                 }
             }
         }
         if (!$model->hasErrors()) {
             if ($model->save()) {
                 Yii::app()->user->setState('customer_id', $model->customer_id);
                 $this->redirect(array('//shop/order/create', 'customer' => $model->customer_id));
             }
         }
     }
     $this->render('create', array('customer' => $model, 'address' => isset($address) ? $address : new Address()));
 }
	public function actionCreate($mode)
	{
		switch($mode)
		{
			case 'user':
				$model = new YumUser;
				$profile = new YumProfile;
				break;
			default:
		}
		$username = $_POST['username'] or $this->_sendResponse(
				501, 'Username missing');
		$password = $_POST['password'] or $this->_sendResponse(
				501, 'Password missing');

		foreach($_POST as $key => $value)
			if($profile->hasAttribute($key))
				$profile->$key = $value;

		if($profile->validate() && $model->register($username, $password, $profile))
			$this->_sendResponse(200, 
					CJSON::encode(array($model, $profile)));	
		else {
			$msg = "<h1>Error</h1>";
			$msg .= sprintf("Couldn't create %s", $mode);
			$msg .= "<ul>";
			foreach($model->errors as $attribute => $attr_errors) {
				$msg .= "<li>Attribute: $attribute</li>";
				$msg .= "<ul>";
				foreach($attr_errors as $attr_error)
					$msg .= "<li>$attr_error</li>";
				$msg .= "</ul>";
			}

			foreach($profile->errors as $attribute => $attr_errors) {
				$msg .= "<li>Attribute: $attribute</li>";
				$msg .= "<ul>";
				foreach($attr_errors as $attr_error)
					$msg .= "<li>$attr_error</li>";
				$msg .= "</ul>";
			}
			$msg .= "</ul>";
			$this->_sendResponse(500, $msg );

		}
	}
 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));
 }
	public function actionRegistration() {
		// When we overrie the registrationUrl, this one is not valid anymore!
		if(Yum::module('registration')->registrationUrl != array(
					'//registration/registration/registration'))
			throw new CHttpException(403);

		Yii::import('application.modules.profile.models.*');
		$form = new YumRegistrationForm;
		$profile = new YumProfile;

		$this->performAjaxValidation('YumRegistrationForm', $form);

		if (isset($_POST['YumRegistrationForm'])) { 
			$form->attributes = $_POST['YumRegistrationForm'];
			$profile->attributes = $_POST['YumProfile'];

			$form->validate();
			$profile->validate();

			if(!$form->hasErrors() && !$profile->hasErrors()) {
				$user = new YumUser;
				
				$user->register($form->username, $form->password, $profile->email);
				$profile->user_id = $user->id;
				$profile->save();

				$this->sendRegistrationEmail($user);
				Yum::setFlash('Thank you for your registration. Please check your email.');
				$this->redirect(Yum::module()->loginUrl);
			}
		} 

		$this->render(Yum::module()->registrationView, array(
					'form' => $form,
					'profile' => $profile,
					)
				);  
	}