本文整理汇总了PHP中YumUser::register方法的典型用法代码示例。如果您正苦于以下问题:PHP YumUser::register方法的具体用法?PHP YumUser::register怎么用?PHP YumUser::register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YumUser
的用法示例。
在下文中一共展示了YumUser::register方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRegistration
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));
}
示例2: actionCreate
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()));
}
示例3: actionCreate
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 );
}
}
示例4: actionRegistration
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));
}
示例5: actionRegistration
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,
)
);
}