index.php 4.06 KB
Newer Older
martin's avatar
martin committed
1
2
3
4
<?  // $Id$
    // index.php - the front page.
    
    require("config.php");
5
    include("course/lib.php");
6
    include("mod/reading/lib.php"); 
7
    include("mod/forum/lib.php");
martin's avatar
martin committed
8

9
    if (! $site = get_site()) {
martin's avatar
martin committed
10
11
12
        redirect("$CFG->wwwroot/admin/");
    }

martin's avatar
martin committed
13
    if (isset($USER->id)) {
martin's avatar
martin committed
14
15
        $headerbutton = update_course_icon($site->id);
    } else {
martin's avatar
martin committed
16
        $headerbutton = "<FONT SIZE=2><A HREF=\"login/\">".get_string("login")."</A></FONT>";
martin's avatar
martin committed
17
    }
18
    print_header("$site->fullname", "$site->fullname", "", "",
martin's avatar
martin committed
19
                 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
martin's avatar
martin committed
20
                 true, $headerbutton);
martin's avatar
martin committed
21

22

martin's avatar
martin committed
23
24
?>

25

martin's avatar
martin committed
26
27
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
  <TR>
martin's avatar
martin committed
28
    <TD VALIGN="TOP" NOWRAP>
29
30
31
      <? 

         $sections = get_all_sections($site->id);
32
      
33
         if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {
34
      
35
36
37
38
39
40
41
             if ($sections[0]->sequence or isediting($site->id)) {
                 get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
                 print_simple_box(get_string("mainmenu"), "CENTER", "100%", "$THEME->cellheading");
             }   

             if ($sections[0]->sequence) {
                 print_section($site->id, $sections[0], $mods, $modnamesused, true);
42
             }
43

44
             if (isediting($site->id)) {
45
46
47
48
                 echo "<DIV ALIGN=right>";
                 popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=", 
                             $modnames, "section0", "", "Add...");
                 echo "</DIV>";
martin's avatar
martin committed
49
             }
martin's avatar
martin committed
50
51
52
53
54

             if ($site->newsitems > 0 ) {
                 print_simple_box(get_string("courses"), "CENTER", "100%", "$THEME->cellheading");
                 print_all_courses($cat=1, "minimal", 10);
             } 
55
             echo "<IMG SRC=\"pix/spacer.gif\" WIDTH=200 HEIGHT=0><BR>";
56
57
         }
     
58
         if (isadmin()) {
martin's avatar
martin committed
59
             print_admin_links($site->id);
60
         }
martin's avatar
martin committed
61
62
63
64
      ?>

    </TD>

martin's avatar
martin committed
65
    <TD WIDTH="70%" VALIGN="TOP">
66
      <? if ($site->newsitems == 0 ) {
martin's avatar
martin committed
67
             print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
68
69
70
71
             echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
             print_all_courses();

         } else {
72
73
             if (! $newsforum = forum_get_course_forum($site->id, "news")) {
                 error("Could not find or create a main news forum for the site");
74
75
             }

martin's avatar
martin committed
76
             if (isset($USER->id)) {
77
                 $SESSION->fromdiscussion = "$CFG->wwwroot";
martin's avatar
martin committed
78
                 save_session("SESSION");
79
                 if (forum_is_subscribed($USER->id, $newsforum->id)) {
martin's avatar
martin committed
80
                     $subtext = get_string("unsubscribe", "forum");
81
                 } else {
martin's avatar
martin committed
82
                     $subtext = get_string("subscribe", "forum");
83
84
                 }
                 $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
martin's avatar
martin committed
85
                                <TD>".get_string("sitenews")."</TD>
86
                                <TD ALIGN=RIGHT><FONT SIZE=1>
martin's avatar
martin committed
87
                                <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
88
89
                                </TD></TR></TABLE>";
             } else {
martin's avatar
martin committed
90
                 $headertext = get_string("sitenews");
91
             }
martin's avatar
martin committed
92
             print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
93
             echo "<IMG HEIGHT=8 SRC=\"pix/spacer.gif\" ALT=\"\"><BR>";
94
             forum_print_latest_discussions($newsforum->id, $site->newsitems);
95
         }
martin's avatar
martin committed
96
      ?>
97

martin's avatar
martin committed
98
    </TD>
martin's avatar
martin committed
99
    <TD WIDTH="30%" VALIGN="TOP"> 
martin's avatar
martin committed
100
      <? 
101
         if (isediting($site->id)) {
martin's avatar
martin committed
102
103
             $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
         }
martin's avatar
martin committed
104
         print_simple_box($site->summary, "", "100%", $THEME->cellheading);
martin's avatar
martin committed
105
      ?>
martin's avatar
martin committed
106
107
108
109
    </TD>
  </TR>
</TABLE>

110
<? include("$CFG->dirroot/theme/$CFG->theme/footer.html"); ?>
martin's avatar
martin committed
111
112
113
114
115

<P ALIGN=center>
<A WIDTH=85 HEIGHT=25 HREF="http://moodle.com/"><IMG SRC="pix/madewithmoodle.gif" BORDER=0></A>
</P>