Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / group / printgrouping.php
blob7a42b042fb84818a5a2d1909435f6de16e877055
1 <?php
2 /**
3 * Print groups in groupings, and members of groups.
5 * @copyright &copy; 2006 The Open University
6 * @author J.White AT open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
8 * @package groups
9 */
10 require_once('../config.php');
11 require_once('lib.php');
13 $success = true;
15 $courseid = required_param('courseid', PARAM_INT);
16 $groupingid = required_param('groupingid', PARAM_INT);
18 // Get the course information so we can print the header and
19 // check the course id is valid
20 $course = groups_get_course_info($courseid);
21 if (! $course) {
22 $success = false;
23 print_error('invalidcourse');
27 if ($success) {
28 // Make sure that the user has permissions to manage groups.
29 require_login($courseid);
31 $context = get_context_instance(CONTEXT_COURSE, $courseid);
32 if (! has_capability('moodle/course:managegroups', $context)) {
33 redirect();
36 //( confirm_sesskey checks that this is a POST request.)
38 // Print the page and form
39 $strgroups = get_string('groups');
40 $strparticipants = get_string('participants');
41 print_header("$course->shortname: $strgroups", $course->fullname,
42 "<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
43 "-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
44 "-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
45 "-> ".get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER));
47 $groupingname = groups_get_grouping_name($groupingid);
48 if (! $groupingname) {
49 print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
50 } else {
51 // Print the name of the grouping
52 if (!empty($CFG->enablegroupings)) {
53 // NO GROUPINGS YET!
54 echo "<h1>$groupingname</h1>\n";
58 // Get the groups and group members for the grouping.
59 if (GROUP_NOT_IN_GROUPING == $groupingid) {
60 $groupids = groups_get_groups_not_in_any_grouping($courseid);
61 } else {
62 $groupids = groups_get_groups_in_grouping($groupingid);
65 if ($groupids) {
66 // Make sure the groups are in the right order
67 $group_names = groups_groupids_to_group_names($groupids);
69 // Go through each group in turn and print the group name and then the members
70 foreach ($group_names as $group) {
72 echo "<h2>{$group->name}</h2>\n";
73 $userids = groups_get_members($group->id);
74 if ($userids != false) {
75 // Make sure the users are in the right order
76 $user_names = groups_userids_to_user_names($userids, $courseid);
78 echo "<ol>\n";
79 foreach ($user_names as $user) {
81 echo "<li>{$user->name}</li>\n";
83 echo "</ol>\n";
88 print_footer($course);