本文整理汇总了PHP中enrol_plugin::update_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP enrol_plugin::update_instance方法的具体用法?PHP enrol_plugin::update_instance怎么用?PHP enrol_plugin::update_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enrol_plugin
的用法示例。
在下文中一共展示了enrol_plugin::update_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_instance
/**
* Update instance of enrol plugin.
* @param stdClass $instance
* @param stdClass $data modified instance fields
* @return boolean
*/
public function update_instance($instance, $data)
{
// In the form we are representing 2 db columns with one field.
if ($data->expirynotify == 2) {
$data->expirynotify = 1;
$data->notifyall = 1;
} else {
$data->notifyall = 0;
}
// Keep previous/default value of disabled expirythreshold option.
if (!$data->expirynotify) {
$data->expirythreshold = $instance->expirythreshold;
}
// Add previous value of newenrols if disabled.
if (!isset($data->customint6)) {
$data->customint6 = $instance->customint6;
}
return parent::update_instance($instance, $data);
}
示例2: update_instance
/**
* Update instance of enrol plugin.
* @param stdClass $instance
* @param stdClass $data modified instance fields
* @return boolean
*/
public function update_instance($instance, $data)
{
global $CFG;
require_once "{$CFG->dirroot}/enrol/meta/locallib.php";
if (!empty($data->customint2) && $data->customint2 == ENROL_META_CREATE_GROUP) {
$context = context_course::instance($instance->courseid);
require_capability('moodle/course:managegroups', $context);
$groupid = enrol_meta_create_new_group($instance->courseid, $data->customint1);
$data->customint2 = $groupid;
}
$result = parent::update_instance($instance, $data);
enrol_meta_sync($instance->courseid);
return $result;
}