From: moodler Date: Tue, 16 Sep 2003 02:42:22 +0000 (+0000) Subject: New feature: "Show Parent" on all posts will take you to to the parent X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=2e2e71a8da89e0707d6c29ab956f2b9eb194b6c5;p=moodle.git New feature: "Show Parent" on all posts will take you to to the parent of any given post. Detects threaded mode and behaves a bit differently though intuitively. --- diff --git a/lang/en/forum.php b/lang/en/forum.php index 5718c8216b..8822d8781f 100644 --- a/lang/en/forum.php +++ b/lang/en/forum.php @@ -80,6 +80,7 @@ $string['olderdiscussions'] = "Older discussions"; $string['openmode0'] = "No discussions, no replies"; $string['openmode1'] = "No discussions, but replies are allowed"; $string['openmode2'] = "Discussions and replies are allowed"; +$string['parent'] = "Show parent"; $string['parentofthispost'] = "Parent of this post"; $string['postadded'] = "Your post was successfully added.

You have \$a to edit it if you want to make any changes."; $string['postincontext'] = "See this post in context"; diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 9732a03dac..4626a76c03 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4,10 +4,15 @@ require_once("$CFG->dirroot/files/mimetypes.php"); /// CONSTANTS /////////////////////////////////////////////////////////// -$FORUM_LAYOUT_MODES = array ( "1" => get_string("modeflatoldestfirst", "forum"), - "-1" => get_string("modeflatnewestfirst", "forum"), - "2" => get_string("modethreaded", "forum"), - "3" => get_string("modenested", "forum") ); +define("FORUM_MODE_FLATOLDEST", 1); +define("FORUM_MODE_FLATNEWEST", -1); +define("FORUM_MODE_THREADED", 2); +define("FORUM_MODE_NESTED", 3); + +$FORUM_LAYOUT_MODES = array ( FORUM_MODE_FLATOLDEST => get_string("modeflatoldestfirst", "forum"), + FORUM_MODE_FLATNEWEST => get_string("modeflatnewestfirst", "forum"), + FORUM_MODE_THREADED => get_string("modethreaded", "forum"), + FORUM_MODE_NESTED => get_string("modenested", "forum") ); // These are course content forums that can be added to the course manually $FORUM_TYPES = array ("general" => get_string("generalforum", "forum"), @@ -19,7 +24,7 @@ $FORUM_OPEN_MODES = array ("2" => get_string("openmode2", "forum"), "0" => get_string("openmode0", "forum") ); if (!isset($CFG->forum_displaymode)) { - set_config("forum_displaymode", 3); + set_config("forum_displaymode", FORUM_MODE_NESTED); } if (!isset($CFG->forum_shortpost)) { @@ -945,6 +950,14 @@ function forum_make_mail_post(&$post, $user, $touser, $course, // returns the HTML in a string. This is designed for sending via HTML email. global $THEME, $CFG; + static $stredit, $strdelete, $strreply, $strparent; + + if (empty($stredit)) { + $stredit = get_string("edit", "forum"); + $strdelete = get_string("delete", "forum"); + $strreply = get_string("reply", "forum"); + $strparent = get_string("parent", "forum"); + } $output = ""; @@ -988,16 +1001,19 @@ function forum_make_mail_post(&$post, $user, $touser, $course, $output .= "

"; + if ($post->parent) { + $output .= "wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent | "; + } $age = time() - $post->created; if ($ownpost) { - $output .= "wwwroot/mod/forum/post.php?delete=$post->id\">".get_string("delete", "forum").""; + $output .= "wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete"; if ($reply) { - $output .= " | wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("reply", "forum").""; + $output .= " | wwwroot/mod/forum/post.php?reply=$post->id\">$strreply"; } $output .= "  "; } else { if ($reply) { - $output .= "wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("reply", "forum")."  "; + $output .= "wwwroot/mod/forum/post.php?reply=$post->id\">$strreply  "; } } @@ -1027,6 +1043,16 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link $ratings=NULL, $footer="", $highlight="") { global $THEME, $USER, $CFG; + static $stredit, $strdelete, $strreply, $strparent, $threadedmode; + + if (empty($stredit)) { + $stredit = get_string("edit", "forum"); + $strdelete = get_string("delete", "forum"); + $strreply = get_string("reply", "forum"); + $strparent = get_string("parent", "forum"); + $threadedmode = (!empty($USER->mode) and ($USER->mode == FORUM_MODE_THREADED)); + } + echo "id\">"; if ($post->parent) { echo ''; @@ -1083,14 +1109,22 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link echo "

"; + if ($post->parent) { + if ($threadedmode) { + echo "wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent | "; + } else { + echo "wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->parent\">$strparent | "; + } + } + $age = time() - $post->created; if ($ownpost) { if ($age < $CFG->maxeditingtime) { - echo "wwwroot/mod/forum/post.php?edit=$post->id\">".get_string("edit", "forum")." | "; + echo "wwwroot/mod/forum/post.php?edit=$post->id\">$stredit | "; } } if ($ownpost or isteacher($courseid)) { - echo "wwwroot/mod/forum/post.php?delete=$post->id\">".get_string("delete", "forum").""; + echo "wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete"; if ($reply) { echo "| "; } else { @@ -1098,7 +1132,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link } } if ($reply) { - echo "wwwroot/mod/forum/post.php?reply=$post->id\">".get_string("reply", "forum").""; + echo "wwwroot/mod/forum/post.php?reply=$post->id\">$strreply"; echo "  "; } echo "

"; @@ -1991,19 +2025,19 @@ function forum_print_discussion($course, $forum, $discussion, $post, $mode) { forum_print_post($post, $course->id, $ownpost, $reply, $link=false, $ratings); switch ($mode) { - case 1 : // Flat ascending - case -1 : // Flat descending + case FORUM_MODE_FLATOLDEST : + case FORUM_MODE_FLATNEWEST : default: echo "
    "; forum_print_posts_flat($post->discussion, $course->id, $mode, $ratings, $reply); echo "
"; break; - case 2 : // Threaded + case FORUM_MODE_THREADED : forum_print_posts_threaded($post->id, $course->id, 0, $ratings, $reply); break; - case 3 : // Nested + case FORUM_MODE_NESTED : forum_print_posts_nested($post->id, $course->id, $ratings, $reply); break; }