$coursenode->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
if ($this->page->user_is_editing()) {
- // Add `add` resources|activities branches
- $structurefile = $CFG->dirroot.'/course/format/'.$course->format.'/lib.php';
- if (file_exists($structurefile)) {
- require_once($structurefile);
- $formatstring = call_user_func('callback_'.$course->format.'_definition');
- $formatidentifier = optional_param(call_user_func('callback_'.$course->format.'_request_key'), 0, PARAM_INT);
- } else {
- $formatstring = get_string('topic');
- $formatidentifier = optional_param('topic', 0, PARAM_INT);
- }
-
- $sections = get_all_sections($course->id);
-
- $addresource = $this->add(get_string('addresource'));
- $addactivity = $this->add(get_string('addactivity'));
- if ($formatidentifier!==0) {
- $addresource->force_open();
- $addactivity->force_open();
- }
-
- if (!$this->cache->cached('course'.$course->id.'resources')) {
- $this->get_course_modules($course);
- }
- $resources = $this->cache->{'course'.$course->id.'resources'};
- $activities = $this->cache->{'course'.$course->id.'activities'};
-
- $textlib = textlib_get_instance();
-
- foreach ($sections as $section) {
- if ($formatidentifier !== 0 && $section->section != $formatidentifier) {
- continue;
- }
- $sectionurl = new moodle_url('/course/view.php', array('id'=>$course->id, $formatstring=>$section->section));
- if ($section->section == 0) {
- $sectionresources = $addresource->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
- $sectionactivities = $addactivity->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
- } else {
- $sectionresources = $addresource->add($formatstring.' '.$section->section, $sectionurl, self::TYPE_SETTING);
- $sectionactivities = $addactivity->add($formatstring.' '.$section->section, $sectionurl, self::TYPE_SETTING);
- }
- foreach ($resources as $value=>$resource) {
- $url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'sesskey'=>sesskey(), 'section'=>$section->section));
- $pos = strpos($value, '&type=');
- if ($pos!==false) {
- $url->param('add', $textlib->substr($value, 0,$pos));
- $url->param('type', $textlib->substr($value, $pos+6));
- } else {
- $url->param('add', $value);
- }
- $sectionresources->add($resource, $url, self::TYPE_SETTING);
- }
- $subbranch = false;
- foreach ($activities as $activityname=>$activity) {
- if ($activity==='--') {
- $subbranch = false;
- continue;
- }
- if (strpos($activity, '--')===0) {
- $subbranch = $sectionactivities->add(trim($activity, '-'));
- continue;
- }
- $url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'sesskey'=>sesskey(), 'section'=>$section->section));
- $pos = strpos($activityname, '&type=');
- if ($pos!==false) {
- $url->param('add', $textlib->substr($activityname, 0,$pos));
- $url->param('type', $textlib->substr($activityname, $pos+6));
- } else {
- $url->param('add', $activityname);
- }
- if ($subbranch !== false) {
- $subbranch->add($activity, $url, self::TYPE_SETTING);
- } else {
- $sectionactivities->add($activity, $url, self::TYPE_SETTING);
- }
- }
- }
+ // Removed as per MDL-22732
+ // $this->add_course_editing_links($course);
}
// Add the course settings link
return $coursenode;
}
+ /**
+ * Adds branches and links to the settings navigaiton to add course activities
+ * and resources.
+ *
+ * @param stdClass $course
+ */
+ protected function add_course_editing_links($course) {
+ // Add `add` resources|activities branches
+ $structurefile = $CFG->dirroot.'/course/format/'.$course->format.'/lib.php';
+ if (file_exists($structurefile)) {
+ require_once($structurefile);
+ $formatstring = call_user_func('callback_'.$course->format.'_definition');
+ $formatidentifier = optional_param(call_user_func('callback_'.$course->format.'_request_key'), 0, PARAM_INT);
+ } else {
+ $formatstring = get_string('topic');
+ $formatidentifier = optional_param('topic', 0, PARAM_INT);
+ }
+
+ $sections = get_all_sections($course->id);
+
+ $addresource = $this->add(get_string('addresource'));
+ $addactivity = $this->add(get_string('addactivity'));
+ if ($formatidentifier!==0) {
+ $addresource->force_open();
+ $addactivity->force_open();
+ }
+
+ if (!$this->cache->cached('course'.$course->id.'resources')) {
+ $this->get_course_modules($course);
+ }
+ $resources = $this->cache->{'course'.$course->id.'resources'};
+ $activities = $this->cache->{'course'.$course->id.'activities'};
+
+ $textlib = textlib_get_instance();
+
+ foreach ($sections as $section) {
+ if ($formatidentifier !== 0 && $section->section != $formatidentifier) {
+ continue;
+ }
+ $sectionurl = new moodle_url('/course/view.php', array('id'=>$course->id, $formatstring=>$section->section));
+ if ($section->section == 0) {
+ $sectionresources = $addresource->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
+ $sectionactivities = $addactivity->add(get_string('course'), $sectionurl, self::TYPE_SETTING);
+ } else {
+ $sectionresources = $addresource->add($formatstring.' '.$section->section, $sectionurl, self::TYPE_SETTING);
+ $sectionactivities = $addactivity->add($formatstring.' '.$section->section, $sectionurl, self::TYPE_SETTING);
+ }
+ foreach ($resources as $value=>$resource) {
+ $url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'sesskey'=>sesskey(), 'section'=>$section->section));
+ $pos = strpos($value, '&type=');
+ if ($pos!==false) {
+ $url->param('add', $textlib->substr($value, 0,$pos));
+ $url->param('type', $textlib->substr($value, $pos+6));
+ } else {
+ $url->param('add', $value);
+ }
+ $sectionresources->add($resource, $url, self::TYPE_SETTING);
+ }
+ $subbranch = false;
+ foreach ($activities as $activityname=>$activity) {
+ if ($activity==='--') {
+ $subbranch = false;
+ continue;
+ }
+ if (strpos($activity, '--')===0) {
+ $subbranch = $sectionactivities->add(trim($activity, '-'));
+ continue;
+ }
+ $url = new moodle_url('/course/mod.php', array('id'=>$course->id, 'sesskey'=>sesskey(), 'section'=>$section->section));
+ $pos = strpos($activityname, '&type=');
+ if ($pos!==false) {
+ $url->param('add', $textlib->substr($activityname, 0,$pos));
+ $url->param('type', $textlib->substr($activityname, $pos+6));
+ } else {
+ $url->param('add', $activityname);
+ }
+ if ($subbranch !== false) {
+ $subbranch->add($activity, $url, self::TYPE_SETTING);
+ } else {
+ $sectionactivities->add($activity, $url, self::TYPE_SETTING);
+ }
+ }
+ }
+ }
+
/**
* This function calls the module function to inject module settings into the
* settings navigation tree.