mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-74634 theme_boost: remove old drawer-open-nav user preference.
This commit is contained in:
parent
ca583bddaf
commit
47d119945d
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
@ -1 +1,3 @@
|
||||
totop,theme_boost
|
||||
privacy:drawernavclosed,theme_boost
|
||||
privacy:drawernavopen,theme_boost
|
||||
|
@ -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.';
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -14,32 +14,46 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 <adriangreeve.com>
|
||||
* @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 <adriangreeve.com>
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user