本文整理汇总了PHP中grade_category::updated_forced_settings方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_category::updated_forced_settings方法的具体用法?PHP grade_category::updated_forced_settings怎么用?PHP grade_category::updated_forced_settings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_category
的用法示例。
在下文中一共展示了grade_category::updated_forced_settings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write_setting
/**
* Save the new settings passed in $data
*
* @todo Add vartype handling to ensure $data is array
* @param array $data Associative array of value=>xx, forced=>xx, adv=>xx
* @return string empty or error message
*/
public function write_setting($data)
{
global $CFG;
$value = $data['value'];
$forced = empty($data['forced']) ? 0 : 1;
$adv = empty($data['adv']) ? 0 : 2;
$flag = $forced | $adv;
//bitwise or
if (!in_array($value, array_keys($this->choices))) {
return 'Error setting ';
}
$oldvalue = $this->config_read($this->name);
$oldflag = (int) $this->config_read($this->name . '_flag');
$oldforced = 1 & $oldflag;
// first bit
$result1 = $this->config_write($this->name, $value);
$result2 = $this->config_write($this->name . '_flag', $flag);
// force regrade if needed
if ($oldforced != $forced or $forced and $value != $oldvalue) {
require_once $CFG->libdir . '/gradelib.php';
grade_category::updated_forced_settings();
}
if ($result1 and $result2) {
return '';
} else {
return get_string('errorsetting', 'admin');
}
}