本文整理汇总了PHP中Profile::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::save方法的具体用法?PHP Profile::save怎么用?PHP Profile::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerUser
private function registerUser($username, $data = NULL)
{
try {
$gingerKey = sfConfig::get('app_portail_ginger_key');
if ($gingerKey != "abc") {
$ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
$cotisants = $ginger->getUser($username);
} else {
$cotisants = new stdClass();
$cotisants->mail = $username . "@etu.utc.fr";
$cotisants->prenom = "Le";
$cotisants->nom = "Testeur";
$cotisants->type = "etu";
}
if (!$data) {
$data = new sfGuardUser();
}
$data->setUsername($username);
$data->setEmailAddress($cotisants->mail);
$data->setFirstName($cotisants->prenom);
$data->setLastName($cotisants->nom);
$data->setIsActive(true);
$data->save();
$profile = new Profile();
$profile->setUser($data);
$profile->setDomain($cotisants->type);
$profile->save();
return $data;
} catch (\Ginger\Client\ApiException $ex) {
$this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
}
return false;
}
示例2: postIndex
public function postIndex()
{
$input = Input::only('first_name', 'last_name', 'email', 'username', 'password', 'domain_id');
$domain_id = Cookie::get('domain_hash') ? Cookie::get('domain_hash') : 'NULL';
$rules = array('first_name' => 'required|min:1', 'email' => 'required|email|unique:users,email,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'username' => 'required|min:3|must_alpha_num|unique:users,username,NULL,id,deleted_at,NULL,domain_id,' . $domain_id, 'password' => 'required|min:6');
$v = Validator::make($input, $rules);
if ($v->fails()) {
return Output::push(array('path' => 'register', 'errors' => $v, 'input' => TRUE));
}
$profile = new Profile(array('first_name' => $input['first_name'], 'last_name' => $input['last_name'], 'website' => ''));
$profile->save();
$user = new User(array('domain_id' => Cookie::get('domain_hash') ? Cookie::get('domain_hash') : NULL, 'email' => $input['email'], 'username' => $input['username'], 'password' => Hash::make($input['password']), 'status' => Cookie::get('domain_hash') ? 4 : 3));
$user->profile()->associate($profile);
$user->save();
if ($user->id) {
if ($user->status == 4) {
$this->add_phone_number($user->id);
}
$cookie = Cookie::forget('rndext');
$confirmation = App::make('email-confirmation');
$confirmation->send($user);
Mail::send('emails.register', array('new_user' => $input['username']), function ($message) {
$message->from(Config::get('mail.from.address'), Config::get('mail.from.name'))->to(Input::get('email'))->subject(_('New user registration'));
});
Event::fire('logger', array(array('account_register', array('id' => $user->id, 'username' => $user->username), 2)));
// return Output::push(array(
// 'path' => 'register',
// 'messages' => array('success' => _('You have registered successfully')),
// ));
return Redirect::to('register')->with('success', _('You have registered successfully'))->withCookie($cookie);
} else {
return Output::push(array('path' => 'register', 'messages' => array('fail' => _('Fail to register')), 'input' => TRUE));
}
}
示例3: createUser
/**
* for person create user, assign Customer office role, send Inivation email
* @param int $person_id
* @return boolean
*/
public function createUser($person_id)
{
$m = Person::model();
$model = $m->findByPk($person_id);
//person may be already registred as user
if (!empty($model->user_id)) {
return TRUE;
}
//create user
$password = $this->randomPassword();
$mUser = new User();
$mUser->attributes = array('username' => $model->email, 'password' => UserModule::encrypting($password), 'email' => $model->email, 'superuser' => 0, 'status' => User::STATUS_ACTIVE);
$mUser->activkey = UserModule::encrypting(microtime() . $password);
if (!$mUser->save()) {
return FALSE;
}
//attach user to person
$model->user_id = $mUser->id;
$model->save();
//create user profile
$profile = new Profile();
$profile->user_id = $mUser->id;
$profile->first_name = $model->first_name;
$profile->last_name = $model->last_name;
$profile->save();
unset($profile);
//add Customer office role
Rights::assign(DbrUser::RoleCustomerOffice, $mUser->id);
//send email
Yii::import('vendor.dbrisinajumi.person.components.invitationEmail');
$e = new invitationEmail();
$name = $model->first_name . ' ' . $model->last_name;
$e->sendInvitate($model->email, $password, $model->email, $name);
return true;
}
示例4: createUser
public function createUser(RegistrationForm $form)
{
$transaction = Yii::app()->db->beginTransaction();
try {
$user = new User('registration');
$profile = new Profile('registration');
$data = $form->getAttributes();
// Устанавливаем атрибуты пользователя
$user->setAttributes(array('email' => $data['email']));
// Генерируем для пользователя новый пароль
$password = $this->hasher->generateRandomPassword();
$user->hash = $this->hasher->hashPassword($password);
// Устанавливаем роль пользователя
$user->role = User::USER_ROLE;
$profile->setAttributes(array('name' => $data['name'], 'gender' => $data['gender'], 'birth_date' => $data['date'], 'birth_time' => $form->getTime(), 'city_id' => $data['city_id']));
$profile->subscriber = Profile::SUBSCRIBER_YES;
if ($user->save() && ($token = $this->tokenStorage->createAccountActivationToken($user)) !== false) {
$profile->user_id = $user->id;
if (!$profile->save()) {
throw new CException(Yii::t('UserModule.user', 'Error creating profile!'));
}
$event = new CEvent($this, array('user' => $user, 'password' => $password, 'token' => $token, 'programId' => $data['programId'], 'subscriptionType' => $data['subscriptionType']));
$this->onSuccessRegistration($event);
Yii::log(Yii::t('UserModule.user', 'Account {nick_name} was created', array('{nick_name}' => $user->email)), CLogger::LEVEL_INFO, UserModule::$logCategory);
$transaction->commit();
return $user;
}
throw new CException(Yii::t('UserModule.user', 'Error creating account!'));
} catch (Exception $e) {
Yii::log(Yii::t('UserModule.user', 'Error {error} account creating!', array('{error}' => $e->__toString())), CLogger::LEVEL_INFO, UserModule::$logCategory);
$transaction->rollback();
return false;
}
}
示例5: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$password = $_POST['User']['password'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
//send mail
UserModule::sendMail($model->email, UserModule::t("You are registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please login to your account with your email id as username and password {password}", array('{password}' => $password)));
$profile->user_id = $model->id;
$profile->save();
}
$this->redirect(array('/rights/assignment/user', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例6: profile
function profile()
{
// get the data to save. low on security because the user can only save to himself from here
if ($this->input->post()) {
$this->form_validation->set_rules('display_name', _('Display Name'), 'trim|max_length[30]|xss_clean');
$this->form_validation->set_rules('twitter', _('Twitter username'), 'trim|max_length[20]|xss_clean');
$this->form_validation->set_rules('bio', _('Bio'), 'trim|max_length[140]|xss_clean');
if ($this->form_validation->run()) {
$profile = new Profile($this->tank_auth->get_user_id());
// use the from_array to be sure what's being inputted
$profile->display_name = $this->form_validation->set_value('display_name');
$profile->twitter = $this->form_validation->set_value('twitter');
$profile->bio = $this->form_validation->set_value('bio');
if ($profile->save()) {
$data["saved"] = TRUE;
}
}
}
$user = new User($this->tank_auth->get_user_id());
$profile = new Profile($this->tank_auth->get_user_id());
$data["user_id"] = $user->id;
$data["user_name"] = $user->username;
$data["user_email"] = $user->email;
$data["user_display_name"] = $profile->display_name;
$data["user_twitter"] = $profile->twitter;
$data["user_bio"] = $profile->bio;
$this->viewdata["function_title"] = _("Your profile");
$this->viewdata["main_content_view"] = $this->load->view('account/profile/profile', $data, TRUE);
$this->load->view("account/default.php", $this->viewdata);
}
示例7: doClean
/**
* @see sfValidatorBase
*/
protected function doClean($values)
{
// only validate if username and password are both present
if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) {
$username = $values[$this->getOption('username_field')];
$password = $values[$this->getOption('password_field')];
// user exists?
if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
// password is ok?
if ($user->getIsActive()) {
if (Configuration::get('ldap_enabled', false)) {
if (authLDAP::checkPassword($username, $password)) {
return array_merge($values, array('user' => $user));
}
} elseif ($user->checkPassword($password)) {
return array_merge($values, array('user' => $user));
}
}
} elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) {
$user = new sfGuardUser();
$user->setUsername($username);
$user->save();
$profile = new Profile();
$profile->setSfGuardUserId($user->getId());
$profile->save();
return array_merge($values, array('user' => $user));
}
if ($this->getOption('throw_global_error')) {
throw new sfValidatorError($this, 'invalid');
}
throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
}
// assume a required error has already been thrown, skip validation
return $values;
}
示例8: setUp
public function setUp()
{
parent::setUp();
$this->setUpData();
$this->setUpProfile();
$user = new User();
$user->email = 'test_1@gmail.com';
$user->password = '123456';
$user->save();
$other_user = User::where('email', 'test_1@gmail.com')->first()->user_id;
$profile = new Profile();
$profile->user_id = $other_user;
$profile->follower_count = '4';
$profile->following_count = '7';
$profile->rate_count = '6';
$profile->comment_count = '9';
$profile->scan_count = '15';
$profile->last_name = 'pro2';
$profile->first_name = 'user other 1';
$profile->save();
$follow = new Follow();
$follow->from_id = $this->_user_id;
$follow->to_id = $other_user;
$follow->save();
}
示例9: aProfile
private function aProfile($pid)
{
$this->caller->requireAuthentication();
require_once FRAMEWORK_PATH . 'models/profile.php';
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
if ($pid == $this->registry->getObject('authenticate')->getUser()->getUserID()) {
$profile = new Profile($this->registry, $pid);
if ($profile->isValid()) {
$data = $this->caller->getRequestData();
$profile->setName($this->registry->getObject('db')->sanitizeData($data['name']));
$profile->setDinoName($this->registry->getObject('db')->sanitizeData($data['dino_name']));
// etc, set all appropriate methods
$profile->save();
header('HTTP/1.0 204 No Content');
exit;
} else {
header('HTTP/1.0 404 Not Found');
exit;
}
} else {
header('HTTP/1.0 403 Forbidden');
exit;
}
} else {
$profile = new Profile($this->registry, $pid);
if ($profile->isValid()) {
header('HTTP/1.0 200 OK');
echo json_encode($profile->toArray());
exit;
} else {
header('HTTP/1.0 404 Not Found');
exit;
}
}
}
示例10: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
if (isset($_POST['Profile'])) {
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
}
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
$_POST['Profile']['firstname'] = $model->firstname;
$_POST['Profile']['lastname'] = $model->lastname;
if (isset($_POST['Profile'])) {
$profile->user_id = $model->id;
$profile->save();
}
//Function in components/Controller.php
//$this->assignRole($model->id, 'Subscription');
if (isset($_POST['System']['role'])) {
$this->assignRole($model->id, $_POST['System']['role']);
}
}
$this->redirect(array('view', 'id' => $model->id));
//} else {
//$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例11: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
$manager = !User::model()->isAuthor();
$admin = User::model()->isAdmin();
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$_temp = array('', 'icq', 'sms', 'email');
$_POST['Profile']['mailing_list'] = array_search($_POST['Profile']['mailing_list'], $_temp);
$profile->attributes = $_POST['Profile'];
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
}
$this->redirect(array('view', 'id' => $model->id));
} else {
$profile->validate();
}
}
$fields = ProfileField::model()->findAll();
$this->render('create', array('model' => $model, 'profile' => $profile, 'fields' => $fields, 'manager' => $manager, 'admin' => $admin));
}
示例12: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
$this->performAjaxValidation(array($model, $profile));
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
$profile->user_id = $model->id;
/**
* date added: 03 December 2013
* purpose: save Pstc (profile field) during User Update
*/
//$profile->pstc=$_POST['Profile']['pstc'];
if ($profile->accesslist != '') {
$profile->accesslist = implode(',', $_POST['Profile']['accesslist']);
}
//converting to string...
$profile->save();
$authorizer = Yii::app()->getModule("rights")->getAuthorizer();
$authorizer->authManager->assign($_POST['accesslevel'], $model->id);
}
$this->redirect(array('view', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例13: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new User();
$profile = new Profile();
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
$model->activkey = Yii::app()->controller->module->encrypting(microtime() . $model->password);
$model->createtime = time();
$model->lastvisit = time();
$profile->attributes = $_POST['Profile'];
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$model->password = Yii::app()->controller->module->encrypting($model->password);
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
// assign user the 'Authenticated' role for Rights module
$authenticatedName = Rights::module()->authenticatedName;
Rights::assign($authenticatedName, $model->id);
// end of change
}
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例14: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*
* @return void
*/
public function actionCreate()
{
$model = new User('create');
$profile = new Profile();
if (($data = Yii::app()->getRequest()->getPost('User')) !== null) {
$model->setAttributes($data);
$model->setAttributes(array('hash' => Yii::app()->userManager->hasher->hashPassword(Yii::app()->userManager->hasher->generateRandomPassword())));
$profile->setAttributes(Yii::app()->getRequest()->getPost('Profile'));
$profile->user_id = 0;
if ($model->validate() && $profile->validate()) {
$transaction = Yii::app()->db->beginTransaction();
if ($model->save()) {
$profile->user_id = $model->id;
$profile->save();
$transaction->commit();
Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('UserModule.user', 'New user was created!'));
$this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', array('create')));
} else {
$transaction->rollback();
}
$this->redirect(array('view', 'id' => $model->id));
} else {
$profile->validate();
}
}
$this->render('create', array('model' => $model, 'profile' => $profile));
}
示例15: setUp
public function setUp()
{
parent::setUp();
$this->setUpData();
$this->setUpRating();
$this->setUpProfile();
$user = new User();
$user->email = 'test_1@gmail.com';
$user->password = '123456';
$user->save();
$follow_id = User::where('email', 'test_1@gmail.com')->first()->user_id;
$profile = new Profile();
$profile->user_id = $follow_id;
$profile->follower_count = '13';
$profile->following_count = '2';
$profile->rate_count = '32';
$profile->comment_count = '12';
$profile->scan_count = '8';
$profile->last_name = 'pro3';
$profile->first_name = 'user login';
$profile->save();
$follow = new Follow();
$follow->id = 1;
$follow->from_id = $this->_user_id;
$follow->to_id = $follow_id;
$follow->save();
}