Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'MDL-62994-master' of git://github.com/mihailges/moodle
  • Loading branch information
David Monllao committed Aug 13, 2018
2 parents e99564e + db03bff commit 66be962
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
54 changes: 1 addition & 53 deletions course/renderer.php
Expand Up @@ -69,62 +69,10 @@ public function __construct(moodle_page $page, $target) {
}

/**
* Adds the item in course settings navigation to toggle modchooser
*
* Theme can overwrite as an empty function to exclude it (for example if theme does not
* use modchooser at all)
*
* @deprecated since 3.2
*/
protected function add_modchoosertoggle() {
debugging('core_course_renderer::add_modchoosertoggle() is deprecated.', DEBUG_DEVELOPER);

global $CFG;

// Only needs to be done once per page.
if (!$this->page->requires->should_create_one_time_item_now('core_course_modchoosertoggle')) {
return;
}

if ($this->page->state > moodle_page::STATE_PRINTING_HEADER ||
$this->page->course->id == SITEID ||
!$this->page->user_is_editing() ||
!($context = context_course::instance($this->page->course->id)) ||
!has_capability('moodle/course:manageactivities', $context) ||
!course_ajax_enabled($this->page->course) ||
!($coursenode = $this->page->settingsnav->find('courseadmin', navigation_node::TYPE_COURSE)) ||
!($turneditingnode = $coursenode->get('turneditingonoff'))) {
// Too late, or we are on site page, or we could not find the
// adjacent nodes in course settings menu, or we are not allowed to edit.
return;
}

if ($this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
// We are on the course page, retain the current page params e.g. section.
$modchoosertoggleurl = clone($this->page->url);
} else {
// Edit on the main course page.
$modchoosertoggleurl = new moodle_url('/course/view.php', array('id' => $this->page->course->id,
'return' => $this->page->url->out_as_local_url(false)));
}
$modchoosertoggleurl->param('sesskey', sesskey());
if ($usemodchooser = get_user_preferences('usemodchooser', $CFG->modchooserdefault)) {
$modchoosertogglestring = get_string('modchooserdisable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'off');
} else {
$modchoosertogglestring = get_string('modchooserenable', 'moodle');
$modchoosertoggleurl->param('modchooser', 'on');
}
$modchoosertoggle = navigation_node::create($modchoosertogglestring, $modchoosertoggleurl, navigation_node::TYPE_SETTING, null, 'modchoosertoggle');

// Insert the modchoosertoggle after the settings node 'turneditingonoff' (navigation_node only has function to insert before, so we insert before and then swap).
$coursenode->add_node($modchoosertoggle, 'turneditingonoff');
$turneditingnode->remove();
$coursenode->add_node($turneditingnode, 'modchoosertoggle');

$modchoosertoggle->add_class('modchoosertoggle');
$modchoosertoggle->add_class('visibleifjs');
user_preference_allow_ajax_update('usemodchooser', PARAM_BOOL);
throw new coding_exception('core_course_renderer::add_modchoosertoggle() can not be used anymore.');
}

/**
Expand Down
1 change: 1 addition & 0 deletions theme/upgrade.txt
Expand Up @@ -17,6 +17,7 @@ information provided here is intended especially for theme designer.
* css_is_colour()
* css_is_width()
* css_sort_by_count()
* core_course_renderer::add_modchoosertoggle()
* class css_optimiser

=== 3.4 ===
Expand Down

0 comments on commit 66be962

Please sign in to comment.