Skip to content

Commit

Permalink
MDL-27171 messages: clean up pereferences on message provider removal
Browse files Browse the repository at this point in the history
Signed-off-by: Ruslan Kabalin <ruslan.kabalin@luns.net.uk>
  • Loading branch information
Ruslan Kabalin committed May 31, 2011
1 parent 31afb0a commit 298925d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/messagelib.php
Expand Up @@ -211,7 +211,7 @@ function message_update_providers($component='moodle') {
foreach ($fileproviders as $messagename => $fileprovider) {

if (!empty($dbproviders[$messagename])) { // Already exists in the database

// check if capability has changed
if ($dbproviders[$messagename]->capability == $fileprovider['capability']) { // Same, so ignore
// exact same message provider already present in db, ignore this entry
unset($dbproviders[$messagename]);
Expand Down Expand Up @@ -242,6 +242,8 @@ function message_update_providers($component='moodle') {

foreach ($dbproviders as $dbprovider) { // Delete old ones
$DB->delete_records('message_providers', array('id' => $dbprovider->id));
$DB->delete_records_select('config_plugins', "plugin = 'message' AND ".$DB->sql_like('name', '?', false), array("%_provider_{$component}_{$dbprovider->name}_%"));
$DB->delete_records_select('user_preferences', $DB->sql_like('name', '?', false), array("message_provider_{$component}_{$dbprovider->name}_%"));
}

return true;
Expand Down

0 comments on commit 298925d

Please sign in to comment.