本文整理汇总了PHP中UserProfile::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UserProfile::save方法的具体用法?PHP UserProfile::save怎么用?PHP UserProfile::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserProfile
的用法示例。
在下文中一共展示了UserProfile::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionRegister
/**
* Creates account for new users
*/
public function actionRegister()
{
if (!Yii::app()->user->isGuest) {
Yii::app()->request->redirect('/');
}
$user = new User('register');
$profile = new UserProfile();
if (Yii::app()->request->isPostRequest && isset($_POST['User'], $_POST['UserProfile'])) {
$user->attributes = $_POST['User'];
$profile->attributes = $_POST['UserProfile'];
$valid = $user->validate();
$valid = $profile->validate() && $valid;
if ($valid) {
$user->save();
$profile->save();
$profile->setUser($user);
// Add user to authenticated group
Yii::app()->authManager->assign('Authenticated', $user->id);
$this->addFlashMessage(Yii::t('UsersModule.core', 'Спасибо за регистрацию на нашем сайте.'));
// Authenticate user
$identity = new UserIdentity($user->username, $_POST['User']['password']);
if ($identity->authenticate()) {
Yii::app()->user->login($identity, Yii::app()->user->rememberTime);
Yii::app()->request->redirect($this->createUrl('/users/profile/index'));
}
}
}
$this->render('register', array('user' => $user, 'profile' => $profile));
}
示例2: callback
public function callback()
{
if (!$this->fb->generateSessionFromRedirect()) {
return Redirect::route('home')->with('flash_error', 'Failed to connect on Facebook.')->with('flash_color', '#c0392b');
}
$user_fb = $this->fb->getGraph();
if (empty($user_fb)) {
return Redirect::route('home')->with('flash_error', 'Failed to get data on Facebook.')->with('flash_color', '#c0392b');
}
$user = User::whereUidFb($user_fb->getProperty('id'))->first();
if (empty($user)) {
$user_profile = new UserProfile();
$user_profile->name = $user_fb->getProperty('name');
$user_profile->birthday = date(strtotime($user_fb->getProperty('birthday')));
$user_profile->photo = 'http://graph.facebook.com/' . $user_fb->getProperty('id') . '/picture?type=large';
$user_profile->save();
$user = new User();
$user->user_profile_id = $user_profile->id;
$user->privilage = 1;
$user->email = $user_fb->getProperty('email');
$user->uid_fb = $user_fb->getProperty('id');
$user->save();
}
$user->access_token_fb = $this->fb->getToken();
$user->save();
Auth::login($user);
return Redirect::route('home')->with('flash_error', 'Successfully logged in using Facebook.')->with('flash_color', '#27ae60');
}
示例3: actionAddcompany
public function actionAddcompany()
{
$companyModel = new Company();
$userLoginModel = new UserLogin();
$userProfileModel = new UserProfile();
if (isset($_POST['Company'])) {
$companyModel->attributes = $_POST['Company'];
$userLoginModel->attributes = $_POST['UserLogin'];
$userProfileModel->attributes = $_POST['UserProfile'];
if ($companyModel->validate()) {
if ($companyModel->save()) {
$userLoginModel->UserRoleID = 2;
// $userLoginModel->LoginEmail = 'addeduser@test.com';
$userLoginModel->UserPassword = md5($userLoginModel->UserPassword);
$userLoginModel->IsPasswordReset = 1;
$userLoginModel->IsActive = 1;
$userLoginModel->save();
$userProfileModel->UserLoginID = $userLoginModel->UserLoginID;
$userProfileModel->CompanyID = $companyModel->CompanyID;
// $userProfileModel->FirstName = 'Test';
// $userProfileModel->LastName = 'test';
$userProfileModel->AgreeToTerms = 0;
$userProfileModel->IsFacilitator = 0;
$userProfileModel->save();
$this->redirect(Yii::app()->createUrl('admin/setup', array('id' => $companyModel->CompanyID)));
}
}
}
$this->render('add-company', array('companyModel' => $companyModel, 'userLoginModel' => $userLoginModel, 'userProfileModel' => $userProfileModel));
}
示例4: save
public function save($username, $email, $password, $passwordConfirmation)
{
$user = new User($username, $email);
$user->password = $password;
$user->passwordConfirmation = $passwordConfirmation;
try
{
$key = $user->save();
$profile = new UserProfile;
$profile->user = $user;
$profile->save();
$mail = $this->mail();
$mail->username = $username;
$mail->activationURL = CoOrg::createFullURL(array('user/activate', $username, $key));
$mail->site = CoOrg::config()->get('site/title');
$mail->to($email)->subject(t('Complete your registration'))
->send('mails/registration');
$this->notice(t('We have sent an email to confirm your registration'));
$this->redirect('/');
}
catch (ValidationException $e)
{
$this->error(t('We could not complete your registration'));
$this->user = $user;
$this->render('create');
}
}
示例5: postAdminAccount
public function postAdminAccount()
{
$data = Input::all();
//return View::make('install.done');
try {
$user = Sentry::createUser(array('email' => $data['email'], 'password' => $data['password'], 'activated' => true, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']));
$group = Sentry::findGroupByName('admin');
$user->addGroup($group);
$quicknote = new \Quicknote();
$quicknote->user_id = $user->id;
$quicknote->save();
$userProfile = new \UserProfile();
$userProfile->id = $user->id;
$userProfile->save();
$imageResult = App::make('AuthController')->{'createUserImage'}($user->id, $data['first_name'][0], $data['last_name'][0]);
$installationDate = date('Y-m-d H:i:s');
$installationHost = Request::server('PATH_INFO');
$new92fiveConfig = new NewConfig();
$new92fiveConfig->toFile(app_path() . '/config/92five.php', ['install' => true, 'version' => '1.0', 'installationDate' => $installationDate, 'installationHost' => $installationHost]);
return View::make('install.done');
} catch (Exception $e) {
Log::error('Something Went Wrong in Install Controller Repository - addUserWithDetails():' . $e->getMessage());
throw new Exception('Something Went Wrong in Install Controller Repository - addUserWithDetails()');
}
}
示例6: run
public function run()
{
$model = new UserProfile();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['UserProfile'])) {
$model->attributes = $_POST['UserProfile'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例7: nullableFieldsSavedAsNull
public function nullableFieldsSavedAsNull()
{
$user = new UserProfile();
$user->facebook_profile = ' ';
$user->twitter_profile = 'michaeldyrynda';
$user->linkedin_profile = '';
$user->array_casted = [];
$user->save();
$this->assertSame(' ', $user->facebook_profile);
$this->assertSame('michaeldyrynda', $user->twitter_profile);
$this->assertNull($user->linkedin_profile);
$this->assertNull($user->array_casted);
$this->assertNull(null);
}
示例8: install
/**
* @return bool
*/
public function install()
{
if ($this->hasErrors()) {
return false;
}
$config = (require Yii::getPathOfAlias('application.config') . DIRECTORY_SEPARATOR . 'main.php');
$conn = new CDbConnection($config['components']['db']['connectionString'], $config['components']['db']['username'], $config['components']['db']['password']);
$conn->charset = 'utf8';
Yii::app()->setComponent('db', $conn);
$model = User::model()->findByPk(1);
if (!$model) {
$model = new User();
}
// Set user data
$model->username = $this->adminLogin;
$model->email = $this->adminEmail;
$model->password = $this->adminPassword;
$model->created_at = date('Y-m-d H:i:s');
$model->last_login = date('Y-m-d H:i:s');
$model->save(false);
// Create user profile
$profile = new UserProfile();
$profile->user_id = $model->id;
$profile->full_name = $model->username;
$profile->save();
// Translate attributes
$attrsData = array('Rms power' => 'Суммарная мощность', 'Monitor dimension' => 'Разрешение', 'Corpus material' => 'Материал', 'View angle' => 'Угол обзора', 'Sound type' => 'Тип', 'Manufacturer' => 'Производитель', 'Processor manufacturer' => 'Тип процессора', 'Phone platform' => 'Платформа', 'Freq' => 'Частота процессора', 'Phone weight' => 'Вес', 'Memmory' => 'Объем памяти', 'Phone display' => 'Диагональ', 'Memmory type' => 'Тип памяти', 'Phone camera' => 'Камера', 'Screen' => 'Диагональ', 'Tablet screen size' => 'Диагональ', 'Video' => 'Видео', 'Memmory size' => 'Объем памяти', 'Screen dimension' => 'Разрешение', 'Monitor diagonal' => 'Диагональ', 'Weight' => 'Вес');
foreach ($attrsData as $key => $val) {
Yii::app()->db->createCommand("UPDATE StoreAttributeTranslate SET title='{$val}' WHERE title='{$key}'")->execute();
}
// Translate product types
$typesData = array('laptop' => 'Ноутбук', 'computer_sound' => 'Акустика', 'monitor' => 'Монитор', 'phone' => 'Телефон', 'tablet' => 'Планшет');
foreach ($typesData as $key => $val) {
Yii::app()->db->createCommand("UPDATE StoreProductType SET name='{$val}' WHERE name='{$key}'")->execute();
}
// Display all attributes on compare page
Yii::app()->db->createCommand("UPDATE StoreAttribute SET use_in_compare=1")->execute();
$filters = array('processor_manufacturer', 'screen', 'corpus_material', 'sound_type', 'monitor_diagonal', 'phone_platform');
foreach ($filters as $name) {
Yii::app()->db->createCommand("UPDATE StoreAttribute SET use_in_filter=1 WHERE name='{$name}'")->execute();
}
// Update site settings
$siteName = Yii::app()->db->quoteValue($this->siteName);
Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value={$siteName} WHERE t.key='siteName'")->execute();
Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value='12,18,24' WHERE t.key='productsPerPage'")->execute();
Yii::app()->db->createCommand("UPDATE SystemSettings t SET t.value='30' WHERE t.key='productsPerPageAdmin'")->execute();
$this->createDiscount();
$this->createPopularProducts();
return true;
}
示例9: registerUser
public static function registerUser($input)
{
$confirmation_code = str_random(30);
$input = (object) $input;
$user = new \User();
$user->role = '5';
$user->username = $input->username;
$user->email = $input->email;
$user->password = \Hash::make($input->password);
$user->confirmation_code = $confirmation_code;
$user->save();
$profile = new \UserProfile();
$profile->id_user = $user->id;
$profile->save();
\Mail::send('warauth::emails.verify.verify', ['confirmation_code' => $confirmation_code], function ($message) use($user) {
$message->to($user->email, $user->username)->subject('verification your email address');
});
\Session::flash('register', 'Thanks for sign up to squidrop please check your email addres<br/>for verification your account.');
}
示例10: testProfile
public function testProfile()
{
$profile = new UserProfile;
$profile->user = User::getUserByName('no-profile');
$profile->gender = PROPERTY_GENDER_MALE;
$profile->birthDate = '2010-3-21';
try
{
$profile->save();
}
catch (ValidationException $e)
{
var_dump($profile->avatar_error);
}
$user = User::getUserByName('no-profile');
$userP = $user->profile;
$this->assertEquals(PROPERTY_GENDER_MALE, $userP->gender);
$this->assertEquals('2010-03-21', date('Y-m-d', $userP->birthDate));
$this->assertNull($userP->firstName);
$this->assertNull($userP->lastName);
$this->assertNull($userP->intrests);
$this->assertNull($userP->website);
$this->assertNull($userP->biography);
$userP->firstName = 'No';
$userP->lastName = 'Profile';
$userP->intrests = 'Reading, Programming, Opensource, and more';
$userP->biography = 'A user without profile (not anymore)';
$userP->website = 'somesite.in.the.wild/some/link';
$userP->save();
$profile = UserProfile::get('no-profile');
$this->assertEquals('No', $userP->firstName);
$this->assertEquals('Profile', $userP->lastName);
$this->assertEquals('Reading, Programming, Opensource, and more', $userP->intrests);
$this->assertEquals('http://somesite.in.the.wild/some/link', $userP->website);
$this->assertEquals('A user without profile (not anymore)', $userP->biography);
}
示例11: createUserProfile
/**
* {@inheritDoc}
* @see PluggableUserModule::createUserProfile()
*/
public function createUserProfile(IPluggableWebUser $user)
{
try {
$profile = new UserProfile();
$profile->user_status_id = 'ACT';
$profile->pseudo = $user->getName();
$profile->hash = sha1($user->getName());
$profile->created = date('Y-m-d H:i:s');
if ($profile->save()) {
// no user record needed
return $profile;
}
} catch (CException $e) {
// silent
}
return null;
}
示例12: range
echo "<script>window.opener.location.href='" . Yii::app()->baseUrl . "/index.php/user/dashboard/';window.close();</script>";
} else {
$length = 06;
$chars = array_merge(range(0, 9), range('a', 'z'), range('A', 'Z'));
shuffle($chars);
$password = implode(array_slice($chars, 0, $length));
$model = new User();
$model->username = $user->name;
$model->password = $password;
$model->email = $user->email;
$model->user_type = 1;
$model->is_active = 1;
$model->save();
$Id = Yii::app()->db->getLastInsertId();
$profile_pic = "http://graph.facebook.com/" . $user->id . "/picture";
$userProfile = new UserProfile();
$userProfile->user_id = $Id;
$userProfile->first_name = $user->first_name;
$userProfile->last_name = $user->last_name;
$userProfile->image = $profile_pic;
$userProfile->join_date = date('Y-m-d');
$userProfile->save(false);
Yii::app()->request->cookies['username'] = new CHttpCookie('username', $user->name);
Yii::app()->request->cookies['userId'] = new CHttpCookie('userId', $Id);
Yii::app()->request->cookies['userType'] = new CHttpCookie('userType', 1);
Yii::app()->user->setFlash('success', "You Are Now Logged With Facebook Account");
echo "<script>window.opener.location.href='" . Yii::app()->baseUrl . "/index.php/user/dashboard/';window.close();</script>";
}
} else {
echo "The state does not match. You may be a victim of CSRF.";
}
示例13: createUserAndProfile
protected function createUserAndProfile($username, $con = null)
{
// no user with this username
if (null === $con) {
$con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME);
}
try {
$con->begin();
// create a new user object
$user = new sfGuardUser();
$user->setUsername($username);
$user->setIsActive(1);
$user->setAlgorithm('');
$user->save($con);
// do we have a profile in the system with this net_id?
// this could happen if the profile was added manually by an admin
$userProfile = UserProfilePeer::selectByNetIdWithNoUserId($username);
if ($userProfile) {
// there is already a dangling user profile with this net id, link the user with the profile
$userProfile->setUserId($user->getId());
$userProfile->save($con);
} else {
// make a new user profile
$userProfile = new UserProfile();
$userProfile->setUserId($user->getId());
$userProfile->setNetId($user->getUsername());
$userProfile->save($con);
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
return $user;
}
示例14: actionLogin
public function actionLogin()
{
if (!Yii::app()->user->isGuest) {
$this->redirect(Yii::app()->createUrl('id' . Yii::app()->user->id));
}
$this->layout = 'authorization';
$model = new LoginForm();
$user = new User();
$profile = new UserProfile();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'register-form') {
echo CActiveForm::validate($user);
Yii::app()->end();
}
if (isset($_POST['User'])) {
$user->attributes = $_POST['User'];
$user->salt = time();
$user->login = $user->email;
$password = $user->password;
if ($_POST['password_repeat'] != $user->password) {
$user->addError('password', 'Пароли не совпадают');
}
if (isset($_POST['UserProfile'])) {
$profile->attributes = $_POST['UserProfile'];
$profile->birth_date = mktime(0, 0, 0, (int) $_POST['UserProfile']['birth_date'][1], (int) $_POST['UserProfile']['birth_date'][0], (int) $_POST['UserProfile']['birth_date'][2]);
}
$profile->scenario = 'register';
if (!$user->hasErrors() && $profile->validate() && $user->save()) {
//TODO: $user->validate()
$profile->tryGravatar = true;
$profile->third_name = '';
$profile->city_id = '1';
$profile->family = '0';
$profile->user_id = $user->id;
$profile->save();
}
$_POST['LoginForm'] = array('login' => $user->email, 'password' => $password);
}
// collect user input data
if (isset($_POST['LoginForm'])) {
$model->attributes = $_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if ($model->validate() && $model->login()) {
if (!isset($_GET['back'])) {
$this->redirect(Yii::app()->createUrl('id' . Yii::app()->user->id));
} else {
$this->redirect(base64_decode(urldecode($_GET['back'])));
}
}
}
// display the login form
$this->render('login', array('model' => $model, 'user' => $user, 'profile' => $profile));
}
示例15: actionCreateUser
/**
* Creates a new User Login.
* If creation is successful, the browser will be redirected to the 'index' page.
* author wawan
*/
public function actionCreateUser()
{
$model = new Userlogin();
$user_profile = new UserProfile();
//componen user option
$profile = Yii::$app->getUserOpt->Profile_user();
$usercreate = $profile->username;
$model->scenario = Userlogin::SCENARIO_USER;
if ($model->load(Yii::$app->request->post()) && $user_profile->load(Yii::$app->request->post())) {
$post = Yii::$app->request->post();
$datapostion = $post['Userlogin']['POSITION_LOGIN'];
if ($datapostion == 1) {
$auth = "SALESMAN";
// auth key untuk salesmen
} elseif ($datapostion == 2) {
$auth = "SALES PROMOTION";
// auth key untuk sales promotion
} elseif ($datapostion == 3) {
$auth = "CUSTOMER";
// auth key untuk Customers
} elseif ($datapostion == 4) {
$auth = "DISTRIBUTOR";
// auth key untuk Customers
} elseif ($datapostion == 5) {
$auth = "FACTORY PABRIK";
// auth key untuk Customers
} elseif ($datapostion == 6) {
$auth = "OUTSOURCE";
// auth key untuk Customers
}
$model->POSITION_LOGIN = $datapostion;
$model->POSITION_SITE = "CRM";
// untuk login crm
$pass = $model->password_hash;
$security = Yii::$app->security->generatePasswordHash($pass);
$authkey = Yii::$app->security->generatePasswordHash($auth);
$model->password_hash = $security;
$model->auth_key = $authkey;
$model->save();
$user_profile->ID_USER = $model->id;
$user_profile->CREATED_BY = $usercreate;
$user_profile->CREATED_AT = date("Y-m-d H:i:s");
$user_profile->save();
return $this->redirect(['index?tab=4']);
} else {
return $this->renderAjax('_usercreate', ['model' => $model, 'user_profile' => $user_profile]);
}
}