index.php 4.44 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
        }
17
18
19
20
    }

    if (empty($USER->id)) {
        $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
21
    } else {
22
        $loginstring = "<font size=1>".user_login_string($site)."</font>";
martin's avatar
martin committed
23
    }
24
25
26
27
28

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

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

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

martin's avatar
martin committed
36
37
?>

38

39
40
<table width="100%" border="0" cellspacing="5" cellpadding="5">
  <tr>
moodler's avatar
moodler committed
41
  <?PHP 
42
43
     $sections = get_all_sections($site->id);
  
44
     if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
45

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

55
56
57
58
59
         if (isadmin()) {
             echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
             echo "<br />";
         }

60
         if ($site->newsitems > 0 ) {
61
             $categories = get_categories();
62
63
64
65
             if (count($categories) > 1) {
                 print_course_categories($categories, "none", $side);
             } else {
                 $category = array_shift($categories);
66
                 print_all_courses($category->id, "minimal", 10, $side);
67
             }
68
69
70
71
         } 
         print_spacer(1,$side);
     }
 
72
     if (iscreator()) {
73
         if (!$firstcolumn) {
74
75
             echo "<td width=\"$side\" valign=top nowrap>"; 
             $firstcolumn=true;
76
         }
77
78
79
80
         print_admin_links($site->id, $side);
     }

     if ($firstcolumn) {
81
         echo "</td>";
82
     }
83
     echo "<td width=\"70%\" valign=\"top\">";
84
85

     if ($site->newsitems == 0 ) {
86
         print_heading_block(get_string("availablecourses"));
87
         print_spacer(8,1);
88
         $categories = get_categories();
89
90
91
92
93
         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
         if (isset($USER->id)) {
             $SESSION->fromdiscussion = "$CFG->wwwroot";
             if (forum_is_subscribed($USER->id, $newsforum->id)) {
                 $subtext = get_string("unsubscribe", "forum");
104
             } else {
105
                 $subtext = get_string("subscribe", "forum");
106
             }
107
108
109
110
111
             $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
                            <td>$newsforum->name</td>
                            <td align=right><font size=1>
                            <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
                            </td></tr></table>";
112
         } else {
113
             $headertext = $newsforum->name;
114
         }
115
         print_heading_block($headertext);
116
117
118
119
         print_spacer(8,1);
         forum_print_latest_discussions($newsforum->id, $site->newsitems);
     }

120
121
     echo "</td>";
     echo "<td width=30% valign=top>";
122
123
     
     if (isediting($site->id)) {
124
         $site->summary .= "<br><center><a href=\"admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
125
126
     }

moodler's avatar
moodler committed
127
     print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
128
     print_spacer(1,$side);
129
     echo "</td>";
130
  ?>
131

132
133
  </tr>
</table>
martin's avatar
martin committed
134

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