]> git.mjollnir.org Git - moodle.git/commitdiff
Switch to using global variables instead of defined values,
authormoodler <moodler>
Mon, 18 Aug 2003 17:33:40 +0000 (17:33 +0000)
committermoodler <moodler>
Mon, 18 Aug 2003 17:33:40 +0000 (17:33 +0000)
controlled using the button on the "Modules" configuration page.

mod/forum/config.html [new file with mode: 0644]
mod/forum/lib.php
mod/forum/view.php

diff --git a/mod/forum/config.html b/mod/forum/config.html
new file mode 100644 (file)
index 0000000..6686c4b
--- /dev/null
@@ -0,0 +1,46 @@
+<form method="post" action="module.php" name="form">
+
+<table cellpadding=9 cellspacing=0 >
+<tr valign=top>
+       <td align=right><p>forum_displaymode:</td>
+       <td>
+    <?php choose_from_menu ($FORUM_LAYOUT_MODES, "forum_displaymode", $CFG->forum_displaymode, "", "", ""); ?>
+    </td>
+    <td>
+    <?php print_string("configdisplaymode", "forum") ?>
+    </td>
+</tr>
+<tr valign=top>
+       <td align=right><p>forum_shortpost:</td>
+       <td>
+    <input name=forum_shortpost type=text size=5 value="<?php p($CFG->forum_shortpost) ?>">
+    </td>
+    <td>
+    <?php print_string("configshortpost", "forum") ?>
+    </td>
+</tr>
+<tr valign=top>
+       <td align=right><p>forum_longpost:</td>
+       <td>
+    <input name=forum_longpost type=text size=5 value="<?php p($CFG->forum_longpost) ?>">
+    </td>
+    <td>
+    <?php print_string("configlongpost", "forum") ?>
+    </td>
+</tr>
+<tr valign=top>
+       <td align=right><p>forum_manydiscussions:</td>
+       <td>
+    <input name=forum_manydiscussions type=text size=5 value="<?php p($CFG->forum_manydiscussions) ?>">
+    </td>
+    <td>
+    <?php print_string("configmanydiscussions", "forum") ?>
+    </td>
+</tr>
+<tr>
+    <td colspan=3 align=center>
+       <input type="submit" value="<?php print_string("savechanges") ?>"></td>
+</tr>
+</table>
+
+</form>
index 8ad181a40e746fa8ce2c656656a54b562af134c2..3049a7e447e51c77a0376b9ddce4609bcef9a448 100644 (file)
@@ -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;
     }
 }
 
index b1ba1c1c01e2db82006fc452ac4ff7156f63712d..154c8b061588831cd90c736a287de23a8e24badb 100644 (file)
             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;
 
             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;
 
             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;
     }