本文整理汇总了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);
}
示例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;
}