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.'&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.'&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.'&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 | '&id='.$user->id.'&mode=posts', get_string('posts', 'forum')); |
53 | $secondrow[] = new tabobject('discussions', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id. |
54 | '&id='.$user->id.'&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 | '&user='.$user->id.'&mode=outline', get_string('activityreports')); |
63 | |
f3221af9 |
64 | if (in_array($currenttab, array('outline', 'complete', 'todaylogs', 'alllogs', 'stats'))) { |
f9a0ea69 |
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 | '&user='.$user->id.'&mode=outline', get_string('outlinereport')); |
71 | $secondrow[] = new tabobject('complete', $CFG->wwwroot.'/course/user.php?id='.$course->id. |
72 | '&user='.$user->id.'&mode=complete', get_string('completereport')); |
73 | $secondrow[] = new tabobject('todaylogs', $CFG->wwwroot.'/course/user.php?id='.$course->id. |
74 | '&user='.$user->id.'&mode=todaylogs', get_string('todaylogs')); |
75 | $secondrow[] = new tabobject('alllogs', $CFG->wwwroot.'/course/user.php?id='.$course->id. |
f3221af9 |
76 | '&user='.$user->id.'&mode=alllogs', get_string('alllogs')); |
77 | if (!empty($CFG->enablestats)) { |
78 | $secondrow[] = new tabobject('stats',$CFG->wwwroot.'/course/user.php?id='.$course->id. |
79 | '&user='.$user->id.'&mode=stats',get_string('stats')); |
80 | } |
f9a0ea69 |
81 | } |
82 | |
83 | } |
84 | |
85 | |
86 | /// Add second row to display if there is one |
87 | |
88 | if (!empty($secondrow)) { |
89 | $tabs = array($toprow, $secondrow); |
90 | } else { |
91 | $tabs = array($toprow); |
92 | } |
93 | |
94 | |
95 | /// Print out the tabs and continue! |
96 | |
e1ddfa6b |
97 | print_tabs($tabs, $currenttab, $inactive, $activetwo); |
f9a0ea69 |
98 | |
99 | ?> |