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


PHP admin_setting_configcheckbox::write_setting方法代码示例

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


在下文中一共展示了admin_setting_configcheckbox::write_setting方法的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: write_setting

 /**
  * Saves the new settings passed in $data
  *
  * @param string $data
  * @return mixed string or Array
  */
 public function write_setting($data)
 {
     global $CFG, $DB;
     $oldvalue = $this->config_read($this->name);
     $return = parent::write_setting($data);
     $newvalue = $this->config_read($this->name);
     if ($oldvalue !== $newvalue) {
         // force full regrading
         $DB->set_field('grade_items', 'needsupdate', 1, array('needsupdate' => 0));
     }
     return $return;
 }
开发者ID:ajv,项目名称:Offline-Caching,代码行数:18,代码来源:adminlib.php


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