The very last save button is tabindexed, too. Forgot to include it in the last commit...
[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
9if (!$course = get_record('course', 'id', $courseid)) {
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
62d63838 40print_heading($strgroupings);
41
42$data = array();
325c194a 43if ($groupings = get_records('groupings', '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 }
57 $line[2] = (int)count_records('course_modules', 'course', $course->id, 'groupingid', $grouping->id);
58
59 $buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img".
60 " src=\"$CFG->pixpath/t/edit.gif\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
61 $buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&amp;delete=1\"><img".
62 " src=\"$CFG->pixpath/t/delete.gif\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
63 $buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img".
778918fd 64 " src=\"$CFG->pixpath/i/group.gif\" 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
82print_footer($course);
83
84?>