Skip to content

Commit

Permalink
MDL-57115 blocks: Cleanup block_messages instances and other configs
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal committed Sep 14, 2017
1 parent 898ba89 commit f3a3e23
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
1 change: 1 addition & 0 deletions blocks/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ information provided here is intended especially for developers.
* Blocks can now be included in Moodle global search, with some limitations (at present, the search
works only for blocks located directly on course pages or site home page). See the HTML block for
an example.
* Block block_messages is no longer a part of core.

=== 3.3 ===

Expand Down
4 changes: 2 additions & 2 deletions lib/classes/plugin_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1647,7 +1647,7 @@ public static function is_deleted_standard_plugin($type, $name) {
$plugins = array(
'qformat' => array('blackboard', 'learnwise'),
'auth' => array('radius', 'fc', 'nntp', 'pam', 'pop3', 'imap'),
'block' => array('course_overview'),
'block' => array('course_overview', 'messages'),
'enrol' => array('authorize'),
'report' => array('search'),
'repository' => array('alfresco'),
Expand Down Expand Up @@ -1715,7 +1715,7 @@ public static function standard_plugins_list($type) {
'calendar_upcoming', 'comments', 'community',
'completionstatus', 'course_list', 'course_summary',
'feedback', 'globalsearch', 'glossary_random', 'html',
'login', 'lp', 'mentees', 'messages', 'mnet_hosts', 'myoverview', 'myprofile',
'login', 'lp', 'mentees', 'mnet_hosts', 'myoverview', 'myprofile',
'navigation', 'news_items', 'online_users', 'participants',
'private_files', 'quiz_results', 'recent_activity',
'rss_client', 'search_forums', 'section_links',
Expand Down
36 changes: 36 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2436,5 +2436,41 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2017082800.00);
}

if ($oldversion < 2017091000.00) {

if (!file_exists($CFG->dirroot . '/blocks/messages/block_messages.php')) {

// Delete instances.
$instances = $DB->get_records_list('block_instances', 'blockname', ['messages']);
$instanceids = array_keys($instances);

if (!empty($instanceids)) {
$DB->delete_records_list('block_positions', 'blockinstanceid', $instanceids);
$DB->delete_records_list('block_instances', 'id', $instanceids);
list($sql, $params) = $DB->get_in_or_equal($instanceids, SQL_PARAMS_NAMED);
$params['contextlevel'] = CONTEXT_BLOCK;
$DB->delete_records_select('context', "contextlevel=:contextlevel AND instanceid " . $sql, $params);

$preferences = array();
foreach ($instances as $instanceid => $instance) {
$preferences[] = 'block' . $instanceid . 'hidden';
$preferences[] = 'docked_block_instance_' . $instanceid;
}
$DB->delete_records_list('user_preferences', 'name', $preferences);
}

// Delete the block from the block table.
$DB->delete_records('block', array('name' => 'messages'));

// Remove capabilities.
capabilities_cleanup('block_messages');

// Clean config.
unset_all_config_for_plugin('block_messages');
}

upgrade_main_savepoint(true, 2017091000.00);
}

return true;
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

defined('MOODLE_INTERNAL') || die();

$version = 2017090700.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2017091000.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 f3a3e23

Please sign in to comment.