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

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

13
14
    if (isadmin()) {
        if (moodle_needs_upgrading()) {
15
            redirect("$CFG->wwwroot/admin/index.php");
16
        }
martin's avatar
martin committed
17
        $headerbutton = update_course_icon($site->id);
18
19
20
21
    } else {
        if (isset($USER->id)) {
            $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</A></FONT>";
        } else {
martin's avatar
martin committed
22
            $headerbutton = "<FONT SIZE=2><A HREF=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</A></FONT>";
23
        }
martin's avatar
martin committed
24
    }
25
    print_header("$site->fullname", "$site->fullname", "home", "",
martin's avatar
martin committed
26
                 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
27
                 true, "", $headerbutton);
martin's avatar
martin committed
28

29
    $side = 180;
30

martin's avatar
martin committed
31
32
?>

33

martin's avatar
martin committed
34
35
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="5" CELLPADDING="5">
  <TR>
36
37
38
39
40
41
42
43
44
45
46
47
48
  <? 
     $sections = get_all_sections($site->id);
  
     if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id)) {

         echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
  
         if ($sections[0]->sequence or isediting($site->id)) {
             get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
             print_simple_box(get_string("mainmenu"), "CENTER", $side, "$THEME->cellheading");
         }   

         if ($sections[0]->sequence) {
moodler's avatar
moodler committed
49
             print_section($site, $sections[0], $mods, $modnamesused, true, $side);
50
         }
51

52
53
54
         if (isediting($site->id)) {
             echo "<DIV ALIGN=right>";
             popup_form("$CFG->wwwroot/course/mod.php?id=$site->id&section=0&add=", 
55
                         $modnames, "section0", "", get_string("add")."...");
56
57
             echo "</DIV>";
         }
martin's avatar
martin committed
58

59
         if ($site->newsitems > 0 ) {
60
61
62
63
64
65
66
67
68
             $categories = get_all_categories();
             if (count($categories) > 1) {
                 print_simple_box(get_string("categories"), "CENTER", $side, "$THEME->cellheading");
                 print_course_categories($categories, "none", $side);
             } else {
                 print_simple_box(get_string("courses"), "CENTER", $side, "$THEME->cellheading");
                 $category = array_shift($categories);
                 print_all_courses($category->id, "minimal", 10);
             }
69
70
71
72
73
74
75
         } 
         print_spacer(1,$side);
     }
 
     if (isadmin()) {
         if (!$firstcolumn) {
             echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
76
         }
77
78
79
80
81
82
         print_admin_links($site->id, $side);
     }

     if ($firstcolumn) {
         echo "</TD>";
     }
83
     echo "<TD WIDTH=70% VALIGN=TOP>";
84
85
86
87

     if ($site->newsitems == 0 ) {
         print_simple_box(get_string("availablecourses"), "CENTER", "100%", "$THEME->cellheading");
         print_spacer(8,1);
88
89
90
91
92
93
         $categories = get_all_categories();
         if (count($categories) > 1) {
             print_course_categories($categories, "index");
         } else {
             print_all_courses("all");
         }
94
95
96
97

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

100
101
102
103
104
         if (isset($USER->id)) {
             $SESSION->fromdiscussion = "$CFG->wwwroot";
             save_session("SESSION");
             if (forum_is_subscribed($USER->id, $newsforum->id)) {
                 $subtext = get_string("unsubscribe", "forum");
105
             } else {
106
                 $subtext = get_string("subscribe", "forum");
107
             }
108
109
110
111
112
113
114
             $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
                            <TD>".get_string("sitenews")."</TD>
                            <TD ALIGN=RIGHT><FONT SIZE=1>
                            <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
                            </TD></TR></TABLE>";
         } else {
             $headertext = get_string("sitenews");
115
         }
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
         print_simple_box($headertext, "CENTER", "100%", $THEME->cellheading);
         print_spacer(8,1);
         forum_print_latest_discussions($newsforum->id, $site->newsitems);
     }

     echo "</TD>";
     echo "<TD WIDTH=30% VALIGN=TOP>";
     
     if (isediting($site->id)) {
         $site->summary .= "<BR><CENTER><A HREF=\"admin/site.php\"><IMG SRC=\"pix/i/edit.gif\" BORDER=0></A>";
     }

     print_simple_box($site->summary, "", "100%", $THEME->cellheading);
     print_spacer(1,$side);
     echo "</TD>";
  ?>
132

martin's avatar
martin committed
133
134
135
  </TR>
</TABLE>

martin's avatar
martin committed
136
<? print_footer("home");     // Please do not modify this line ?>
martin's avatar
martin committed
137