MDL-67924 core: Now show the editing button everywhere
authorMathew May <mathewm@hotmail.co.nz>
Thu, 27 Feb 2020 07:15:29 +0000 (15:15 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Fri, 13 Mar 2020 00:50:14 +0000 (08:50 +0800)
course/tests/behat/behat_course.php
lib/navigationlib.php
theme/boost/classes/output/core_renderer.php

index 1f16af6..6847675 100644 (file)
@@ -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;
         }
 
index 13feb3b..6bb6b81 100644 (file)
@@ -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));
index b582821..05c2ef8 100644 (file)
@@ -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
+
+}