3eefc613e6675764d1f5dc04370344e529a9b188
[moodle.git] / course / social.php
1 <?  // $Id$
2     // social.php - course format featuring social forum
3     //              included from view.php
4     
5     include("../mod/discuss/lib.php");
6     include("../mod/reading/lib.php"); 
7 ?>
9 <TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
10   <TR>
11     <TD WIDTH="15%" VALIGN="TOP">
12       <? 
13       //print_simple_box("News", $align="CENTER", $width="100%", $color="$THEME->cellheading");
15       //print_side_block("<A HREF=\"new.php?id=$course->id\">What's New!</A>", 
16       //                 "", "<FONT SIZE=1>...since your last login</FONT>");
17       //if ($news = get_course_news_forum($course->id)) {
18           //forum_latest_topics($news->id, 5, "minimal", "DESC", false);
19       //}
21       //echo "<BR><BR>";
22       print_simple_box("People", $align="CENTER", $width="100%", $color="$THEME->cellheading");
23       $moddata[]="<A HREF=\"../user/index.php?id=$course->id\">Participants</A>";
24       $modicon[]="<IMG SRC=\"../user/users.gif\" HEIGHT=16 WIDTH=16 ALT=\"List of everyone\">";
25       $moddata[]="<A HREF=\"../user/view.php?id=$USER->id&course=$course->id\">Edit my profile</A>";
26       $modicon[]="<IMG SRC=\"../user/user.gif\" HEIGHT=16 WIDTH=16 ALT=\"Me\">";
27       print_side_block("", $moddata, "", $modicon);
28       
30       // Then, print all the available readings
32       print_simple_box("Readings", $align="CENTER", $width="100%", $color="$THEME->cellheading");
34       if ($readings = list_all_readings($course->id, "timemodified ASC", 0, true)) {
35          foreach ($readings as $reading) {
36              $readingdata[] = $reading;
37              $readingicon[] = "<IMG SRC=\"../mod/reading/icon.gif\" HEIGHT=16 WIDTH=16 ALT=\"Reading\">";
38          }
39          if ($USER->editing) {
40              $readingdata[] = "<A HREF=\"mod.php?id=$course->id&week=0&add=reading\">Add reading...</A>";
41              $readingicon[] = "&nbsp;";
42          }
43       }
44       print_side_block("", $readingdata, "", $readingicon);
46       if (isteacher($USER->id)) {
47           print_simple_box("Admin", $align="CENTER", $width="100%", $color="$THEME->cellheading");
48           $adminicon[]="<IMG SRC=\"../pix/i/edit.gif\" HEIGHT=16 WIDTH=16 ALT=\"Edit\">";
49           if ($USER->editing) {
50               $admindata[]="<A HREF=\"view.php?id=$course->id&edit=off\">Turn editing off</A>";
51           } else {
52               $admindata[]="<A HREF=\"view.php?id=$course->id&edit=on\">Turn editing on</A>";
53           }
55           $admindata[]="<A HREF=\"edit.php?id=$course->id\">Course settings...</A>";
56           $adminicon[]="<IMG SRC=\"../pix/i/settings.gif\" HEIGHT=16 WIDTH=16 ALT=\"Course\">";
57           $admindata[]="<A HREF=\"log.php?id=$course->id\">Logs...</A>";
58           $adminicon[]="<IMG SRC=\"../pix/i/log.gif\" HEIGHT=16 WIDTH=16 ALT=\"Log\">";
59           $admindata[]="<A HREF=\"../files/index.php?id=$course->id\">Files...</A>";
60           $adminicon[]="<IMG SRC=\"../files/pix/files.gif\" HEIGHT=16 WIDTH=16 ALT=\"Files\">";
62           print_side_block("", $admindata, "", $adminicon);
64       }
65       ?>
67     </TD>
69     <TD WIDTH="55%" VALIGN="TOP">
70       <? 
71       if (!$social = get_course_social_forum($course->id)) {
72           error("Could not find or create a social forum here");
73       }
75       $SESSION->fromdiscuss = "$CFG->wwwdir/course/view.php?id=$course->id";
76       if (is_subscribed($USER->id, $social->id)) {
77           $subtext = "Unsubscribe";
78       } else {
79           $subtext = "Subscribe me by mail";
80       }
81       $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/discuss/subscribe.php?id=$social->id\">$subtext</A></TD></TR></TABLE>";
82          print_simple_box("$headertext", $align="CENTER", $width="100%", $color="$THEME->cellheading"); ?>
83       <IMG ALT="" HEIGHT=7 SRC="../pix/spacer.gif"><BR>
85       <? 
86           if ($social = get_course_social_forum($course->id)) {
87               forum_latest_topics($social->id, 10, "plain", "DESC", false);
88           } else {
89               error("Could not find or create a social forum here");
90           }
91       ?>
92     
93     </TD>
94   </TR>
95 </TABLE>