本文整理汇总了PHP中course_enrolment_manager::add_user_to_group方法的典型用法代码示例。如果您正苦于以下问题:PHP course_enrolment_manager::add_user_to_group方法的具体用法?PHP course_enrolment_manager::add_user_to_group怎么用?PHP course_enrolment_manager::add_user_to_group使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类course_enrolment_manager
的用法示例。
在下文中一共展示了course_enrolment_manager::add_user_to_group方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Makes the user a member of a given group
*/
case 'addmember':
if (has_capability('moodle/course:managegroups', $manager->get_context())) {
$userid = required_param('user', PARAM_INT);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$mform = new enrol_users_addmember_form(NULL, array('user' => $user, 'course' => $course, 'allgroups' => $manager->get_all_groups()));
$mform->set_data($PAGE->url->params());
$data = $mform->get_data();
if ($mform->is_cancelled()) {
redirect($PAGE->url);
}
if (!empty($data->groupids)) {
foreach ($data->groupids as $groupid) {
$manager->add_user_to_group($user, $groupid);
}
redirect($PAGE->url);
} else {
$pagetitle = get_string('addgroup', 'group');
}
$actiontaken = true;
}
break;
}
// If we took an action display we need to display something special.
if ($actiontaken) {
if (empty($pageheading)) {
$pageheading = $pagetitle;
}
$PAGE->set_title($pagetitle);
示例2: array
}
break;
/**
* Makes the user a member of a given group
*/
/**
* Makes the user a member of a given group
*/
case 'addmember':
if (has_capability('moodle/course:managegroups', $manager->get_context())) {
$userid = required_param('user', PARAM_INT);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$mform = new enrol_users_addmember_form(NULL, array('user' => $user, 'course' => $course, 'allgroups' => $manager->get_all_groups()));
$mform->set_data($PAGE->url->params());
$data = $mform->get_data();
if ($mform->is_cancelled() || $data && $manager->add_user_to_group($user, $data->groupid)) {
redirect($PAGE->url);
} else {
$pagetitle = get_string('addgroup', 'group');
}
$actiontaken = true;
}
break;
}
// If we took an action display we need to display something special.
if ($actiontaken) {
if (empty($pageheading)) {
$pageheading = $pagetitle;
}
$PAGE->set_title($pagetitle);
$PAGE->set_heading($pageheading);