Merged from MOODLE_15_STABLE: merging check_db_compat function for backwards compatab...
[moodle.git] / user / tabs.php
CommitLineData
f9a0ea69 1<?php // $Id$
2/// This file to be included so we can assume config.php has already been included.
3/// We also assume that $user, $course, $currenttab have been set
4
5
6 if (empty($currenttab) or empty($user) or empty($course)) {
7 error('You cannot call this script in that way');
8 }
9
5bae88b6 10 print_heading(fullname($user, isteacher($course->id)));
f9a0ea69 11
12//if (!empty($USER) and (isteacher($course->id) or (($USER->id == $user->id) and !isguest()))) { // tabs are shown
13
14 $inactive = NULL;
e1ddfa6b 15 $activetwo = NULL;
f9a0ea69 16 $toprow = array();
17
18 $toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id,
19 get_string('profile'));
20
21
22
23/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
24
25 if (($mainadmin = get_admin()) === false) {
26 $mainadmin->id = 0; /// Weird - no primary admin!
27 }
28 if ((!empty($USER->id) and ($USER->id == $user->id) and !isguest()) or
29 (isadmin() and ($user->id != $mainadmin->id)) ) {
30
31 if(empty($CFG->loginhttps)) {
32 $wwwroot = $CFG->wwwroot;
33 } else {
34 $wwwroot = str_replace('http','https',$CFG->wwwroot);
35 }
36 $toprow[] = new tabobject('editprofile', $wwwroot.'/user/edit.php?id='.$user->id.'&amp;course='.$course->id,
37 get_string('editmyprofile'));
38 }
39
40
41/// Everyone can see posts for this user
42
43 $toprow[] = new tabobject('forumposts', $CFG->wwwroot.'/mod/forum/user.php?id='.$user->id.'&amp;course='.$course->id,
44 get_string('forumposts', 'forum'));
45
46 if (in_array($currenttab, array('posts', 'discussions'))) {
47 $inactive = array('forumposts');
e1ddfa6b 48 $activetwo = array('forumposts');
f9a0ea69 49
50 $secondrow = array();
51 $secondrow[] = new tabobject('posts', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id.
52 '&amp;id='.$user->id.'&amp;mode=posts', get_string('posts', 'forum'));
53 $secondrow[] = new tabobject('discussions', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id.
54 '&amp;id='.$user->id.'&amp;mode=discussions', get_string('discussions', 'forum'));
55 }
56
57
58/// Current user must be teacher of the course or the course allows user to view their reports
59 if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
60
61 $toprow[] = new tabobject('reports', $CFG->wwwroot.'/course/user.php?id='.$course->id.
62 '&amp;user='.$user->id.'&amp;mode=outline', get_string('activityreports'));
63
64 if (in_array($currenttab, array('outline', 'complete', 'todaylogs', 'alllogs'))) {
65 $inactive = array('reports');
e1ddfa6b 66 $activetwo = array('reports');
f9a0ea69 67
68 $secondrow = array();
69 $secondrow[] = new tabobject('outline', $CFG->wwwroot.'/course/user.php?id='.$course->id.
70 '&amp;user='.$user->id.'&amp;mode=outline', get_string('outlinereport'));
71 $secondrow[] = new tabobject('complete', $CFG->wwwroot.'/course/user.php?id='.$course->id.
72 '&amp;user='.$user->id.'&amp;mode=complete', get_string('completereport'));
73 $secondrow[] = new tabobject('todaylogs', $CFG->wwwroot.'/course/user.php?id='.$course->id.
74 '&amp;user='.$user->id.'&amp;mode=todaylogs', get_string('todaylogs'));
75 $secondrow[] = new tabobject('alllogs', $CFG->wwwroot.'/course/user.php?id='.$course->id.
76 '&amp;user='.$user->id.'&amp;mode=alllogs', get_string('alllogs'));
77 }
78
79 }
80
81
82/// Add second row to display if there is one
83
84 if (!empty($secondrow)) {
85 $tabs = array($toprow, $secondrow);
86 } else {
87 $tabs = array($toprow);
88 }
89
90
91/// Print out the tabs and continue!
92
e1ddfa6b 93 print_tabs($tabs, $currenttab, $inactive, $activetwo);
f9a0ea69 94
95?>