From ddd387ef68fe6a2f2a5e9e663f205fb674b53922 Mon Sep 17 00:00:00 2001 From: Mathew May Date: Thu, 27 Feb 2020 15:15:29 +0800 Subject: [PATCH] MDL-67924 core: Now show the editing button everywhere --- course/tests/behat/behat_course.php | 4 ++-- lib/navigationlib.php | 23 -------------------- theme/boost/classes/output/core_renderer.php | 19 ++++++++++------ 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 1f16af605b6..68476759ed0 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -1339,8 +1339,8 @@ class behat_course extends behat_base { protected function is_course_editor() { // We don't need to behat_base::spin() here as all is already loaded. - if (!$this->getSession()->getPage()->findLink(get_string('turneditingoff')) && - !$this->getSession()->getPage()->findLink(get_string('turneditingon'))) { + if (!$this->getSession()->getPage()->findButton(get_string('turneditingoff')) && + !$this->getSession()->getPage()->findButton(get_string('turneditingon'))) { return false; } diff --git a/lib/navigationlib.php b/lib/navigationlib.php index 13feb3bbc0d..6bb6b81b960 100644 --- a/lib/navigationlib.php +++ b/lib/navigationlib.php @@ -4434,29 +4434,6 @@ class settings_navigation extends navigation_node { $coursenode->add(get_string('editsettings'), $url, self::TYPE_SETTING, null, 'editsettings', new pix_icon('i/settings', '')); } - if ($this->page->user_allowed_editing()) { - // Add the turn on/off settings - - 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. - $baseurl = clone($this->page->url); - $baseurl->param('sesskey', sesskey()); - } else { - // Edit on the main course page. - $baseurl = new moodle_url('/course/view.php', array('id'=>$course->id, 'return'=>$this->page->url->out_as_local_url(false), 'sesskey'=>sesskey())); - } - - $editurl = clone($baseurl); - if ($this->page->user_is_editing()) { - $editurl->param('edit', 'off'); - $editstring = get_string('turneditingoff'); - } else { - $editurl->param('edit', 'on'); - $editstring = get_string('turneditingon'); - } - $coursenode->add($editstring, $editurl, self::TYPE_SETTING, null, 'turneditingonoff', new pix_icon('i/edit', '')); - } - if ($adminoptions->editcompletion) { // Add the course completion settings link $url = new moodle_url('/course/completion.php', array('id' => $course->id)); diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index b582821d67d..05c2ef8c68e 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -27,14 +27,19 @@ defined('MOODLE_INTERNAL') || die; * @copyright 2012 Bas Brands, www.basbrands.nl * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class core_renderer extends \core_renderer { - /** - * We don't like these... - * - */ public function edit_button(moodle_url $url) { - return ''; + $url->param('sesskey', sesskey()); + if ($this->page->user_is_editing()) { + $url->param('edit', 'off'); + $editstring = get_string('turneditingoff'); + } else { + $url->param('edit', 'on'); + $editstring = get_string('turneditingon'); + } + $button = new \single_button($url, $editstring, 'post', ['class' => 'btn btn-primary']); + return $this->render_single_button($button); } -} \ No newline at end of file + +} -- 2.43.0