MDL-19839, rename file area for comments block, and migrating old comments in that area, thanks Eloy's migrating sql

This commit is contained in:
Dongsheng Cai 2010-04-28 06:08:31 +00:00
parent 6fbf3c4868
commit 442636301f
3 changed files with 25 additions and 4 deletions

View File

@ -43,9 +43,9 @@ class block_comments extends block_base {
$args = new stdclass;
$args->context = $PAGE->context;
$args->course = $course;
$args->area = 'block_comments';
$args->itemid = $this->instance->id;
//XXX: this is a hack to adjust commenting UI in block_comments
$args->area = 'page_comments';
$args->itemid = 0;
// set 'env' to tell moodle tweak ui for this block
$args->env = 'block_comments';
$args->linktext = get_string('showcomments');
$comment = new comment($args);

View File

@ -3644,6 +3644,27 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
upgrade_main_savepoint($result, 2010042800);
}
if ($result && $oldversion < 2010042801) {
// migrating old comments block content
$DB->execute("
UPDATE {comments} SET contextid = (
SELECT parentcontextid FROM {block_instances}
WHERE id = {comments}.itemid AND blockname = 'comments'
),
commentarea = 'page_comments',
itemid = 0
WHERE commentarea = 'block_comments'
AND itemid != 0
AND EXISTS (SELECT 'x'
FROM {block_instances}
WHERE id = {comments}.itemid
AND blockname = 'comments')");
// remove all orphaned record
$DB->delete_records('comments', array('commentarea'=>'block_comments'));
upgrade_main_savepoint($result, 2010042801);
}
return $result;
}

View File

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2010042800; // YYYYMMDD = date of the last version bump
$version = 2010042801; // YYYYMMDD = date of the last version bump
// XX = daily increments
$release = '2.0 dev (Build: 20100428)'; // Human-friendly version name