From f9a0ea699ca28bc0780a3e617afffbe704a55ce7 Mon Sep 17 00:00:00 2001 From: moodler Date: Sun, 20 Mar 2005 12:02:14 +0000 Subject: [PATCH] New user tabs from Shane and myself ... these bring together the 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 | 37 +++++------ lang/en/forum.php | 1 + lang/en/moodle.php | 4 ++ mod/forum/user.php | 107 +++++++++++++++++++++++++++++++ theme/standard/styles_color.css | 6 -- theme/standard/styles_layout.css | 41 ++++++++++-- theme/standard/styles_moz.css | 8 ++- user/edit.php | 13 +++- user/tabs.php | 92 ++++++++++++++++++++++++++ user/view.php | 54 ++++++---------- 10 files changed, 290 insertions(+), 73 deletions(-) create mode 100644 mod/forum/user.php create mode 100644 user/tabs.php diff --git a/course/user.php b/course/user.php index dcc222b230e..f8f330e113e 100644 --- a/course/user.php +++ b/course/user.php @@ -49,36 +49,32 @@ "id&course=$course->id\">$fullname -> $stractivityreport -> $strmode"); } - print_heading($fullname); - echo ""; - echo ""; - foreach ($modes as $listmode) { - $strmode = get_string($listmode); - if ($mode == $listmode) { - echo ""; - } else { - echo ""; - } - } - echo "
$stractivityreport: $strmodeid&user=$user->id&mode=$listmode\">$strmode
"; +/// 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 "
"; + echo '
'; print_log_graph($course, $user->id, "userday.png"); - echo "
"; + echo ''; print_log($course, $user->id, usergetmidnight(time()), "l.time DESC", $page, $perpage, "user.php?id=$course->id&user=$user->id&mode=$mode"); break; case "alllogs" : - echo "
"; + echo '
'; print_log_graph($course, $user->id, "usercourse.png"); - echo "
"; + echo ''; print_log($course, $user->id, 0, "l.time DESC", $page, $perpage, "user.php?id=$course->id&user=$user->id&mode=$mode"); break; @@ -98,8 +94,8 @@ if ($showsection) { // prevent hidden sections in user activity. Thanks to Geoff Wilbert! if ($section->sequence) { - echo "
"; - echo "

"; + echo '
'; + echo '

'; switch ($course->format) { case "weeks": print_string("week"); break; case "topics": print_string("topic"); break; @@ -107,7 +103,7 @@ } echo " $i

"; - echo "
    "; + echo '
    '; if ($mode == "outline") { echo ""; @@ -159,7 +155,8 @@ echo "
    "; print_simple_box_end(); } - echo "
"; + echo '
'; // content + echo ''; // section } } } diff --git a/lang/en/forum.php b/lang/en/forum.php index 4016433d7a7..4ba4f2740f5 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -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'; diff --git a/lang/en/moodle.php b/lang/en/moodle.php index dd69ed973dc..1d492293af1 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -10,6 +10,7 @@ $string['activityclipboard'] = 'Moving this activity: $a'; $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 index 00000000000..4c3f7a84b11 --- /dev/null +++ b/mod/forum/user.php @@ -0,0 +1,107 @@ +id, "forum", "user report", "user.php?id=$course->id&user=$user->id&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", + "wwwroot/course/view.php?id=$course->id\">$course->shortname -> + wwwroot/user/index.php?id=$course->id\">$strparticipants -> + wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname -> + $strforumposts -> $strmode"); + } else { + print_header("$course->shortname: $fullname: $strmode", "$course->fullname", + "wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname -> + $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&course=$course->id&mode=$mode&perpage=$perpage&"); + 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 = "id\">$forum->name"; + if ($forum->type != 'single') { + $fullsubject .= " -> id\">$discussion->name"; + if ($post->parent != 0) { + $fullsubject .= " -> discussion&parent=$post->id\">$post->subject"; + } + } + + $post->subject = $fullsubject; + + /// Add the forum id to the post object - used by read tracking. + $post->forum = $forum->id; + + $fulllink = "discussion#$post->id\">". + get_string("postincontext", "forum").""; + + forum_print_post($post, $course->id, false, false, false, false, $fulllink); + + echo "
"; + } + + print_paging_bar($totalcount, $page, $perpage, + "user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&"); + } else { + print_heading(get_string('noposts', 'forum')); + } + print_footer($course); + +?> + diff --git a/theme/standard/styles_color.css b/theme/standard/styles_color.css index 2a9aa1e34e6..fcc5f111baf 100644 --- a/theme/standard/styles_color.css +++ b/theme/standard/styles_color.css @@ -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 */ diff --git a/theme/standard/styles_layout.css b/theme/standard/styles_layout.css index da31e8221ce..1895916a4d1 100644 --- a/theme/standard/styles_layout.css +++ b/theme/standard/styles_layout.css @@ -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; +} diff --git a/theme/standard/styles_moz.css b/theme/standard/styles_moz.css index 6c9267d6382..80d59cb3f10 100644 --- a/theme/standard/styles_moz.css +++ b/theme/standard/styles_moz.css @@ -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; +} diff --git a/user/edit.php b/user/edit.php index 4f6a6fff6a7..f895f1cd484 100644 --- a/user/edit.php +++ b/user/edit.php @@ -249,6 +249,17 @@ "wwwroot/$CFG->admin/users.php\">$strusers -> $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).")"; @@ -256,8 +267,6 @@ $teacheronly = ""; } - print_heading( get_string("userprofilefor", "", "$userfullname") ); - if (isset($USER->newadminuser)) { print_simple_box(get_string("configintroadmin", 'admin'), "center", "50%"); echo "
"; diff --git a/user/tabs.php b/user/tabs.php new file mode 100644 index 00000000000..891509998cb --- /dev/null +++ b/user/tabs.php @@ -0,0 +1,92 @@ +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.'&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.'&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.'&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. + '&id='.$user->id.'&mode=posts', get_string('posts', 'forum')); + $secondrow[] = new tabobject('discussions', $CFG->wwwroot.'/mod/forum/user.php?course='.$course->id. + '&id='.$user->id.'&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. + '&user='.$user->id.'&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. + '&user='.$user->id.'&mode=outline', get_string('outlinereport')); + $secondrow[] = new tabobject('complete', $CFG->wwwroot.'/course/user.php?id='.$course->id. + '&user='.$user->id.'&mode=complete', get_string('completereport')); + $secondrow[] = new tabobject('todaylogs', $CFG->wwwroot.'/course/user.php?id='.$course->id. + '&user='.$user->id.'&mode=todaylogs', get_string('todaylogs')); + $secondrow[] = new tabobject('alllogs', $CFG->wwwroot.'/course/user.php?id='.$course->id. + '&user='.$user->id.'&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); + +?> diff --git a/user/view.php b/user/view.php index e46593bfbff..b30f625dba9 100644 --- a/user/view.php +++ b/user/view.php @@ -109,32 +109,22 @@ print_heading(get_string("userdeleted")); } - echo ""; + +/// Print tabs at top +/// This same call is made in: +/// /user/view.php +/// /user/edit.php +/// /course/user.php + $currenttab = 'profile'; + include('tabs.php'); + + + + echo "
"; echo ""; - echo "\n"; + echo "\n\n"; } ?>
"; + echo ""; print_user_picture($user->id, $course->id, $user->picture, true, false, false); - echo ""; - - - // Print name and edit button across top - - echo "
"; - echo "

$fullname

"; - echo "
"; - if (($currentuser and !isguest()) or isadmin()) { - if(empty($CFG->loginhttps)) { - $wwwroot = $CFG->wwwroot; - } else { - $wwwroot = str_replace('http','https',$CFG->wwwroot); - } - echo "
"; - echo ""; - echo "id\" />"; - echo ""; - echo "
"; - } - echo "
\n\n"; - + echo "
"; // Print the description @@ -144,7 +134,7 @@ // Print all the little details in a list - echo ""; + echo '
'; if ($user->city or $user->country) { $countries = get_list_of_countries(); @@ -287,13 +277,14 @@ echo "shortname)."\">"; echo ""; } - 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 ""; } +*/ if ((isadmin() and !isadmin($user->id)) or (isteacher($course->id) and ($USER->id != $user->id) and !iscreator($user->id))) { echo ""; } 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 { @@ -321,20 +312,13 @@ echo ""; echo "
"; echo "id\" />"; echo "id\" />"; echo ""; echo "
"; echo "id\" />"; @@ -302,7 +293,7 @@ echo "
\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
$left$right
$left$right