MDL-19797 upgraded calls to print_table, print_single_button, print_user_picture...
[moodle.git] / group / groupings.php
CommitLineData
62d63838 1<?php // $Id$
2 // Allows a creator to edit groupings
3
4require_once '../config.php';
5require_once $CFG->dirroot.'/group/lib.php';
6
7$courseid = required_param('id', PARAM_INT);
8
dfdaabd6 9if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
62d63838 10 print_error('nocourseid');
11}
12
13require_login($course);
14$context = get_context_instance(CONTEXT_COURSE, $course->id);
15require_capability('moodle/course:managegroups', $context);
16
17$strgrouping = get_string('grouping', 'group');
18$strgroups = get_string('groups');
19$strname = get_string('name');
20$strdelete = get_string('delete');
21$stredit = get_string('edit');
22$srtnewgrouping = get_string('creategrouping', 'group');
23$strgroups = get_string('groups');
24$strgroupings = get_string('groupings', 'group');
25$struses = get_string('activities');
26$strparticipants = get_string('participants');
778918fd 27$strmanagegrping = get_String('showgroupsingrouping', 'group');
62d63838 28
29$navlinks = array(array('name'=>$strparticipants, 'link'=>$CFG->wwwroot.'/user/index.php?id='.$courseid, 'type'=>'misc'),
62d63838 30 array('name'=>$strgroupings, 'link'=>'', 'type'=>'misc'));
31$navigation = build_navigation($navlinks);
32
33/// Print header
34print_header_simple($strgroupings, ': '.$strgroupings, $navigation, '', '', true, '', navmenu($course));
35
778918fd 36// Add tabs
37$currenttab = 'groupings';
38require('tabs.php');
39
9cb990ec 40echo $OUTPUT->heading($strgroupings);
62d63838 41
42$data = array();
dfdaabd6 43if ($groupings = $DB->get_records('groupings', array('courseid'=>$course->id), 'name')) {
62d63838 44 foreach($groupings as $grouping) {
45 $line = array();
46 $line[0] = format_string($grouping->name);
47
48 if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) {
49 $groupnames = array();
50 foreach ($groups as $group) {
51 $groupnames[] = format_string($group->name);
52 }
53 $line[1] = implode(', ', $groupnames);
54 } else {
55 $line[1] = get_string('none');
56 }
dfdaabd6 57 $line[2] = $DB->count_records('course_modules', array('course'=>$course->id, 'groupingid'=>$grouping->id));
62d63838 58
59 $buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img".
4096752d 60 " src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
62d63838 61 $buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&amp;delete=1\"><img".
4096752d 62 " src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
62d63838 63 $buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img".
4096752d 64 " src=\"" . $OUTPUT->old_icon_url('i/group') . "\" class=\"icon\" alt=\"$strmanagegrping\" /></a> ";
62d63838 65
66 $line[3] = $buttons;
67 $data[] = $line;
68 }
69}
0b5a80a1 70$table = new object();
62d63838 71$table->head = array($strgrouping, $strgroups, $struses, $stredit);
72$table->size = array('30%', '50%', '10%', '10%');
73$table->align = array('left', 'left', 'center', 'center');
74$table->width = '90%';
75$table->data = $data;
76print_table($table);
77
78echo '<div class="buttons">';
79print_single_button('grouping.php', array('courseid'=>$courseid), $srtnewgrouping);
80echo '</div>';
81
653468d4 82echo $OUTPUT->footer();
62d63838 83
84?>