MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / data / tabs.php
blob6164f9bcd6d8bf5bf23766cf1df08800777ca215
1 <?php // $Id$
2 ///////////////////////////////////////////////////////////////////////////
3 // //
4 // NOTICE OF COPYRIGHT //
5 // //
6 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
7 // http://moodle.org //
8 // //
9 // Copyright (C) 2005 Martin Dougiamas http://dougiamas.com //
10 // //
11 // This program is free software; you can redistribute it and/or modify //
12 // it under the terms of the GNU General Public License as published by //
13 // the Free Software Foundation; either version 2 of the License, or //
14 // (at your option) any later version. //
15 // //
16 // This program is distributed in the hope that it will be useful, //
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
19 // GNU General Public License for more details: //
20 // //
21 // http://www.gnu.org/copyleft/gpl.html //
22 // //
23 ///////////////////////////////////////////////////////////////////////////
24 /// This file to be included so we can assume config.php has already been included.
25 /// We also assume that $user, $course, $currenttab have been set
28 if (empty($currenttab) or empty($data) or empty($course)) {
29 error('You cannot call this script in that way');
32 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
34 $inactive = NULL;
35 $row = array();
37 $row[] = new tabobject('list', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id, get_string('list','data'), '', true);
39 //Add an advanced search tab.
40 $row[] = new tabobject('asearch', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=asearch', get_string('advancedsearch', 'data'), '', true);
42 if (isset($record)) {
43 $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;rid='.$record->id, get_string('single','data'), '', true);
44 } else {
45 $row[] = new tabobject('single', $CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&amp;mode=single', get_string('single','data'), '', true);
48 if (isloggedin()) {
49 if (data_user_can_add_entry($data, $currentgroup, $groupmode)) { // took out participation list here!
50 $addstring = empty($editentry) ? get_string('add', 'data') : get_string('editentry', 'data');
51 $row[] = new tabobject('add', $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id, $addstring, '', true);
53 if (has_capability('mod/data:managetemplates', $context)) {
54 if ($currenttab == 'list') {
55 $defaultemplate = 'listtemplate';
56 } else if ($currenttab == 'add') {
57 $defaultemplate = 'addtemplate';
58 } else if ($currenttab == 'asearch') {
59 $defaultemplate = 'asearchtemplate';
60 } else {
61 $defaultemplate = 'singletemplate';
64 $row[] = new tabobject('templates', $CFG->wwwroot.'/mod/data/templates.php?d='.$data->id.'&amp;mode='.$defaultemplate,
65 get_string('templates','data'));
66 $row[] = new tabobject('fields', $CFG->wwwroot.'/mod/data/field.php?d='.$data->id,
67 get_string('fields','data'), '', true);
68 $row[] = new tabobject('presets', $CFG->wwwroot.'/mod/data/preset.php?d='.$data->id,
69 get_string('presets', 'data'), '', true);
73 $tabs[] = $row;
75 if ($currenttab == 'templates' and isset($mode)) {
77 $inactive[] = 'templates';
78 $templatelist = array ('listtemplate', 'asearchtemplate' , 'singletemplate', 'addtemplate', 'rsstemplate', 'csstemplate', 'jstemplate');
80 $row = array();
81 $currenttab ='';
82 foreach ($templatelist as $template) {
83 $row[] = new tabobject($template, "templates.php?d=$data->id&amp;mode=$template", get_string($template, 'data'));
84 if ($template == $mode) {
85 $currenttab = $template;
88 if ($currenttab == '') {
89 $currenttab = $mode = 'singletemplate';
91 $tabs[] = $row;
92 $activetwo = array('templates');
93 } else {
94 $activetwo = array();
97 /// Print out the tabs and continue!
99 print_tabs($tabs, $currenttab, $inactive, $activetwo);