libdir.'/moodlelib.php'); require_once($CFG->libdir.'/json/JSON.php'); require_js('yui_yahoo'); require_js('yui_dom'); require_js('yui_connection'); require_js($CFG->wwwroot.'/group/lib/clientlib.js'); $success = true; $courseid = required_param('id', PARAM_INT); $groupingid = optional_param('grouping', GROUP_NOT_IN_GROUPING, PARAM_INT); $groupid = optional_param('group', false, PARAM_INT); $userid = optional_param('user', false, PARAM_INT); $action = groups_param_action(); if ($groupid) { $groupingsforgroup = groups_get_groupings_for_group($groupid); if ($groupingsforgroup) { // NOTE // We currently assume that a group can only belong to one grouping. // FIXME // The UI will have to be fixed if we want to support more than one // groupings per group in the future. // // vy-shane AT moodle DOT com $groupingid = array_shift($groupingsforgroup); } } // Get the course information so we can print the header and // check the course id is valid $course = groups_get_course_info($courseid); if (! $course) { $success = false; print_error('invalidcourse'); //'The course ID is invalid' } if ($success) { // Make sure that the user has permissions to manage groups. require_login($courseid); $context = get_context_instance(CONTEXT_COURSE, $courseid); if (! has_capability('moodle/course:managegroups', $context)) { redirect(); //"group.php?id=$course->id"); // Not allowed to see all groups } // Set the session key so we can check this later $sesskey = !empty($USER->id) ? $USER->sesskey : ''; switch ($action) { case false: //OK, display form. break; case 'ajax_getgroupsingrouping': if (GROUP_NOT_IN_GROUPING == $groupingid) { $groupids = groups_get_groups_not_in_any_grouping($courseid); } else { $groupids = groups_get_groups_in_grouping($groupingid); } $group_names = groups_groupids_to_group_names($groupids); $json = new Services_JSON(); echo $json->encode($group_names); die; // Client side JavaScript takes it from here. case 'ajax_getmembersingroup': $members = array(); if ($memberids = groups_get_members($groupid)) { $member_names = groups_userids_to_user_names($memberids, $courseid); $json = new Services_JSON(); echo $json->encode($member_names); } die; // Client side JavaScript takes it from here. case 'showgroupingsettingsform': redirect(groups_grouping_edit_url($courseid, $groupingid, false)); break; case 'showgroupingpermsform': break; case 'deletegrouping': redirect(groups_grouping_edit_url($courseid, $groupingid, $html=false, $param='delete=1')); break; case 'showcreategroupingform': redirect(groups_grouping_edit_url($courseid, null, false)); break; case 'printerfriendly': redirect('groupui/printgrouping.php?courseid='. $courseid .'&groupingid='. $groupingid); break; case 'showgroupsettingsform': redirect(groups_group_edit_url($courseid, $groupid, $groupingid, false)); break; case 'deletegroup': redirect(groups_group_edit_url($courseid, $groupid, $groupingid, $html=false, $param='delete=1')); break; case 'removegroup': break; case 'showcreategroupform': if (GROUP_NOT_IN_GROUPING == $groupingid) { print_error('errornotingrouping', 'group', groups_home_url($courseid), get_string('notingrouping', 'group')); } redirect(groups_group_edit_url($courseid, null, $groupingid, false)); break; case 'addgroupstogroupingform': break; case 'updategroups': //Currently reloading. break; case 'removemembers': break; case 'showaddmembersform': redirect(groups_members_add_url($courseid, $groupid, $groupingid, false)); break; case 'updatemembers': //Currently reloading. break; default: //ERROR. if (debugging()) { error('Error, unknown button/action. Probably a user-interface bug!', groups_home_url($courseid)); break; } } // Print the page and form $strgroups = get_string('groups'); $strparticipants = get_string('participants'); print_header("$course->shortname: $strgroups home", //TODO: home $course->fullname, "wwwroot/course/view.php?id=$courseid\">$course->shortname ". "-> wwwroot/user/index.php?id=$courseid\">$strparticipants ". "-> $strgroups", '', '', true, '', user_login_string($course, $USER)); $usehtmleditor = false; //TODO: eventually we'll implement all buttons, meantime hide the ones we haven't finised. $shownotdone = false; print_heading(format_string($course->shortname) .' '.$strgroups, 'center', 3); ?>
" /> */ ?>

?>
'."\n"; echo '//wwwroot.'", '.$course->id.');'."\n"; echo 'var membersCombo = new UpdatableMembersCombo("'.$CFG->wwwroot.'", '.$course->id.');'."\n"; echo '//]]>'."\n"; echo ''."\n"; print_footer($course); } ?>