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
5 if (!isset($filtertype)) {
8 if (!isset($filterselect)) {
12 //make sure everything is cleaned properly
13 $filtertype = clean_param($filtertype, PARAM_ALPHA
);
14 $filterselect = clean_param($filterselect, PARAM_INT
);
16 if (empty($currenttab) or empty($user) or empty($course)) {
17 //error('You cannot call this script in that way');
20 if (($filtertype == 'site' && $filterselect) ||
($filtertype=='user' && $filterselect)) {
21 $user = get_record('user','id',$filterselect);
28 /**************************************
29 * Site Level participation or Blogs *
30 **************************************/
31 if ($filtertype == 'site') {
34 print_heading($site->fullname
);
36 if ($CFG->bloglevel
>= 4) {
37 if (isteacher(SITEID
) ||
38 ($CFG->showsiteparticipants
== 1 && isteacherinanycourse()) ||
39 ($CFG->showsiteparticipantslist
== 2)) {
40 $toprow[] = new tabobject('participants', $CFG->wwwroot
.'/user/index.php?id='.SITEID
,
41 get_string('participants'));
44 $toprow[] = new tabobject('blogs', $CFG->wwwroot
.'/blog/index.php?filtertype=site&',
45 get_string('blogs','blog'));
48 /**************************************
49 * Course Level participation or Blogs *
50 **************************************/
51 } else if ($filtertype == 'course' && $filterselect) {
53 $course = get_record('course','id',$filterselect);
54 print_heading($course->fullname
);
56 if ($CFG->bloglevel
>= 3) {
58 $toprow[] = new tabobject('participants', $CFG->wwwroot
.'/user/index.php?id='.$filterselect.'&group=0',
59 get_string('participants')); //the groupid hack is necessary, otherwise the group in the session willbe used
61 $toprow[] = new tabobject('blogs', $CFG->wwwroot
.'/blog/index.php?filtertype=course&filterselect='.$filterselect, get_string('blogs','blog'));
64 /**************************************
65 * Group Level participation or Blogs *
66 **************************************/
67 } else if ($filtertype == 'group' && $filterselect) {
69 $group = get_record('groups','id',$filterselect);
70 print_heading($group->name
);
72 if ($CFG->bloglevel
>= 2) {
74 $toprow[] = new tabobject('participants', $CFG->wwwroot
.'/user/index.php?id='.$course->id
.'&group='.$filterselect,
75 get_string('participants'));
78 $toprow[] = new tabobject('blogs', $CFG->wwwroot
.'/blog/index.php?filtertype=group&filterselect='.$filterselect, get_string('blogs','blog'));
81 /**************************************
82 * User Level participation or Blogs *
83 **************************************/
86 $user = get_record('user','id', $userid);
88 print_heading(fullname($user, isteacher($course->id
)));
90 $toprow[] = new tabobject('profile', $CFG->wwwroot
.'/user/view.php?id='.$user->id
.'&course='.$course->id
, get_string('profile'));
93 /// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
95 if (($mainadmin = get_admin()) === false) {
96 $mainadmin->id
= 0; /// Weird - no primary admin!
98 if ((!empty($USER->id
) and ($USER->id
== $user->id
) and !isguest()) or
99 (isadmin() and ($user->id
!= $mainadmin->id
)) ) {
101 if(empty($CFG->loginhttps
)) {
102 $wwwroot = $CFG->wwwroot
;
104 $wwwroot = str_replace('http:','https:',$CFG->wwwroot
);
107 $toprow[] = new tabobject('editprofile', $wwwroot.'/user/edit.php?id='.$user->id
.'&course='.$course->id
, get_string('editmyprofile'));
111 /// Everyone can see posts for this user
113 $toprow[] = new tabobject('forumposts', $CFG->wwwroot
.'/mod/forum/user.php?id='.$user->id
.'&course='.$course->id
,
114 get_string('forumposts', 'forum'));
116 if (in_array($currenttab, array('posts', 'discussions'))) {
117 $inactive = array('forumposts');
118 $activetwo = array('forumposts');
120 $secondrow = array();
121 $secondrow[] = new tabobject('posts', $CFG->wwwroot
.'/mod/forum/user.php?course='.$course->id
.
122 '&id='.$user->id
.'&mode=posts', get_string('posts', 'forum'));
123 $secondrow[] = new tabobject('discussions', $CFG->wwwroot
.'/mod/forum/user.php?course='.$course->id
.
124 '&id='.$user->id
.'&mode=discussions', get_string('discussions', 'forum'));
128 /// Blog entry, everyone can view
129 if ($CFG->bloglevel
> 0) { // only if blog is enabled. Permission check kicks in when display list
130 $toprow[] = new tabobject('blogs', $CFG->wwwroot
.'/blog/index.php?userid='.$user->id
.'&courseid='.$course->id
, get_string('blogs', 'blog'));
134 /// Current user must be teacher of the course or the course allows user to view their reports
135 if (isteacher($course->id
) or ($course->showreports
and $USER->id
== $user->id
)) {
137 $toprow[] = new tabobject('reports', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
138 '&user='.$user->id
.'&mode=outline', get_string('activityreports'));
140 if (in_array($currenttab, array('outline', 'complete', 'todaylogs', 'alllogs', 'stats'))) {
141 $inactive = array('reports');
142 $activetwo = array('reports');
144 $secondrow = array();
145 $secondrow[] = new tabobject('outline', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
146 '&user='.$user->id
.'&mode=outline', get_string('outlinereport'));
147 $secondrow[] = new tabobject('complete', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
148 '&user='.$user->id
.'&mode=complete', get_string('completereport'));
149 $secondrow[] = new tabobject('todaylogs', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
150 '&user='.$user->id
.'&mode=todaylogs', get_string('todaylogs'));
151 $secondrow[] = new tabobject('alllogs', $CFG->wwwroot
.'/course/user.php?id='.$course->id
.
152 '&user='.$user->id
.'&mode=alllogs', get_string('alllogs'));
153 if (!empty($CFG->enablestats
)) {
154 $secondrow[] = new tabobject('stats',$CFG->wwwroot
.'/course/user.php?id='.$course->id
.
155 '&user='.$user->id
.'&mode=stats',get_string('stats'));
161 } //close last bracket (individual tags)
163 /// Add second row to display if there is one
165 if (!empty($secondrow)) {
166 $tabs = array($toprow, $secondrow);
168 $tabs = array($toprow);
171 /// Print out the tabs and continue!
173 print_tabs($tabs, $currenttab, $inactive, $activetwo);