本文整理汇总了PHP中core_component::get_plugin_directory方法的典型用法代码示例。如果您正苦于以下问题:PHP core_component::get_plugin_directory方法的具体用法?PHP core_component::get_plugin_directory怎么用?PHP core_component::get_plugin_directory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core_component
的用法示例。
在下文中一共展示了core_component::get_plugin_directory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_qtype
/**
* Get the question type class for a particular question type.
* @param string $qtypename the question type name. For example 'multichoice' or 'shortanswer'.
* @param bool $mustexist if false, the missing question type is returned when
* the requested question type is not installed.
* @return question_type the corresponding question type class.
*/
public static function get_qtype($qtypename, $mustexist = true)
{
global $CFG;
if (isset(self::$questiontypes[$qtypename])) {
return self::$questiontypes[$qtypename];
}
$file = core_component::get_plugin_directory('qtype', $qtypename) . '/questiontype.php';
if (!is_readable($file)) {
if ($mustexist || $qtypename == 'missingtype') {
throw new coding_exception('Unknown question type ' . $qtypename);
} else {
return self::get_qtype('missingtype');
}
}
include_once $file;
$class = 'qtype_' . $qtypename;
if (!class_exists($class)) {
throw new coding_exception("Class {$class} must be defined in {$file}.");
}
self::$questiontypes[$qtypename] = new $class();
return self::$questiontypes[$qtypename];
}
示例2: get_component_string
/**
* This gets the mod/block/course/core etc strings.
*
* @param string $component
* @param int $contextlevel
* @return string|bool String is success, false if failed
*/
function get_component_string($component, $contextlevel) {
if ($component === 'moodle' or $component === 'core') {
switch ($contextlevel) {
// TODO: this should probably use context level names instead
case CONTEXT_SYSTEM: return get_string('coresystem');
case CONTEXT_USER: return get_string('users');
case CONTEXT_COURSECAT: return get_string('categories');
case CONTEXT_COURSE: return get_string('course');
case CONTEXT_MODULE: return get_string('activities');
case CONTEXT_BLOCK: return get_string('block');
default: print_error('unknowncontext');
}
}
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
return $component.' ???';
}
switch ($type) {
// TODO: this is really hacky, anyway it should be probably moved to lib/pluginlib.php
case 'quiz': return get_string($name.':componentname', $component);// insane hack!!!
case 'repository': return get_string('repository', 'repository').': '.get_string('pluginname', $component);
case 'gradeimport': return get_string('gradeimport', 'grades').': '.get_string('pluginname', $component);
case 'gradeexport': return get_string('gradeexport', 'grades').': '.get_string('pluginname', $component);
case 'gradereport': return get_string('gradereport', 'grades').': '.get_string('pluginname', $component);
case 'webservice': return get_string('webservice', 'webservice').': '.get_string('pluginname', $component);
case 'block': return get_string('block').': '.get_string('pluginname', basename($component));
case 'mod':
if (get_string_manager()->string_exists('pluginname', $component)) {
return get_string('activity').': '.get_string('pluginname', $component);
} else {
return get_string('activity').': '.get_string('modulename', $component);
}
default: return get_string('pluginname', $component);
}
}
示例3: plugin_supports
/**
* Checks whether a plugin supports a specified feature.
*
* @param string $type Plugin type e.g. 'mod'
* @param string $name Plugin name e.g. 'forum'
* @param string $feature Feature code (FEATURE_xx constant)
* @param mixed $default default value if feature support unknown
* @return mixed Feature result (false if not supported, null if feature is unknown,
* otherwise usually true but may have other feature-specific value such as array)
* @throws coding_exception
*/
function plugin_supports($type, $name, $feature, $default = null)
{
global $CFG;
if ($type === 'mod' and $name === 'NEWMODULE') {
// Somebody forgot to rename the module template.
return false;
}
$component = clean_param($type . '_' . $name, PARAM_COMPONENT);
if (empty($component)) {
throw new coding_exception('Invalid component used in plugin_supports():' . $type . '_' . $name);
}
$function = null;
if ($type === 'mod') {
// We need this special case because we support subplugins in modules,
// otherwise it would end up in infinite loop.
if (file_exists("{$CFG->dirroot}/mod/{$name}/lib.php")) {
include_once "{$CFG->dirroot}/mod/{$name}/lib.php";
$function = $component . '_supports';
if (!function_exists($function)) {
// Legacy non-frankenstyle function name.
$function = $name . '_supports';
}
}
} else {
if (!($path = core_component::get_plugin_directory($type, $name))) {
// Non existent plugin type.
return false;
}
if (file_exists("{$path}/lib.php")) {
include_once "{$path}/lib.php";
$function = $component . '_supports';
}
}
if ($function and function_exists($function)) {
$supports = $function($feature);
if (is_null($supports)) {
// Plugin does not know - use default.
return $default;
} else {
return $supports;
}
}
// Plugin does not care, so use default.
return $default;
}
示例4: upgrade_plugin_mnet_functions
/**
* upgrades the mnet rpc definitions for the given component.
* this method doesn't return status, an exception will be thrown in the case of an error
*
* @param string $component the plugin to upgrade, eg auth_mnet
*/
function upgrade_plugin_mnet_functions($component) {
global $DB, $CFG;
list($type, $plugin) = core_component::normalize_component($component);
$path = core_component::get_plugin_directory($type, $plugin);
$publishes = array();
$subscribes = array();
if (file_exists($path . '/db/mnet.php')) {
require_once($path . '/db/mnet.php'); // $publishes comes from this file
}
if (empty($publishes)) {
$publishes = array(); // still need this to be able to disable stuff later
}
if (empty($subscribes)) {
$subscribes = array(); // still need this to be able to disable stuff later
}
static $servicecache = array();
// rekey an array based on the rpc method for easy lookups later
$publishmethodservices = array();
$subscribemethodservices = array();
foreach($publishes as $servicename => $service) {
if (is_array($service['methods'])) {
foreach($service['methods'] as $methodname) {
$service['servicename'] = $servicename;
$publishmethodservices[$methodname][] = $service;
}
}
}
// Disable functions that don't exist (any more) in the source
// Should these be deleted? What about their permissions records?
foreach ($DB->get_records('mnet_rpc', array('pluginname'=>$plugin, 'plugintype'=>$type), 'functionname ASC ') as $rpc) {
if (!array_key_exists($rpc->functionname, $publishmethodservices) && $rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 0, array('id' => $rpc->id));
} else if (array_key_exists($rpc->functionname, $publishmethodservices) && !$rpc->enabled) {
$DB->set_field('mnet_rpc', 'enabled', 1, array('id' => $rpc->id));
}
}
// reflect all the services we're publishing and save them
require_once($CFG->dirroot . '/lib/zend/Zend/Server/Reflection.php');
static $cachedclasses = array(); // to store reflection information in
foreach ($publishes as $service => $data) {
$f = $data['filename'];
$c = $data['classname'];
foreach ($data['methods'] as $method) {
$dataobject = new stdClass();
$dataobject->plugintype = $type;
$dataobject->pluginname = $plugin;
$dataobject->enabled = 1;
$dataobject->classname = $c;
$dataobject->filename = $f;
if (is_string($method)) {
$dataobject->functionname = $method;
} else if (is_array($method)) { // wants to override file or class
$dataobject->functionname = $method['method'];
$dataobject->classname = $method['classname'];
$dataobject->filename = $method['filename'];
}
$dataobject->xmlrpcpath = $type.'/'.$plugin.'/'.$dataobject->filename.'/'.$method;
$dataobject->static = false;
require_once($path . '/' . $dataobject->filename);
$functionreflect = null; // slightly different ways to get this depending on whether it's a class method or a function
if (!empty($dataobject->classname)) {
if (!class_exists($dataobject->classname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
$key = $dataobject->filename . '|' . $dataobject->classname;
if (!array_key_exists($key, $cachedclasses)) { // look to see if we've already got a reflection object
try {
$cachedclasses[$key] = Zend_Server_Reflection::reflectClass($dataobject->classname);
} catch (Zend_Server_Reflection_Exception $e) { // catch these and rethrow them to something more helpful
throw new moodle_exception('installreflectionclasserror', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname, 'error' => $e->getMessage()));
}
}
$r =& $cachedclasses[$key];
if (!$r->hasMethod($dataobject->functionname)) {
throw new moodle_exception('installnosuchmethod', 'mnet', '', (object)array('method' => $dataobject->functionname, 'class' => $dataobject->classname));
}
// stupid workaround for zend not having a getMethod($name) function
$ms = $r->getMethods();
foreach ($ms as $m) {
if ($m->getName() == $dataobject->functionname) {
$functionreflect = $m;
break;
}
}
$dataobject->static = (int)$functionreflect->isStatic();
//.........这里部分代码省略.........
示例5: get_test_helper
/**
* Get the test helper class for a particular question type.
* @param $qtype the question type name, e.g. 'multichoice'.
* @return question_test_helper the test helper class.
*/
public static function get_test_helper($qtype)
{
global $CFG;
if (array_key_exists($qtype, self::$testhelpers)) {
return self::$testhelpers[$qtype];
}
$file = core_component::get_plugin_directory('qtype', $qtype) . '/tests/helper.php';
if (!is_readable($file)) {
throw new coding_exception('Question type ' . $qtype . ' does not have test helper code.');
}
include_once $file;
$class = 'qtype_' . $qtype . '_test_helper';
if (!class_exists($class)) {
throw new coding_exception('Class ' . $class . ' is not defined in ' . $file);
}
self::$testhelpers[$qtype] = new $class();
return self::$testhelpers[$qtype];
}
示例6: get_plugin_directory
/**
* Returns the exact absolute path to plugin directory.
*
* @deprecated since 2.6, use core_component::get_plugin_directory()
*
* @param string $plugintype type of plugin
* @param string $name name of the plugin
* @return string full path to plugin directory; NULL if not found
*/
function get_plugin_directory($plugintype, $name)
{
// NOTE: do not add any other debugging here, keep forever.
if ($plugintype === '') {
$plugintype = 'mod';
}
return core_component::get_plugin_directory($plugintype, $name);
}
示例7: resolve_font_location
/**
* Resolves the real font location.
*
* @param string $font name of font file
* @param string $component
* @return string full file path
*/
public function resolve_font_location($font, $component)
{
global $CFG;
if ($component === 'moodle' or $component === 'core' or empty($component)) {
if (file_exists("{$this->dir}/fonts_core/{$font}")) {
return "{$this->dir}/fonts_core/{$font}";
}
foreach (array_reverse($this->parent_configs) as $parent_config) {
// Base first, the immediate parent last.
if (file_exists("{$parent_config->dir}/fonts_core/{$font}")) {
return "{$parent_config->dir}/fonts_core/{$font}";
}
}
if (file_exists("{$CFG->dataroot}/fonts/{$font}")) {
return "{$CFG->dataroot}/fonts/{$font}";
}
if (file_exists("{$CFG->dirroot}/lib/fonts/{$font}")) {
return "{$CFG->dirroot}/lib/fonts/{$font}";
}
return null;
} else {
if ($component === 'theme') {
// Exception.
if (file_exists("{$this->dir}/fonts/{$font}")) {
return "{$this->dir}/fonts/{$font}";
}
foreach (array_reverse($this->parent_configs) as $parent_config) {
// Base first, the immediate parent last.
if (file_exists("{$parent_config->dir}/fonts/{$font}")) {
return "{$parent_config->dir}/fonts/{$font}";
}
}
return null;
} else {
if (strpos($component, '_') === false) {
$component = 'mod_' . $component;
}
list($type, $plugin) = explode('_', $component, 2);
if (file_exists("{$this->dir}/fonts_plugins/{$type}/{$plugin}/{$font}")) {
return "{$this->dir}/fonts_plugins/{$type}/{$plugin}/{$font}";
}
foreach (array_reverse($this->parent_configs) as $parent_config) {
// Base first, the immediate parent last.
if (file_exists("{$parent_config->dir}/fonts_plugins/{$type}/{$plugin}/{$font}")) {
return "{$parent_config->dir}/fonts_plugins/{$type}/{$plugin}/{$font}";
}
}
if (file_exists("{$CFG->dataroot}/fonts_plugins/{$type}/{$plugin}/{$font}")) {
return "{$CFG->dataroot}/fonts_plugins/{$type}/{$plugin}/{$font}";
}
$dir = core_component::get_plugin_directory($type, $plugin);
if (file_exists("{$dir}/fonts/{$font}")) {
return "{$dir}/fonts/{$font}";
}
return null;
}
}
}
示例8: component_writable
/**
* Checks if the given component's directory is writable
*
* For the purpose of the deployment, the web server process has to have
* write access to all files in the component's directory (recursively) and for the
* directory itself.
*
* @see worker::move_directory_source_precheck()
* @param string $component normalized component name
* @return boolean
*/
protected function component_writable($component) {
list($plugintype, $pluginname) = core_component::normalize_component($component);
$directory = core_component::get_plugin_directory($plugintype, $pluginname);
if (is_null($directory)) {
throw new coding_exception('Unknown component location', $component);
}
return $this->directory_writable($directory);
}
示例9: can_control_visibility
/**
* Returns whether the grade item can control the visibility of the grades
*
* @return bool
*/
public function can_control_visibility()
{
if (core_component::get_plugin_directory($this->itemtype, $this->itemmodule)) {
return !plugin_supports($this->itemtype, $this->itemmodule, FEATURE_CONTROLS_GRADE_VISIBILITY, false);
}
return parent::can_control_visibility();
}
示例10: test_deprecated_get_plugin_directory
public function test_deprecated_get_plugin_directory()
{
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $plugintype => $fulldir) {
$plugins = core_component::get_plugin_list($plugintype);
foreach ($plugins as $pluginname => $plugindir) {
$this->assertSame(core_component::get_plugin_directory($plugintype, $pluginname), get_plugin_directory($plugintype, $pluginname));
}
}
}
示例11: elis_versions
/**
* elis_versions method to get all ELIS PM and component version info
* @return string
*/
protected function elis_versions()
{
global $CFG;
$ret = html_writer::script("function toggle_elis_component_versions() {\n var compdiv;\n if (compdiv = document.getElementById('eliscomponentversions')) {\n if (compdiv.className.indexOf('accesshide') != -1) {\n compdiv.className = '';\n } else {\n compdiv.className = 'accesshide';\n }\n }\n }");
$ret .= html_writer::tag('p', get_string('elispmversion', 'local_elisprogram', elispm::$release) . ' ' . html_writer::empty_tag('input', array('type' => 'button', 'value' => get_string('alleliscomponents', 'local_elisprogram'), 'onclick' => 'toggle_elis_component_versions();')));
$eliscomponents = array('block_elisadmin' => null, 'block_courserequest' => null, 'block_enrolsurvey' => null, 'block_repository' => null, 'enrol_elis' => null, 'local_eliscore' => null, 'local_elisprogram' => null, 'local_elisreports' => null, 'local_datahub' => null, 'auth_elisfilessso' => null, 'repository_elisfiles' => null, 'lib_tcpdf' => array($this, 'get_tcpdf_info'), 'lib_pChart' => array($this, 'get_pchart_info'), 'lib_jquery1' => array($this, 'get_re_jquery_info'), 'lib_jquery_ui1' => array($this, 'get_re_jquery_ui_info'), 'lib_jquery2' => array($this, 'get_ds_jquery_info'), 'lib_jquery_ui2' => array($this, 'get_ds_jquery_ui_info'));
$componenttable = new html_table();
$componenttable->attributes = array('width' => '70%', 'border' => '0');
$componenttable->head = array(get_string('eliscomponent', 'local_elisprogram'), get_string('eliscomponentrelease', 'local_elisprogram'), get_string('eliscomponentversion', 'local_elisprogram'));
$componenttable->data = array();
foreach ($eliscomponents as $eliscomponent => $getinfocallback) {
list($plugintype, $pluginname) = explode('_', $eliscomponent);
if (!empty($getinfocallback)) {
list($componentname, $release, $version) = call_user_func($getinfocallback);
// error_log("elis_versions(): {$componentname}, {$release}, {$version}");
if (!empty($componentname)) {
$thirdpartylib = get_string('thirdpartylib', 'local_elisprogram');
$componenttable->data[] = array("{$componentname} {$thirdpartylib}", $release, $version);
}
} else {
if (($compdir = core_component::get_plugin_directory($plugintype, $pluginname)) && file_exists($compdir . '/version.php')) {
$plugin = new stdClass();
require $compdir . '/version.php';
if (!empty($plugin->version)) {
$version = $plugin->version;
$release = !empty($plugin->release) ? $plugin->release : '';
$componenttable->data[] = array($eliscomponent, $release, $version);
}
}
}
}
$ret .= html_writer::tag('div', html_writer::table($componenttable), array('id' => 'eliscomponentversions', 'class' => 'accesshide'));
return $ret;
}
示例12: get_string
/**
* Get String returns a requested string
*
* @param string $identifier The identifier of the string to search for
* @param string $component The module the string is associated with
* @param string|object|array $a An object, string or number that can be used
* within translation strings
* @param string $lang moodle translation language, null means use current
* @return string The String !
*/
public function get_string($identifier, $component = '', $a = null, $lang = null)
{
global $CFG;
$this->countgetstring++;
// There are very many uses of these time formatting strings without the 'langconfig' component,
// it would not be reasonable to expect that all of them would be converted during 2.0 migration.
static $langconfigstrs = array('strftimedate' => 1, 'strftimedatefullshort' => 1, 'strftimedateshort' => 1, 'strftimedatetime' => 1, 'strftimedatetimeshort' => 1, 'strftimedaydate' => 1, 'strftimedaydatetime' => 1, 'strftimedayshort' => 1, 'strftimedaytime' => 1, 'strftimemonthyear' => 1, 'strftimerecent' => 1, 'strftimerecentfull' => 1, 'strftimetime' => 1);
if (empty($component)) {
if (isset($langconfigstrs[$identifier])) {
$component = 'langconfig';
} else {
$component = 'moodle';
}
}
if ($lang === null) {
$lang = current_language();
}
$string = $this->load_component_strings($component, $lang);
if (!isset($string[$identifier])) {
if ($component === 'pix' or $component === 'core_pix') {
// This component contains only alt tags for emoticons, not all of them are supposed to be defined.
return '';
}
if ($identifier === 'parentlanguage' and ($component === 'langconfig' or $component === 'core_langconfig')) {
// Identifier parentlanguage is a special string, undefined means use English if not defined.
return 'en';
}
// Do not rebuild caches here!
// Devs need to learn to purge all caches after any change or disable $CFG->langstringcache.
if (!isset($string[$identifier])) {
// The string is still missing - should be fixed by developer.
if ($CFG->debugdeveloper) {
list($plugintype, $pluginname) = core_component::normalize_component($component);
if ($plugintype === 'core') {
$file = "lang/en/{$component}.php";
} else {
if ($plugintype == 'mod') {
$file = "mod/{$pluginname}/lang/en/{$pluginname}.php";
} else {
$path = core_component::get_plugin_directory($plugintype, $pluginname);
$file = "{$path}/lang/en/{$plugintype}_{$pluginname}.php";
}
}
debugging("Invalid get_string() identifier: '{$identifier}' or component '{$component}'. " . "Perhaps you are missing \$string['{$identifier}'] = ''; in {$file}?", DEBUG_DEVELOPER);
}
return "[[{$identifier}]]";
}
}
$string = $string[$identifier];
if ($a !== null) {
// Process array's and objects (except lang_strings).
if (is_array($a) or is_object($a) && !$a instanceof lang_string) {
$a = (array) $a;
$search = array();
$replace = array();
foreach ($a as $key => $value) {
if (is_int($key)) {
// We do not support numeric keys - sorry!
continue;
}
if (is_array($value) or is_object($value) && !$value instanceof lang_string) {
// We support just string or lang_string as value.
continue;
}
$search[] = '{$a->' . $key . '}';
$replace[] = (string) $value;
}
if ($search) {
$string = str_replace($search, $replace, $string);
}
} else {
$string = str_replace('{$a}', (string) $a, $string);
}
}
if ($CFG->debugdeveloper) {
// Display a debugging message if sting exists but was deprecated.
if ($this->string_deprecated($identifier, $component)) {
list($plugintype, $pluginname) = core_component::normalize_component($component);
$normcomponent = $pluginname ? $plugintype . '_' . $pluginname : $plugintype;
debugging("String [{$identifier},{$normcomponent}] is deprecated. " . 'Either you should no longer be using that string, or the string has been incorrectly deprecated, in which case you should report this as a bug. ' . 'Please refer to https://docs.moodle.org/dev/String_deprecation', DEBUG_DEVELOPER);
}
}
return $string;
}
示例13: mod_hsuforum_comment_message
/**
* @param stdClass $comment
* @param stdClass $options
* @throws comment_exception
*/
function mod_hsuforum_comment_message(stdClass $comment, stdClass $options)
{
global $DB;
if ($options->commentarea != 'userposts_comments') {
throw new comment_exception('invalidcommentarea');
}
if (!($user = $DB->get_record('user', array('id' => $options->itemid)))) {
throw new comment_exception('invalidcommentitemid');
}
/** @var context $context */
$context = $options->context;
if (!($cm = get_coursemodule_from_id('hsuforum', $context->instanceid))) {
throw new comment_exception('invalidcontext');
}
// Get all the users with the ability to rate.
$recipients = get_users_by_capability($context, 'mod/hsuforum:rate');
// Add the item user if they are different from commenter.
if ($comment->userid != $user->id and has_capability('mod/hsuforum:replypost', $context, $user)) {
$recipients[$user->id] = $user;
}
// Sender is the author of the comment.
$sender = $DB->get_record('user', array('id' => $comment->userid));
// Make sure that the commenter is not getting the message.
unset($recipients[$comment->userid]);
if (\core_component::get_plugin_directory('local', 'joulegrader') !== null) {
// Joule Grader is installed and control panel enabled.
$gareaid = component_callback('local_joulegrader', 'area_from_context', array($context, 'hsuforum'));
$contexturl = new moodle_url('/local/joulegrader/view.php', array('courseid' => $cm->course, 'garea' => $gareaid, 'guser' => $user->id));
} else {
$contexturl = $context->get_url();
}
$params = array($comment, $recipients, $sender, $cm->name, $contexturl);
component_callback('local_mrooms', 'comment_send_messages', $params);
}
示例14: mnet_setup_dummy_method
/**
* Figure out exactly what needs to be called and stashes it in $remoteclient
* Does some further verification that the method is callable
*
* @param string $method the full xmlrpc method that was called eg auth/mnet/auth.php/user_authorise
* @param array $callstack the exploded callstack
* @param stdclass $rpcrecord the record from mnet_rpc
*
* @throws mnet_server_exception
*/
function mnet_setup_dummy_method($method, $callstack, $rpcrecord)
{
global $CFG;
$remoteclient = get_mnet_remote_client();
// verify that the callpath in the stack matches our records
// callstack will look like array('mod', 'forum', 'lib.php', 'forum_add_instance');
$path = core_component::get_plugin_directory($rpcrecord->plugintype, $rpcrecord->pluginname);
$path = substr($path, strlen($CFG->dirroot) + 1);
// this is a bit hacky and fragile, it is not guaranteed that plugins are in dirroot
array_pop($callstack);
$providedpath = implode('/', $callstack);
if ($providedpath != $path . '/' . $rpcrecord->filename) {
throw new mnet_server_exception(705, "nosuchfile");
}
if (!file_exists($CFG->dirroot . '/' . $providedpath)) {
throw new mnet_server_exception(705, "nosuchfile");
}
require_once $CFG->dirroot . '/' . $providedpath;
if (!empty($rpcrecord->classname)) {
if (!class_exists($rpcrecord->classname)) {
throw new mnet_server_exception(708, 'nosuchclass');
}
if (!$rpcrecord->static) {
try {
$object = new $rpcrecord->classname();
} catch (Exception $e) {
throw new mnet_server_exception(709, "classerror");
}
if (!is_callable(array($object, $rpcrecord->functionname))) {
throw new mnet_server_exception(706, "nosuchfunction");
}
$remoteclient->object_to_call($object);
} else {
if (!is_callable(array($rpcrecord->classname, $rpcrecord->functionname))) {
throw new mnet_server_exception(706, "nosuchfunction");
}
$remoteclient->static_location($rpcrecord->classname);
}
}
}
示例15: uninstall_plugin
/**
* Automatically clean-up all plugin data and remove the plugin DB tables
*
* NOTE: do not call directly, use new /admin/plugins.php?uninstall=component instead!
*
* @param string $type The plugin type, eg. 'mod', 'qtype', 'workshopgrading' etc.
* @param string $name The plugin name, eg. 'forum', 'multichoice', 'accumulative' etc.
* @uses global $OUTPUT to produce notices and other messages
* @return void
*/
function uninstall_plugin($type, $name)
{
global $CFG, $DB, $OUTPUT;
// This may take a long time.
core_php_time_limit::raise();
// Recursively uninstall all subplugins first.
$subplugintypes = core_component::get_plugin_types_with_subplugins();
if (isset($subplugintypes[$type])) {
$base = core_component::get_plugin_directory($type, $name);
if (file_exists("{$base}/db/subplugins.php")) {
$subplugins = array();
include "{$base}/db/subplugins.php";
foreach ($subplugins as $subplugintype => $dir) {
$instances = core_component::get_plugin_list($subplugintype);
foreach ($instances as $subpluginname => $notusedpluginpath) {
uninstall_plugin($subplugintype, $subpluginname);
}
}
}
}
$component = $type . '_' . $name;
// eg. 'qtype_multichoice' or 'workshopgrading_accumulative' or 'mod_forum'
if ($type === 'mod') {
$pluginname = $name;
// eg. 'forum'
if (get_string_manager()->string_exists('modulename', $component)) {
$strpluginname = get_string('modulename', $component);
} else {
$strpluginname = $component;
}
} else {
$pluginname = $component;
if (get_string_manager()->string_exists('pluginname', $component)) {
$strpluginname = get_string('pluginname', $component);
} else {
$strpluginname = $component;
}
}
echo $OUTPUT->heading($pluginname);
// Delete all tag instances associated with this plugin.
require_once $CFG->dirroot . '/tag/lib.php';
tag_delete_instances($component);
// Custom plugin uninstall.
$plugindirectory = core_component::get_plugin_directory($type, $name);
$uninstalllib = $plugindirectory . '/db/uninstall.php';
if (file_exists($uninstalllib)) {
require_once $uninstalllib;
$uninstallfunction = 'xmldb_' . $pluginname . '_uninstall';
// eg. 'xmldb_workshop_uninstall()'
if (function_exists($uninstallfunction)) {
// Do not verify result, let plugin complain if necessary.
$uninstallfunction();
}
}
// Specific plugin type cleanup.
$plugininfo = core_plugin_manager::instance()->get_plugin_info($component);
if ($plugininfo) {
$plugininfo->uninstall_cleanup();
core_plugin_manager::reset_caches();
}
$plugininfo = null;
// perform clean-up task common for all the plugin/subplugin types
//delete the web service functions and pre-built services
require_once $CFG->dirroot . '/lib/externallib.php';
external_delete_descriptions($component);
// delete calendar events
$DB->delete_records('event', array('modulename' => $pluginname));
// Delete scheduled tasks.
$DB->delete_records('task_scheduled', array('component' => $pluginname));
// Delete Inbound Message datakeys.
$DB->delete_records_select('messageinbound_datakeys', 'handler IN (SELECT id FROM {messageinbound_handlers} WHERE component = ?)', array($pluginname));
// Delete Inbound Message handlers.
$DB->delete_records('messageinbound_handlers', array('component' => $pluginname));
// delete all the logs
$DB->delete_records('log', array('module' => $pluginname));
// delete log_display information
$DB->delete_records('log_display', array('component' => $component));
// delete the module configuration records
unset_all_config_for_plugin($component);
if ($type === 'mod') {
unset_all_config_for_plugin($pluginname);
}
// delete message provider
message_provider_uninstall($component);
// delete the plugin tables
$xmldbfilepath = $plugindirectory . '/db/install.xml';
drop_plugin_tables($component, $xmldbfilepath, false);
if ($type === 'mod' or $type === 'block') {
// non-frankenstyle table prefixes
drop_plugin_tables($name, $xmldbfilepath, false);
//.........这里部分代码省略.........