本文整理汇总了PHP中webservice::get_external_functions_by_enabled_services方法的典型用法代码示例。如果您正苦于以下问题:PHP webservice::get_external_functions_by_enabled_services方法的具体用法?PHP webservice::get_external_functions_by_enabled_services怎么用?PHP webservice::get_external_functions_by_enabled_services使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webservice
的用法示例。
在下文中一共展示了webservice::get_external_functions_by_enabled_services方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_site_info
/**
* Return user information including profile picture + basic site information
* Note:
* - no capability checking because we return just known information by logged user
* @param array $serviceshortnames of service shortnames - the functions of these services will be returned
* @return array
*/
public function get_site_info($serviceshortnames = array())
{
global $USER, $SITE, $CFG;
$params = self::validate_parameters(self::get_site_info_parameters(), array('serviceshortnames' => $serviceshortnames));
$profileimageurl = moodle_url::make_pluginfile_url(get_context_instance(CONTEXT_USER, $USER->id)->id, 'user', 'icon', NULL, '/', 'f1');
require_once $CFG->dirroot . "/webservice/lib.php";
$webservice = new webservice();
//If no service listed always return the mobile one by default
if (empty($params['serviceshortnames']) and $CFG->enablewebservices) {
$mobileservice = $webservice->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
if ($mobileservice->enabled) {
$params['serviceshortnames'] = array(MOODLE_OFFICIAL_MOBILE_SERVICE);
//return mobile service by default
}
}
//retrieve the functions related to the services
$functions = $webservice->get_external_functions_by_enabled_services($params['serviceshortnames']);
//built up the returned values of the list of functions
$componentversions = array();
$avalaiblefunctions = array();
foreach ($functions as $function) {
$functioninfo = array();
$functioninfo['name'] = $function->name;
if ($function->component == 'moodle') {
$version = $CFG->version;
//moodle version
} else {
$versionpath = 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])) {
include $versionpath;
$componentversions[$function->component] = $plugin->version;
$version = $plugin->version;
} else {
$version = $componentversions[$function->component];
}
} else {
//function component should always have a version.php,
//otherwise the function should have been described with component => 'moodle'
throw new moodle_exception('missingversionfile', 'webservice', '', $function->component);
}
}
$functioninfo['version'] = $version;
$avalaiblefunctions[] = $functioninfo;
}
return array('sitename' => $SITE->fullname, 'siteurl' => $CFG->wwwroot, 'username' => $USER->username, 'firstname' => $USER->firstname, 'lastname' => $USER->lastname, 'fullname' => fullname($USER), 'userid' => $USER->id, 'userpictureurl' => $profileimageurl->out(false), 'functions' => $avalaiblefunctions);
}