diff --git a/Changes.md b/Changes.md index b65e72d..5f51b1c 100644 --- a/Changes.md +++ b/Changes.md @@ -6,6 +6,8 @@ Version 402.1.5 - TBR 1. Swap over user name and icon in navbar. In line with a design style of other online applications. 2. Add 'activitynavigationenabled' setting to enable / disable activity navigation. 3. Add 'activitynavigationmodulenames' setting to show the activity module names in the navigation or previous / next if unset. +4. Change of name from 'usermenulogouturl' to 'customlogouturl' and move setting from 'Menus' to 'General' in the theme settings + to fix the logout URL in the footer being inconsistent with the user menu - #33. Version 402.1.4 - 11/03/24 -------------------------- diff --git a/classes/module/menus_module.php b/classes/module/menus_module.php index 17c8b5a..f048917 100644 --- a/classes/module/menus_module.php +++ b/classes/module/menus_module.php @@ -87,14 +87,6 @@ public function add_settings(&$settingspages, $toolbox) { $setting->set_updatedcallback('theme_reset_all_caches'); // Config file uses this setting. $settingspages['menus'][\theme_foundation\toolbox::SETTINGPAGE]->add($setting); - // Custom user menu url. - $name = 'theme_foundation/usermenulogouturl'; - $title = get_string('usermenulogouturl', 'theme_foundation'); - $default = ''; - $description = get_string('usermenulogouturldesc', 'theme_foundation'); - $setting = new \admin_setting_configtext($name, $title, $description, $default, PARAM_URL); - $settingspages['menus'][\theme_foundation\toolbox::SETTINGPAGE]->add($setting); - // Edit switch. $name = 'theme_foundation/navbareditswitch'; $title = get_string('navbareditswitch', 'theme_foundation'); diff --git a/classes/output/core_renderer_toolbox.php b/classes/output/core_renderer_toolbox.php index 1cd7205..9df3dd3 100644 --- a/classes/output/core_renderer_toolbox.php +++ b/classes/output/core_renderer_toolbox.php @@ -605,6 +605,27 @@ public function activity_navigation() { return $renderer->render($activitynav); } + /** + * Return the standard string that says whether you are logged in (and switched + * roles/logged in as another user). + * @param bool $withlinks if false, then don't include any links in the HTML produced. + * If not set, the default is the nologinlinks option from the theme config.php file, + * and if that is not set, then links are included. + * @return string HTML fragment. + */ + public function login_info($withlinks = null) { + $loggedinas = parent::login_info($withlinks); + + $toolbox = \theme_foundation\toolbox::get_instance(); + $customlogouturl = $toolbox->get_setting('customlogouturl'); + if (!empty($customlogouturl)) { + // Replace if there. + $loggedinas = str_replace('/login/logout.php', '/theme/foundation/logout.php', $loggedinas); + } + + return $loggedinas; + } + /** * Take a node in the nav tree and make an action menu out of it. * The links are injected in the action menu. @@ -860,8 +881,8 @@ public function user_menu($user = null, $withlinks = null) { // Logout URL. Only works when Foundation not in $CFG->themedir. $toolbox = \theme_foundation\toolbox::get_instance(); - $usermenulogouturl = $toolbox->get_setting('usermenulogouturl'); - if (!empty($usermenulogouturl)) { + $customlogouturl = $toolbox->get_setting('customlogouturl'); + if (!empty($customlogouturl)) { foreach ($opts->navitems as $object) { if (!empty($object->titleidentifier)) { $titleidentifier = explode(',', $object->titleidentifier); diff --git a/classes/toolbox.php b/classes/toolbox.php index b87f346..42050d6 100644 --- a/classes/toolbox.php +++ b/classes/toolbox.php @@ -390,6 +390,14 @@ public function add_settings() { ) ); + // Custom logout url. + $name = 'theme_foundation/customlogouturl'; + $title = get_string('customlogouturl', 'theme_foundation'); + $default = ''; + $description = get_string('customlogouturldesc', 'theme_foundation'); + $setting = new \admin_setting_configtext($name, $title, $description, $default, PARAM_URL); + $settingspages['general'][self::SETTINGPAGE]->add($setting); + // Core favicon information. $name = 'theme_foundation/favicon'; $title = get_string('favicon', 'theme_foundation'); diff --git a/db/upgrade.php b/db/upgrade.php index 0eaa444..392f5bb 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -51,6 +51,18 @@ function xmldb_theme_foundation_upgrade($oldversion = 0) { upgrade_plugin_savepoint(true, 2023042200, 'theme', 'foundation'); } + if ($oldversion < 2023042405) { + // Change of name from 'usermenulogouturl' to 'customlogouturl'. + $value = get_config('theme_foundation', 'usermenulogouturl'); + if (!empty($value)) { + set_config('customlogouturl', $value, 'theme_foundation'); + // Prevent replacement in a newer version of the theme! + unset_config('usermenulogouturl', 'theme_foundation'); + } + + upgrade_plugin_savepoint(true, 2023042405, 'theme', 'foundation'); + } + // Automatic 'Purge all caches'.... purge_all_caches(); diff --git a/lang/en/theme_foundation.php b/lang/en/theme_foundation.php index 58e598c..5b9f691 100644 --- a/lang/en/theme_foundation.php +++ b/lang/en/theme_foundation.php @@ -82,6 +82,9 @@ $string['generalheadingsub'] = 'General settings'; $string['generalheadingdesc'] = 'Configure the general settings.'; +$string['customlogouturl'] = 'Custom logout URL'; +$string['customlogouturldesc'] = 'Set a custom URL to use for the \'Log out\' link. Leave blank for system default. When set, will only work if Foundation is not installed in $CFG->themedir.'; + $string['footerantigravityhorizontaloffset'] = 'Screen anti-gravity horizontal offset'; $string['footerantigravityhorizontaloffsetdesc'] = 'Set the horizontal offset of the anti-gravity buttons on the screen (not the navbar) from the default. This can be an positive (move right) or negative (move left) number. The units are pixels. Note: Flip this logic for RTL languages.'; @@ -297,9 +300,6 @@ $string['navbarstyledark'] = 'Dark'; $string['navbarstylelight'] = 'Light'; -$string['usermenulogouturl'] = 'User menu log out URL'; -$string['usermenulogouturldesc'] = 'Set a custom URL to use for the \'Log out\' menu item on the user menu. Leave blank for system default. When set, will only work if Foundation is not installed in $CFG->themedir.'; - $string['navbareditswitch'] = 'Edit switch'; $string['navbareditswitchdesc'] = 'Have the edit switch on the navbar.'; diff --git a/logout.php b/logout.php index 5cdd380..d97a52b 100644 --- a/logout.php +++ b/logout.php @@ -58,7 +58,7 @@ // Logout URL. $toolbox = \theme_foundation\toolbox::get_instance(); -$redirect = $toolbox->get_setting('usermenulogouturl'); +$redirect = $toolbox->get_setting('customlogouturl'); if (!$loggedin) { // User has already logged out.