Merge branch 'm20_MDL-26176_cleanup' of github.com:danmarsden/moodle
[moodle.git] / mod / scorm / tabs.php
CommitLineData
411b8c23 1<?php
6f8dda46 2/**
eab8ed9f 3 * Sets up the tabs used by the scorm pages based on the users capabilities.
6f8dda46
DM
4 *
5 * @author Dan Marsden and others.
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
7 * @package scorm
8 */
9
10if (empty($scorm)) {
11 error('You cannot call this script in that way');
12}
13if (!isset($currenttab)) {
14 $currenttab = '';
15}
16if (!isset($cm)) {
17 $cm = get_coursemodule_from_instance('scorm', $scorm->id);
18}
19
20
21$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
22
23$tabs = array();
24$row = array();
25$inactive = array();
26$activated = array();
27
28if (has_capability('mod/scorm:savetrack', $contextmodule)) {
29 $row[] = new tabobject('info', "$CFG->wwwroot/mod/scorm/view.php?id=$cm->id", get_string('info', 'scorm'));
30}
31if (has_capability('mod/scorm:viewreport', $contextmodule)) {
32 $row[] = new tabobject('reports', "$CFG->wwwroot/mod/scorm/report.php?id=$cm->id", get_string('results', 'scorm'));
33}
34
35if ($currenttab == 'info' && count($row) == 1) {
36 // Don't show only an info tab (e.g. to students).
37} else {
38 $tabs[] = $row;
39}
40
41print_tabs($tabs, $currenttab, $inactive, $activated);