workshop: removing "Login as random participant" which was used during development
[moodle.git] / mod / workshop / tabs.php
CommitLineData
b761e6d9
DM
1<?php
2
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.
14//
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/>.
17
18/**
19 * Defines and prints the workshop navigation tabs
20 *
21 * Can be included from within a workshop script only
22 *
23 * @package mod-workshop
24 * @copyright 2009 David Mudrak <david.mudrak@gmail.com>
25 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 */
27
28defined('MOODLE_INTERNAL') || die();
29
30if (empty($workshop) or !is_a($workshop, 'workshop')) {
31 print_error('cannotcallscript');
32}
33if (!isset($currenttab)) {
34 $currenttab = 'info';
35}
36
37$tabs = array();
38$row = array();
39$inactive = array();
40$activated = array();
41
42// top level tabs
f05c168d 43if (has_capability('mod/workshop:view', $PAGE->context)) {
b761e6d9
DM
44 $row[] = new tabobject('info', $workshop->view_url()->out(), get_string('info', 'workshop'));
45}
f05c168d 46if (has_capability('mod/workshop:editdimensions', $PAGE->context)) {
b761e6d9
DM
47 $row[] = new tabobject('editform', $workshop->editform_url()->out(), get_string('editassessmentform', 'workshop'));
48}
becec954
DM
49if ($currenttab == 'example' and has_any_capability(array('mod/workshop:submit', 'mod/workshop:manageexamples'), $PAGE->context)) {
50 $row[] = new tabobject('example', '', get_string('example', 'workshop'));
51}
f05c168d 52if (has_capability('mod/workshop:submit', $PAGE->context)) {
51508f25 53 $row[] = new tabobject('submission', $workshop->submission_url()->out(), get_string('submission', 'workshop'));
da0b1f70 54}
f05c168d 55if (has_capability('mod/workshop:allocate', $PAGE->context)) {
3189fb2d
DM
56 $row[] = new tabobject('allocation', $workshop->allocation_url()->out(), get_string('allocate', 'workshop'));
57}
b761e6d9
DM
58$tabs[] = $row;
59
3189fb2d
DM
60if ($currenttab == 'allocation' and !empty($allocators)) {
61 // this is included from allocation.php so we rely of some variables defined there
62 $activated[] = 'allocation';
63 $row = array();
64 foreach ($allocators as $methodid => $methodname) {
65 $row[] = new tabobject($methodid, "allocation.php?cmid={$cmid}&amp;method={$methodid}", $methodname);
66 if ($methodid == $method) {
67 $currenttab = $methodid;
68 }
69 }
70 $tabs[] = $row;
71}
72
73
b761e6d9 74print_tabs($tabs, $currenttab, $inactive, $activated);