MDL-31006 revert partially @ get_config()
[moodle.git] / group / groupings.php
blob80ad8bd340958cc36201c25c45007e26a56830fe
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * Allows a creator to edit groupings
21 * @copyright 1999 Martin Dougiamas http://dougiamas.com
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 * @package groups
26 require_once '../config.php';
27 require_once $CFG->dirroot.'/group/lib.php';
29 $courseid = required_param('id', PARAM_INT);
31 $PAGE->set_url('/group/groupings.php', array('id'=>$courseid));
33 if (!$course = $DB->get_record('course', array('id'=>$courseid))) {
34 print_error('nocourseid');
37 require_login($course);
38 $context = get_context_instance(CONTEXT_COURSE, $course->id);
39 require_capability('moodle/course:managegroups', $context);
41 $strgrouping = get_string('grouping', 'group');
42 $strgroups = get_string('groups');
43 $strname = get_string('name');
44 $strdelete = get_string('delete');
45 $stredit = get_string('edit');
46 $srtnewgrouping = get_string('creategrouping', 'group');
47 $strgroups = get_string('groups');
48 $strgroupings = get_string('groupings', 'group');
49 $struses = get_string('activities');
50 $strparticipants = get_string('participants');
51 $strmanagegrping = get_string('showgroupsingrouping', 'group');
53 navigation_node::override_active_url(new moodle_url('/group/index.php', array('id'=>$courseid)));
54 $PAGE->navbar->add($strgroupings);
56 /// Print header
57 $PAGE->set_title($strgroupings);
58 $PAGE->set_heading($course->fullname);
59 $PAGE->set_pagelayout('standard');
60 echo $OUTPUT->header();
62 // Add tabs
63 $currenttab = 'groupings';
64 require('tabs.php');
66 echo $OUTPUT->heading($strgroupings);
68 $data = array();
69 if ($groupings = $DB->get_records('groupings', array('courseid'=>$course->id), 'name')) {
70 foreach($groupings as $grouping) {
71 $line = array();
72 $line[0] = format_string($grouping->name);
74 if ($groups = groups_get_all_groups($courseid, 0, $grouping->id)) {
75 $groupnames = array();
76 foreach ($groups as $group) {
77 $groupnames[] = format_string($group->name);
79 $line[1] = implode(', ', $groupnames);
80 } else {
81 $line[1] = get_string('none');
83 $line[2] = $DB->count_records('course_modules', array('course'=>$course->id, 'groupingid'=>$grouping->id));
85 $buttons = "<a title=\"$stredit\" href=\"grouping.php?id=$grouping->id\"><img".
86 " src=\"" . $OUTPUT->pix_url('t/edit') . "\" class=\"iconsmall\" alt=\"$stredit\" /></a> ";
87 $buttons .= "<a title=\"$strdelete\" href=\"grouping.php?id=$grouping->id&amp;delete=1\"><img".
88 " src=\"" . $OUTPUT->pix_url('t/delete') . "\" class=\"iconsmall\" alt=\"$strdelete\" /></a> ";
89 $buttons .= "<a title=\"$strmanagegrping\" href=\"assign.php?id=$grouping->id\"><img".
90 " src=\"" . $OUTPUT->pix_url('i/group') . "\" class=\"icon\" alt=\"$strmanagegrping\" /></a> ";
92 $line[3] = $buttons;
93 $data[] = $line;
96 $table = new html_table();
97 $table->head = array($strgrouping, $strgroups, $struses, $stredit);
98 $table->size = array('30%', '50%', '10%', '10%');
99 $table->align = array('left', 'left', 'center', 'center');
100 $table->width = '90%';
101 $table->data = $data;
102 echo html_writer::table($table);
104 echo $OUTPUT->container_start('buttons');
105 echo $OUTPUT->single_button(new moodle_url('grouping.php', array('courseid'=>$courseid)), $srtnewgrouping);
106 echo $OUTPUT->container_end();
108 echo $OUTPUT->footer();