MDL-67924 core: Now show the editing button everywhere

This commit is contained in:
Mathew May 2020-02-27 15:15:29 +08:00
parent 73f8c56dfc
commit ddd387ef68
3 changed files with 14 additions and 32 deletions

View 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;
}

View 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));

View 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);
}
}
}