Merge branch 'MDL-35971-master' of git://github.com/junpataleta/moodle
[moodle.git] / mod / scorm / tabs.php
CommitLineData
411b8c23 1<?php
f7b5c6aa
DM
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
6f8dda46 17/**
b2614417
DM
18 * Sets up the tabs used by the scorm pages based on the users capabilities.
19 *
20 * @author Dan Marsden and others.
21 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
6da956e6 22 * @package mod_scorm
b2614417 23 */
6f8dda46
DM
24
25if (empty($scorm)) {
2149326b 26 print_error('cannotaccess', 'mod_scorm');
6f8dda46
DM
27}
28if (!isset($currenttab)) {
29 $currenttab = '';
30}
31if (!isset($cm)) {
32 $cm = get_coursemodule_from_instance('scorm', $scorm->id);
33}
34
a3fc4b3a 35$contextmodule = context_module::instance($cm->id);
6f8dda46
DM
36
37$tabs = array();
62b82cbc 38$row = array();
6f8dda46
DM
39$inactive = array();
40$activated = array();
41
42if (has_capability('mod/scorm:savetrack', $contextmodule)) {
f7b5c6aa 43 $row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
6f8dda46
DM
44}
45if (has_capability('mod/scorm:viewreport', $contextmodule)) {
62b82cbc 46 $row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('reports', 'scorm'));
6f8dda46
DM
47}
48
4cb25b36 49if (!($currenttab == 'info' && count($row) == 1)) {
6f8dda46
DM
50 $tabs[] = $row;
51}
52
b2614417
DM
53if ($currenttab == 'reports' && !empty($reportlist) && count($reportlist) > 1) {
54 $row2 = array();
55 foreach ($reportlist as $rep) {
4cb25b36 56 $row2[] = new tabobject('scorm_'.$rep, $CFG->wwwroot."/mod/scorm/report.php?id=$cm->id&mode=$rep",
57 get_string('pluginname', 'scormreport_'.$rep));
b2614417
DM
58 }
59 $tabs[] = $row2;
60}
61
6f8dda46 62print_tabs($tabs, $currenttab, $inactive, $activated);