Commit f4a604e4 authored by Sara Arjona's avatar Sara Arjona

Merge branch 'MDL-68716-310' of git://github.com/paulholden/moodle into MOODLE_310_STABLE

parents 0ecc30eb 76e39a9c
......@@ -444,7 +444,7 @@ class provider implements
$vaultfactory = \mod_forum\local\container::get_vault_factory();
$discussionlistvault = $vaultfactory->get_discussions_in_forum_vault();
$discussionlistsortorder = get_user_preferences('forum_discussionlistsortorder',
$discussionlistvault::SORTORDER_LASTPOST_DESC);
$discussionlistvault::SORTORDER_LASTPOST_DESC, $user->id);
switch ($discussionlistsortorder) {
case $discussionlistvault::SORTORDER_LASTPOST_DESC:
$discussionlistsortorderdescription = get_string('discussionlistsortbylastpostdesc',
......@@ -470,6 +470,30 @@ class provider implements
$discussionlistsortorderdescription = get_string('discussionlistsortbyrepliesasc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_DISCUSSION_DESC:
$discussionlistsortorderdescription = get_string('discussionlistsortbydiscussiondesc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_DISCUSSION_ASC:
$discussionlistsortorderdescription = get_string('discussionlistsortbydiscussionasc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_STARTER_DESC:
$discussionlistsortorderdescription = get_string('discussionlistsortbystarterdesc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_STARTER_ASC:
$discussionlistsortorderdescription = get_string('discussionlistsortbystarterasc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_GROUP_DESC:
$discussionlistsortorderdescription = get_string('discussionlistsortbygroupdesc',
'mod_forum');
break;
case $discussionlistvault::SORTORDER_GROUP_ASC:
$discussionlistsortorderdescription = get_string('discussionlistsortbygroupasc',
'mod_forum');
break;
}
writer::export_user_preference('mod_forum', 'forum_discussionlistsortorder',
$discussionlistsortorder, $discussionlistsortorderdescription);
......
......@@ -1996,4 +1996,55 @@ class mod_forum_privacy_provider_testcase extends \core_privacy\tests\provider_t
$this->assertEquals($expected, $actual);
}
/**
* Test exporting plugin user preferences
*/
public function test_export_user_preferences(): void {
$this->setAdminUser();
// Create a user with some forum preferences.
$user = $this->getDataGenerator()->create_user([
'maildigest' => 2,
'autosubscribe' => 1,
'trackforums' => 0,
]);
set_user_preference('markasreadonnotification', 0, $user);
set_user_preference('forum_discussionlistsortorder', \mod_forum\local\vaults\discussion_list::SORTORDER_STARTER_ASC,
$user);
// Export test users preferences.
provider::export_user_preferences($user->id);
$writer = \core_privacy\local\request\writer::with_context(\context_system::instance());
$this->assertTrue($writer->has_any_data());
$preferences = (array) $writer->get_user_preferences('mod_forum');
$this->assertEquals((object) [
'value' => 2,
'description' => get_string('emaildigestsubjects'),
], $preferences['maildigest']);
$this->assertEquals((object) [
'value' => 1,
'description' => get_string('autosubscribeyes'),
], $preferences['autosubscribe']);
$this->assertEquals((object) [
'value' => 0,
'description' => get_string('trackforumsno'),
], $preferences['trackforums']);
$this->assertEquals((object) [
'value' => 0,
'description' => get_string('markasreadonnotificationno', 'mod_forum'),
], $preferences['markasreadonnotification']);
$this->assertEquals((object) [
'value' => \mod_forum\local\vaults\discussion_list::SORTORDER_STARTER_ASC,
'description' => get_string('discussionlistsortbystarterasc', 'mod_forum'),
], $preferences['forum_discussionlistsortorder']);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment