Commit 1b7c2e7b authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Fix bugs in the emoticon-rewrite code (Bug 1499568)"

parents 2a8185ab f8c5a7f9
......@@ -4045,17 +4045,25 @@ function xmldb_core_upgrade($oldversion=0) {
log_debug("Updating TinyMCE emoticon locations in mahara database");
// Seeing as tinymce has moved the location of the emoticons
// we need to fix up a few places where users could have added emoticons.
// $replacements is key = table, value = column
$replacements = array('view' => 'description',
'artefact' => 'title',
'artefact' => 'description',
'group' => 'description',
'interaction_forum_post' => 'body',
'notification_internal_activity' => 'message',
'blocktype_wall_post' => 'text',
'site_content' => 'content');
// $replacements is $value['table'] = table, $value['column'] = column
$replacements = array(array('table' => 'view',
'column' => 'description'),
array('table' => 'artefact',
'column' => 'title'),
array('table' => 'artefact',
'column' => 'description'),
array('table' => 'group',
'column' => 'description'),
array('table' => 'interaction_forum_post',
'column' => 'body'),
array('table' => 'notification_internal_activity',
'column' => 'message'),
array('table' => 'blocktype_wall_post',
'column' => 'text'),
array('table' => 'site_content',
'column' => 'content'));
foreach ($replacements as $key => $value) {
execute_sql("UPDATE {" . $key . "} SET " . $value . " = REPLACE(" . $value . ", '/emotions/img', '/emoticons/img') WHERE " . $value . " LIKE '%/emotions/img%'");
execute_sql("UPDATE {" . $value['table'] . "} SET " . $value['column'] . " = REPLACE(" . $value['column'] . ", '/emotions/img', '/emoticons/img') WHERE " . $value['column'] . " LIKE '%/emotions/img%'");
}
// we need to handle block_instance configdata in a special way
if ($results = get_records_sql_array("SELECT id FROM {block_instance} WHERE configdata LIKE '%/emotions/img%'", array())) {
......@@ -4068,7 +4076,7 @@ function xmldb_core_upgrade($oldversion=0) {
$bi = new BlockInstance($result->id);
$configdata = $bi->get('configdata');
foreach ($configdata as $key => $value) {
$configdata[$key] = preg_replace('/\/emotions\/img/', '/emotions/img', $value);
$configdata[$key] = preg_replace('/\/emotions\/img/', '/emoticons/img', $value);
}
$bi->set('configdata', $configdata);
$bi->commit();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment