Skip to content

Commit

Permalink
MDL-45902 navigation: Moving repositories to the preferences
Browse files Browse the repository at this point in the history
Part of MDL-45774
  • Loading branch information
FMCorz authored and abgreeve committed Apr 10, 2015
1 parent 9461ea0 commit 8309caa
Showing 2 changed files with 21 additions and 14 deletions.
1 change: 1 addition & 0 deletions lang/en/repository.php
Original file line number Diff line number Diff line change
@@ -161,6 +161,7 @@
$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';
34 changes: 20 additions & 14 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
@@ -2285,20 +2285,10 @@ protected function load_for_user($user=null, $forceforcontext=false) {

// 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 @@ protected function generate_user_settings($courseid, $userid, $gstitle='usercurr
$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');

0 comments on commit 8309caa

Please sign in to comment.