本文整理匯總了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;
}