index.php 4.39 KB
Newer Older
moodler's avatar
moodler committed
1
2
<?PHP  // $Id$
       // index.php - the front page.
martin's avatar
martin committed
3
    
4
5
6
7
    require_once("config.php");
    require_once("course/lib.php");
    require_once("mod/resource/lib.php"); 
    require_once("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
26
27
28
29

    $currlang = current_language();
    $langs = get_list_of_languages();
    $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);

30
    print_header("$site->fullname", "$site->fullname", "home", "",
martin's avatar
martin committed
31
                 "<META NAME=\"Description\" CONTENT=\"".stripslashes(strip_tags($site->summary))."\">",
32
                 true, "", "<div align=right>$headerbutton$langmenu</div>");
martin's avatar
martin committed
33

34
    $firstcolumn = false;  // for now
moodler's avatar
moodler committed
35
    $side = 175;
36

martin's avatar
martin committed
37
38
?>

39

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

47
48
         echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; 
         $firstcolumn=true;
49
50
51
  
         if ($sections[0]->sequence or isediting($site->id)) {
             get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
52
53
             print_section_block(get_string("mainmenu"), $site, $sections[0], 
                                 $mods, $modnames, $modnamesused, true, $side, isediting($site->id));
54
         }
martin's avatar
martin committed
55

56
         if ($site->newsitems > 0 ) {
57
             $categories = get_categories();
58
59
60
61
             if (count($categories) > 1) {
                 print_course_categories($categories, "none", $side);
             } else {
                 $category = array_shift($categories);
62
                 print_all_courses($category->id, "minimal", 10, $side);
63
             }
64
65
66
67
         } 
         print_spacer(1,$side);
     }
 
68
     if (iscreator()) {
69
70
         if (!$firstcolumn) {
             echo "<TD WIDTH=\"$side\" VALIGN=TOP NOWRAP>"; $firstcolumn=true;
71
         }
72
73
74
75
76
77
         print_admin_links($site->id, $side);
     }

     if ($firstcolumn) {
         echo "</TD>";
     }
78
     echo "<TD WIDTH=70% VALIGN=TOP>";
79
80

     if ($site->newsitems == 0 ) {
81
         print_heading_block(get_string("availablecourses"));
82
         print_spacer(8,1);
83
         $categories = get_categories();
84
85
86
87
88
         if (count($categories) > 1) {
             print_course_categories($categories, "index");
         } else {
             print_all_courses("all");
         }
89
90
91
92

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

95
96
97
98
         if (isset($USER->id)) {
             $SESSION->fromdiscussion = "$CFG->wwwroot";
             if (forum_is_subscribed($USER->id, $newsforum->id)) {
                 $subtext = get_string("unsubscribe", "forum");
99
             } else {
100
                 $subtext = get_string("subscribe", "forum");
101
             }
102
             $headertext = "<TABLE BORDER=0 WIDTH=100% CELLPADDING=0 CELLSPACING=0><TR>
103
                            <TD>$newsforum->name</TD>
104
105
106
107
                            <TD ALIGN=RIGHT><FONT SIZE=1>
                            <A HREF=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</A>
                            </TD></TR></TABLE>";
         } else {
108
             $headertext = $newsforum->name;
109
         }
110
         print_heading_block($headertext);
111
112
113
114
115
116
117
118
119
120
121
         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>";
     }

moodler's avatar
moodler committed
122
     print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
123
124
125
     print_spacer(1,$side);
     echo "</TD>";
  ?>
126

martin's avatar
martin committed
127
128
129
  </TR>
</TABLE>

moodler's avatar
moodler committed
130
<?PHP print_footer("home");     // Please do not modify this line ?>
martin's avatar
martin committed
131