New user tabs from Shane and myself ... these bring together the
authormoodler <moodler>
Sun, 20 Mar 2005 12:02:14 +0000 (12:02 +0000)
committermoodler <moodler>
Sun, 20 Mar 2005 12:02:14 +0000 (12:02 +0000)
profile interface a little better.

There is also a new feature for showing all posts from a user, as well
as all discussions from a user.

course/user.php
lang/en/forum.php
lang/en/moodle.php
mod/forum/user.php [new file with mode: 0644]
theme/standard/styles_color.css
theme/standard/styles_layout.css
theme/standard/styles_moz.css
user/edit.php
user/tabs.php [new file with mode: 0644]
user/view.php

index dcc222b..f8f330e 100644 (file)
                  "<a href=\"../user/view.php?id=$user->id&amp;course=$course->id\">$fullname</a> -> 
                   $stractivityreport -> $strmode");
     }
-    print_heading($fullname);
-
-    echo "<table cellpadding=\"10\" align=\"center\"><tr>";
-    echo "<td>$stractivityreport: </td>";
-
-    foreach ($modes as $listmode) {
-        $strmode = get_string($listmode);
-        if ($mode == $listmode) {
-            echo "<td><u>$strmode</u></td>";
-        } else {
-            echo "<td><a href=\"user.php?id=$course->id&amp;user=$user->id&amp;mode=$listmode\">$strmode</a></td>";
-        }
-    }
-    echo "</tr></table>";
+
+
+/// Print tabs at top
+/// This same call is made in:
+///     /user/view.php
+///     /user/edit.php
+///     /course/user.php
+    $currenttab = $mode;
+    include($CFG->dirroot.'/user/tabs.php');
+
 
     get_all_mods($course->id, $mods, $modnames, $modnamesplural, $modnamesused);
 
     switch ($mode) {
         case "todaylogs" :
-            echo "<hr /><center>";
+            echo '<div class="graph">';
             print_log_graph($course, $user->id, "userday.png");
-            echo "</center>";
+            echo '</div>';
             print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, 
                       "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode");
             break;
 
         case "alllogs" :
-            echo "<hr /><center>";
+            echo '<div class="graph">';
             print_log_graph($course, $user->id, "usercourse.png");
-            echo "</center>";
+            echo '</div>';
             print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, 
                       "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode");
             break;
@@ -98,8 +94,8 @@
                     if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert!
 
                         if ($section->sequence) {
-                            echo "<hr />";
-                            echo "<h2>";
+                            echo '<div class="section">';
+                            echo '<h2>';
                             switch ($course->format) {
                                 case "weeks": print_string("week"); break;
                                 case "topics": print_string("topic"); break;
                             }
                             echo " $i</h2>";
     
-                            echo "<ul>";
+                            echo '<div class="content">';
 
                             if ($mode == "outline") {
                                 echo "<table cellpadding=\"4\" cellspacing=\"0\">";
                                 echo "</table>";
                                 print_simple_box_end();
                             }
-                            echo "</ul>";
+                            echo '</div>';  // content
+                            echo '</div>';  // section
                         }
                     }
                 }
index 4016433..4ba4f27 100644 (file)
@@ -55,6 +55,7 @@ $string['forcesubscribeq'] = 'Force everyone to be subscribed?';
 $string['forum'] = 'Forum';
 $string['forumintro'] = 'Forum introduction';
 $string['forumname'] = 'Forum name';
+$string['forumposts'] = 'Forum posts';
 $string['forums'] = 'Forums';
 $string['forumtype'] = 'Forum type';
 $string['generalforum'] = 'Standard forum for general use';
index dd69ed9..1d49229 100644 (file)
@@ -10,6 +10,7 @@ $string['activityclipboard'] = 'Moving this activity: <b>$a</b>';
 $string['activityiscurrentlyhidden'] = 'Sorry, this activity is currently hidden';
 $string['activitymodule'] = 'Activity module';
 $string['activityreport'] = 'Activity report';
+$string['activityreports'] = 'Activity reports';
 $string['activityselect'] = 'Select this activity to be moved elsewhere';
 $string['activitysince'] = 'Activity since $a';
 $string['add'] = 'Add';
@@ -174,6 +175,7 @@ $string['clicktochange'] = 'Click to change';
 $string['closewindow'] = 'Close this window';
 $string['comparelanguage'] = 'Compare and edit current language';
 $string['complete'] = 'Complete';
+$string['completereport'] = 'Complete report';
 $string['configuration'] = 'Configuration';
 $string['confirm'] = 'Confirm';
 $string['confirmed'] = 'Your registration has been confirmed';
@@ -808,6 +810,7 @@ $string['optional'] = 'optional';
 $string['order'] = 'Order';
 $string['other'] = 'Other';
 $string['outline'] = 'Outline';
+$string['outlinereport'] = 'Outline report';
 $string['page'] = 'Page';
 $string['pageheaderconfigablock'] = 'Configuring a block in %%fullname%%';
 $string['parentcoursenotfound'] = 'Parent course not found!';
@@ -847,6 +850,7 @@ $string['preferredtheme'] = 'Preferred theme';
 $string['preview'] = 'Preview';
 $string['previeworchoose'] = 'Preview or choose a theme';
 $string['previous'] = 'Previous';
+$string['profile'] = 'Profile';
 $string['publicdirectory'] = 'Public directory';
 $string['publicdirectory0'] = 'Please do not publish this site';
 $string['publicdirectory1'] = 'Publish the site name only';
diff --git a/mod/forum/user.php b/mod/forum/user.php
new file mode 100644 (file)
index 0000000..4c3f7a8
--- /dev/null
@@ -0,0 +1,107 @@
+<?php // $Id$
+
+// Display user activity reports for a course
+
+    require_once('../../config.php');
+    require_once('lib.php');
+
+    $id      = required_param('id');       // user id
+    $course    = required_param('course');     // course id
+    $mode    = optional_param('mode', 'posts');
+    $page    = optional_param('page', 0);
+    $perpage = optional_param('perpage', 5);
+
+    if (! $user = get_record("user", "id", $id)) {
+        error("User ID is incorrect");
+    }
+
+    if (! $course = get_record("course", "id", $course)) {
+        error("Course id is incorrect.");
+    }
+
+    require_course_login($course);
+
+
+    add_to_log($course->id, "forum", "user report", "user.php?id=$course->id&amp;user=$user->id&amp;mode=$mode", "$user->id"); 
+
+    $strforumposts   = get_string('forumposts', 'forum');
+    $strparticipants = get_string('participants');
+    $strmode         = get_string($mode, 'forum');
+    $fullname        = fullname($user, isteacher($course->id));
+
+    if ($course->category) {
+        print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
+                 "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> ->
+                  <a href=\"$CFG->wwwroot/user/index.php?id=$course->id\">$strparticipants</a> ->
+                  <a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">$fullname</a> -> 
+                  $strforumposts -> $strmode");
+    } else {
+        print_header("$course->shortname: $fullname: $strmode", "$course->fullname",
+                 "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=$course->id\">$fullname</a> -> 
+                  $strforumposts -> $strmode");
+    }
+
+    $currenttab = $mode;
+    include($CFG->dirroot.'/user/tabs.php');   /// Prints out tabs as part of user page
+
+    $isseparategroups = ($course->groupmode == SEPARATEGROUPS and
+                         $course->groupmodeforce and
+                         !isteacheredit($course->id));
+
+    $groupid = $isseparategroups ? get_current_group($course->id) : NULL;
+
+    switch ($mode) {
+        case 'posts' :
+            $searchterms = array('userid:'.$user->id);
+            $extrasql = '';
+            break;
+
+        default:
+            $searchterms = array('userid:'.$user->id);
+            $extrasql = 'AND p.parent = 0';
+            break;
+    }
+
+    if ($posts = forum_search_posts($searchterms, $course->id, $page*$perpage, $perpage, 
+                                    $totalcount, $groupid, $extrasql)) {
+        print_paging_bar($totalcount, $page, $perpage, 
+                         "user.php?id=$user->id&amp;course=$course->id&amp;mode=$mode&amp;perpage=$perpage&amp;");
+        foreach ($posts as $post) {
+    
+            if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
+                error('Discussion ID was incorrect');
+            }
+            if (! $forum = get_record('forum', 'id', "$discussion->forum")) {
+                error("Could not find forum $discussion->forum");
+            }
+    
+            $fullsubject = "<a href=\"view.php?f=$forum->id\">$forum->name</a>";
+            if ($forum->type != 'single') {
+                $fullsubject .= " -> <a href=\"discuss.php?d=$discussion->id\">$discussion->name</a>";
+                if ($post->parent != 0) {
+                    $fullsubject .= " -> <a href=\"discuss.php?d=$post->discussion&amp;parent=$post->id\">$post->subject</a>";
+                }
+            }
+    
+            $post->subject = $fullsubject;
+    
+            /// Add the forum id to the post object - used by read tracking.
+            $post->forum = $forum->id;
+    
+            $fulllink = "<a href=\"discuss.php?d=$post->discussion#$post->id\">".
+                         get_string("postincontext", "forum")."</a>";
+
+            forum_print_post($post, $course->id, false, false, false, false, $fulllink);
+    
+            echo "<br />";
+        }
+    
+        print_paging_bar($totalcount, $page, $perpage, 
+                         "user.php?id=$user->id&amp;course=$course->id&amp;mode=$mode&amp;perpage=$perpage&amp;");
+    } else {
+        print_heading(get_string('noposts', 'forum'));
+    }
+    print_footer($course);
+
+?>
+
index 2a9aa1e..fcc5f11 100644 (file)
@@ -163,12 +163,6 @@ td.header {
     border-color:#DDDDDD; /* borders */
 }
 
-/* summary of a user in a nice little box - weblib.php */
-.userinfobox {
-    border-color:#DDDDDD; /* borders */
-}
-
-
 /* weblib.php table */
 .tabledivider {
     border-color:#DDDDDD; /* borders */
index da31e82..1895916 100644 (file)
@@ -164,11 +164,6 @@ a img {
     border-style:solid;
 }
 
-.userinfoboxside,
-.userinfoboxsummary,
-.userinfoboxlinkcontent { }
-
-
 /* weblib.php table */
 .tabledivider {
     border-width:1px;
@@ -325,6 +320,10 @@ table.formtable tbody th
     vertical-align: bottom;
 }
 
+.userinfobox .list td {
+    padding: 3px;
+}
+
 .userinfobox .username {
     padding-bottom: 20px;
 }    
@@ -572,14 +571,21 @@ body#mod-forum-search .introcontent {
 }
 
 body#mod-quiz-report .tabs .side,
-body#message-index .tabs .side {
+body#message-index .tabs .side,
+body.course .tabs .side, 
+body.user .tabs .side,
+body#mod-forum-user .tabs .side {
     border-style: solid;
     border-width: 0px 0px 1px 0px;
     border-color: #AAAAAA;
     width: 50%;
 }
 
-body#mod-quiz-report .tabs {
+body#mod-quiz-report .tabs,
+body#message-index .tabs,
+body.course .tabs,
+body.user .tabs,
+body#mod-forum-user .tabs {
     margin-bottom: 15px;
 }
 
@@ -1119,3 +1125,24 @@ body#course-enrol .coursebox {
     text-align:right;
 }
 
+body#course-user .graph {
+    text-align: center;
+}
+
+body#course-user .section,
+body#course-user .content {
+    margin-left: 30px;
+    margin-right: 30px;
+}
+
+body#course-user .section {
+    border-width:1px;
+    border-style:solid;
+    padding:10px;
+    border-color:#AAAAAA;
+    margin-bottom: 20px;
+}
+
+body#course-user .section h2 {
+    margin-top: 0px;
+}
index 6c9267d..80d59cb 100644 (file)
@@ -57,8 +57,6 @@
     -moz-border-radius-bottomright:20px;
 }
 
-.userinfoboxsummary {
-}
 
 .generaltab, .generaltabinactive{
     -moz-border-radius-topleft:15px;
@@ -175,7 +173,7 @@ table.minicalendar td {
     -moz-border-radius:20px;
 }
 
-.userinfoboxlinkcontent, .forumpostmessage, .userinfoboxcontent {
+.forumpostmessage {
     -moz-border-radius-bottomright:20px;
 }
 
@@ -203,3 +201,7 @@ table.minicalendar td {
 .loginbox .content.right {
     -moz-border-radius-bottomright:20px;
 }
+
+body#course-user .section {
+    -moz-border-radius:20px;
+}
index 4f6a6ff..f895f1c 100644 (file)
                      "<a href=\"$CFG->wwwroot/$CFG->admin/users.php\">$strusers</a> -> $straddnewuser", "");
     }
 
+
+/// Print tabs at top
+/// This same call is made in:
+///     /user/view.php
+///     /user/edit.php
+///     /course/user.php
+    $currenttab = 'editprofile';
+    include('tabs.php');
+
+    
+
     $teacher = strtolower($course->teacher);
     if (!isadmin()) {
         $teacheronly = "(".get_string("teacheronly", "", $teacher).")";
         $teacheronly = "";
     }
 
-    print_heading( get_string("userprofilefor", "", "$userfullname") );
-
     if (isset($USER->newadminuser)) {
         print_simple_box(get_string("configintroadmin", 'admin'), "center", "50%");
         echo "<br />";
diff --git a/user/tabs.php b/user/tabs.php
new file mode 100644 (file)
index 0000000..8915099
--- /dev/null
@@ -0,0 +1,92 @@
+<?php  // $Id$
+/// This file to be included so we can assume config.php has already been included.
+/// We also assume that $user, $course, $currenttab have been set
+
+
+    if (empty($currenttab) or empty($user) or empty($course)) {
+        error('You cannot call this script in that way');
+    }
+
+    print_heading(fullname($user, isteacher($course)));
+
+//if (!empty($USER) and (isteacher($course->id) or (($USER->id == $user->id) and !isguest()))) { // tabs are shown
+
+    $inactive = NULL;
+    $toprow = array();
+
+    $toprow[] = new tabobject('profile', $CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id, 
+                get_string('profile'));
+
+
+
+/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
+
+    if (($mainadmin = get_admin()) === false) {
+        $mainadmin->id = 0; /// Weird - no primary admin!
+    }
+    if ((!empty($USER->id) and ($USER->id == $user->id) and !isguest()) or 
+        (isadmin() and ($user->id != $mainadmin->id)) ) {
+
+        if(empty($CFG->loginhttps)) {
+            $wwwroot = $CFG->wwwroot;
+        } else {
+            $wwwroot = str_replace('http','https',$CFG->wwwroot);
+        }
+        $toprow[] = new tabobject('editprofile', $wwwroot.'/user/edit.php?id='.$user->id.'&amp;course='.$course->id, 
+                    get_string('editmyprofile'));
+    }
+
+
+/// Everyone can see posts for this user
+
+    $toprow[] = new tabobject('forumposts', $CFG->wwwroot.'/mod/forum/user.php?id='.$user->id.'&amp;course='.$course->id, 
+                get_string('forumposts', 'forum'));
+
+    if (in_array($currenttab, array('posts', 'discussions'))) {
+        $inactive = array('forumposts');
+
+        $secondrow = array();
+        $secondrow[] = new tabobject('posts', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id.
+                                  '&amp;id='.$user->id.'&amp;mode=posts', get_string('posts', 'forum'));
+        $secondrow[] = new tabobject('discussions', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id.
+                                  '&amp;id='.$user->id.'&amp;mode=discussions', get_string('discussions', 'forum'));
+    }
+
+
+/// Current user must be teacher of the course or the course allows user to view their reports
+    if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
+
+        $toprow[] = new tabobject('reports', $CFG->wwwroot.'/course/user.php?id='.$course->id.
+                                  '&amp;user='.$user->id.'&amp;mode=outline', get_string('activityreports'));
+
+        if (in_array($currenttab, array('outline', 'complete', 'todaylogs', 'alllogs'))) {
+            $inactive = array('reports');
+
+            $secondrow = array();
+            $secondrow[] = new tabobject('outline', $CFG->wwwroot.'/course/user.php?id='.$course->id.
+                                      '&amp;user='.$user->id.'&amp;mode=outline', get_string('outlinereport'));
+            $secondrow[] = new tabobject('complete', $CFG->wwwroot.'/course/user.php?id='.$course->id.
+                                      '&amp;user='.$user->id.'&amp;mode=complete', get_string('completereport'));
+            $secondrow[] = new tabobject('todaylogs', $CFG->wwwroot.'/course/user.php?id='.$course->id.
+                                      '&amp;user='.$user->id.'&amp;mode=todaylogs', get_string('todaylogs'));
+            $secondrow[] = new tabobject('alllogs', $CFG->wwwroot.'/course/user.php?id='.$course->id.
+                                  '&amp;user='.$user->id.'&amp;mode=alllogs', get_string('alllogs'));
+        }
+
+    }
+
+
+/// Add second row to display if there is one
+
+    if (!empty($secondrow)) {
+        $tabs = array($toprow, $secondrow);
+    } else {
+        $tabs = array($toprow);
+    }
+
+
+/// Print out the tabs and continue!
+
+    print_tabs($tabs, $currenttab, $inactive);
+
+?>
index e46593b..b30f625 100644 (file)
         print_heading(get_string("userdeleted"));
     }
 
-    echo "<table width=\"80%\" align=\"center\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\" class=\"userinfobox\">";
-    echo "<tr>";
-    echo "<td width=\"100\" valign=\"top\" class=\"userinfoboxside\">";
-    print_user_picture($user->id, $course->id, $user->picture, true, false, false);
-    echo "</td><td width=\"100%\" class=\"userinfoboxcontent\">";
 
+/// Print tabs at top
+/// This same call is made in:
+///     /user/view.php
+///     /user/edit.php
+///     /course/user.php
+    $currenttab = 'profile';
+    include('tabs.php');
 
-    // Print name and edit button across top
 
-    echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td nowrap=\"nowrap\">";
-    echo "<h3>$fullname</h3>";
-    echo "</td><td align=\"right\">";
-    if (($currentuser and !isguest()) or isadmin()) {
-        if(empty($CFG->loginhttps)) {
-            $wwwroot = $CFG->wwwroot;
-        } else {
-            $wwwroot = str_replace('http','https',$CFG->wwwroot);
-        }
-        echo "<form action=\"$wwwroot/user/edit.php\" method=\"get\">";
-        echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />";
-        echo "<input type=\"hidden\" name=\"course\" value=\"$course->id\" />";
-        echo "<input type=\"submit\" value=\"".get_string("editmyprofile")."\" />";
-        echo "</form>";
-    }
-    echo "</td></tr></table>\n\n";
 
+    echo "<table width=\"80%\" align=\"center\" border=\"0\" cellspacing=\"0\" class=\"userinfobox\">";
+    echo "<tr>";
+    echo "<td width=\"100\" valign=\"top\" class=\"side\">";
+    print_user_picture($user->id, $course->id, $user->picture, true, false, false);
+    echo "</td><td width=\"100%\" class=\"content\">";
 
     // Print the description
 
 
     // Print all the little details in a list
 
-    echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\">";
+    echo '<table border="0" cellpadding="0" cellspacing="0" class="list">';
 
     if ($user->city or $user->country) {
         $countries = get_list_of_countries();
         echo "<input type=\"submit\" value=\"".get_string("unenrolme", "", $course->shortname)."\">";
         echo "</form></td>";
     }
-    if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
+/*    if (isteacher($course->id) or ($course->showreports and $USER->id == $user->id)) {
         echo "<td nowrap=\"nowrap\"><form action=\"../course/user.php\" method=\"get\">";
         echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
         echo "<input type=\"hidden\" name=\"user\" value=\"$user->id\" />";
         echo "<input type=\"submit\" value=\"".get_string("activityreport")."\" />";
         echo "</form></td>";
     }
+*/
     if ((isadmin() and !isadmin($user->id)) or (isteacher($course->id) and ($USER->id != $user->id) and !iscreator($user->id))) {
         echo "<td nowrap=\"nowrap\"><form action=\"../course/loginas.php\" method=\"get\">";
         echo "<input type=\"hidden\" name=\"id\" value=\"$course->id\" />";
         echo "</form></td>";
     }
     if (!empty($CFG->messaging) and !isguest()) {
-        if ($USER->id == $user->id) {
+        if (!empty($USER->id) and ($USER->id == $user->id)) {
             if ($countmessages = count_records('message', 'useridto', $user->id)) {
                 $messagebuttonname = get_string("messages", "message")."($countmessages)";
             } else {
     echo "<td></td>";
     echo "</tr></table></div>\n";
 
-    $isseparategroups = ($course->groupmode == SEPARATEGROUPS and
-                         $course->groupmodeforce and
-                         !isteacheredit($course->id));
-
-    $groupid = $isseparategroups ? get_current_group($course->id) : NULL;
-
-    forum_print_user_discussions($course->id, $user->id, $groupid);
 
     print_footer($course);
 
 /// Functions ///////
 
 function print_row($left, $right) {
-    echo "\n<tr><td nowrap=\"nowrap\" align=\"right\" valign=\"top\">$left</td><td align=\"left\" valign=\"top\">$right</td></tr>\n";
+    echo "\n<tr><td nowrap=\"nowrap\" align=\"right\" valign=\"top\" class=\"label c0\">$left</td><td align=\"left\" valign=\"top\" class=\"info c1\">$right</td></tr>\n";
 }
 
 ?>