Commit 0dab95a5 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review

Merge "Making sure core message notifications are correct on upgrade"

parents d37f4130 47ee961e
......@@ -3673,5 +3673,31 @@ function xmldb_core_upgrade($oldversion=0) {
}
}
if ($oldversion < 2014101300) {
// Make sure the 'system messages' and 'messages from other users' have a notification method set
// It was possible after earlier upgrades to set method to 'none'.
// Also make sure old defaultmethod is respected.
$activitytypes = get_records_assoc('activity_type');
foreach ($activitytypes as $type) {
$type->defaultmethod = get_config('defaultnotificationmethod') ? get_config('defaultnotificationmethod') : 'email';
if ($type->name == 'maharamessage' || $type->name == 'usermessage') {
$type->allownonemethod = 0;
}
update_record('activity_type', $type);
}
// Make sure users have their 'system messages' and 'messages from other users' notification method set
if ($useractivities = get_records_sql_assoc("SELECT * FROM {activity_type} at, {usr_activity_preference} uap
WHERE at.id = uap.activity
AND at.name IN ('maharamessage', 'usermessage')
AND (method IS NULL OR method = '')", array())) {
foreach ($useractivities as $activity) {
$userprefs = new stdClass();
$userprefs->method = $activity->defaultmethod;
update_record('usr_activity_preference', $userprefs, array('usr' => $activity->usr, 'activity' => $activity->activity));
}
}
}
return $status;
}
......@@ -525,19 +525,23 @@ function upgrade_plugin($upgrade) {
if (!class_exists($classname)) {
throw new InstallationException(get_string('classmissing', 'error', $classname, $pluginname, $plugintype));
}
$activity->plugintype = $plugintype;
$activity->pluginname = $pluginname;
$where = (object) array(
'name' => $activity->name,
'plugintype' => $plugintype,
'pluginname' => $pluginname,
);
// Work around the fact that insert_record cached the columns that
// _were_ in the activity_type table before it was upgraded
global $INSERTRECORD_NOCACHE;
$INSERTRECORD_NOCACHE = true;
ensure_record_exists('activity_type', $where, $activity);
unset($INSERTRECORD_NOCACHE);
// Add activity_type if it doesn't exist
if (!get_record('activity_type', 'name', $activity->name, 'plugintype', $plugintype, 'pluginname', $pluginname)) {
$activity->plugintype = $plugintype;
$activity->pluginname = $pluginname;
$activity->defaultmethod = get_config('defaultnotificationmethod') ? get_config('defaultnotificationmethod') : $activity->defaultmethod;
$where = (object) array(
'name' => $activity->name,
'plugintype' => $plugintype,
'pluginname' => $pluginname,
);
// Work around the fact that insert_record cached the columns that
// _were_ in the activity_type table before it was upgraded
global $INSERTRECORD_NOCACHE;
$INSERTRECORD_NOCACHE = true;
ensure_record_exists('activity_type', $where, $activity);
unset($INSERTRECORD_NOCACHE);
}
}
}
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2014092500;
$config->version = 2014101300;
$config->release = '1.11.0dev';
$config->minupgradefrom = 2009022600;
$config->minupgraderelease = '1.1.0 (release tag 1.1.0_RELEASE)';
......
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