From 56da374e1eb7dc09fa05368af3572e7f5d58ff13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20S=CC=8Ckoda?= Date: Tue, 16 Jul 2013 22:41:00 +0200 Subject: [PATCH] MDL-40220 use new core_component::normalize_component() --- admin/tool/customlang/filter_form.php | 2 +- admin/tool/customlang/locallib.php | 2 +- admin/tool/installaddon/classes/installer.php | 2 +- admin/tool/installaddon/classes/validator.php | 2 +- comment/lib.php | 2 +- course/dnduploadlib.php | 2 +- grade/grading/form/lib.php | 2 +- grade/grading/lib.php | 4 ++-- lib/accesslib.php | 2 +- lib/adminlib.php | 2 +- lib/messagelib.php | 2 +- lib/outputfactories.php | 2 +- lib/pluginlib.php | 12 ++++++------ lib/testing/generator/data_generator.php | 2 +- lib/upgradelib.php | 2 +- rating/lib.php | 6 +++--- rss/file.php | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-) diff --git a/admin/tool/customlang/filter_form.php b/admin/tool/customlang/filter_form.php index 547a8a4d513..19d74c1c768 100644 --- a/admin/tool/customlang/filter_form.php +++ b/admin/tool/customlang/filter_form.php @@ -39,7 +39,7 @@ class tool_customlang_filter_form extends moodleform { // Component $options = array(); foreach (tool_customlang_utils::list_components() as $component => $normalized) { - list($type, $plugin) = normalize_component($normalized); + list($type, $plugin) = core_component::normalize_component($normalized); if ($type == 'core' and is_null($plugin)) { $plugin = 'moodle'; } diff --git a/admin/tool/customlang/locallib.php b/admin/tool/customlang/locallib.php index f209785de31..24927309448 100644 --- a/admin/tool/customlang/locallib.php +++ b/admin/tool/customlang/locallib.php @@ -267,7 +267,7 @@ class tool_customlang_utils { if ($filename !== clean_param($filename, PARAM_FILE)) { throw new coding_exception('Incorrect file name '.s($filename)); } - list($package, $subpackage) = normalize_component($component); + list($package, $subpackage) = core_component::normalize_component($component); $packageinfo = " * @package $package"; if (!is_null($subpackage)) { $packageinfo .= "\n * @subpackage $subpackage"; diff --git a/admin/tool/installaddon/classes/installer.php b/admin/tool/installaddon/classes/installer.php index d3affb98af6..37c36007c3f 100644 --- a/admin/tool/installaddon/classes/installer.php +++ b/admin/tool/installaddon/classes/installer.php @@ -250,7 +250,7 @@ class tool_installaddon_installer { exit(); } - list($plugintype, $pluginname) = normalize_component($data->component); + list($plugintype, $pluginname) = core_component::normalize_component($data->component); $plugintypepath = $this->get_plugintype_root($plugintype); diff --git a/admin/tool/installaddon/classes/validator.php b/admin/tool/installaddon/classes/validator.php index e5865c7ccd3..cafd9b99474 100644 --- a/admin/tool/installaddon/classes/validator.php +++ b/admin/tool/installaddon/classes/validator.php @@ -332,7 +332,7 @@ class tool_installaddon_validator { if (isset($info[$type.'->component'])) { $this->versionphp['component'] = $info[$type.'->component']; - list($reqtype, $reqname) = normalize_component($this->versionphp['component']); + list($reqtype, $reqname) = core_component::normalize_component($this->versionphp['component']); if ($reqtype !== $this->assertions['plugintype']) { $this->add_message(self::ERROR, 'componentmismatchtype', array( 'expected' => $this->assertions['plugintype'], diff --git a/comment/lib.php b/comment/lib.php index ef1e619cd80..5381866c424 100644 --- a/comment/lib.php +++ b/comment/lib.php @@ -260,7 +260,7 @@ class comment { throw new coding_exception('You cannot change the component of a comment once it has been set'); } $this->component = $component; - list($this->plugintype, $this->pluginname) = normalize_component($component); + list($this->plugintype, $this->pluginname) = core_component::normalize_component($component); } /** diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index 45564e878e4..a1b8d02253d 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -122,7 +122,7 @@ class dndupload_handler { // Loop through all modules to find handlers. $mods = get_plugin_list_with_function('mod', 'dndupload_register'); foreach ($mods as $component => $funcname) { - list($modtype, $modname) = normalize_component($component); + list($modtype, $modname) = core_component::normalize_component($component); if ($modnames && !array_key_exists($modname, $modnames)) { continue; // Module is deactivated (hidden) at the site level. } diff --git a/grade/grading/form/lib.php b/grade/grading/form/lib.php index 6c8c8acc5da..f28c5162a93 100644 --- a/grade/grading/form/lib.php +++ b/grade/grading/form/lib.php @@ -88,7 +88,7 @@ abstract class gradingform_controller { global $DB; $this->context = $context; - list($type, $name) = normalize_component($component); + list($type, $name) = core_component::normalize_component($component); $this->component = $type.'_'.$name; $this->area = $area; $this->areaid = $areaid; diff --git a/grade/grading/lib.php b/grade/grading/lib.php index c0cd8ce4dee..215d346bd93 100644 --- a/grade/grading/lib.php +++ b/grade/grading/lib.php @@ -139,7 +139,7 @@ class grading_manager { */ public function set_component($component) { $this->areacache = null; - list($type, $name) = normalize_component($component); + list($type, $name) = core_component::normalize_component($component); $this->component = $type.'_'.$name; } @@ -288,7 +288,7 @@ class grading_manager { public static function available_areas($component) { global $CFG; - list($plugintype, $pluginname) = normalize_component($component); + list($plugintype, $pluginname) = core_component::normalize_component($component); if ($component === 'core_grading') { return array(); diff --git a/lib/accesslib.php b/lib/accesslib.php index 02df5586b8e..a8cc9c09102 100644 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -2895,7 +2895,7 @@ function get_component_string($component, $contextlevel) { } } - list($type, $name) = normalize_component($component); + list($type, $name) = core_component::normalize_component($component); $dir = core_component::get_plugin_directory($type, $name); if (!file_exists($dir)) { // plugin not installed, bad luck, there is no way to find the name diff --git a/lib/adminlib.php b/lib/adminlib.php index f10b899f371..d4f8853a5df 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -342,7 +342,7 @@ function uninstall_plugin($type, $name) { function get_component_version($component, $source='installed') { global $CFG, $DB; - list($type, $name) = normalize_component($component); + list($type, $name) = core_component::normalize_component($component); // moodle core or a core subsystem if ($type === 'core') { diff --git a/lib/messagelib.php b/lib/messagelib.php index defa97d34e8..c07af1dab2b 100644 --- a/lib/messagelib.php +++ b/lib/messagelib.php @@ -414,7 +414,7 @@ function message_get_providers_for_user($userid) { // If the component is an enrolment plugin, check it is enabled foreach ($providers as $providerid => $provider) { - list($type, $name) = normalize_component($provider->component); + list($type, $name) = core_component::normalize_component($provider->component); if ($type == 'enrol' && !enrol_is_enabled($name)) { unset($providers[$providerid]); } diff --git a/lib/outputfactories.php b/lib/outputfactories.php index 1d8183f324d..499ca562a57 100644 --- a/lib/outputfactories.php +++ b/lib/outputfactories.php @@ -165,7 +165,7 @@ abstract class renderer_factory_base implements renderer_factory { global $CFG; // needed in included files // standardize component name ala frankenstyle - list($plugin, $type) = normalize_component($component); + list($plugin, $type) = core_component::normalize_component($component); if ($type === null) { $component = $plugin; } else { diff --git a/lib/pluginlib.php b/lib/pluginlib.php index c4fa6b10621..4926796e101 100644 --- a/lib/pluginlib.php +++ b/lib/pluginlib.php @@ -868,7 +868,7 @@ class plugin_manager { } /** - * Wrapper for the core function {@link normalize_component()}. + * Wrapper for the core function {@link core_component::normalize_component()}. * * This is here just to make it possible to mock it in unit tests. * @@ -876,7 +876,7 @@ class plugin_manager { * @return array */ protected function normalize_component($component) { - return normalize_component($component); + return core_component::normalize_component($component); } /** @@ -1619,7 +1619,7 @@ class available_update_checker { // is a real update with higher version. That is, the $componentchange // is present in the array of {@link available_update_info} objects // returned by the plugin's available_updates() method. - list($plugintype, $pluginname) = normalize_component($component); + list($plugintype, $pluginname) = core_component::normalize_component($component); if (!empty($plugins[$plugintype][$pluginname])) { $availableupdates = $plugins[$plugintype][$pluginname]->available_updates(); if (!empty($availableupdates)) { @@ -1974,7 +1974,7 @@ class available_update_deployer { public function plugin_external_source(available_update_info $info) { $paths = core_component::get_plugin_types(); - list($plugintype, $pluginname) = normalize_component($info->component); + list($plugintype, $pluginname) = core_component::normalize_component($info->component); $pluginroot = $paths[$plugintype].'/'.$pluginname; if (is_dir($pluginroot.'/.git')) { @@ -2033,7 +2033,7 @@ class available_update_deployer { $pluginrootpaths = core_component::get_plugin_types(); - list($plugintype, $pluginname) = normalize_component($info->component); + list($plugintype, $pluginname) = core_component::normalize_component($info->component); if (empty($pluginrootpaths[$plugintype])) { throw new coding_exception('Unknown plugin type root location', $plugintype); @@ -2302,7 +2302,7 @@ class available_update_deployer { */ protected function component_writable($component) { - list($plugintype, $pluginname) = normalize_component($component); + list($plugintype, $pluginname) = core_component::normalize_component($component); $directory = core_component::get_plugin_directory($plugintype, $pluginname); diff --git a/lib/testing/generator/data_generator.php b/lib/testing/generator/data_generator.php index 423d4a793c7..fe0f34bb9dc 100644 --- a/lib/testing/generator/data_generator.php +++ b/lib/testing/generator/data_generator.php @@ -95,7 +95,7 @@ EOD; * @return component_generator_base or rather an instance of the appropriate subclass. */ public function get_plugin_generator($component) { - list($type, $plugin) = normalize_component($component); + list($type, $plugin) = core_component::normalize_component($component); $cleancomponent = $type . '_' . $plugin; if ($cleancomponent != $component) { debugging("Please specify the component you want a generator for as " . diff --git a/lib/upgradelib.php b/lib/upgradelib.php index a11c4ead72c..e04b0c8089e 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1164,7 +1164,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) { $plugin = 'core'; } - list($plugintype, $pluginname) = normalize_component($plugin); + list($plugintype, $pluginname) = core_component::normalize_component($plugin); $component = is_null($pluginname) ? $plugintype : $plugintype . '_' . $pluginname; $backtrace = format_backtrace($backtrace, true); diff --git a/rating/lib.php b/rating/lib.php index 969fbd98c5d..e2d786d6b2a 100644 --- a/rating/lib.php +++ b/rating/lib.php @@ -523,7 +523,7 @@ class rating_manager { // Get the item table name, the item id field, and the item user field for the given rating item // from the related component. - list($type, $name) = normalize_component($options->component); + list($type, $name) = core_component::normalize_component($options->component); $default = array(null, 'id', 'userid'); list($itemtablename, $itemidcol, $itemuseridcol) = plugin_callback($type, $name, 'rating', 'get_item_fields', array($options), $default); @@ -928,7 +928,7 @@ class rating_manager { $pluginpermissionsarray = null; $defaultpluginpermissions = array('rate'=>false,'view'=>false,'viewany'=>false,'viewall'=>false);//deny by default if (!empty($component)) { - list($type, $name) = normalize_component($component); + list($type, $name) = core_component::normalize_component($component); $pluginpermissionsarray = plugin_callback($type, $name, 'rating', 'permissions', array($contextid, $component, $ratingarea), $defaultpluginpermissions); } else { $pluginpermissionsarray = $defaultpluginpermissions; @@ -971,7 +971,7 @@ class rating_manager { throw new coding_exception('The rateduserid option is now a required option when checking rating validity'); } - list($plugintype, $pluginname) = normalize_component($params['component']); + list($plugintype, $pluginname) = core_component::normalize_component($params['component']); //this looks for a function like forum_rating_validate() in mod_forum lib.php //wrapping the params array in another array as call_user_func_array() expands arrays into multiple arguments diff --git a/rss/file.php b/rss/file.php index d7e47c8f4f8..c231c91f06b 100644 --- a/rss/file.php +++ b/rss/file.php @@ -149,7 +149,7 @@ try { // Work out which component in Moodle we want (from the frankenstyle name) $componentdir = get_component_directory($componentname); -list($type, $plugin) = normalize_component($componentname); +list($type, $plugin) = core_component::normalize_component($componentname); // Call the component to check/update the feed and tell us the path to the cached file