MDL-45902 navigation: Moving repositories to the preferences
authorFrederic Massart <fmcell@gmail.com>
Wed, 25 Feb 2015 15:23:21 +0000 (16:23 +0100)
committerAdrian Greeve <adrian@moodle.com>
Fri, 10 Apr 2015 09:17:06 +0000 (17:17 +0800)
Part of MDL-45774

lang/en/repository.php
lib/navigationlib.php

index cc3eb9b..c8e7771 100644 (file)
@@ -161,6 +161,7 @@ $string['makefileinternal'] = 'Make a copy of the file';
 $string['makefilelink'] = 'Link to the file directly';
 $string['makefilereference'] = 'Create an alias/shortcut to the file';
 $string['manage'] = 'Manage repositories';
+$string['manageinstances'] = 'Manage instances';
 $string['manageurl'] = 'Manage';
 $string['manageuserrepository'] = 'Manage individual repository';
 $string['moving'] = 'Moving';
index fac67c6..921fe30 100644 (file)
@@ -2285,20 +2285,10 @@ class global_navigation extends navigation_node {
 
         // If the user is the current user add the repositories for the current user
         $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
-        if ($iscurrentuser) {
-            if (!$this->cache->cached('contexthasrepos'.$usercontext->id)) {
-                require_once($CFG->dirroot . '/repository/lib.php');
-                $editabletypes = repository::get_editable_types($usercontext);
-                $haseditabletypes = !empty($editabletypes);
-                unset($editabletypes);
-                $this->cache->set('contexthasrepos'.$usercontext->id, $haseditabletypes);
-            } else {
-                $haseditabletypes = $this->cache->{'contexthasrepos'.$usercontext->id};
-            }
-            if ($haseditabletypes) {
-                $usernode->add(get_string('repositories', 'repository'), new moodle_url('/repository/manage_instances.php', array('contextid' => $usercontext->id)));
-            }
-        } else if ($course->id == $SITE->id && has_capability('moodle/user:viewdetails', $usercontext) && (!in_array('mycourses', $hiddenfields) || has_capability('moodle/user:viewhiddendetails', $coursecontext))) {
+        if (!$iscurrentuser &&
+                $course->id == $SITE->id &&
+                has_capability('moodle/user:viewdetails', $usercontext) &&
+                (!in_array('mycourses', $hiddenfields) || has_capability('moodle/user:viewhiddendetails', $coursecontext))) {
 
             // Add view grade report is permitted
             $reports = core_component::get_plugin_list('gradereport');
@@ -4273,6 +4263,22 @@ class settings_navigation extends navigation_node {
             $roles->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING);
         }
 
+        // Repositories.
+        if (!$this->cache->cached('contexthasrepos'.$usercontext->id)) {
+            require_once($CFG->dirroot . '/repository/lib.php');
+            $editabletypes = repository::get_editable_types($usercontext);
+            $haseditabletypes = !empty($editabletypes);
+            unset($editabletypes);
+            $this->cache->set('contexthasrepos'.$usercontext->id, $haseditabletypes);
+        } else {
+            $haseditabletypes = $this->cache->{'contexthasrepos'.$usercontext->id};
+        }
+        if ($haseditabletypes) {
+            $repositories = $usersetting->add(get_string('repositories', 'repository'), null, self::TYPE_SETTING);
+            $repositories->add(get_string('manageinstances', 'repository'), new moodle_url('/repository/manage_instances.php',
+                array('contextid' => $usercontext->id)));
+        }
+
         // Portfolio
         if ($currentuser && !empty($CFG->enableportfolios) && has_capability('moodle/portfolio:export', $systemcontext)) {
             require_once($CFG->libdir . '/portfoliolib.php');