Merge branch 'MDL-57373-master' of git://github.com/ankitagarwal/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 9 Jan 2017 09:42:27 +0000 (09:42 +0000)
committerDan Poltawski <dan@moodle.com>
Mon, 9 Jan 2017 09:42:27 +0000 (09:42 +0000)
1  2 
lib/navigationlib.php

diff --combined lib/navigationlib.php
@@@ -2104,7 -2104,7 +2104,7 @@@ class global_navigation extends navigat
                  $onclick = htmlspecialchars_decode($activity->onclick, ENT_QUOTES);
                  // Build the JS function the click event will call
                  $jscode = "function {$functionname}(e) { $propogrationhandler $onclick }";
 -                $this->page->requires->js_init_code($jscode);
 +                $this->page->requires->js_amd_inline($jscode);
                  // Override the default url with the new action link
                  $action = new action_link($action, $activityname, new component_action('click', $functionname));
              }
@@@ -3748,7 -3748,14 +3748,14 @@@ class flat_navigation extends navigatio
          if ($course->id > 1) {
              // It's a real course.
              $url = new moodle_url('/course/view.php', array('id' => $course->id));
-             $flat = new flat_navigation_node(navigation_node::create($course->shortname, $url), 0);
+             $coursecontext = context_course::instance($course->id, MUST_EXIST);
+             // This is the name that will be shown for the course.
+             $coursename = empty($CFG->navshowfullcoursenames) ?
+                 format_string($course->shortname, true, array('context' => $coursecontext)) :
+                 format_string($course->fullname, true, array('context' => $coursecontext));
+             $flat = new flat_navigation_node(navigation_node::create($coursename, $url), 0);
              $flat->key = 'coursehome';
  
              $courseformat = course_get_format($course);
@@@ -3913,38 -3920,34 +3920,38 @@@ class settings_navigation extends navig
          if (isloggedin() && !isguestuser() && (!isset($SESSION->load_navigation_admin) || $SESSION->load_navigation_admin)) {
              $isadminpage = $this->is_admin_tree_needed();
  
 -            if (has_capability('moodle/site:config', context_system::instance())) {
 -                // Make sure this works even if config capability changes on the fly
 -                // and also make it fast for admin right after login.
 -                $SESSION->load_navigation_admin = 1;
 -                if ($isadminpage) {
 -                    $adminsettings = $this->load_administration_settings();
 -                }
 -
 -            } else if (!isset($SESSION->load_navigation_admin)) {
 -                $adminsettings = $this->load_administration_settings();
 -                $SESSION->load_navigation_admin = (int)($adminsettings->children->count() > 0);
 +            if (has_capability('moodle/site:configview', context_system::instance())) {
 +                if (has_capability('moodle/site:config', context_system::instance())) {
 +                    // Make sure this works even if config capability changes on the fly
 +                    // and also make it fast for admin right after login.
 +                    $SESSION->load_navigation_admin = 1;
 +                    if ($isadminpage) {
 +                        $adminsettings = $this->load_administration_settings();
 +                    }
  
 -            } else if ($SESSION->load_navigation_admin) {
 -                if ($isadminpage) {
 +                } else if (!isset($SESSION->load_navigation_admin)) {
                      $adminsettings = $this->load_administration_settings();
 +                    $SESSION->load_navigation_admin = (int)($adminsettings->children->count() > 0);
 +
 +                } else if ($SESSION->load_navigation_admin) {
 +                    if ($isadminpage) {
 +                        $adminsettings = $this->load_administration_settings();
 +                    }
                  }
 -            }
  
 -            // Print empty navigation node, if needed.
 -            if ($SESSION->load_navigation_admin && !$isadminpage) {
 -                if ($adminsettings) {
 -                    // Do not print settings tree on pages that do not need it, this helps with performance.
 -                    $adminsettings->remove();
 -                    $adminsettings = false;
 +                // Print empty navigation node, if needed.
 +                if ($SESSION->load_navigation_admin && !$isadminpage) {
 +                    if ($adminsettings) {
 +                        // Do not print settings tree on pages that do not need it, this helps with performance.
 +                        $adminsettings->remove();
 +                        $adminsettings = false;
 +                    }
 +                    $siteadminnode = $this->add(get_string('administrationsite'), new moodle_url('/admin/search.php'),
 +                            self::TYPE_SITE_ADMIN, null, 'siteadministration');
 +                    $siteadminnode->id = 'expandable_branch_' . $siteadminnode->type . '_' .
 +                            clean_param($siteadminnode->key, PARAM_ALPHANUMEXT);
 +                    $siteadminnode->requiresajaxloading = 'true';
                  }
 -                $siteadminnode = $this->add(get_string('administrationsite'), new moodle_url('/admin/search.php'), self::TYPE_SITE_ADMIN, null, 'siteadministration');
 -                $siteadminnode->id = 'expandable_branch_'.$siteadminnode->type.'_'.clean_param($siteadminnode->key, PARAM_ALPHANUMEXT);
 -                $siteadminnode->requiresajaxloading = 'true';
              }
          }