Merge branch 'MDL-81132-master' of https://github.com/jleyva/moodle

This commit is contained in:
Jun Pataleta 2024-03-22 11:57:23 +08:00
commit f150d5016d
No known key found for this signature in database
GPG Key ID: F83510526D99E2C7
6 changed files with 11 additions and 3 deletions

View File

@ -1197,6 +1197,7 @@ class externallib_test extends externallib_advanced_testcase {
), $module['purpose']
);
$this->assertFalse($module['branded']);
$this->assertStringContainsString('trackingtype', $module['customdata']); // The customdata is JSON encoded.
$testexecuted = $testexecuted + 2;
} else if ($module['id'] == $labelcm->id and $module['modname'] == 'label') {
$cm = $modinfo->cms[$labelcm->id];

View File

@ -6478,7 +6478,7 @@ function forum_get_coursemodule_info($coursemodule) {
global $DB;
$dbparams = ['id' => $coursemodule->instance];
$fields = 'id, name, intro, introformat, completionposts, completiondiscussions, completionreplies, duedate, cutoffdate';
$fields = 'id, name, intro, introformat, completionposts, completiondiscussions, completionreplies, duedate, cutoffdate, trackingtype';
if (!$forum = $DB->get_record('forum', $dbparams, $fields)) {
return false;
}
@ -6505,6 +6505,8 @@ function forum_get_coursemodule_info($coursemodule) {
if ($forum->cutoffdate) {
$result->customdata['cutoffdate'] = $forum->cutoffdate;
}
// Add the forum type to the custom data for Web Services (core_course_get_contents).
$result->customdata['trackingtype'] = $forum->trackingtype;
return $result;
}

View File

@ -1139,6 +1139,8 @@ class core_user_external extends \core_external\external_api {
'theme' => new external_value(core_user::get_property_type('theme'), 'Theme name such as "standard", must exist on server', VALUE_OPTIONAL),
'timezone' => new external_value(core_user::get_property_type('timezone'), 'Timezone code such as Australia/Perth, or 99 for default', VALUE_OPTIONAL),
'mailformat' => new external_value(core_user::get_property_type('mailformat'), 'Mail format code is 0 for plain text, 1 for HTML etc', VALUE_OPTIONAL),
'trackforums' => new external_value(core_user::get_property_type('trackforums'),
'Whether the user is tracking forums.', VALUE_OPTIONAL),
'description' => new external_value(core_user::get_property_type('description'), 'User profile description', VALUE_OPTIONAL),
'descriptionformat' => new external_format_value(core_user::get_property_type('descriptionformat'), VALUE_OPTIONAL),
'city' => new external_value(core_user::get_property_type('city'), 'Home city of the user', VALUE_OPTIONAL),

View File

@ -300,7 +300,7 @@ function user_get_default_fields() {
'institution', 'interests', 'firstaccess', 'lastaccess', 'auth', 'confirmed',
'idnumber', 'lang', 'theme', 'timezone', 'mailformat', 'description', 'descriptionformat',
'city', 'country', 'profileimageurlsmall', 'profileimageurl', 'customfields',
'groups', 'roles', 'preferences', 'enrolledcourses', 'suspended', 'lastcourseaccess'
'groups', 'roles', 'preferences', 'enrolledcourses', 'suspended', 'lastcourseaccess', 'trackforums',
);
}
@ -612,7 +612,7 @@ function user_get_user_details($user, $course = null, array $userfields = array(
}
if ($currentuser or has_capability('moodle/user:viewalldetails', $context)) {
$extrafields = ['auth', 'confirmed', 'lang', 'theme', 'mailformat'];
$extrafields = ['auth', 'confirmed', 'lang', 'theme', 'mailformat', 'trackforums'];
foreach ($extrafields as $extrafield) {
if (in_array($extrafield, $userfields) && isset($user->$extrafield)) {
$userdetails[$extrafield] = $user->$extrafield;

View File

@ -304,6 +304,7 @@ class externallib_test extends externallib_advanced_testcase {
}
// Default language and no theme were used for the user.
$this->assertEquals($CFG->lang, $returneduser['lang']);
$this->assertEquals($generateduser->trackforums, $returneduser['trackforums']);
$this->assertEmpty($returneduser['theme']);
if ($returneduser['id'] == $user1->id) {

View File

@ -892,6 +892,7 @@ class userlib_test extends \advanced_testcase {
'theme' => $CFG->theme,
'timezone' => '5',
'mailformat' => '0',
'trackforums' => '1',
]);
// Fields that should get by default.
@ -903,6 +904,7 @@ class userlib_test extends \advanced_testcase {
self::assertSame($CFG->theme, $got['theme']);
self::assertSame('5', $got['timezone']);
self::assertSame('0', $got['mailformat']);
self::assertSame('1', $got['trackforums']);
}
/**