当前位置: 首页>>代码示例>>PHP>>正文


PHP user_save函数代码示例

本文整理汇总了PHP中user_save函数的典型用法代码示例。如果您正苦于以下问题:PHP user_save函数的具体用法?PHP user_save怎么用?PHP user_save使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了user_save函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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('artem_07_93@mail.ru'), 'password' => array('123456'));
    user_save($admin);
    $editor = (object) array('name' => array('Редактор Стас'), 'mail' => array('editor@mail.com'), '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


注:本文中的user_save函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。