From 4b0075414e5796a10aae62d75e10f44c21e6bbd9 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Fri, 30 Oct 2015 14:14:24 +0000 Subject: [PATCH 1/3] MDL-35982 blog: prevent index throwing errors with 0 courseid Regression from MDL-49845 where Dave made the page not handle courseid = 0 and so now some urls will send you back to a db error.. --- blog/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blog/index.php b/blog/index.php index ddbdf454245..56ab7eb8b91 100644 --- a/blog/index.php +++ b/blog/index.php @@ -63,9 +63,9 @@ if ($entryid and !isset($userid)) { $userid = $entry->userid; } -if (isset($userid) && !isset($courseid)) { +if (isset($userid) && empty($courseid)) { $context = context_user::instance($userid); -} else if (isset($courseid) && $courseid != SITEID) { +} else if (!empty($courseid) && $courseid != SITEID) { $context = context_course::instance($courseid); } else { $context = context_system::instance(); From 45600c4a0b10f7ae339c22ac7879da7a68cf620d Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Fri, 30 Oct 2015 14:22:39 +0000 Subject: [PATCH 2/3] MDL-35982 blog: reorder blog delete confirmation Improves accessibility to be ordered logically in page --- blog/edit.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 58b64bb04b6..b8686e04b5f 100644 --- a/blog/edit.php +++ b/blog/edit.php @@ -138,14 +138,15 @@ if ($action === 'delete') { $PAGE->set_heading($SITE->fullname); echo $OUTPUT->header(); + echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog'), + new moodle_url('edit.php', $optionsyes), + new moodle_url('index.php', $optionsno)); + + echo '
'; // Output the entry. $entry->prepare_render(); echo $output->render($entry); - echo '
'; - echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog'), - new moodle_url('edit.php', $optionsyes), - new moodle_url('index.php', $optionsno)); echo $OUTPUT->footer(); die; } From 48cf88458c0dceedb930f1d0955cf671df56a8e8 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Fri, 30 Oct 2015 15:15:07 +0000 Subject: [PATCH 3/3] MDL-35982 behat: delete blog entry coverage --- blog/tests/behat/delete.feature | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 blog/tests/behat/delete.feature diff --git a/blog/tests/behat/delete.feature b/blog/tests/behat/delete.feature new file mode 100644 index 00000000000..dba76517cb4 --- /dev/null +++ b/blog/tests/behat/delete.feature @@ -0,0 +1,43 @@ +@core @core_blog +Feature: Delete a blog entry + In order to manage my blog entries + As a user + I need to be able to delete entries I no longer wish to appear + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | testuser | Test | User | moodle@example.com | + And I log in as "testuser" + And I expand "Site pages" node + And I follow "Site blogs" + And I follow "Add a new entry" + And I set the following fields to these values: + | Entry title | Blog post one | + | Blog entry body | User 1 blog post content | + And I press "Save changes" + And I follow "Add a new entry" + And I set the following fields to these values: + | Entry title | Blog post two | + | Blog entry body | User 1 blog post content | + And I press "Save changes" + And I am on site homepage + And I expand "Site pages" node + And I follow "Site blogs" + + Scenario: Delete blog post results in post deleted + Given I follow "Blog post one" + And I follow "Delete" + And I should see "Delete this blog entry?" + When I press "Continue" + Then I should not see "Blog post one" + And I should see "Blog post two" + + Scenario: Delete confirmation screen works and allows cancel + Given I follow "Blog post one" + When I follow "Delete" + Then I should see "Delete this blog entry?" + And I press "Cancel" + And I should see "Blog post one" + And I should see "Blog post two" +