Permalink
Browse files

Changes to add subscribe/unsubscribe to site News forum

  • Loading branch information...
1 parent a325bd2 commit 30e1a2ee559af85424c74bd9b944fb62c220bc23 martin committed Jun 16, 2002
Showing with 23 additions and 4 deletions.
  1. +23 −4 index.php
View
@@ -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/");
@@ -61,14 +63,31 @@
<? 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);
}
?>

0 comments on commit 30e1a2e

Please sign in to comment.