Skip to content

Commit

Permalink
Merge branch 'MDL-35982-master' of git://github.com/danpoltawski/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Nov 30, 2015
2 parents 096b98b + 3e0f566 commit c256bac
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
9 changes: 5 additions & 4 deletions blog/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@
// Output edit mode title.
echo $OUTPUT->heading($strblogs . ': ' . get_string('deleteentry', 'blog'), 2);

echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog', format_string($entry->subject)),
new moodle_url('edit.php', $optionsyes),
new moodle_url('index.php', $optionsno));

echo '<br />';
// Output the entry.
$entry->prepare_render();
echo $output->render($entry);

echo '<br />';
echo $OUTPUT->confirm(get_string('blogdeleteconfirm', 'blog'),
new moodle_url('edit.php', $optionsyes),
new moodle_url('index.php', $optionsno));
echo $OUTPUT->footer();
die;
}
Expand Down
4 changes: 2 additions & 2 deletions blog/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
$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();
Expand Down
43 changes: 43 additions & 0 deletions blog/tests/behat/delete.feature
Original file line number Diff line number Diff line change
@@ -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 the blog entry 'Blog post one'?"
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 the blog entry 'Blog post one'?"
And I press "Cancel"
And I should see "Blog post one"
And I should see "Blog post two"

2 changes: 1 addition & 1 deletion lang/en/blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
$string['blogaboutthiscourse'] = 'Add an entry about this course';
$string['blogaboutthismodule'] = 'Add an entry about this {$a}';
$string['blogadministration'] = 'Blog administration';
$string['blogdeleteconfirm'] = 'Delete this blog entry?';
$string['blogdeleteconfirm'] = 'Delete the blog entry \'{$a}\'?';
$string['blogdisable'] = 'Blogging is disabled!';
$string['blogentries'] = 'Blog entries';
$string['blogentriesabout'] = 'Blog entries about {$a}';
Expand Down

0 comments on commit c256bac

Please sign in to comment.