本文整理汇总了PHP中user_save函数的典型用法代码示例。如果您正苦于以下问题:PHP user_save函数的具体用法?PHP user_save怎么用?PHP user_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user_save函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _scratchpadify_install_configure_form_submit
function _scratchpadify_install_configure_form_submit($form, &$form_state)
{
global $user;
variable_set('site_name', $form_state['values']['site_name']);
variable_set('site_mail', $form_state['values']['site_mail']);
variable_set('date_default_timezone', $form_state['values']['date_default_timezone']);
// Enable update.module if this option was selected.
if ($form_state['values']['update_status_module'][1]) {
// Stop enabling the update module, it's a right royal pain in the arse.
//drupal_install_modules(array('update'));
}
// Turn this off temporarily so that we can pass a password through.
variable_set('user_email_verification', FALSE);
$form_state['old_values'] = $form_state['values'];
$form_state['values'] = $form_state['values']['account'];
// We precreated user 1 with placeholder values. Let's save the real values.
$account = user_load(1);
$merge_data = array('init' => $form_state['values']['mail'], 'roles' => array(), 'status' => 0);
user_save($account, array_merge($form_state['values'], $merge_data));
// Log in the first user.
user_authenticate($form_state['values']);
$form_state['values'] = $form_state['old_values'];
unset($form_state['old_values']);
variable_set('user_email_verification', TRUE);
if (isset($form_state['values']['clean_url'])) {
variable_set('clean_url', $form_state['values']['clean_url']);
}
// The user is now logged in, but has no session ID yet, which
// would be required later in the request, so remember it.
$user->sid = session_id();
// Record when this install ran.
variable_set('install_time', time());
}
开发者ID:edchacon,项目名称:scratchpads,代码行数:33,代码来源:scratchpadify.profile-help.php
示例2: createUser
/**
* Create a new user.
*
* @param array $data
* Array with the user's data from GitHub
* @param array $options
* Options array as passed to drupal_http_request().
* @param string $access_token
* The GitHub access token.
*
* @return \stdClass
* The newly saved user object.
*/
protected function createUser($data, $options, $access_token)
{
$fields = array('name' => $data['login'], 'mail' => $this->getEmailFromGithub($options), 'pass' => user_password(8), 'status' => TRUE, 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'), '_github' => array('access_token' => $access_token, 'data' => $data));
// The first parameter is left blank so a new user is created.
$account = user_save('', $fields);
return $account;
}
开发者ID:Gizra,项目名称:hedley-server,代码行数:20,代码来源:HedleyGithubAuthAuthentication.class.php
示例3: hook_ldapauth_create
/**
* hook_ldapauth_create
*
* Ldapauth will invoke this after a new Drupal user has been created from
* the LDAP data and saved.
*
* @param User $account The user object for the new user.
*/
function hook_ldapauth_create($account)
{
// Some example code to create an e-mail if ldap didn't provide one
if ($account->name == $account->mail) {
user_save($account, array('mail' => $account->name . "@mydomain.com"));
}
}
开发者ID:ddipika,项目名称:Cysec-PHP-code,代码行数:15,代码来源:ldapauth.api.php
示例4: save
/**
* {@inheritdoc}
*/
public function save($entity)
{
if ($entity instanceof User) {
$entity->setIsNew(false);
}
return user_save($entity);
}
开发者ID:makinacorpus,项目名称:drupal-sf-dic,代码行数:10,代码来源:UserStorage.php
示例5: create_new_user
function create_new_user(&$row)
{
msg('create_new_user');
if (!$row->is_cell_valid && !$row->is_email_valid) {
msg("no email and no cell");
$log = import_user_log_get_default($user->uid, $row->record_id, 'import', 'no-cell-or-email');
import_user_log_insert($log);
return false;
}
if (user_exists_by_phone($row)) {
msg('user_exists_by_phone');
return false;
}
if (user_exists_by_email($row)) {
msg('user_exists_by_email');
return false;
}
msg('creating');
$log_type = 'import';
$log_value = 'new';
$existing_log = import_user_log_get_by_rid_type($row->record_id, $log_type);
if ($existing_log) {
msg('already have a log for this id,type ' . $row->record_id . ',' . $log_type);
return false;
}
// cell
$number = $row->cell;
if (strlen($number) > 0) {
$sms_user[0] = array(status => 2, number => $number);
}
// password
// just a random sha hash including time so we can set the password
// we don't know/don't care what it is
// it's secure and will need to be reset by the user if they register via email later
$token = base64_encode(hash_hmac('sha256', $number, drupal_get_private_key() . time(), TRUE));
$token = strtr($token, array('+' => '-', '/' => '_', '=' => ''));
$details = array('name' => strlen($row->handle) > 1 ? $row->handle . $row->record_id : $number, 'pass' => $token, 'mail' => $row->is_email_valid ? $row->email : $number, 'access' => 0, 'status' => 1, 'sms_user' => $sms_user);
$user = user_save(null, $details);
// set values for the imported profile fields
healthimo_profile_save($user, 'profile_age', $row->age, null);
healthimo_profile_save($user, 'profile_zip_code', $row->zip, null);
healthimo_profile_save($user, 'profile_gender', $row->gender, null);
healthimo_profile_save($user, 'profile_goal', $row->goal, null);
healthimo_profile_save($user, 'profile_areas_of_interest_reply', $row->interest_areas, null);
healthimo_profile_save($user, 'profile_areas_of_interest_diabetes', $row->interest_diabetes, null);
//healthimo_profile_save($user, 'xxxxxxxxxxx', $row->interest_asthma, null);
if ($user) {
msg("import_user created user {$user->uid}");
// link to import record
$log = import_user_log_get_default($user->uid, $row->record_id, $log_type, $log_value);
import_user_log_insert($log);
print_r($user);
return $user;
}
return false;
}
开发者ID:ericlink,项目名称:asthma-adherence-and-general-health-sms,代码行数:56,代码来源:import_users_rural.php
示例6: drupalLdapUpdateUser
function drupalLdapUpdateUser($edit = array(), $ldap_authenticated = FALSE, $user)
{
if (count($edit)) {
$user = user_save($user, $edit);
}
if ($ldap_authenticated) {
user_set_authmaps($user, array('authname_ldap_authentication' => $user->name));
}
return $user;
}
开发者ID:mrschleig,项目名称:sensdata,代码行数:10,代码来源:LdapTestFunctions.class.php
示例7: actionCreate
public function actionCreate()
{
if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time']) & isset($_POST['uid'])) {
//用户积分修改
$u = user_load($_POST['uid']);
$edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 3))));
user_save($u, $edit);
$node->title = $_POST['title'];
$node->field_phone['und'][0]['value'] = $_POST['phone'];
$node->type = "sr";
$node->body['und'][0]['value'] = $_POST['content'];
$node->uid = $_POST['uid'];
$node->language = 'zh-hans';
$node->status = 0;
//(1 or 0): published or not
$node->promote = 0;
//(1 or 0): promoted to front page
$node->comment = 2;
// 0 = comments disabled, 1 = read only, 2 = read/write
//$node->field_riq['und'][0]['value'] =date('Y:m:d H:i:s');
$node->field_riq['und'][0]['value'] = $_POST['create_time'];
$node->field_src['und'][0]['value'] = $_POST['place'];
$node->field_status['und'][0]['value'] = '处理中';
//默认为匿名
if (isset($_POST['name'])) {
$node->field_shimin['und'][0]['value'] = $_POST['name'];
}
$image = CUploadedFile::getInstanceByName('img');
if (is_object($image) && get_class($image) === 'CUploadedFile') {
$dir = Yii::getPathOfAlias('webroot') . '/assets/urban/';
//$ext = $image->getExtensionName();
$fileName = uniqid() . '.jpg';
$name = $dir . $fileName;
$image->saveAs($name, true);
$file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1);
$file = file_copy($file, 'public://pictures/urban');
$node->field_tux['und'][0] = (array) $file;
}
$node = node_submit($node);
// Prepare node for saving
node_save($node);
$basic = new basic();
$basic->error_code = 0;
//$basic->error_msg="no input parameters";
$jsonObj = CJSON::encode($basic);
echo $jsonObj;
} else {
$basic = new basic();
$basic->error_code = 1;
$basic->error_msg = "no input parameters";
$jsonObj = CJSON::encode($basic);
echo $jsonObj;
}
}
开发者ID:dingruoting,项目名称:tydaily,代码行数:54,代码来源:UrbanController.php
示例8: assignRoleToUser
/**
* Assign a specific role to an user, give its UID.
*
* @param string $role_name
* Role machine name.
* @param string $uid
* User UID.
*
* @return bool
* TRUE if operation was successful, FALSE otherwise.
*/
public function assignRoleToUser($role_name, $uid)
{
$account = user_load($uid);
$role = user_role_load_by_name($role_name);
if ($role && $account) {
$account->roles[$role->rid] = $role->name;
user_save($account);
return TRUE;
}
return FALSE;
}
开发者ID:kimlop,项目名称:platform-dev,代码行数:22,代码来源:Config.php
示例9: postReset
public function postReset()
{
$drupal = new \erdiko\drupal\models\User();
$account = \user_load_by_mail($_POST['mail']);
$edit = array();
if ($_POST['pass']['pass1'] == $_POST['pass']['pass2']) {
$edit['pass'] = $_POST['pass']['pass1'];
\user_save($account, $edit);
$this->setContent('Your password was successfully changed.');
} else {
$this->setContent('The password and confirmation password do not match.');
}
}
开发者ID:saarmstrong,项目名称:erdiko-drupal,代码行数:13,代码来源:Password.php
示例10: createUser
/**
* Helper function that creates a user object with the given role.
*/
protected function createUser($role)
{
$edit = array();
$edit['name'] = $this->randomName();
$edit['mail'] = $edit['name'] . '@example.com';
// @todo role ids are completely broken, if modules are enable in the wrong
// order.
$edit['roles'] = array($role->rid => $role->name);
$edit['pass'] = user_password();
$edit['status'] = 1;
$user = user_save(drupal_anonymous_user(), $edit);
$user->pass_raw = $edit['pass'];
return $user;
}
开发者ID:hguru,项目名称:224recruiter,代码行数:17,代码来源:recruiter_common_test_case.php
示例11: iAmLoggedInWithNewUser
/**
* @Given I am logged in with new user :username
*/
public function iAmLoggedInWithNewUser($username)
{
//This will generate a random password, you could set your own here
$password = user_password(8);
//set up the user fields
$fields = array('name' => $username . user_password(), 'mail' => $username . '@email.com', 'pass' => $password, 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'));
//the first parameter is left blank so a new user is created
$account = user_save('', $fields);
// Now for the actual login.
$this->getSession()->visit('/user');
$this->getSession()->getPage()->fillField('edit-name', $username);
$this->getSession()->getPage()->fillField('edit-pass', $password);
$this->getSession()->getPage()->pressButton('edit-submit');
}
开发者ID:OS2Valghalla,项目名称:valghalla,代码行数:17,代码来源:FeatureContext.php
示例12: create_drupal_user
function create_drupal_user()
{
$user_successfully_created = "false";
$server_base = variable_get('apiary_research_base_url', 'http://localhost');
include_once drupal_get_path('module', 'apiary_project') . '/apiaryPermissionsClass.php';
$user_name = '';
if (user_access(apiaryPermissionsClass::$ADMINISTER_APIARY)) {
if (isset($_POST['name']) && $_POST['name'] != '') {
if (isset($_POST['mail']) && $_POST['mail'] != '') {
$name = $_POST['name'];
$mail = $_POST['mail'];
if (isset($_POST['pass']) && $_POST['pass'] != '') {
$pass = $_POST['pass'];
//using drupals user_save function does the md5 hash
//$pass = md5($_POST['pass']);
} else {
$pass = user_password();
//drupal function to create a md5 hash password
}
$require_role_to_use_apiary_workflow = 'administrator';
//this gets assigned to the created user
$results = db_query("SELECT rid FROM {role} WHERE NAME='%s'", $require_role_to_use_apiary_workflow);
$result = db_fetch_object($results);
$rid = $result->rid;
$newuser = array('name' => $name, 'mail' => $mail, 'status' => 1, 'pass' => $pass, 'roles' => array($rid => $require_role_to_use_apiary_workflow));
$new_user = user_save('', $newuser);
if ($new_user != false) {
$user_successfully_created = "true";
$user_name = $name;
$msg = "User " . $new_user->name . " successfully created.";
} else {
$msg = "User " . $new_user->name . " failed to be created.";
}
} else {
$msg = "No e-mail address was provided.";
}
} else {
$msg = "No username was provided.";
}
} else {
$msg = "You do not have permissions to create new users.";
}
$returnJSON['user_name'] = $user_name;
$returnJSON['user_successfully_created'] = $user_successfully_created;
$returnJSON['msg'] = $msg;
echo json_encode($returnJSON);
}
开发者ID:0x27,项目名称:apiary-project,代码行数:47,代码来源:user.functions.php
示例13: install
function install()
{
// @TODO Replace this table to one function.
db_query('DROP TABLE IF EXISTS `permissions`');
db_query('CREATE TABLE `permissions` (`rid` int NOT NULL, `type` varchar(255) CHARACTER SET utf8 NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8');
db_query('INSERT INTO `permissions` (`rid`, `type`) VALUES (\'1\', \'user anonymous\')');
db_query('INSERT INTO `permissions` (`rid`, `type`) VALUES (\'2\', \'user authorized\')');
db_query('DROP TABLE IF EXISTS `roles`');
db_query('CREATE TABLE `roles` (`rid` int NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) CHARACTER SET utf8 NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8');
db_query('INSERT INTO `roles` (`rid`, `name`) VALUES (\'1\', \'Aнонимный\')');
db_query('INSERT INTO `roles` (`rid`, `name`) VALUES (\'2\', \'Авторизованный\')');
db_query('INSERT INTO `roles` (`rid`, `name`) VALUES (\'3\', \'Редактор\')');
entity_create('users');
$admin = (object) array('name' => array('Artem'), 'mail' => array('[email protected]'), 'password' => array('123456'));
user_save($admin);
$editor = (object) array('name' => array('Редактор Стас'), 'mail' => array('[email protected]'), 'password' => array('654321'), 'roles' => array(2 => 2, 3 => 3));
user_save($editor);
}
开发者ID:artem0793,项目名称:orangutan,代码行数:18,代码来源:common.php
示例14: setUp
/**
* Setup the test.
*/
function setUp()
{
parent::setUp('block_test');
// Create an admin user, log in and enable test blocks.
$this->admin_user = $this->drupalCreateUser(array('administer blocks', 'access administration pages'));
$this->drupalLogin($this->admin_user);
// Create additional users to test caching modes.
$this->normal_user = $this->drupalCreateUser();
$this->normal_user_alt = $this->drupalCreateUser();
// Sync the roles, since drupalCreateUser() creates separate roles for
// the same permission sets.
user_save($this->normal_user_alt, array('roles' => $this->normal_user->roles));
$this->normal_user_alt->roles = $this->normal_user->roles;
// Enable block caching.
variable_set('block_cache', TRUE);
// Enable our test block.
$edit['block_test_test_cache[region]'] = 'sidebar_first';
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
}
开发者ID:pjcdawkins,项目名称:drupal7mongodb,代码行数:22,代码来源:BlockCacheTest.php
示例15: run
public function run($args)
{
//$users=Yw::model()->findAll();
$criteria = new CDbCriteria();
$criteria->condition = 'type=:type AND id<=:idmax AND id>:idmin';
$criteria->params = array(':type' => 0, ':idmax' => 60000, ':idmin' => 50000);
$criteria->order = 'id ASC';
$users = User::model()->findAll($criteria);
foreach ($users as $user) {
$account = new stdClass();
$account->name = $user->account;
$account->pass = $user->psw;
$account->field_nick['und'][0]['value'] = $user->nick;
$account->mail = $user->account . '@sina.com';
$roles = array(4 => true);
$account->roles = $roles;
$account = user_save($account);
unset($account);
}
}
开发者ID:dingruoting,项目名称:tydaily,代码行数:20,代码来源:UserCommand.php
示例16: testAuthorize
/**
* Tests authorization.
*/
public function testAuthorize()
{
// Create a user with limited permissions. We can't use
// $this->drupalCreateUser here because we need to to set a specific user
// name.
$edit = array('name' => 'Poor user', 'mail' => '[email protected]', 'pass' => user_password(), 'status' => 1);
$account = user_save(drupal_anonymous_user(), $edit);
// // Adding a mapping to the user_name will invoke authorization.
$this->addMappings('comment', array(5 => array('source' => 'mail', 'target' => 'user_mail')));
$url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds_comment_processor') . '/tests/test.csv';
$nid = $this->createFeedNode('comment', $url, 'Comment test');
$this->assertText('Failed importing 1 comment');
$this->assertText('User ' . $account->name . ' is not permitted to post comments.');
$this->assertEqual(0, db_query("SELECT COUNT(*) FROM {comment}")->fetchField());
user_role_change_permissions(2, array('post comments' => TRUE));
$this->drupalPost("node/{$nid}/import", array(), 'Import');
$this->assertText('Created 1 comment.');
$this->assertEqual(1, db_query("SELECT COUNT(*) FROM {comment}")->fetchField());
$comment = comment_load(1);
$this->assertEqual(0, $comment->status);
}
开发者ID:redponey,项目名称:openatrium-7.x-2.51,代码行数:24,代码来源:ProcessorWebTest.php
示例17: setUp
public function setUp()
{
// For benchmarking.
$this->start = time();
// Enable any modules required for the test.
parent::setUp('better_exposed_filters', 'date', 'date_views', 'list', 'number', 'taxonomy', 'text', 'views', 'views_ui');
// One of these days I'll figure out why Features is breaking all my tests.
module_enable(array('bef_test_content'));
// User with edit views perms
$this->admin_user = $this->drupalCreateUser();
$role = user_role_load_by_name('administrator');
$this->assertTrue(!empty($role->rid), 'Found the "administrator" role.');
user_save($this->admin_user, array('roles' => array($role->rid => $role->rid)));
$this->drupalLogin($this->admin_user);
// Build a basic view for use in tests.
$this->createView();
// $this->createDisplay('Page', array('path' => array('path' => 'bef_test_page')));
// Add field to default display
// $this->addField('node.title');
// Turn of Better Exposed Filters
$this->setBefExposedForm();
}
开发者ID:rwelle,项目名称:mukurtucms,代码行数:22,代码来源:better_exposed_filters_TestBase.php
示例18: createNewUser
function createNewUser($form_state)
{
//This will generate a random password, you could set your own here
$password = user_password(8);
$userName = $form_state['values']['firstName'] . ' ' . $form_state['values']['lastName'];
//set up the user fields
$fields = array('name' => $form_state['values']['primaryEmail'], 'mail' => $form_state['values']['primaryEmail'], 'pass' => $password, 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user'));
//the first parameter is left blank so a new user is created
$account = user_save('', $fields);
// Manually set the password so it appears in the e-mail.
$account->password = $fields['pass'];
// Send the e-mail through the user module.
$params['url'] = user_pass_reset_url($account);
$params['teamName'] = dbGetTeamName($form_state['TID']);
drupal_mail('users', 'userCreated', $form_state['values']['primaryEmail'], NULL, $params, '[email protected]');
$fields = array('firstName', 'lastName');
$profileData = getFields($fields, $form_state['values']);
$profileData = stripTags($profileData, '');
$profileData['UID'] = $account->uid;
dbCreateProfile($profileData);
// creating new profile
return $profileData['UID'];
}
开发者ID:ChapResearch,项目名称:CROMA,代码行数:23,代码来源:addTeamMember.php
示例19: save
/**
* Overrides Entity::save().
*
* Maintains the role, adding or removing it from the owner when necessary.
*/
public function save()
{
if ($this->uid && $this->product_id) {
$role = $this->wrapper->product->commerce_license_role->value();
$owner = $this->wrapper->owner->value();
$save_owner = FALSE;
if (!empty($this->license_id)) {
$this->original = entity_load_unchanged('commerce_license', $this->license_id);
// A plan change occurred. Remove the previous role.
if ($this->original->product_id && $this->product_id != $this->original->product_id) {
$previous_role = $this->original->wrapper->product->commerce_license_role->value();
if (isset($owner->roles[$previous_role])) {
unset($owner->roles[$previous_role]);
$save_owner = TRUE;
}
}
}
// The owner of an active license must have the role.
if ($this->status == COMMERCE_LICENSE_ACTIVE) {
if (!isset($owner->roles[$role])) {
$owner->roles[$role] = $role;
$save_owner = TRUE;
}
} elseif ($this->status > COMMERCE_LICENSE_ACTIVE) {
// The owner of an inactive license must not have the role.
if (isset($owner->roles[$role])) {
unset($owner->roles[$role]);
$save_owner = TRUE;
}
}
// If a role was added or removed, save the owner.
if ($save_owner) {
user_save($owner);
}
}
parent::save();
}
开发者ID:chelsiejohnston,项目名称:stevesstage,代码行数:42,代码来源:CommerceLicenseRole.class.php
示例20: brukar_client_login
function brukar_client_login($data)
{
global $user;
$edit = array('name' => t(variable_get('brukar_name', '!name'), array('!name' => $data['name'], '!sident' => substr($data['id'], 0, 4), '!ident' => $data['id'])), 'mail' => $data['mail'], 'status' => 1, 'data' => array('brukar' => $data));
if ($user->uid != 0) {
user_save($user, $edit);
user_set_authmaps($user, array('authname_brukar' => $data['id']));
drupal_goto('user');
}
$authmap_user = db_query('SELECT uid FROM {authmap} WHERE module = :module AND authname = :ident', array(':ident' => $data['id'], ':module' => 'brukar'))->fetch();
if ($authmap_user === FALSE) {
$provided = module_invoke_all('brukar_client_user', $edit);
$user = !empty($provided) ? $provided[0] : user_save(user_load_by_mail($data['mail']), $edit);
user_set_authmaps($user, array('authname_brukar' => $data['id']));
} else {
$user = user_save(user_load($authmap_user->uid), $edit);
}
$form_state = (array) $user;
user_login_submit(array(), $form_state);
// Better solution available?
$query = $_GET;
unset($query['q']);
drupal_goto($_GET['q'] == variable_get('site_frontpage') ? '<front>' : url($_GET['q'], array('absolute' => TRUE, 'query' => $query)));
}
开发者ID:evenos,项目名称:drupal7-module-brukar,代码行数:24,代码来源:brukar_client.oauth.php
注:本文中的user_save函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论