- // Modules.
- $mods = core_component::get_plugin_list('mod');
- $installed = $DB->get_records('modules', array(), '', 'name, version');
- foreach ($mods as $mod => $fullmod) {
- if ($mod === 'NEWMODULE') { // Someone has unzipped the template, ignore it.
- continue;
- }
- $module = new stdClass();
- $plugin = new stdClass();
- if (!is_readable($fullmod.'/version.php')) {
- continue;
- }
- include($fullmod.'/version.php'); // Defines $module with version etc.
- if (!isset($module->version) and isset($plugin->version)) {
- $module = $plugin;
- }
- if (empty($installed[$mod])) {
- return true;
- } else if ($module->version > $installed[$mod]->version) {
- return true;
- }
- }
- unset($installed);
-
- // Blocks.
- $blocks = core_component::get_plugin_list('block');
- $installed = $DB->get_records('block', array(), '', 'name, version');
- require_once($CFG->dirroot.'/blocks/moodleblock.class.php');
- foreach ($blocks as $blockname => $fullblock) {
- if ($blockname === 'NEWBLOCK') { // Someone has unzipped the template, ignore it.
- continue;
- }
- if (!is_readable($fullblock.'/version.php')) {
- continue;
- }
- $plugin = new stdClass();
- $plugin->version = null;
- include($fullblock.'/version.php');
- if (empty($installed[$blockname])) {
- return true;
- } else if ($plugin->version > $installed[$blockname]->version) {
- return true;
- }
- }
- unset($installed);
-
- // Now the rest of plugins.
- $plugintypes = core_component::get_plugin_types();
- unset($plugintypes['mod']);
- unset($plugintypes['block']);