當前位置: 首頁>>代碼示例>>PHP>>正文


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怎麽用?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);
 }
開發者ID:rosenclever,項目名稱:moodle,代碼行數:55,代碼來源:externallib.php


注:本文中的webservice::get_external_functions_by_enabled_services方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。