]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to add subscribe/unsubscribe to site News forum
authormartin <martin>
Sun, 16 Jun 2002 09:44:22 +0000 (09:44 +0000)
committermartin <martin>
Sun, 16 Jun 2002 09:44:22 +0000 (09:44 +0000)
index.php

index 7df04482d9f47eb8c9a44c72f1081e58dbb1da72..85ed014516220d5c12136be1b1bbabfa29264015 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,7 +2,9 @@
     // index.php - the front page.
     
     require("config.php");
+    include("course/lib.php");
     include("mod/reading/lib.php"); 
+    include("mod/discuss/lib.php");
 
     if (! $site = get_record("course", "category", 0)) {
         redirect("$CFG->wwwroot/admin/");
       <? if ($site->format == 0 ) {
              print_simple_box("Available Courses", $align="CENTER", $width="100%", $color="$THEME->cellheading");
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
-             include("course/lib.php");
              print_all_courses();
 
          } else {
-             print_simple_box("Site News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
+             if (! $newsforum = get_course_news_forum($site->id)) {
+                 error("Could not find or create a main forum for the site");
+             }
+
+             if ($USER) {
+                 $SESSION->fromdiscuss = "$CFG->wwwroot";
+                 if (is_subscribed($USER->id, $newsforum->id)) {
+                     $subtext = "Unsubscribe from news";
+                 } else {
+                     $subtext = "Subscribe me by mail";
+                 }
+                 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
+                                <TD>Site News</TD>
+                                <TD ALIGN=RIGHT><FONT SIZE=1>
+                                <A HREF=\"mod/discuss/subscribe.php?id=$newsforum->id\">$subtext</A>
+                                </TD></TR></TABLE>";
+             } else {
+                 $headertext = "Site News";
+             }
+             print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
              echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
-             include("mod/discuss/lib.php");
-             forum_latest_topics(0, $site->format);
+             forum_latest_topics($newsforum->id, $site->format);
          }
       ?>