dirroot . '/user/selector/lib.php'); require_once($CFG->dirroot . '/course/lib.php'); $groupid = required_param('group', PARAM_INT); if (!$group = $DB->get_record('groups', array('id'=>$groupid))) { print_error('invalidgroupid'); } if (!$course = $DB->get_record('course', array('id'=>$group->courseid))) { print_error('invalidcourse'); } $courseid = $course->id; $PAGE->set_url(new moodle_url($CFG->wwwroot.'/groups/members.php', array('id'=>$groupid))); require_login($course); $context = get_context_instance(CONTEXT_COURSE, $courseid); require_capability('moodle/course:managegroups', $context); $returnurl = $CFG->wwwroot.'/group/index.php?id='.$courseid.'&group='.$group->id; if (optional_param('cancel', false, PARAM_BOOL)) { redirect($returnurl); } $groupmembersselector = new group_members_selector('removeselect', array('groupid' => $groupid, 'courseid' => $course->id)); $groupmembersselector->set_extra_fields(array()); $potentialmembersselector = new group_non_members_selector('addselect', array('groupid' => $groupid, 'courseid' => $course->id)); $potentialmembersselector->set_extra_fields(array()); if (optional_param('add', false, PARAM_BOOL) && confirm_sesskey()) { $userstoadd = $potentialmembersselector->get_selected_users(); if (!empty($userstoadd)) { foreach ($userstoadd as $user) { if (!groups_add_member($groupid, $user->id)) { print_error('erroraddremoveuser', 'group', $returnurl); } $groupmembersselector->invalidate_selected_users(); $potentialmembersselector->invalidate_selected_users(); } } } if (optional_param('remove', false, PARAM_BOOL) && confirm_sesskey()) { $userstoremove = $groupmembersselector->get_selected_users(); if (!empty($userstoremove)) { foreach ($userstoremove as $user) { if (!groups_remove_member($groupid, $user->id)) { print_error('erroraddremoveuser', 'group', $returnurl); } $groupmembersselector->invalidate_selected_users(); $potentialmembersselector->invalidate_selected_users(); } } } // Print the page and form $strgroups = get_string('groups'); $strparticipants = get_string('participants'); $stradduserstogroup = get_string('adduserstogroup', 'group'); $strusergroupmembership = get_string('usergroupmembership', 'group'); $groupname = format_string($group->name); $PAGE->requires->js('group/clientlib.js'); $PAGE->requires->js_function_call('init_add_remove_members_page'); $PAGE->navbar->add($strparticipants, new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid))); $PAGE->navbar->add($strgroups, new moodle_url($CFG->wwwroot.'/group/index.php', array('id'=>$courseid))); $PAGE->navbar->add($stradduserstogroup); /// Print header $PAGE->set_title("$course->shortname: $strgroups"); $PAGE->set_heading($course->fullname); $PAGE->set_headingmenu(user_login_string($course, $USER)); echo $OUTPUT->header(); check_theme_arrows(); ?>

display(); ?>


display(); ?>
footer(); ?>