Skip to content

Commit

Permalink
MDL-40220 use new core_component::get_component_directory()
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 16, 2013
1 parent 56da374 commit b0d1d94
Show file tree
Hide file tree
Showing 17 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ public function process_member($data) {
}

} else {
$dir = get_component_directory($data->component);
$dir = core_component::get_component_directory($data->component);
if ($dir and is_dir($dir)) {
if (component_callback($data->component, 'restore_group_member', array($this, $data), true)) {
return;
Expand Down Expand Up @@ -1597,7 +1597,7 @@ public function process_assignment($data) {
$data->roleid = $newroleid;
$data->userid = $newuserid;
$data->contextid = $contextid;
$dir = get_component_directory($data->component);
$dir = core_component::get_component_directory($data->component);
if ($dir and is_dir($dir)) {
if (component_callback($data->component, 'restore_role_assignment', array($this, $data), true)) {
return;
Expand Down
2 changes: 1 addition & 1 deletion group/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function groups_add_member($grouporid, $userorid, $component=null, $itemid=0) {

// Check the component exists if specified
if (!empty($component)) {
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if ($dir && is_dir($dir)) {
// Component exists and can be used
$member->component = $component;
Expand Down
4 changes: 2 additions & 2 deletions lib/accesslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ function count_enrolled_users(context $context, $withcapability = '', $groupid =
* @return array array of capabilities
*/
function load_capability_def($component) {
$defpath = get_component_directory($component).'/db/access.php';
$defpath = core_component::get_component_directory($component).'/db/access.php';

$capabilities = array();
if (file_exists($defpath)) {
Expand Down Expand Up @@ -2863,7 +2863,7 @@ function get_capability_string($capabilityname) {
return get_string($stringname, $component);
}

$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if (!file_exists($dir)) {
// plugin broken or does not exist, do not bother with printing of debug message
return $capabilityname.' ???';
Expand Down
2 changes: 1 addition & 1 deletion lib/cronlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ function cron_execute_plugin_type($plugintype, $description = null) {
}

foreach ($plugins as $component=>$cronfunction) {
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);

// Get cron period if specified in version.php, otherwise assume every cron
$cronperiod = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/editor/tinymce/classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public static function all_update_init_params(array &$params,
* @return editor_tinymce_plugin Plugin object
*/
public static function get($plugin) {
$dir = get_component_directory('tinymce_' . $plugin);
$dir = core_component::get_component_directory('tinymce_' . $plugin);
require_once($dir . '/lib.php');
$classname = 'tinymce_' . $plugin;
return new $classname($plugin);
Expand Down
2 changes: 1 addition & 1 deletion lib/eventslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function events_load_def($component) {
if ($component === 'unittest') {
$defpath = $CFG->dirroot.'/lib/tests/fixtures/events.php';
} else {
$defpath = get_component_directory($component).'/db/events.php';
$defpath = core_component::get_component_directory($component).'/db/events.php';
}

$handlers = array();
Expand Down
4 changes: 2 additions & 2 deletions lib/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function external_function_info($function, $strictness=MUST_EXIST) {
}

//first find and include the ext implementation class
$function->classpath = empty($function->classpath) ? get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
$function->classpath = empty($function->classpath) ? core_component::get_component_directory($function->component).'/externallib.php' : $CFG->dirroot.'/'.$function->classpath;
if (!file_exists($function->classpath)) {
throw new coding_exception('Can not find file with external function implementation');
}
Expand Down Expand Up @@ -83,7 +83,7 @@ function external_function_info($function, $strictness=MUST_EXIST) {
// on the other hand this is still a bit in a flux and we need to find some new naming
// conventions for these descriptions in lang packs
$function->description = null;
$servicesfile = get_component_directory($function->component).'/db/services.php';
$servicesfile = core_component::get_component_directory($function->component).'/db/services.php';
if (file_exists($servicesfile)) {
$functions = null;
include($servicesfile);
Expand Down
2 changes: 1 addition & 1 deletion lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4543,7 +4543,7 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {

} else {
// try to serve general plugin file in arbitrary context
$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
if (!file_exists("$dir/lib.php")) {
send_file_not_found();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/messagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function message_send($eventdata) {

if (PHPUNIT_TEST and class_exists('phpunit_util')) {
// Add some more tests to make sure the normal code can actually work.
$componentdir = get_component_directory($eventdata->component);
$componentdir = core_component::get_component_directory($eventdata->component);
if (!$componentdir or !is_dir($componentdir)) {
throw new coding_exception('Invalid component specified in message-send(): '.$eventdata->component);
}
Expand Down Expand Up @@ -525,7 +525,7 @@ function message_get_providers_from_db($component) {
* @return array An array of message providers or empty array if not exists
*/
function message_get_providers_from_file($component) {
$defpath = get_component_directory($component).'/db/messages.php';
$defpath = core_component::get_component_directory($component).'/db/messages.php';

$messageproviders = array();

Expand Down
2 changes: 1 addition & 1 deletion lib/outputfactories.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function standard_renderer_classname($component, $subtype = null) {

if ($component !== 'core') {
// renderers are stored in renderer.php files
if (!$compdirectory = get_component_directory($component)) {
if (!$compdirectory = core_component::get_component_directory($component)) {
throw new coding_exception('Invalid component specified in renderer request');
}
$rendererfile = $compdirectory . '/renderer.php';
Expand Down
6 changes: 3 additions & 3 deletions lib/outputrequirementslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public function jquery_plugin($plugin, $component = 'core') {
return true;
}

$componentdir = get_component_directory($component);
$componentdir = core_component::get_component_directory($component);
if (!file_exists($componentdir) or !file_exists("$componentdir/jquery/plugins.php")) {
debugging("Can not load jQuery plugin '$plugin', missing plugins.php in component '$component'.", DEBUG_DEVELOPER);
return false;
Expand Down Expand Up @@ -704,7 +704,7 @@ protected function find_module($component) {
}

} else {
if ($dir = get_component_directory($component)) {
if ($dir = core_component::get_component_directory($component)) {
if (file_exists("$dir/module.js")) {
if (strpos($dir, $CFG->dirroot.'/') === 0) {
$dir = substr($dir, strlen($CFG->dirroot));
Expand Down Expand Up @@ -1647,7 +1647,7 @@ public function add_moodle_metadata() {
private function get_moodle_metadata() {
$moodlemodules = array();
// Core isn't a plugin type or subsystem - handle it seperately.
if ($module = $this->get_moodle_path_metadata(get_component_directory('core'))) {
if ($module = $this->get_moodle_path_metadata(core_component::get_component_directory('core'))) {
$moodlemodules = array_merge($moodlemodules, $module);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/portfoliolib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ function portfolio_include_callback_file($component, $class = null) {
}

// Obtain the component's location.
if (!$componentloc = get_component_directory($component)) {
if (!$componentloc = core_component::get_component_directory($component)) {
throw new portfolio_button_exception('nocallbackcomponent', 'portfolio', '', $component);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/questionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,7 @@ function question_pluginfile($course, $context, $component, $filearea, $args, $f
$component, $filearea, $qubaid, $slot, $args, $forcedownload, $options);

} else {
$dir = get_component_directory($module);
$dir = core_component::get_component_directory($module);
if (!file_exists("$dir/lib.php")) {
send_file_not_found();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/testing/generator/data_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function get_plugin_generator($component) {
return $this->generators[$component];
}

$dir = get_component_directory($component);
$dir = core_component::get_component_directory($component);
$lib = $dir . '/tests/generator/lib.php';
if (!$dir || !is_readable($lib)) {
throw new coding_exception("Component {$component} does not support " .
Expand Down
16 changes: 8 additions & 8 deletions lib/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function upgrade_plugins($type, $startcallback, $endcallback, $verbose) {
if (isset($plugin->component)) {
if ($plugin->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullplug);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($plugin->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($plugin->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
Expand Down Expand Up @@ -571,7 +571,7 @@ function upgrade_plugins_modules($startcallback, $endcallback, $verbose) {
if (isset($module->component)) {
if ($module->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullmod);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($module->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($module->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
Expand Down Expand Up @@ -751,7 +751,7 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
if (isset($block->component)) {
if ($block->component !== $component) {
$current = str_replace($CFG->dirroot, '$CFG->dirroot', $fullblock);
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', get_component_directory($block->component));
$expected = str_replace($CFG->dirroot, '$CFG->dirroot', core_component::get_component_directory($block->component));
throw new plugin_misplaced_exception($component, $expected, $current);
}
}
Expand Down Expand Up @@ -909,7 +909,7 @@ function upgrade_plugins_blocks($startcallback, $endcallback, $verbose) {
function log_update_descriptions($component) {
global $DB;

$defpath = get_component_directory($component).'/db/log.php';
$defpath = core_component::get_component_directory($component).'/db/log.php';

if (!file_exists($defpath)) {
$DB->delete_records('log_display', array('component'=>$component));
Expand Down Expand Up @@ -966,7 +966,7 @@ function log_update_descriptions($component) {
function external_update_descriptions($component) {
global $DB, $CFG;

$defpath = get_component_directory($component).'/db/services.php';
$defpath = core_component::get_component_directory($component).'/db/services.php';

if (!file_exists($defpath)) {
require_once($CFG->dirroot.'/lib/externallib.php');
Expand Down Expand Up @@ -1187,7 +1187,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
$currentversion = ($currentversion === false) ? null : $currentversion;
} catch (Exception $ignored) {
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$module = new stdClass();
$module->version = null;
Expand All @@ -1202,7 +1202,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
}
} catch (Exception $ignored) {
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$plugin = new stdClass();
$plugin->version = null;
Expand All @@ -1215,7 +1215,7 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
if (!empty($pluginversion)) {
$currentversion = $pluginversion;
}
$cd = get_component_directory($component);
$cd = core_component::get_component_directory($component);
if (file_exists("$cd/version.php")) {
$plugin = new stdClass();
$plugin->version = null;
Expand Down
2 changes: 1 addition & 1 deletion rss/file.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
}

// Work out which component in Moodle we want (from the frankenstyle name)
$componentdir = get_component_directory($componentname);
$componentdir = core_component::get_component_directory($componentname);
list($type, $plugin) = core_component::normalize_component($componentname);


Expand Down
2 changes: 1 addition & 1 deletion webservice/externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function get_site_info($serviceshortnames = array()) {
if ($function->component == 'moodle' || $function->component == 'core') {
$version = $CFG->version; // Moodle version.
} else {
$versionpath = get_component_directory($function->component).'/version.php';
$versionpath = core_component::get_component_directory($function->component).'/version.php';
if (is_readable($versionpath)) {
// We store the component version once retrieved (so we don't load twice the version.php).
if (!isset($componentversions[$function->component])) {
Expand Down

0 comments on commit b0d1d94

Please sign in to comment.