diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 8fd277ebe8f..afea6a97ebc 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -4565,5 +4565,13 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2022060300.01);
}
+ if ($oldversion < 2022061000.01) {
+ // Remove drawer-open-nav user preference for every user.
+ $DB->delete_records('user_preferences', ['name' => 'drawer-open-nav']);
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2022061000.01);
+ }
+
return true;
}
diff --git a/theme/boost/classes/privacy/provider.php b/theme/boost/classes/privacy/provider.php
index 35856be9413..772df51ab18 100644
--- a/theme/boost/classes/privacy/provider.php
+++ b/theme/boost/classes/privacy/provider.php
@@ -40,9 +40,6 @@ class provider implements
// This plugin has some sitewide user preferences to export.
\core_privacy\local\request\user_preference_provider {
- /** The user preference for the navigation drawer. */
- const DRAWER_OPEN_NAV = 'drawer-open-nav';
-
/** The user preferences for the course index. */
const DRAWER_OPEN_INDEX = 'drawer-open-index';
@@ -56,7 +53,6 @@ class provider implements
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $items) : collection {
- $items->add_user_preference(self::DRAWER_OPEN_NAV, 'privacy:metadata:preference:draweropennav');
$items->add_user_preference(self::DRAWER_OPEN_INDEX, 'privacy:metadata:preference:draweropenindex');
$items->add_user_preference(self::DRAWER_OPEN_BLOCK, 'privacy:metadata:preference:draweropenblock');
return $items;
@@ -68,20 +64,6 @@ class provider implements
* @param int $userid The userid of the user whose data is to be exported.
*/
public static function export_user_preferences(int $userid) {
- $draweropennavpref = get_user_preferences(self::DRAWER_OPEN_NAV, null, $userid);
-
- if (isset($draweropennavpref)) {
- $preferencestring = get_string('privacy:drawernavclosed', 'theme_boost');
- if ($draweropennavpref == 'true') {
- $preferencestring = get_string('privacy:drawernavopen', 'theme_boost');
- }
- \core_privacy\local\request\writer::export_user_preference(
- 'theme_boost',
- self::DRAWER_OPEN_NAV,
- $draweropennavpref,
- $preferencestring
- );
- }
$draweropenindexpref = get_user_preferences(self::DRAWER_OPEN_INDEX, null, $userid);
diff --git a/theme/boost/lang/en/deprecated.txt b/theme/boost/lang/en/deprecated.txt
index 5735003853f..04956efb9aa 100644
--- a/theme/boost/lang/en/deprecated.txt
+++ b/theme/boost/lang/en/deprecated.txt
@@ -1 +1,3 @@
totop,theme_boost
+privacy:drawernavclosed,theme_boost
+privacy:drawernavopen,theme_boost
diff --git a/theme/boost/lang/en/theme_boost.php b/theme/boost/lang/en/theme_boost.php
index 73b97ee1b2d..87d019153eb 100644
--- a/theme/boost/lang/en/theme_boost.php
+++ b/theme/boost/lang/en/theme_boost.php
@@ -59,8 +59,10 @@ $string['privacy:drawerindexclosed'] = 'The current preference for the index dra
$string['privacy:drawerindexopen'] = 'The current preference for the index drawer is open.';
$string['privacy:drawerblockclosed'] = 'The current preference for the block drawer is closed.';
$string['privacy:drawerblockopen'] = 'The current preference for the block drawer is open.';
-$string['privacy:drawernavclosed'] = 'The current preference for the navigation drawer is closed.';
-$string['privacy:drawernavopen'] = 'The current preference for the navigation drawer is open.';
// Deprecated since Moodle 4.0.
$string['totop'] = 'Go to top';
+
+// Deprecated since Moodle 4.1.
+$string['privacy:drawernavclosed'] = 'The current preference for the navigation drawer is closed.';
+$string['privacy:drawernavopen'] = 'The current preference for the navigation drawer is open.';
diff --git a/theme/boost/layout/columns2.php b/theme/boost/layout/columns2.php
index 3c35b1ad345..2b7ec4a0df1 100644
--- a/theme/boost/layout/columns2.php
+++ b/theme/boost/layout/columns2.php
@@ -24,7 +24,6 @@
defined('MOODLE_INTERNAL') || die();
-user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');
// Add block button in editing mode.
diff --git a/theme/boost/layout/drawers.php b/theme/boost/layout/drawers.php
index dcea9528c1e..bd8b502d43c 100644
--- a/theme/boost/layout/drawers.php
+++ b/theme/boost/layout/drawers.php
@@ -30,7 +30,6 @@ require_once($CFG->dirroot . '/course/lib.php');
// Add block button in editing mode.
$addblockbutton = $OUTPUT->addblockbutton();
-user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
user_preference_allow_ajax_update('drawer-open-index', PARAM_BOOL);
user_preference_allow_ajax_update('drawer-open-block', PARAM_BOOL);
diff --git a/theme/boost/tests/privacy/provider_test.php b/theme/boost/tests/privacy/provider_test.php
index 18f13df989c..4655f3b5f5a 100644
--- a/theme/boost/tests/privacy/provider_test.php
+++ b/theme/boost/tests/privacy/provider_test.php
@@ -14,32 +14,46 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+namespace theme_boost\privacy;
+
+use context_user;
+use core_privacy\local\request\writer;
+
/**
* Privacy tests for theme_boost.
*
* @package theme_boost
* @category test
- * @copyright 2018 Adrian Greeve
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-namespace theme_boost\privacy;
-
-defined('MOODLE_INTERNAL') || die();
-
-use theme_boost\privacy\provider;
-
-/**
- * Unit tests for theme_boost/classes/privacy/policy
- *
+ * @covers \theme_boost\privacy\provider
* @copyright 2018 Adrian Greeve
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider_test extends \core_privacy\tests\provider_testcase {
/**
- * Test for provider::test_export_user_preferences().
+ * Data provider for {@see test_export_user_preferences}
+ *
+ * @return array[]
*/
- public function test_export_user_preferences() {
+ public function export_user_preference_provider(): array {
+ return [
+ 'Index drawer open' => [provider::DRAWER_OPEN_INDEX, true, 'privacy:drawerindexopen'],
+ 'Index drawer closed' => [provider::DRAWER_OPEN_INDEX, false, 'privacy:drawerindexclosed'],
+ 'Block drawer open' => [provider::DRAWER_OPEN_BLOCK, true, 'privacy:drawerblockopen'],
+ 'Block drawer closed' => [provider::DRAWER_OPEN_BLOCK, false, 'privacy:drawerblockclosed'],
+ ];
+ }
+
+ /**
+ * Test for provider::test_export_user_preferences().
+ *
+ * @param string $preference
+ * @param bool $value
+ * @param string $expectdescription
+ *
+ * @dataProvider export_user_preference_provider
+ */
+ public function test_export_user_preferences(string $preference, bool $value, string $expectdescription): void {
$this->resetAfterTest();
// Test setup.
@@ -47,33 +61,16 @@ class provider_test extends \core_privacy\tests\provider_testcase {
$this->setUser($user);
// Add a user home page preference for the User.
- set_user_preference(provider::DRAWER_OPEN_NAV, 'false', $user);
+ set_user_preference($preference, $value, $user);
// Test the user preferences export contains 1 user preference record for the User.
provider::export_user_preferences($user->id);
- $contextuser = \context_user::instance($user->id);
- $writer = \core_privacy\local\request\writer::with_context($contextuser);
+ $writer = writer::with_context(context_user::instance($user->id));
$this->assertTrue($writer->has_any_data());
$exportedpreferences = $writer->get_user_preferences('theme_boost');
$this->assertCount(1, (array) $exportedpreferences);
- $this->assertEquals('false', $exportedpreferences->{provider::DRAWER_OPEN_NAV}->value);
- $this->assertEquals(get_string('privacy:drawernavclosed', 'theme_boost'),
- $exportedpreferences->{provider::DRAWER_OPEN_NAV}->description);
-
- // Add a user home page preference for the User.
- set_user_preference(provider::DRAWER_OPEN_NAV, 'true', $user);
-
- // Test the user preferences export contains 1 user preference record for the User.
- provider::export_user_preferences($user->id);
- $contextuser = \context_user::instance($user->id);
- $writer = \core_privacy\local\request\writer::with_context($contextuser);
- $this->assertTrue($writer->has_any_data());
-
- $exportedpreferences = $writer->get_user_preferences('theme_boost');
- $this->assertCount(1, (array) $exportedpreferences);
- $this->assertEquals('true', $exportedpreferences->{provider::DRAWER_OPEN_NAV}->value);
- $this->assertEquals(get_string('privacy:drawernavopen', 'theme_boost'),
- $exportedpreferences->{provider::DRAWER_OPEN_NAV}->description);
+ $this->assertEquals($value, (bool) $exportedpreferences->{$preference}->value);
+ $this->assertEquals(get_string($expectdescription, 'theme_boost'), $exportedpreferences->{$preference}->description);
}
}
diff --git a/version.php b/version.php
index 5a0f0c28bf3..bd6eb45cc29 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2022061000.00; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2022061000.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.1dev (Build: 20220610)'; // Human-friendly version name