moodle/course/social.php
martin 8223d27193 Widespread changes throughout Moodle to make sure it works on
servers that have register_globals turned off (this is the
default setting on newer version of PHP).

In fact it's partly a hack that globalises all GET, POST, FILES
AND COOKIE variables.  Unfortunately though the SESSION and
USER global session variables are only available as $_SESSION["USER"]
and $_SESSION["SESSION"], which is cumbersome to use.

So, for every request I now make a copy of these two session variables
into $USER and $SESSION.  Whenever I update them thoughout Moodle I
now have to call save_session("USER") which copies them back to the
session variable.  This seems to be working well now.

Because I'm using $_SESSION etc now this will raise
the required minimum version of PHP to 4.1.0
2002-08-06 17:23:45 +00:00

95 lines
4.2 KiB
PHP

<? // $Id$
// social.php - course format featuring social forum
// included from view.php
include("../mod/forum/lib.php");
include("../mod/reading/lib.php");
?>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
<TR>
<TD WIDTH="15%" VALIGN="TOP">
<?
//if ($news = forum_get_course_forum($course->id, "news")) {
//forum_print_latest_discussions($news->id, 5, "minimal", "DESC", false);
//}
//echo "<BR><BR>";
print_simple_box("People", $align="CENTER", $width="100%", $color="$THEME->cellheading");
$moddata[]="<A HREF=\"../user/index.php?id=$course->id\">List of all people</A>";
$modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"List of everyone\">";
$moddata[]="<A HREF=\"../user/view.php?id=$USER->id&course=$course->id\">Edit my profile</A>";
$modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"Me\">";
print_side_block("", $moddata, "", $modicon);
// Then, print all the available resources (Section 0)
print_simple_box("Resources", $align="CENTER", $width="100%", $color="$THEME->cellheading");
print_section($site->id, $sections[0], $mods, $modnamesused, true);
if (isediting($site->id)) {
echo "<DIV ALIGN=right>";
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=0&add=",
$modnames, "section0", "", "Add...");
echo "</DIV>";
}
// Print all the recent activity
print_simple_box("Recent Activity", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<TABLE CELLPADDING=4 CELLSPACING=0><TR><TD>";
print_recent_activity($course);
echo "</TD></TR></TABLE>";
echo "<BR>";
// Print a form to search forums
print_simple_box(get_string("search","forum"), $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<DIV ALIGN=CENTER>";
forum_print_search_form($course);
echo "</DIV>";
// Print Admin links for teachers and admin.
if (isteacher($course->id) || isadmin()) {
print_simple_box("Admin", $align="CENTER", $width="100%", $color="$THEME->cellheading");
$adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
if (isediting($course->id)) {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
} else {
$admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
}
$admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
$admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
$adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
$admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
$adminicon[]="<IMG SRC=\"../files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"Files\">";
print_side_block("", $admindata, "", $adminicon);
}
echo "</TD>";
echo "<TD WIDTH=\"55%\" VALIGN=\"TOP\">";
if ($social = forum_get_course_forum($course->id, "social")) {
if (forum_is_subscribed($USER->id, $social->id)) {
$subtext = "Unsubscribe";
} else {
$subtext = "Subscribe me by mail";
}
$headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR><TD>Social Forum - Current Topics<TD ALIGN=RIGHT><FONT SIZE=1><A HREF=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading");
echo "<IMG ALT=\"\" HEIGHT=7 SRC=\"../pix/spacer.gif\"><BR>";
forum_print_latest_discussions($social->id, 10, "plain", "DESC", false);
$SESSION->fromdiscussion = "$CFG->wwwroot/course/view.php?id=$course->id";
save_session("SESSION");
} else {
notify("Could not find or create a social forum here");
}
?>
</TD>
</TR>
</TABLE>