Skip to content

Commit

Permalink
Merge pull request #174 from moodle-an-hochschulen/issue-65
Browse files Browse the repository at this point in the history
Feature: Allow admins to hide primary navigation items, solves #65
  • Loading branch information
abias authored Dec 28, 2022
2 parents 69b74ba + a2931f3 commit 6d29f40
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
22 changes: 22 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
29 changes: 29 additions & 0 deletions tests/behat/theme_boost_union_feelsettings_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <nodename> | theme_boost_union |
When I log in as "admin"
And I am on homepage
Then I should not see "<nodetitle>" 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 | <nodenames> | theme_boost_union |
When I log in as "admin"
And I am on homepage
Then I should not see "<firstnodetitle>" in the ".primary-navigation" "css_element"
And I should not see "<secondnodetitle>" 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:
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 6d29f40

Please sign in to comment.