/** * Sign up a new user ready for confirmation. * Password is passed in plaintext. * * @param object $user new user object (with system magic quotes) * @param boolean $notify print notice with link and terminate */ function user_signup($user, $notify = true) { global $CFG; require_once $CFG->dirroot . '/user/profile/lib.php'; $user->password = hash_internal_user_password($user->password); if (!($user->id = insert_record('user', $user))) { print_error('auth_emailnoinsert', 'auth'); } /// Save any custom profile field information profile_save_data($user); $user = get_record('user', 'id', $user->id); events_trigger('user_created', $user); if (function_exists('local_send_confirmation_email')) { if (!local_send_confirmation_email($user)) { print_error('auth_emailnoemail', 'auth'); } } elseif (!send_confirmation_email($user)) { print_error('auth_emailnoemail', 'auth'); } if (function_exists('local_user_signup')) { local_user_signup($user); } if ($notify) { global $CFG; $emailconfirm = get_string('emailconfirm'); $navlinks = array(); $navlinks[] = array('name' => $emailconfirm, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); print_header($emailconfirm, $emailconfirm, $navigation); notice(get_string('emailconfirmsent', '', $user->email), "{$CFG->wwwroot}/index.php"); } else { return true; } }
$info = ': ' . $user->username . ' (ID = ' . $user->id . ')'; $upt->track('status', $struseradded); $upt->track('id', $user->id, 'normal', false); $usersnew++; if ($createpasswords and empty($user->password)) { // passwords will be created and sent out on cron set_user_preference('create_password', 1, $user->id); set_user_preference('auth_forcepasswordchange', 1, $user->id); $upt->track('password', get_string('new')); } if ($forcechangepassword) { set_user_preference('auth_forcepasswordchange', 1, $user->id); } //now do role assignment for PT if (function_exists('local_user_signup')) { local_user_signup($user); } //now do e-mail conf to user. if (function_exists('local_send_confirmation_email')) { if (!local_send_confirmation_email($user)) { print_error('auth_emailnoemail', 'auth'); } } } else { // Record not added -- possibly some other error $upt->track('status', $strusernotaddederror, 'error'); $userserrors++; continue; } // save custom profile fields data profile_save_data($user);