group MDL-19798 Updated print_header and build_navigation to OUTPUT and PAGE equivalents
[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
b87573d7 29$PAGE->navbar->add($strparticipants, new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid)));
30$PAGE->navbar->add($strgroupings);
62d63838 31
32/// Print header
b87573d7 33$PAGE->set_title($strgroupings);
34$PAGE->set_heading(': '.$strgroupings);
35echo $OUTPUT->header();
62d63838 36
778918fd 37// Add tabs
38$currenttab = 'groupings';
39require('tabs.php');
40
9cb990ec 41echo $OUTPUT->heading($strgroupings);
62d63838 42
43$data = array();
dfdaabd6 44if ($groupings = $DB->get_records('groupings', array('courseid'=>$course->id), 'name')) {
62d63838 45 foreach($groupings as $grouping) {
46 $line = array();
47 $line[0] = format_string($grouping->name);
48
49 if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) {
50 $groupnames = array();
51 foreach ($groups as $group) {
52 $groupnames[] = format_string($group->name);
53 }
54 $line[1] = implode(', ', $groupnames);
55 } else {
56 $line[1] = get_string('none');
57 }
dfdaabd6 58 $line[2] = $DB->count_records('course_modules', array('course'=>$course->id, 'groupingid'=>$grouping->id));
62d63838 59
60 $buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img".
4096752d 61 " src=\"" . $OUTPUT->old_icon_url('t/edit') . "\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
62d63838 62 $buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&amp;delete=1\"><img".
4096752d 63 " src=\"" . $OUTPUT->old_icon_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
62d63838 64 $buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img".
4096752d 65 " src=\"" . $OUTPUT->old_icon_url('i/group') . "\" class=\"icon\" alt=\"$strmanagegrping\" /></a> ";
62d63838 66
67 $line[3] = $buttons;
68 $data[] = $line;
69 }
70}
768cefa0 71$table = new html_table();
62d63838 72$table->head = array($strgrouping, $strgroups, $struses, $stredit);
73$table->size = array('30%', '50%', '10%', '10%');
74$table->align = array('left', 'left', 'center', 'center');
75$table->width = '90%';
76$table->data = $data;
768cefa0 77echo $OUTPUT->table($table);
62d63838 78
768cefa0 79echo $OUTPUT->container_start('buttons');
80echo $OUTPUT->button(html_form::make_button('grouping.php', array('courseid'=>$courseid), $srtnewgrouping));
81echo $OUTPUT->container_end();
62d63838 82
653468d4 83echo $OUTPUT->footer();
62d63838 84
85?>