]> git.mjollnir.org Git - moodle.git/commitdiff
Changes related to new forum type: eachuser and some general forum-related tweaking
authormartin <martin>
Tue, 25 Jun 2002 06:47:34 +0000 (06:47 +0000)
committermartin <martin>
Tue, 25 Jun 2002 06:47:34 +0000 (06:47 +0000)
course/mod.php
course/social.php
course/topics.php
course/view.php
course/weeks.php
index.php
lib/moodlelib.php
mod/forum/lib.php
mod/forum/view.php

index 9ac9acdefc9bb37343e611a9b3106125515cc6f0..76c35edc8aa9e6d604e04af6528998a3880343f4 100644 (file)
 
         }
 
-        redirect("view.php?id=$mod->course");
+        if ($SESSION->returnpage) {
+            $return = $SESSION->returnpage;
+            unset($SESSION->returnpage);
+            redirect($return);
+        } else {
+            redirect("view.php?id=$mod->course");
+        }
         exit;
     }
 
+    if (isset($return)) {  
+        $SESSION->returnpage = $HTTP_REFERER;
+    }
 
     if (isset($move)) {  
 
index 7a9a72ffa7e574318cfbe33f285c39a33258281c..6ed869b0feee272650e0a4b9ba10454e49d2fac9 100644 (file)
@@ -11,7 +11,7 @@
     <TD WIDTH="15%" VALIGN="TOP">
       <? 
       //if ($news = get_course_news_forum($course->id)) {
-          //forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+          //print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
       //}
 
       //echo "<BR><BR>";
@@ -93,7 +93,7 @@
 
       <? 
           if ($social = get_course_social_forum($course->id)) {
-              forum_latest_topics($social->id, 10, "plain", "DESC", false);
+              print_forum_latest_topics($social->id, 10, "plain", "DESC", false);
           } else {
               error("Could not find or create a social forum here");
           }
index 022205384d3707967924f8ce7c673580e56d544e..2839fa25aa1ed4ce27cce5898548cef57c6278d9 100644 (file)
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+        print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index 087aaff756c758e5535979f4824f058ea15738ba..cdd23be2ebc6695263d0ff039b3843feb81ba965 100644 (file)
@@ -96,7 +96,7 @@ function print_side_block($heading="", $list=NULL, $footer="", $icons=NULL) {
                 echo "";
             }
             echo "</TD>\n<TD WIDTH=100%>";
-            echo "<P><FONT SIZE=1>$string</FONT></P>";
+            echo "<P><FONT SIZE=2>$string</FONT></P>";
             echo "</TD></TR>\n";
         }
     }
index 721171b42a3033c14071236df015a2673bf326ea..3e7e5be9708a374b5475cfe662272e18002fa3e1 100644 (file)
         print_simple_box("Latest News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
         print_simple_box_start("CENTER", "100%", "#FFFFFF", 3, 0);
         echo "<FONT SIZE=1>";
-        forum_latest_topics($news->id, 5, "minimal", "DESC", false);
+        print_forum_latest_topics($news->id, 5, "minimal", "DESC", false);
         echo "</FONT>";
         print_simple_box_end();
     }
index d1518fa54b5a2c38524fea3ee51136509e930d18..68ea276c50335e776639b5299671ee824a9388e2 100644 (file)
--- a/index.php
+++ b/index.php
@@ -87,7 +87,7 @@
              }
              print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
-             forum_latest_topics($newsforum->id, $site->format);
+             print_forum_latest_topics($newsforum->id, $site->format);
          }
       ?>
 
index 4918127d6eb24c2cbb8fea203b0d93415fe23597..f3871319b829df7fbe41e4f8b37b07164d93e514 100644 (file)
@@ -197,7 +197,7 @@ function update_module_icon($moduleid) {
     global $CFG;
 
     if (isteacher($courseid)) {
-        return "<A TITLE=\"Edit this activity\" HREF=\"$CFG->wwwroot/course/mod.php?update=$moduleid\" TARGET=_top><IMG 
+        return "<A TITLE=\"Edit this activity\" HREF=\"$CFG->wwwroot/course/mod.php?update=$moduleid&return=true\" TARGET=_top><IMG 
                 SRC=\"$CFG->wwwroot/pix/i/edit.gif\" ALIGN=right BORDER=0></A>";
     }
 }
index c97366b0937e2098711705e87a214c17999c5f4d..f8237892bf496f8f8877669c26a13d280beb6667 100644 (file)
@@ -26,11 +26,38 @@ function forum_unsubscribe($user, $forum) {
 }
 
 
-function get_all_topics($forum="0", $forum_sort="DESC") {
+function user_has_posted_discussion($forumid, $userid) {
+    if ($topics = get_all_topics($forumid, "DESC", $userid)) {
+        return true;
+    } else {
+        return false;
+    }
+}
+
+function user_can_post_discussion($forum) {
+// $forum is an object
+    global $USER;
+
+    if ($forum->type == "eachuser") {
+        return (! user_has_posted_discussion($forum->id, $USER->id));
+    } else if (isteacher($forum->course)) {
+        return true;
+    } else {
+        return $forum->open;
+    }
+}
+
+
+function get_all_topics($forum="0", $forum_sort="DESC", $user=0) {
+    if ($user) {
+        $userselect = " AND u.id = '$user' ";
+    } else {
+        $userselect = "";
+    }
     return get_records_sql("SELECT p.*, u.firstname, u.lastname, u.email, u.picture, u.id as userid
                             FROM discuss d, discuss_posts p, user u 
                             WHERE d.forum = '$forum' AND p.discuss = d.id AND 
-                                  p.parent= 0 AND p.user = u.id
+                                  p.parent= 0 AND p.user = u.id $userselect
                             ORDER BY p.created $forum_sort");
 }
 
@@ -87,7 +114,7 @@ function get_course_discussion_forum($courseid) {
 }
 
 
-function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
+function print_forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plain", $forum_sort="DESC") {
     global $CFG, $USER;
     
     if ($forum_id) {
@@ -112,7 +139,7 @@ function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plai
     }
 
     if (! $topics = get_all_topics($forum->id, $forum_sort) ) {
-        echo "<P><B>There are no discussion topics yet in this forum.</B></P>";
+        echo "<P ALIGN=CENTER><B>There are no discussion topics yet in this forum.</B></P>";
 
     } else {
 
@@ -147,7 +174,7 @@ function forum_latest_topics($forum_id=0, $forum_numtopics=5, $forum_style="plai
             }
         }
     }
-    if ($forum->open || $USER->editing) {
+    if (user_can_post_discussion($forum)) {
         echo "<P ALIGN=right>";
         echo "<A HREF=\"$CFG->wwwroot/mod/discuss/post.php?forum=$forum->id\">Add a new topic...</A>";
         echo "</P>";
index 440d5473fbf4c1325babe922c0b5bd42131bec85..e3b58d7498b1970d504fa14f065c960a56869012 100644 (file)
         } else {
             $subtext = "Subscribe to this forum";
         }
-        echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></P>";
+        echo "<DIV ALIGN=RIGHT><FONT SIZE=1><A HREF=\"subscribe.php?id=$forum->id\">$subtext</A></FONT></DIV>";
     }
 
-    forum_latest_topics($forum->id, 0);
+    print_simple_box(text_to_html($forum->intro), "CENTER");
+
+    switch ($forum->type) {
+        case "eachuser":
+            echo "<P ALIGN=CENTER>";
+            if (user_can_post_discussion($forum)) {
+                echo "This forum allows one discussion topic to be posted per person.  Click here to <A HREF=\"../discuss/post.php?forum=$forum->id\">post your topic</A>.";
+            } else {
+                echo "&nbsp";
+            }
+            echo "</P>";
+            break;
+
+        default:
+            echo "<P>&nbsp;</P>";
+            break;
+    }
+
+    print_forum_latest_topics($forum->id, 0);
 
     print_footer($course);