diff --git a/CHANGES.md b/CHANGES.md index 40519655956..c7c81e411ca 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2022-12-19 - Feature: Allow admins to hide primary navigation items, solves #65. * 2022-12-14 - Feature: Built-in contact, help and maintenance pages, solves #150. * 2022-11-28 - Updated Moodle Plugin CI to latest upstream recommendations diff --git a/README.md b/README.md index e40af1bf5d3..44b13dc2348 100644 --- a/README.md +++ b/README.md @@ -162,6 +162,12 @@ Moodle core ships with FontAwesome 4 icons which are fine, but FontAwesome has e In this tab there are the following settings: +##### Primary navigation + +###### Hide nodes in primary navigation + +With this setting, you can hide one or multiple nodes from the primary navigation. + ##### Navigation ###### Back to top button diff --git a/config.php b/config.php index 27ac5b3e04d..bc36310a6d2 100644 --- a/config.php +++ b/config.php @@ -47,6 +47,7 @@ $THEME->iconsystem = \core\output\icon_system::FONTAWESOME; $THEME->haseditswitch = true; $THEME->usescourseindex = true; +$THEME->removedprimarynavitems = explode(',', get_config('theme_boost_union', 'hidenodesprimarynavigation')); // By default, all boost theme do not need their titles displayed. $THEME->activityheaderconfig = [ 'notitle' => true diff --git a/lang/en/theme_boost_union.php b/lang/en/theme_boost_union.php index a3347145a2d..a2f2072d8b9 100644 --- a/lang/en/theme_boost_union.php +++ b/lang/en/theme_boost_union.php @@ -222,6 +222,11 @@ // Settings: Navigation tab. $string['navigationtab'] = 'Navigation'; +// ... Section: Primary navigation. +$string['primarynavigationheading'] = 'Primary navigation'; +// ... ... Settings: Hide nodes in primary navigation. +$string['hidenodesprimarynavigationsetting'] = 'Hide nodes in primary navigation'; +$string['hidenodesprimarynavigationsetting_desc'] = 'With this setting, you can hide one or multiple nodes from the primary navigation.'; // ... Section: Navigation. $string['navigationheading'] = 'Navigation'; // ... ... Setting: Back to top button. diff --git a/lib.php b/lib.php index c18ee7e6d43..9156594611e 100644 --- a/lib.php +++ b/lib.php @@ -31,6 +31,11 @@ define('THEME_BOOST_UNION_SETTING_STATICPAGELINKPOSITION_FOOTER', 'footer'); define('THEME_BOOST_UNION_SETTING_STATICPAGELINKPOSITION_BOTH', 'both'); +define('THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_HOME', 'home'); +define('THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_MYHOME', 'myhome'); +define('THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_MYCOURSES', 'courses'); +define('THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_SITEADMIN', 'siteadmin'); + define('THEME_BOOST_UNION_SETTING_INFOBANNER_COUNT', 5); define('THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_MY', 'mydashboard'); define('THEME_BOOST_UNION_SETTING_INFOBANNERPAGES_MYCOURSES', 'mycourses'); diff --git a/settings.php b/settings.php index 0c87afbfdca..5cde2489026 100644 --- a/settings.php +++ b/settings.php @@ -666,6 +666,28 @@ $tab = new admin_settingpage('theme_boost_union_feel_navigation', get_string('navigationtab', 'theme_boost_union', null, true)); + // Create primary navigation heading. + $name = 'theme_boost_union/primarynavigationheading'; + $title = get_string('primarynavigationheading', 'theme_boost_union', null, true); + $setting = new admin_setting_heading($name, $title, null); + $tab->add($setting); + + // Prepare hide nodes options. + $hidenodesoptions = array( + THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_HOME => get_string('home'), + THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_MYHOME => get_string('myhome'), + THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_MYCOURSES => get_string('mycourses'), + THEME_BOOST_UNION_SETTING_HIDENODESPRIMARYNAVIGATION_SITEADMIN => get_string('administrationsite') + ); + + // Setting: Hide nodes in primary navigation. + $name = 'theme_boost_union/hidenodesprimarynavigation'; + $title = get_string('hidenodesprimarynavigationsetting', 'theme_boost_union', null, true); + $description = get_string('hidenodesprimarynavigationsetting_desc', 'theme_boost_union', null, true); + $setting = new admin_setting_configmulticheckbox($name, $title, $description, array(), $hidenodesoptions); + $setting->set_updatedcallback('theme_reset_all_caches'); + $tab->add($setting); + // Create navigation heading. $name = 'theme_boost_union/navigationheading'; $title = get_string('navigationheading', 'theme_boost_union', null, true); diff --git a/tests/behat/theme_boost_union_feelsettings_navigation.feature b/tests/behat/theme_boost_union_feelsettings_navigation.feature index 038f505e114..517f3f0dc6b 100644 --- a/tests/behat/theme_boost_union_feelsettings_navigation.feature +++ b/tests/behat/theme_boost_union_feelsettings_navigation.feature @@ -17,6 +17,35 @@ Feature: Configuring the theme_boost_union plugin for the "Navigation" tab on th | teacher1 | C1 | editingteacher | | student1 | C1 | student | + Scenario Outline: Setting: Hide a single node in primary navigation. + Given the following config values are set as admin: + | config | value | plugin | + | hidenodesprimarynavigation | | theme_boost_union | + When I log in as "admin" + And I am on homepage + Then I should not see "" in the ".primary-navigation" "css_element" + + Examples: + | nodename | nodetitle | + | home | Home | + | myhome | Dashboard | + | courses | My courses | + | siteadminnode | Site administration | + + Scenario Outline: Setting: Hide multiple nodes in primary navigation. + Given the following config values are set as admin: + | config | value | plugin | + | hidenodesprimarynavigation | | theme_boost_union | + When I log in as "admin" + And I am on homepage + Then I should not see "" in the ".primary-navigation" "css_element" + And I should not see "" in the ".primary-navigation" "css_element" + + Examples: + | nodenames | firstnodetitle | secondnodetitle | + | home,myhome | Home | Dashboard | + | courses,siteadminnode | My courses | Site administration | + @javascript Scenario: Setting: back to top button - Enable "Back to top button" Given the following config values are set as admin: diff --git a/version.php b/version.php index b2d1a48d1ff..e1ff840472f 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'theme_boost_union'; -$plugin->version = 2022080914; +$plugin->version = 2022080915; $plugin->release = 'v4.0-r8'; $plugin->requires = 2022041900; $plugin->supported = [400, 400];