当前位置: 首页>>代码示例>>PHP>>正文


PHP webservice::update_external_service方法代码示例

本文整理汇总了PHP中webservice::update_external_service方法的典型用法代码示例。如果您正苦于以下问题:PHP webservice::update_external_service方法的具体用法?PHP webservice::update_external_service怎么用?PHP webservice::update_external_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webservice的用法示例。


在下文中一共展示了webservice::update_external_service方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write_setting

 /**
  * Save the selected setting
  *
  * @param string $data The selected site
  * @return string empty string or error message
  */
 public function write_setting($data)
 {
     global $DB, $CFG;
     //for install cli script, $CFG->defaultuserroleid is not set so do nothing
     if (empty($CFG->defaultuserroleid)) {
         return '';
     }
     $servicename = MOODLE_OFFICIAL_MOBILE_SERVICE;
     require_once $CFG->dirroot . '/webservice/lib.php';
     $webservicemanager = new webservice();
     if ((string) $data === $this->yes) {
         //code run when enable mobile web service
         //enable web service systeme if necessary
         set_config('enablewebservices', true);
         //enable mobile service
         $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
         $mobileservice->enabled = 1;
         $webservicemanager->update_external_service($mobileservice);
         //enable xml-rpc server
         $activeprotocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
         if (!in_array('xmlrpc', $activeprotocols)) {
             $activeprotocols[] = 'xmlrpc';
             set_config('webserviceprotocols', implode(',', $activeprotocols));
         }
         //allow xml-rpc:use capability for authenticated user
         $this->set_xmlrpc_cap(true);
     } else {
         //disable web service system if no other services are enabled
         $otherenabledservices = $DB->get_records_select('external_services', 'enabled = :enabled AND (shortname != :shortname OR shortname IS NULL)', array('enabled' => 1, 'shortname' => MOODLE_OFFICIAL_MOBILE_SERVICE));
         if (empty($otherenabledservices)) {
             set_config('enablewebservices', false);
             //also disable xml-rpc server
             $activeprotocols = empty($CFG->webserviceprotocols) ? array() : explode(',', $CFG->webserviceprotocols);
             $protocolkey = array_search('xmlrpc', $activeprotocols);
             if ($protocolkey !== false) {
                 unset($activeprotocols[$protocolkey]);
                 set_config('webserviceprotocols', implode(',', $activeprotocols));
             }
             //disallow xml-rpc:use capability for authenticated user
             $this->set_xmlrpc_cap(false);
         }
         //disable the mobile service
         $mobileservice = $webservicemanager->get_external_service_by_shortname(MOODLE_OFFICIAL_MOBILE_SERVICE);
         $mobileservice->enabled = 0;
         $webservicemanager->update_external_service($mobileservice);
     }
     return parent::write_setting($data);
 }
开发者ID:raymondAntonio,项目名称:moodle,代码行数:54,代码来源:adminlib.php

示例2: redirect

    redirect($returnurl);
}
/// EDIT/CREATE/CANCEL operations => at the end redirect to add function page / main service page
$mform = new external_service_form(null, $service);
if ($mform->is_cancelled()) {
    redirect($returnurl);
} else {
    if ($servicedata = $mform->get_data()) {
        $servicedata = (object) $servicedata;
        if (!empty($servicedata->requiredcapability) && $servicedata->requiredcapability == "norequiredcapability") {
            $servicedata->requiredcapability = "";
        }
        //create operation
        if (empty($servicedata->id)) {
            $servicedata->id = $webservicemanager->add_external_service($servicedata);
            add_to_log(SITEID, 'webservice', 'add', $returnurl, get_string('addservice', 'webservice', $servicedata));
            //redirect to the 'add functions to service' page
            $addfunctionpage = new moodle_url($CFG->wwwroot . '/' . $CFG->admin . '/webservice/service_functions.php', array('id' => $servicedata->id));
            $returnurl = $addfunctionpage->out(false);
        } else {
            //update operation
            $webservicemanager->update_external_service($servicedata);
            add_to_log(SITEID, 'webservice', 'edit', $returnurl, get_string('editservice', 'webservice', $servicedata));
        }
        redirect($returnurl);
    }
}
//OUTPUT edit/create form
echo $OUTPUT->header();
$mform->display();
echo $OUTPUT->footer();
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:service.php


注:本文中的webservice::update_external_service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。