From 5be7800c127152ae0c7d98b8c1b876c22f5a5ffe Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 18 Aug 2003 17:33:40 +0000 Subject: [PATCH] Switch to using global variables instead of defined values, controlled using the button on the "Modules" configuration page. --- mod/forum/config.html | 46 +++++++++++++++++++++++++++++++++++++++++++ mod/forum/lib.php | 30 +++++++++++++++++----------- mod/forum/view.php | 6 +++--- 3 files changed, 68 insertions(+), 14 deletions(-) create mode 100644 mod/forum/config.html diff --git a/mod/forum/config.html b/mod/forum/config.html new file mode 100644 index 0000000000..6686c4be6f --- /dev/null +++ b/mod/forum/config.html @@ -0,0 +1,46 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +

forum_displaymode:

+ forum_displaymode, "", "", ""); ?> + + +

forum_shortpost:

+ + + +

forum_longpost:

+ + + +

forum_manydiscussions:

+ + + +
+ ">
+ +
diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 8ad181a40e..3049a7e447 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -4,8 +4,6 @@ require_once("$CFG->dirroot/files/mimetypes.php"); /// CONSTANTS /////////////////////////////////////////////////////////// -$FORUM_DEFAULT_DISPLAY_MODE = 3; - $FORUM_LAYOUT_MODES = array ( "1" => get_string("modeflatoldestfirst", "forum"), "-1" => get_string("modeflatnewestfirst", "forum"), "2" => get_string("modethreaded", "forum"), @@ -16,17 +14,25 @@ $FORUM_TYPES = array ("general" => get_string("generalforum", "forum"), "eachuser" => get_string("eachuserforum", "forum"), "single" => get_string("singleforum", "forum") ); - $FORUM_OPEN_MODES = array ("2" => get_string("openmode2", "forum"), "1" => get_string("openmode1", "forum"), "0" => get_string("openmode0", "forum") ); +if (!isset($CFG->forum_displaymode)) { + set_config("forum_display_mode", 3); +} -define("FORUM_SHORT_POST", 300); // Less non-HTML characters than this is short +if (!isset($CFG->forum_shortpost)) { + set_config("forum_shortpost", 300); // Less non-HTML characters than this is short +} -define("FORUM_LONG_POST", 600); // More non-HTML characters than this is long +if (!isset($CFG->forum_longpost)) { + set_config("forum_longpost", 600); // More non-HTML characters than this is long +} -define("FORUM_MANY_DISCUSSIONS", 100); +if (!isset($CFG->forum_manydiscussions)) { + set_config("forum_manydiscussions", 100); // Number of discussions on a page +} /// STANDARD FUNCTIONS /////////////////////////////////////////////////////////// @@ -996,7 +1002,7 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link $attachedimages = ""; } - if ($link and (strlen(strip_tags($post->message)) > FORUM_LONG_POST)) { + if ($link and (strlen(strip_tags($post->message)) > $CFG->forum_longpost)) { // Print shortened version echo format_text(forum_shorten_post($post->message), $post->format); $numwords = count_words(strip_tags($post->message)); @@ -1107,7 +1113,9 @@ function forum_print_discussion_header(&$post, $courseid, $datestring="") { function forum_shorten_post($message) { // Given a post object that we already know has a long message // this function truncates the message nicely to the first -// sane place between FORUM_LONG_POST and FORUM_SHORT_POST +// sane place between $CFG->forum_longpost and $CFG->forum_shortpost + + global $CFG; $i = 0; $tag = false; @@ -1139,7 +1147,7 @@ function forum_shorten_post($message) { break; } if (!$stopzone) { - if ($count > FORUM_SHORT_POST) { + if ($count > $CFG->forum_shortpost) { $stopzone = true; } } @@ -2002,12 +2010,12 @@ function forum_print_posts_nested($parent, $course, $ratings, $reply) { } function forum_set_display_mode($mode=0) { - global $USER, $FORUM_DEFAULT_DISPLAY_MODE; + global $USER, $CFG; if ($mode) { $USER->mode = $mode; } else if (empty($USER->mode)) { - $USER->mode = $FORUM_DEFAULT_DISPLAY_MODE; + $USER->mode = $CFG->forum_displaymode; } } diff --git a/mod/forum/view.php b/mod/forum/view.php index b1ba1c1c01..154c8b0615 100644 --- a/mod/forum/view.php +++ b/mod/forum/view.php @@ -146,7 +146,7 @@ if (!empty($showall)) { forum_print_latest_discussions($forum->id, 0, "header"); } else { - forum_print_latest_discussions($forum->id, FORUM_MANY_DISCUSSIONS, "header"); + forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, "header"); } break; @@ -154,7 +154,7 @@ if (!empty($showall)) { forum_print_latest_discussions($forum->id, 0, "header"); } else { - forum_print_latest_discussions($forum->id, FORUM_MANY_DISCUSSIONS, "header"); + forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, "header"); } break; @@ -166,7 +166,7 @@ if (!empty($showall)) { forum_print_latest_discussions($forum->id, 0, "header"); } else { - forum_print_latest_discussions($forum->id, FORUM_MANY_DISCUSSIONS, "header"); + forum_print_latest_discussions($forum->id, $CFG->forum_manydiscussions, "header"); } break; } -- 2.39.5