diff --git a/blocks/myoverview/amd/build/tab_preferences.min.js b/blocks/myoverview/amd/build/tab_preferences.min.js
deleted file mode 100644
index da5bd970f13..00000000000
--- a/blocks/myoverview/amd/build/tab_preferences.min.js
+++ /dev/null
@@ -1 +0,0 @@
-define(["jquery","core/ajax","core/custom_interaction_events","core/notification"],function(a,b,c,d){var e=function(e){c.define(e,[c.events.activate]),e.on(c.events.activate,"[data-toggle='tab']",function(c){var e=a(c.currentTarget).data("tabname");"function"==typeof window.history.pushState&&window.history.pushState(null,null,"?myoverviewtab="+e);var f={methodname:"core_user_update_user_preferences",args:{preferences:[{type:"block_myoverview_last_tab",value:e}]}};b.call([f])[0].fail(d.exception)})};return{registerEventListeners:e}});
\ No newline at end of file
diff --git a/blocks/myoverview/amd/src/tab_preferences.js b/blocks/myoverview/amd/src/tab_preferences.js
deleted file mode 100644
index 25ac2eefa3d..00000000000
--- a/blocks/myoverview/amd/src/tab_preferences.js
+++ /dev/null
@@ -1,61 +0,0 @@
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle. If not, see .
-
-/**
- * Javascript used to save the user's tab preference.
- *
- * @package block_myoverview
- * @copyright 2017 Mark Nelson
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-define(['jquery', 'core/ajax', 'core/custom_interaction_events',
- 'core/notification'], function($, Ajax, CustomEvents, Notification) {
-
- /**
- * Registers an event that saves the user's tab preference when switching between them.
- *
- * @param {object} root The container element
- */
- var registerEventListeners = function(root) {
- CustomEvents.define(root, [CustomEvents.events.activate]);
- root.on(CustomEvents.events.activate, "[data-toggle='tab']", function(e) {
- var tabname = $(e.currentTarget).data('tabname');
- // Bootstrap does not change the URL when using BS tabs, so need to do this here.
- // Also check to make sure the browser supports the history API.
- if (typeof window.history.pushState === "function") {
- window.history.pushState(null, null, '?myoverviewtab=' + tabname);
- }
- var request = {
- methodname: 'core_user_update_user_preferences',
- args: {
- preferences: [
- {
- type: 'block_myoverview_last_tab',
- value: tabname
- }
- ]
- }
- };
-
- Ajax.call([request])[0]
- .fail(Notification.exception);
- });
- };
-
- return {
- registerEventListeners: registerEventListeners
- };
-});
diff --git a/blocks/myoverview/block_myoverview.php b/blocks/myoverview/block_myoverview.php
index 8afd4a10471..f22ce15decb 100644
--- a/blocks/myoverview/block_myoverview.php
+++ b/blocks/myoverview/block_myoverview.php
@@ -50,16 +50,7 @@ class block_myoverview extends block_base {
return $this->content;
}
- // Check if the tab to select wasn't passed in the URL, if so see if the user has any preference.
- if (!$tab = optional_param('myoverviewtab', null, PARAM_ALPHA)) {
- // Check if the user has no preference, if so get the site setting.
- if (!$tab = get_user_preferences('block_myoverview_last_tab')) {
- $config = get_config('block_myoverview');
- $tab = $config->defaulttab;
- }
- }
-
- $renderable = new \block_myoverview\output\main($tab);
+ $renderable = new \block_myoverview\output\main();
$renderer = $this->page->get_renderer('block_myoverview');
$this->content = new stdClass();
@@ -77,13 +68,4 @@ class block_myoverview extends block_base {
public function applicable_formats() {
return array('my' => true);
}
-
- /**
- * This block does contain a configuration settings.
- *
- * @return boolean
- */
- public function has_config() {
- return true;
- }
}
diff --git a/blocks/myoverview/classes/output/main.php b/blocks/myoverview/classes/output/main.php
index 28506375fb5..51d6b903af3 100644
--- a/blocks/myoverview/classes/output/main.php
+++ b/blocks/myoverview/classes/output/main.php
@@ -39,21 +39,6 @@ require_once($CFG->libdir . '/completionlib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class main implements renderable, templatable {
-
- /**
- * @var string The tab to display.
- */
- public $tab;
-
- /**
- * Constructor.
- *
- * @param string $tab The tab to display.
- */
- public function __construct($tab) {
- $this->tab = $tab;
- }
-
/**
* Export this data so it can be used as the context for a mustache template.
*
@@ -88,15 +73,6 @@ class main implements renderable, templatable {
$nocoursesurl = $output->image_url('courses', 'block_myoverview')->out();
$noeventsurl = $output->image_url('activities', 'block_myoverview')->out();
- // Now, set the tab we are going to be viewing.
- $viewingtimeline = false;
- $viewingcourses = false;
- if ($this->tab == BLOCK_MYOVERVIEW_TIMELINE_VIEW) {
- $viewingtimeline = true;
- } else {
- $viewingcourses = true;
- }
-
return [
'midnight' => usergetmidnight(time()),
'coursesview' => $coursesview->export_for_template($output),
@@ -104,8 +80,6 @@ class main implements renderable, templatable {
'nocourses' => $nocoursesurl,
'noevents' => $noeventsurl
],
- 'viewingtimeline' => $viewingtimeline,
- 'viewingcourses' => $viewingcourses
];
}
}
diff --git a/blocks/myoverview/classes/privacy/provider.php b/blocks/myoverview/classes/privacy/provider.php
index d0ee9e8b30b..b3cf042afef 100644
--- a/blocks/myoverview/classes/privacy/provider.php
+++ b/blocks/myoverview/classes/privacy/provider.php
@@ -32,30 +32,15 @@ defined('MOODLE_INTERNAL') || die();
* @copyright 2018 Zig Tan
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class provider implements \core_privacy\local\metadata\provider, \core_privacy\local\request\user_preference_provider {
+class provider implements \core_privacy\local\metadata\null_provider {
/**
- * Returns meta-data information about the myoverview block.
+ * Get the language string identifier with the component's language
+ * file to explain why this plugin stores no data.
*
- * @param \core_privacy\local\metadata\collection $collection A collection of meta-data.
- * @return \core_privacy\local\metadata\collection Return the collection of meta-data.
+ * @return string
*/
- public static function get_metadata(\core_privacy\local\metadata\collection $collection) :
- \core_privacy\local\metadata\collection {
- $collection->add_user_preference('block_myoverview_last_tab', 'privacy:metadata:overviewlasttab');
- return $collection;
- }
-
- /**
- * Export all user preferences for the myoverview block
- *
- * @param int $userid The userid of the user whose data is to be exported.
- */
- public static function export_user_preferences(int $userid) {
- $preference = get_user_preferences('block_myoverview_last_tab', null, $userid);
- if (isset($preference)) {
- \core_privacy\local\request\writer::export_user_preference('block_myoverview', 'block_myoverview_last_tab',
- $preference, get_string('privacy:metadata:overviewlasttab', 'block_myoverview'));
- }
+ public static function get_reason() : string {
+ return 'privacy:metadata';
}
}
diff --git a/blocks/myoverview/settings.php b/blocks/myoverview/db/upgrade.php
similarity index 50%
rename from blocks/myoverview/settings.php
rename to blocks/myoverview/db/upgrade.php
index 10f084d6a1f..b91cb9613a3 100644
--- a/blocks/myoverview/settings.php
+++ b/blocks/myoverview/db/upgrade.php
@@ -15,25 +15,27 @@
// along with Moodle. If not, see .
/**
- * Settings for the overview block.
+ * This file keeps track of upgrades to the myoverview block
*
- * @package block_myoverview
- * @copyright 2017 Mark Nelson
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ * @package block_myoverview
+ * @copyright 2018 Ryan Wyllie
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-defined('MOODLE_INTERNAL') || die;
+defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot . '/blocks/myoverview/lib.php');
+/**
+ * Upgrade code for the myoverview block.
+ *
+ * @param int $oldversion
+ */
+function xmldb_block_myoverview_upgrade($oldversion) {
+ global $DB;
-if ($ADMIN->fulltree) {
+ if ($oldversion < 2018092700) {
+ $DB->delete_records('user_preferences', ['name' => 'block_myoverview_last_tab']);
+ upgrade_block_savepoint(true, 2018092700, 'myoverview');
+ }
- $options = [
- BLOCK_MYOVERVIEW_TIMELINE_VIEW => get_string('timeline', 'block_myoverview'),
- BLOCK_MYOVERVIEW_COURSES_VIEW => get_string('courses')
- ];
-
- $settings->add(new admin_setting_configselect('block_myoverview/defaulttab',
- get_string('defaulttab', 'block_myoverview'),
- get_string('defaulttab_desc', 'block_myoverview'), 'timeline', $options));
+ return true;
}
diff --git a/blocks/myoverview/lang/en/block_myoverview.php b/blocks/myoverview/lang/en/block_myoverview.php
index a3ca64e2625..f6a1e65eaeb 100644
--- a/blocks/myoverview/lang/en/block_myoverview.php
+++ b/blocks/myoverview/lang/en/block_myoverview.php
@@ -22,8 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-$string['defaulttab'] = 'Default tab';
-$string['defaulttab_desc'] = 'The tab that will be displayed when a user first views their course overview. When returning to their course overview, the user\'s active tab is remembered.';
$string['future'] = 'Future';
$string['inprogress'] = 'In progress';
$string['morecourses'] = 'More courses';
@@ -44,4 +42,4 @@ $string['sortbydates'] = 'Sort by dates';
$string['timeline'] = 'Timeline';
$string['viewcourse'] = 'View course';
$string['viewcoursename'] = 'View course {$a}';
-$string['privacy:metadata:overviewlasttab'] = 'This stores the last tab selected by the user on the overview block.';
+$string['privacy:metadata'] = 'The myoverview block does not store any personal data.';
diff --git a/blocks/myoverview/templates/main.mustache b/blocks/myoverview/templates/main.mustache
index e9b21bd69ae..8eb3394fe83 100644
--- a/blocks/myoverview/templates/main.mustache
+++ b/blocks/myoverview/templates/main.mustache
@@ -47,9 +47,3 @@
-{{#js}}
-require(['jquery', 'block_myoverview/tab_preferences'], function($, TabPreferences) {
- var root = $('#block-myoverview-view-choices-{{uniqid}}');
- TabPreferences.registerEventListeners(root);
-});
-{{/js}}
diff --git a/blocks/myoverview/tests/privacy_test.php b/blocks/myoverview/tests/privacy_test.php
deleted file mode 100644
index 875dd033abe..00000000000
--- a/blocks/myoverview/tests/privacy_test.php
+++ /dev/null
@@ -1,80 +0,0 @@
-.
-
-/**
- * Unit tests for the block_myoverview implementation of the privacy API.
- *
- * @package block_myoverview
- * @category test
- * @copyright 2018 Adrian Greeve
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-use \core_privacy\local\request\writer;
-use \block_myoverview\privacy\provider;
-
-/**
- * Unit tests for the block_myoverview implementation of the privacy API.
- *
- * @copyright 2018 Adrian Greeve
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class block_myoverview_privacy_testcase extends \core_privacy\tests\provider_testcase {
-
- /**
- * Ensure that export_user_preferences returns no data if the user has not visited the myoverview block.
- */
- public function test_export_user_preferences_no_pref() {
- $this->resetAfterTest();
-
- $user = $this->getDataGenerator()->create_user();
- provider::export_user_preferences($user->id);
- $writer = writer::with_context(\context_system::instance());
- $this->assertFalse($writer->has_any_data());
- }
-
- /**
- * Test that the preference courses is exported properly.
- */
- public function test_export_user_preferences_course_preference() {
- $this->resetAfterTest();
-
- $user = $this->getDataGenerator()->create_user();
- set_user_preference('block_myoverview_last_tab', 'courses', $user);
-
- provider::export_user_preferences($user->id);
- $writer = writer::with_context(\context_system::instance());
- $blockpreferences = $writer->get_user_preferences('block_myoverview');
- $this->assertEquals('courses', $blockpreferences->block_myoverview_last_tab->value);
- }
-
- /**
- * Test that the preference timeline is exported properly.
- */
- public function test_export_user_preferences_timeline_preference() {
- $this->resetAfterTest();
-
- $user = $this->getDataGenerator()->create_user();
- set_user_preference('block_myoverview_last_tab', 'timeline', $user);
-
- provider::export_user_preferences($user->id);
- $writer = writer::with_context(\context_system::instance());
- $blockpreferences = $writer->get_user_preferences('block_myoverview');
- $this->assertEquals('timeline', $blockpreferences->block_myoverview_last_tab->value);
- }
-}
diff --git a/blocks/myoverview/version.php b/blocks/myoverview/version.php
index 26ccc6dffa4..6b8960ce85a 100644
--- a/blocks/myoverview/version.php
+++ b/blocks/myoverview/version.php
@@ -24,6 +24,6 @@
defined('MOODLE_INTERNAL') || die();
-$plugin->version = 2018051400; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version = 2018092700; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2018050800; // Requires this Moodle version.
$plugin->component = 'block_myoverview'; // Full name of the plugin (used for diagnostics).
diff --git a/lib/navigationlib.php b/lib/navigationlib.php
index 398e56e0b8c..f290ceabb7f 100644
--- a/lib/navigationlib.php
+++ b/lib/navigationlib.php
@@ -3036,7 +3036,7 @@ class global_navigation extends navigation_node {
// Show a link to the course page if there are more courses the user is enrolled in.
if ($showmorelinkinnav || $showmorelinkinflatnav) {
// Adding hash to URL so the link is not highlighted in the navigation when clicked.
- $url = new moodle_url('/my/?myoverviewtab=courses');
+ $url = new moodle_url('/my/');
$parent = $this->rootnodes['mycourses'];
$coursenode = $parent->add(get_string('morenavigationlinks'), $url, self::TYPE_CUSTOM, null, self::COURSE_INDEX_PAGE);
diff --git a/message/tests/privacy_provider_test.php b/message/tests/privacy_provider_test.php
index 39e549fdf9a..976df599513 100644
--- a/message/tests/privacy_provider_test.php
+++ b/message/tests/privacy_provider_test.php
@@ -146,7 +146,7 @@ class core_message_privacy_provider_testcase extends \core_privacy\tests\provide
set_user_preference('message_provider_moodle_instantmessage_loggedoff', 'inbound', $user->id);
// Set an unrelated preference.
- set_user_preference('block_myoverview_last_tab', 'courses', $USER->id);
+ set_user_preference('some_unrelated_preference', 'courses', $USER->id);
provider::export_user_preferences($USER->id);