本文整理汇总了PHP中useredit_update_interests函数的典型用法代码示例。如果您正苦于以下问题:PHP useredit_update_interests函数的具体用法?PHP useredit_update_interests怎么用?PHP useredit_update_interests使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了useredit_update_interests函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_postupdate_standard_editor
// Description editor element may not exist!
if (isset($usernew->description_editor) && isset($usernew->description_editor['format'])) {
$usernew = file_postupdate_standard_editor($usernew, 'description', $editoroptions, $personalcontext, 'user', 'profile', 0);
}
// Pass a true old $user here.
if (!$authplugin->user_update($user, $usernew)) {
// Auth update failed.
print_error('cannotupdateprofile');
}
// Update user with new profile data.
user_update_user($usernew, false, false);
// Update preferences.
useredit_update_user_preference($usernew);
// Update interests.
if (isset($usernew->interests)) {
useredit_update_interests($usernew, $usernew->interests);
}
// Update user picture.
if (empty($CFG->disableuserimages)) {
useredit_update_picture($usernew, $userform, $filemanageroptions);
}
// Update mail bounces.
useredit_update_bounces($user, $usernew);
// Update forum track preference.
useredit_update_trackforums($user, $usernew);
// Save custom profile fields data.
profile_save_data($usernew);
// Trigger event.
\core\event\user_updated::create_from_userid($user->id)->trigger();
// If email was changed and confirmation is required, send confirmation email now to the new address.
if ($emailchanged && $CFG->emailchangeconfirmation) {
示例2: useredit_update_interests
// Trigger event.
\core\event\user_created::create_from_userid($user->id)->trigger();
$upt->track('status', $struseradded);
$upt->track('id', $user->id, 'normal', false);
$usersnew++;
// make sure user context exists
context_user::instance($user->id);
if ($bulk == UU_BULK_NEW or $bulk == UU_BULK_ALL) {
if (!in_array($user->id, $SESSION->bulk_users)) {
$SESSION->bulk_users[] = $user->id;
}
}
}
// Update user interests.
if (isset($user->interests) && strval($user->interests) !== '') {
useredit_update_interests($user, preg_split('/\\s*,\\s*/', $user->interests, -1, PREG_SPLIT_NO_EMPTY));
}
// add to cohort first, it might trigger enrolments indirectly - do NOT create cohorts here!
foreach ($filecolumns as $column) {
if (!preg_match('/^cohort\\d+$/', $column)) {
continue;
}
if (!empty($user->{$column})) {
$addcohort = $user->{$column};
if (!isset($cohorts[$addcohort])) {
if (is_number($addcohort)) {
// only non-numeric idnumbers!
$cohort = $DB->get_record('cohort', array('id' => $addcohort));
} else {
$cohort = $DB->get_record('cohort', array('idnumber' => $addcohort));
if (empty($cohort) && has_capability('moodle/cohort:manage', context_system::instance())) {
示例3: create_user
//.........这里部分代码省略.........
$record['firstname'] = 'Firstname' . $i;
} else {
if (!isset($record['lastname'])) {
$record['lastname'] = 'Lastname' . $i;
}
}
}
if (!isset($record['firstnamephonetic'])) {
$firstnamephonetic = rand(0, 59);
$record['firstnamephonetic'] = $this->firstnames[$firstnamephonetic];
}
if (!isset($record['lastnamephonetic'])) {
$lastnamephonetic = rand(0, 59);
$record['lastnamephonetic'] = $this->lastnames[$lastnamephonetic];
}
if (!isset($record['middlename'])) {
$middlename = rand(0, 59);
$record['middlename'] = $this->firstnames[$middlename];
}
if (!isset($record['alternatename'])) {
$alternatename = rand(0, 59);
$record['alternatename'] = $this->firstnames[$alternatename];
}
if (!isset($record['idnumber'])) {
$record['idnumber'] = '';
}
if (!isset($record['mnethostid'])) {
$record['mnethostid'] = $CFG->mnet_localhost_id;
}
if (!isset($record['username'])) {
$record['username'] = 'username' . $i;
$j = 2;
while ($DB->record_exists('user', array('username' => $record['username'], 'mnethostid' => $record['mnethostid']))) {
$record['username'] = 'username' . $i . '_' . $j;
$j++;
}
}
if (isset($record['password'])) {
$record['password'] = hash_internal_user_password($record['password']);
} else {
// The auth plugin may not fully support this,
// but it is still better/faster than hashing random stuff.
$record['password'] = AUTH_PASSWORD_NOT_CACHED;
}
if (!isset($record['email'])) {
$record['email'] = $record['username'] . '@example.com';
}
if (!isset($record['confirmed'])) {
$record['confirmed'] = 1;
}
if (!isset($record['lang'])) {
$record['lang'] = 'en';
}
if (!isset($record['maildisplay'])) {
$record['maildisplay'] = $CFG->defaultpreference_maildisplay;
}
if (!isset($record['mailformat'])) {
$record['mailformat'] = $CFG->defaultpreference_mailformat;
}
if (!isset($record['maildigest'])) {
$record['maildigest'] = $CFG->defaultpreference_maildigest;
}
if (!isset($record['autosubscribe'])) {
$record['autosubscribe'] = $CFG->defaultpreference_autosubscribe;
}
if (!isset($record['trackforums'])) {
$record['trackforums'] = $CFG->defaultpreference_trackforums;
}
if (!isset($record['deleted'])) {
$record['deleted'] = 0;
}
if (!isset($record['timecreated'])) {
$record['timecreated'] = time();
}
$record['timemodified'] = $record['timecreated'];
$record['lastip'] = '0.0.0.0';
if ($record['deleted']) {
$delname = $record['email'] . '.' . time();
while ($DB->record_exists('user', array('username' => $delname))) {
$delname++;
}
$record['idnumber'] = '';
$record['email'] = md5($record['username']);
$record['username'] = $delname;
$record['picture'] = 0;
}
$userid = $DB->insert_record('user', $record);
if (!$record['deleted']) {
context_user::instance($userid);
}
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
if (!$record['deleted'] && isset($record['interests'])) {
require_once $CFG->dirroot . '/user/editlib.php';
if (!is_array($record['interests'])) {
$record['interests'] = preg_split('/\\s*,\\s*/', trim($record['interests']), -1, PREG_SPLIT_NO_EMPTY);
}
useredit_update_interests($user, $record['interests']);
}
return $user;
}
示例4: test_get_users_by_id
/**
* Test get_users_by_id
*/
public function test_get_users_by_id() {
global $USER, $CFG;
$this->resetAfterTest(true);
$user1 = array(
'username' => 'usernametest1',
'idnumber' => 'idnumbertest1',
'firstname' => 'First Name User Test 1',
'lastname' => 'Last Name User Test 1',
'email' => 'usertest1@email.com',
'address' => '2 Test Street Perth 6000 WA',
'phone1' => '01010101010',
'phone2' => '02020203',
'icq' => 'testuser1',
'skype' => 'testuser1',
'yahoo' => 'testuser1',
'aim' => 'testuser1',
'msn' => 'testuser1',
'department' => 'Department of user 1',
'institution' => 'Institution of user 1',
'description' => 'This is a description for user 1',
'descriptionformat' => FORMAT_MOODLE,
'city' => 'Perth',
'url' => 'http://moodle.org',
'country' => 'au'
);
$user1 = self::getDataGenerator()->create_user($user1);
if (!empty($CFG->usetags)) {
require_once($CFG->dirroot . '/user/editlib.php');
require_once($CFG->dirroot . '/tag/lib.php');
$user1->interests = array('Cinema', 'Tennis', 'Dance', 'Guitar', 'Cooking');
useredit_update_interests($user1, $user1->interests);
}
$user2 = self::getDataGenerator()->create_user();
$context = context_system::instance();
$roleid = $this->assignUserCapability('moodle/user:viewdetails', $context->id);
// Call the external function.
$returnedusers = core_user_external::get_users_by_id(array(
$USER->id, $user1->id, $user2->id));
// We need to execute the return values cleaning process to simulate the web service server.
$returnedusers = external_api::clean_returnvalue(core_user_external::get_users_by_id_returns(), $returnedusers);
// Check we retrieve the good total number of enrolled users + no error on capability.
$this->assertEquals(3, count($returnedusers));
// Do the same call as admin to receive all possible fields.
$this->setAdminUser();
$USER->email = "admin@fakeemail.com";
// Call the external function.
$returnedusers = core_user_external::get_users_by_id(array(
$USER->id, $user1->id, $user2->id));
// We need to execute the return values cleaning process to simulate the web service server.
$returnedusers = external_api::clean_returnvalue(core_user_external::get_users_by_id_returns(), $returnedusers);
foreach($returnedusers as $enrolleduser) {
if ($enrolleduser['username'] == $user1->username) {
$this->assertEquals($user1->idnumber, $enrolleduser['idnumber']);
$this->assertEquals($user1->firstname, $enrolleduser['firstname']);
$this->assertEquals($user1->lastname, $enrolleduser['lastname']);
$this->assertEquals($user1->email, $enrolleduser['email']);
$this->assertEquals($user1->address, $enrolleduser['address']);
$this->assertEquals($user1->phone1, $enrolleduser['phone1']);
$this->assertEquals($user1->phone2, $enrolleduser['phone2']);
$this->assertEquals($user1->icq, $enrolleduser['icq']);
$this->assertEquals($user1->skype, $enrolleduser['skype']);
$this->assertEquals($user1->yahoo, $enrolleduser['yahoo']);
$this->assertEquals($user1->aim, $enrolleduser['aim']);
$this->assertEquals($user1->msn, $enrolleduser['msn']);
$this->assertEquals($user1->department, $enrolleduser['department']);
$this->assertEquals($user1->institution, $enrolleduser['institution']);
$this->assertEquals($user1->description, $enrolleduser['description']);
$this->assertEquals(FORMAT_HTML, $enrolleduser['descriptionformat']);
$this->assertEquals($user1->city, $enrolleduser['city']);
$this->assertEquals($user1->country, $enrolleduser['country']);
$this->assertEquals($user1->url, $enrolleduser['url']);
if (!empty($CFG->usetags)) {
$this->assertEquals(implode(', ', $user1->interests), $enrolleduser['interests']);
}
}
}
}
示例5: get_course_user_profiles_setup
public function get_course_user_profiles_setup($capability)
{
global $USER, $CFG;
$this->resetAfterTest(true);
$return = new stdClass();
// Create the course and fetch its context.
$return->course = self::getDataGenerator()->create_course();
$return->user1 = array('username' => 'usernametest1', 'idnumber' => 'idnumbertest1', 'firstname' => 'First Name User Test 1', 'lastname' => 'Last Name User Test 1', 'email' => 'usertest1@example.com', 'address' => '2 Test Street Perth 6000 WA', 'phone1' => '01010101010', 'phone2' => '02020203', 'icq' => 'testuser1', 'skype' => 'testuser1', 'yahoo' => 'testuser1', 'aim' => 'testuser1', 'msn' => 'testuser1', 'department' => 'Department of user 1', 'institution' => 'Institution of user 1', 'description' => 'This is a description for user 1', 'descriptionformat' => FORMAT_MOODLE, 'city' => 'Perth', 'url' => 'http://moodle.org', 'country' => 'AU');
$return->user1 = self::getDataGenerator()->create_user($return->user1);
if (!empty($CFG->usetags)) {
require_once $CFG->dirroot . '/user/editlib.php';
$return->user1->interests = array('Cinema', 'Tennis', 'Dance', 'Guitar', 'Cooking');
useredit_update_interests($return->user1, $return->user1->interests);
}
$return->user2 = self::getDataGenerator()->create_user();
$context = context_course::instance($return->course->id);
$return->roleid = $this->assignUserCapability($capability, $context->id);
// Enrol the users in the course.
$this->getDataGenerator()->enrol_user($return->user1->id, $return->course->id, $return->roleid, 'manual');
$this->getDataGenerator()->enrol_user($return->user2->id, $return->course->id, $return->roleid, 'manual');
$this->getDataGenerator()->enrol_user($USER->id, $return->course->id, $return->roleid, 'manual');
return $return;
}