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
6 if (empty($currenttab) or empty($user) or empty($course)) {
7 error('You cannot call this script in that way');
10 print_heading(fullname($user, isteacher($course->id
)));
12 //if (!empty($USER) and (isteacher($course->id) or (($USER->id == $user->id) and !isguest()))) { // tabs are shown
18 $toprow[] = new tabobject('profile', $CFG->wwwroot
.'/user/view.php?id='.$user->id
.'&course='.$course->id
,
19 get_string('profile'));
23 /// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
25 if (($mainadmin = get_admin()) === false) {
26 $mainadmin->id
= 0; /// Weird - no primary admin!
28 if ((!empty($USER->id
) and ($USER->id
== $user->id
) and !isguest()) or
29 (isadmin() and ($user->id
!= $mainadmin->id
)) ) {
31 if(empty($CFG->loginhttps
)) {
32 $wwwroot = $CFG->wwwroot
;
34 $wwwroot = str_replace('http','https',$CFG->wwwroot
);
36 $toprow[] = new tabobject('editprofile', $wwwroot.'/user/edit.php?id='.$user->id
.'&course='.$course->id
,
37 get_string('editmyprofile'));
41 /// Everyone can see posts for this user
43 $toprow[] = new tabobject('forumposts', $CFG->wwwroot
.'/mod/forum/user.php?id='.$user->id
.'&course='.$course->id
,
44 get_string('forumposts', 'forum'));
46 if (in_array($currenttab, array('posts', 'discussions'))) {
47 $inactive = array('forumposts');
48 $activetwo = array('forumposts');
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'));
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
)) {
61 $toprow[] = new tabobject('reports', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
62 '&user='.$user->id
.'&mode=outline', get_string('activityreports'));
64 if (in_array($currenttab, array('outline', 'complete', 'todaylogs', 'alllogs'))) {
65 $inactive = array('reports');
66 $activetwo = array('reports');
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
.
76 '&user='.$user->id
.'&mode=alllogs', get_string('alllogs'));
82 /// Add second row to display if there is one
84 if (!empty($secondrow)) {
85 $tabs = array($toprow, $secondrow);
87 $tabs = array($toprow);
91 /// Print out the tabs and continue!
93 print_tabs($tabs, $currenttab, $inactive, $activetwo);