From 29507631a9d29b3d09953fb6d6e887c84973aed6 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 18 Apr 2003 03:58:12 +0000 Subject: [PATCH] First pass at a cleaner display for discussion listings --- lang/en/forum.php | 3 + mod/forum/lib.php | 100 +++++++++++++++++++-------------- theme/standard/styles.php | 25 +++++++-- theme/standardblue/styles.php | 25 +++++++-- theme/standardgreen/styles.php | 25 +++++++-- theme/standardlogo/styles.php | 25 +++++++-- theme/standardred/styles.php | 25 +++++++-- theme/standardwhite/styles.php | 25 +++++++-- 8 files changed, 176 insertions(+), 77 deletions(-) diff --git a/lang/en/forum.php b/lang/en/forum.php index 9109b6bd9e..5d2b0a7ad8 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -45,6 +45,7 @@ $string['inforum'] = "in \$a"; $string['intronews'] = "General news and announcements"; $string['introsocial'] = "An open forum for chatting about anything you want to"; $string['introteacher'] = "A forum for teacher-only notes and discussion"; +$string['lastpost'] = "Last post"; $string['learningforums'] = "Learning forums"; $string['maxtimehaspassed'] = "Sorry, but the maximum time for editing this post (\$a) has passed!"; $string['message'] = "Message"; @@ -84,6 +85,7 @@ $string['ratings'] = "Ratings"; $string['ratingssaved'] = "Ratings saved"; $string['readtherest'] = "Read the rest of this topic"; $string['re'] = "Re:"; // Put in front of subjects that are replies to another post +$string['replies'] = "Replies"; $string['repliesmany'] = "\$a replies so far"; $string['repliesone'] = "\$a reply so far"; $string['reply'] = "Reply"; @@ -93,6 +95,7 @@ $string['searchforums'] = "Search forums"; $string['sendinratings'] = "Send in my latest ratings"; $string['showsubscribers'] = "Show subscribers"; $string['singleforum'] = "A single simple discussion"; +$string['startedby'] = "Started by"; $string['subject'] = "Subject"; $string['subscribe'] = "Subscribe to this forum"; $string['subscribed'] = "Subscribed"; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 2bdf785ef7..ff1238c72a 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -29,7 +29,7 @@ define("FORUM_SHORT_POST", 300); // Less non-HTML characters than this is short define("FORUM_LONG_POST", 600); // More non-HTML characters than this is long -define("FORUM_MANY_DISCUSSIONS", 10); +define("FORUM_MANY_DISCUSSIONS", 3); /// STANDARD FUNCTIONS /////////////////////////////////////////////////////////// @@ -573,7 +573,7 @@ function forum_count_unrated_posts($discussionid, $userid) { } } -function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) { +function forum_get_discussions($forum="0", $forumsort="d.timemodified DESC", $user=0) { /// Get all discussions in a forum global $CFG; @@ -582,7 +582,10 @@ function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) { } else { $userselect = ""; } - return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture + if (empty($forumsort)) { + $forumsort = "d.timemodified DESC"; + } + return get_records_sql("SELECT p.*, d.timemodified, u.firstname, u.lastname, u.email, u.picture FROM {$CFG->prefix}forum_discussions d, {$CFG->prefix}forum_posts p, {$CFG->prefix}user u @@ -590,7 +593,7 @@ function forum_get_discussions($forum="0", $forum_sort="DESC", $user=0) { AND p.discussion = d.id AND p.parent= 0 AND p.userid = u.id $userselect - ORDER BY p.created $forum_sort"); + ORDER BY $forumsort"); } @@ -909,49 +912,43 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link } -function forum_print_post_header(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") { +function forum_print_discussion_header(&$post, $courseid, $ownpost=false, $reply=false, $link=false, $rate=false, $footer="") { global $THEME, $USER, $CFG; - if ($post->parent) { - echo ""; - } else { - echo "
"; - } + echo ""; - echo "\n"; + + // Picture + echo ""; + echo "\n"; - if ($post->parent) { - echo "\n"; + + // Replies + echo ""; + echo "\n"; - if ($post->parent) { - echo "\n"; + + echo "\n"; - if ($link) { - if ($post->replies == 1) { - $replystring = get_string("repliesone", "forum", $post->replies); - } else { - $replystring = get_string("repliesmany", "forum", $post->replies); - } - echo "wwwroot/mod/forum/discuss.php?d=$post->discussion\">".get_string("discussthistopic", "forum")." ($replystring)  "; - } - echo "

"; - echo "\n
cellcontent2\" CLASS=\"forumpostpicture\" WIDTH=35 VALIGN=TOP>"; + // Topic + echo "cellheading2\" class=\"forumpostheadertopic\" valign=top width=\"100%\">"; + echo "wwwroot/mod/forum/discuss.php?d=$post->discussion\">$post->subject"; + echo "cellcontent2\" class=\"forumpostheaderpicture\" width=35>"; print_user_picture($post->userid, $courseid, $post->picture); - echo "cellheading\" CLASS=\"forumpostheader\">"; - } else { - echo "cellheading2\" CLASS=\"forumpostheadertopic\">"; + // User name + echo "cellcontent2\" class=\"forumpostheadername\" align=left nowrap>"; + echo "wwwroot/user/view.php?id=$post->userid&course=$courseid\">$post->firstname $post->lastname"; + echo "cellcontent2\" class=\"forumpostheaderreplies\" align=center nowrap>"; + if ($link) { + echo "wwwroot/mod/forum/discuss.php?d=$post->discussion\">$post->replies"; } - echo "

"; - echo "$post->subject
"; - echo ""; - $by->name = "wwwroot/user/view.php?id=$post->userid&course=$courseid\">$post->firstname $post->lastname"; - $by->date = userdate($post->modified); - print_string("bynameondate", "forum", $by); - echo "

cellheading\" CLASS=\"forumpostheader\">"; + echo "cellcontent2\" class=\"forumpostheaderdate\" align=right nowrap>"; + if (!empty($post->timemodified)) { + echo userdate($post->timemodified); } else { - echo "cellheading2\" CLASS=\"forumpostheadertopic\">"; + echo userdate($post->modified); } - echo "

"; + echo "

\n\n"; } @@ -1222,6 +1219,9 @@ function forum_add_new_post($post) { if ($post->attachment = forum_add_attachment($post, $newfile)) { set_field("forum_posts", "attachment", $post->attachment, "id", $post->id); } + + // Update discussion modified date + set_field("forum_discussions", "timemodified", $post->modified, "id", $post->discussion); return $post->id; } @@ -1233,11 +1233,16 @@ function forum_update_post($post) { if (!$post->parent) { // Post is a discussion starter - update discussion title too set_field("forum_discussions", "name", $post->subject, "id", $post->discussion); } + if ($newfilename = forum_add_attachment($post, $post->attachment)) { $post->attachment = $newfilename; } else { unset($post->attachment); } + + // Update discussion modified date + set_field("forum_discussions", "timemodified", $post->modified, "id", $post->discussion); + return update_record("forum_posts", $post); } @@ -1396,7 +1401,7 @@ function forum_unsubscribe($userid, $forumid) { function forum_user_has_posted_discussion($forumid, $userid) { - if ($discussions = forum_get_discussions($forumid, "DESC", $userid)) { + if ($discussions = forum_get_discussions($forumid, "", $userid)) { return true; } else { return false; @@ -1437,7 +1442,7 @@ function forum_user_can_post($forum, $user=NULL) { } -function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $forum_style="plain", $forum_sort="DESC") { +function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $forum_style="plain", $forum_sort="") { global $CFG, $USER; if ($forum_id) { @@ -1471,7 +1476,6 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f if (! $discussions = forum_get_discussions($forum->id, $forum_sort) ) { echo "

(".get_string("nodiscussions", "forum").")

"; return; - } if ((!$forum_numdiscussions) && ($forum_style == "plain") && (count($discussions) > FORUM_MANY_DISCUSSIONS) ) { @@ -1489,6 +1493,16 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f $strmore = get_string("more", "forum"); } + if ($forum_style == "header") { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + foreach ($discussions as $discussion) { $discussioncount++; @@ -1516,7 +1530,7 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f echo "

\n"; break; case "header": - forum_print_post_header($discussion, $forum->course, $ownpost, $reply=0, $link=1, $assessed=false); + forum_print_discussion_header($discussion, $forum->course, $ownpost, $reply=0, $link=1, $assessed=false); break; default: if ($canreply or $discussion->replies) { @@ -1529,6 +1543,10 @@ function forum_print_latest_discussions($forum_id=0, $forum_numdiscussions=5, $f break; } } + + if ($forum_style == "header") { + echo "
".get_string("subject", "forum")."".get_string("startedby", "forum")."".get_string("replies", "forum")."".get_string("lastpost", "forum")."
"; + } } function forum_print_discussion($course, $forum, $discussion, $post, $mode) { diff --git a/theme/standard/styles.php b/theme/standard/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standard/styles.php +++ b/theme/standard/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + diff --git a/theme/standardblue/styles.php b/theme/standardblue/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standardblue/styles.php +++ b/theme/standardblue/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + diff --git a/theme/standardgreen/styles.php b/theme/standardgreen/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standardgreen/styles.php +++ b/theme/standardgreen/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + diff --git a/theme/standardlogo/styles.php b/theme/standardlogo/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standardlogo/styles.php +++ b/theme/standardlogo/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + diff --git a/theme/standardred/styles.php b/theme/standardred/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standardred/styles.php +++ b/theme/standardred/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + diff --git a/theme/standardwhite/styles.php b/theme/standardwhite/styles.php index c8121d3164..c7a61d458a 100644 --- a/theme/standardwhite/styles.php +++ b/theme/standardwhite/styles.php @@ -120,12 +120,6 @@ form { border-style: solid; } -.forumpostheader { -} - -.forumpostheadertopic { -} - .forumpostpicture { } @@ -205,3 +199,22 @@ a.dimmed:hover { text-decoration: underline; color: red; } + +.forumpostheader { +} + +.forumpostheaderpicture { +} + +.forumpostheadername { + font-size: small; +} + +.forumpostheaderreplies { + font-size: small; +} + +.forumpostheaderdate { + font-size: small; +} + -- 2.39.5