Skip to content

Commit

Permalink
Merge branch 'MDL-26504_blog_unregister' of git://github.com/andyjdav…
Browse files Browse the repository at this point in the history
…is/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
  • Loading branch information
Aparup Banerjee committed Sep 4, 2012
2 parents b5b82ae + f361678 commit 736cc6a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions blog/external_blogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@
if ($delete && confirm_sesskey()) {
$externalbloguserid = $DB->get_field('blog_external', 'userid', array('id' => $delete));
if ($externalbloguserid == $USER->id) {
// Delete the external blog
$DB->delete_records('blog_external', array('id' => $delete));

// Delete the external blog's posts
$deletewhere = 'module = :module
AND userid = :userid
AND ' . $DB->sql_isnotempty('post', 'uniquehash', false, false) . '
AND ' . $DB->sql_compare_text('content') . ' = ' . $DB->sql_compare_text(':delete');
$DB->delete_records_select('post', $deletewhere, array('module' => 'blog_external', 'userid' => $USER->id, 'delete' => $delete));

$message = get_string('externalblogdeleted', 'blog');
}
}
Expand Down
10 changes: 10 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -1184,5 +1184,15 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012082300.02);
}

if ($oldversion < 2012090400.00) {
$subquery = 'SELECT b.id FROM {blog_external} b where ' . $DB->sql_compare_text('b.id') . ' = ' . $DB->sql_compare_text('{post}.content');
$sql = 'DELETE FROM {post}
WHERE {post}.module = \'blog_external\'
AND NOT EXISTS (' . $subquery . ')
AND ' . $DB->sql_isnotempty('post', 'uniquehash', false, false);
$DB->execute($sql);
upgrade_main_savepoint(true, 2012090400.00);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();


$version = 2012083100.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012090400.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes

Expand Down

0 comments on commit 736cc6a

Please sign in to comment.