Added setting and feature to automatically add primary navigation menu items to custommenuitems setting
This commit is contained in:
parent
11ed955fd7
commit
c67c40d74d
|
@ -83,6 +83,11 @@ $string["settingdesc_display_heading"] = 'Study plan display settings';
|
|||
$string["setting_display_field"] = 'Course display name';
|
||||
$string["settingdesc_display_field"] = 'Select the field to use for the display name of a course in the study plan';
|
||||
|
||||
$string["setting_navigation_heading"] = 'Navigation';
|
||||
$string["settingdesc_navigation_heading"] = 'Navigation menu configuration';
|
||||
$string["setting_primary_nav_autofill"] = 'Automatically fill User menu items';
|
||||
$string["settingdesc_primary_nav_autofill"] = 'To show the studyplan links in the primary navigation menu, lines have to be added to the setting <b>Appearance</b> - <b>Theme settings</b> - <b>Custom menu items</b>. Enable this feature to do so automatically.';
|
||||
|
||||
$string["settingspage_csync"] = 'Synchronize linked cohorts and users to courses';
|
||||
$string["setting_csync_heading"] = 'Automatically create a cohort sync in all courses linked to a study plan for all cohorts linked to a study plan';
|
||||
$string["settingdesc_csync_heading"] = '';
|
||||
|
@ -194,6 +199,7 @@ $string["coursetiming_future"] = "Upcoming course";
|
|||
|
||||
$string["link_myreport"] = "My study plan";
|
||||
$string["link_viewplan"] = "Study plans";
|
||||
$string["link_editplan"] = "Manage study plans";
|
||||
$string["nav_invited"] = "View study plan by invitation";
|
||||
$string["associations"] = 'Associations';
|
||||
$string["associated_cohorts"] = 'Linked cohorts';
|
||||
|
|
|
@ -78,6 +78,11 @@ $string["view_plan"] = 'Studieplannen bekijken';
|
|||
$string["edit_plan"] = 'Studieplan bewerken';
|
||||
$string["settingspage"] = 'Studieplan instellingen';
|
||||
|
||||
$string["setting_navigation_heading"] = 'Navigatie';
|
||||
$string["settingdesc_navigation_heading"] = 'Instellingen voor navigatie';
|
||||
$string["setting_primary_nav_autofill"] = 'Aangepast menu items automatisch aanvullen';
|
||||
$string["settingdesc_primary_nav_autofill"] = 'Om in het primaire navigatiemenu de studieplan links te tonen, moeten regels worden toegevoegd in de instelling <b>Uiterlijk</b> - <b>Thema instellingen</b> - <b>Aangepast menu items</b>. Zet deze optie aan om dat automatisch te doen.';
|
||||
|
||||
$string["setting_display_heading"] = 'Weergave';
|
||||
$string["settingdesc_display_heading"] = 'Configuratie voor de weergave van de studieplannen';
|
||||
$string["setting_display_field"] = 'Weergavenaam cursus';
|
||||
|
@ -194,6 +199,7 @@ $string["coursetiming_future"] = "Toekomstige cursus";
|
|||
|
||||
$string["link_myreport"] = "Mijn studieplan";
|
||||
$string["link_viewplan"] = "Studieplannen";
|
||||
$string["link_editplan"] = "Studieplannen beheren";
|
||||
$string["nav_invited"] = "Studieplan op uitnodiging bekijken";
|
||||
$string["associations"] = 'Koppelingen';
|
||||
$string["associated_cohorts"] = 'Gekoppelde site-groepen';
|
||||
|
|
55
lib.php
55
lib.php
|
@ -42,6 +42,52 @@ function local_treestudyplan_unit_get_editor_options(context $context) {
|
|||
'trusttext' => 0];
|
||||
}
|
||||
|
||||
function local_treestudyplan_autofill_customusermenuitems() {
|
||||
if (get_config("local_treestudyplan", "primary_nav_autofill")) {
|
||||
$lang = current_language();
|
||||
$navitems = [
|
||||
"/local/treestudyplan/myreport.php" => ["included" => false, "strkey" => "link_myreport"],
|
||||
"/local/treestudyplan/view-plan.php" => ["included" => false, "strkey" => "link_viewplan"],
|
||||
"/local/treestudyplan/edit-plan.php" => ["included" => false, "strkey" => "link_editplan"],
|
||||
];
|
||||
|
||||
// Load the custom menu items from config
|
||||
$custommenuitems = get_config("core", "custommenuitems");
|
||||
|
||||
// Scan through all the lines to see if it is a link to one of our nav items in the current language.
|
||||
$lines = explode("\n", $custommenuitems);
|
||||
//debugging("\n\nLines: ". print_r($lines,true)."\n");
|
||||
$links = array_keys($navitems);
|
||||
foreach ($lines as $line) {
|
||||
$parms = explode('|', $line);
|
||||
if (count($parms) > 3) {
|
||||
$link = trim($parms[1]);
|
||||
if (trim($parms[3]) == $lang && in_array($link, $links)) {
|
||||
// Register the link as already included if it is found.
|
||||
$navitems[$link]["included"] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List through all the links to see if we need to add one or more
|
||||
foreach($navitems as $link => $details){
|
||||
if (!$details["included"]) {
|
||||
$line = implode("|",[
|
||||
get_string($details["strkey"],"local_treestudyplan"), // Menu text.
|
||||
$link, // Link.
|
||||
'', // Tooltip,
|
||||
$lang, // Language code.
|
||||
" #Automatically added by studyplan plugin. See setting 'primary_nav_autofill' to disable this"
|
||||
]);
|
||||
$custommenuitems = trim($custommenuitems)."\n".$line;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the modified custom menu items.
|
||||
set_config("custommenuitems",$custommenuitems);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to extend navigation
|
||||
* @param global_navigation $navigation Navigation object
|
||||
|
@ -66,6 +112,13 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
and not much more complex than loading a separate stylesheet for each link we want to hide).
|
||||
We will add all the hrefs that should be hidden to this variable below.
|
||||
*/
|
||||
|
||||
/*
|
||||
In addition, the function local_treestudyplan_autofill_customusermenuitems() called below will
|
||||
automatically generate the required lines if they are missing...
|
||||
*/
|
||||
local_treestudyplan_autofill_customusermenuitems();
|
||||
|
||||
$hideprimaryhrefs = [];
|
||||
|
||||
if ($USER->id > 1) {
|
||||
|
@ -122,7 +175,7 @@ function local_treestudyplan_extend_navigation(global_navigation $navigation) {
|
|||
|| webservicehelper::has_capability_in_any_category('local/treestudyplan:editstudyplan')
|
||||
) {
|
||||
$node = navigation_node::create(
|
||||
get_string("cfg_plans", "local_treestudyplan"),
|
||||
get_string("link_editplan", "local_treestudyplan"),
|
||||
new moodle_url($CFG->wwwroot . "/local/treestudyplan/edit-plan.php", array()),
|
||||
global_navigation::TYPE_SYSTEM ,
|
||||
null,
|
||||
|
|
14
settings.php
14
settings.php
|
@ -42,7 +42,19 @@ if ($hassiteconfig) {
|
|||
$page = new admin_settingpage('local_treestudyplan_settings',
|
||||
get_string('settingspage', 'local_treestudyplan', null, true));
|
||||
|
||||
// GOAL AGGREGATION SETTINGS.
|
||||
// NAVIGATION
|
||||
$page->add(new admin_setting_heading('local_treestudyplan/navigation_heading',
|
||||
get_string('setting_navigation_heading', 'local_treestudyplan'),
|
||||
get_string('settingdesc_navigation_heading', 'local_treestudyplan')
|
||||
));
|
||||
|
||||
$page->add(new admin_setting_configcheckbox('local_treestudyplan/primary_nav_autofill',
|
||||
get_string('setting_primary_nav_autofill', 'local_treestudyplan'),
|
||||
get_string('settingdesc_primary_nav_autofill', 'local_treestudyplan'),
|
||||
true,
|
||||
));
|
||||
|
||||
// OUTCOME AGGREGATION SETTINGS.
|
||||
$page->add(new admin_setting_heading('local_treestudyplan/aggregation_heading',
|
||||
get_string('setting_aggregation_heading', 'local_treestudyplan'),
|
||||
get_string('settingdesc_aggregation_heading', 'local_treestudyplan')
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$plugin->component = 'local_treestudyplan'; // Recommended since 2.0.2 (MDL-26035). Required since 3.0 (MDL-48494).
|
||||
$plugin->version = 2023090300; // YYYYMMDDHH (year, month, day, iteration).
|
||||
$plugin->version = 2023090400; // YYYYMMDDHH (year, month, day, iteration).
|
||||
$plugin->requires = 2021051700; // YYYYMMDDHH (This is the release version for Moodle 3.11).
|
||||
|
||||
$plugin->release = "1.0.0";
|
||||
$plugin->maturity = MATURITY_RC;
|
||||
$plugin->maturity = MATURITY_STABLE;
|
||||
|
||||
// Supported from Moodle 3.11 to 4.1 (4.2 not yet tested).
|
||||
$plugin->supported = [ 311, 401 ];
|
||||
|
|
Loading…
Reference in New Issue
Block a user