Some blank index.html files to prevent browsing
[moodle.git] / index.php
1 <?PHP  // $Id$
2        // index.php - the front page.
3     
4     require_once("config.php");
5     require_once("course/lib.php");
6     require_once("mod/resource/lib.php"); 
7     require_once("mod/forum/lib.php");
9     if (! $site = get_site()) {
10         redirect("$CFG->wwwroot/$CFG->admin/index.php");
11     }
13     if ($CFG->forcelogin) {
14         require_login();
15     }
17     if (isadmin()) {
18         if (moodle_needs_upgrading()) {
19             redirect("$CFG->wwwroot/$CFG->admin/index.php");
20         }
21     }
23     if (empty($USER->id)) {
24         $loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
25     } else {
26         $loginstring = "<font size=1>".user_login_string($site)."</font>";
27     }
29     if (empty($CFG->langmenu)) {
30         $langmenu = "";
31     } else {
32         $currlang = current_language();
33         $langs = get_list_of_languages();
34         $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
35     }
37     print_header(strip_tags($site->fullname), "$site->fullname", "home", "",
38                  "<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
39                  true, "", "$loginstring$langmenu");
41     $firstcolumn = false;  // for now
42     $lastcolumn = false;   // for now
43     $side = 175;
45     $site_summary_editbuttons = '';
46     if (isediting($site->id)) {
47         $site_summary_editbuttons = "<br><center><a href=\"$CFG->admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
48     }
50     if ($site->summary) {
51         $lastcolumn = true;
52     }
55 ?>
58 <table width="100%" border="0" cellspacing="5" cellpadding="5">
59   <tr>
60   <?PHP 
61      $sections = get_all_sections($site->id);
62   
63      if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
65          echo "<td width=\"$side\" valign=top nowrap>"; 
66          $firstcolumn=true;
67   
68          if ($sections[0]->sequence or isediting($site->id)) {
69              get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
70              print_section_block(get_string("mainmenu"), $site, $sections[0], 
71                                  $mods, $modnames, $modnamesused, true, $side);
72          }
74          if (isadmin()) {
75              echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
76              echo "<br />";
77          }
79          switch ($CFG->frontpage) {
80              case FRONTPAGENEWS:       // print news links on the side
81                  print_courses_sideblock(0, "$side");
82              break;
83     
84              case FRONTPAGECOURSELIST:
85              case FRONTPAGECATEGORYNAMES:
86                  if ($site->newsitems) {
87                      if ($news = forum_get_course_forum($site->id, "news")) {
88                          print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews");
89                          echo "<font size=\"-2\">";
90                          forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false);
91                          echo "</font>";
92                          print_side_block_end();
93                      }
94                  }
95              break;
96          } 
97          print_spacer(1,$side);
98      }
99  
100      if (iscreator()) {
101          if (!$firstcolumn) {
102              echo "<td width=\"$side\" valign=top nowrap>"; 
103              $firstcolumn=true;
104          }
105          print_admin_links($site->id, $side);
106      }
108      if ($firstcolumn) {
109          echo "</td>";
110      }
111      if ($lastcolumn) {
112          echo "<td width=\"70%\" valign=\"top\">";
113      } else {
114          echo "<td width=\"100%\" valign=\"top\">";
115      }
117      switch ($CFG->frontpage) {     /// Display the main part of the front page.
118          case FRONTPAGENEWS:
119              if (! $newsforum = forum_get_course_forum($site->id, "news")) {
120                  error("Could not find or create a main news forum for the site");
121              }
122     
123              if (isset($USER->id)) {
124                  $SESSION->fromdiscussion = "$CFG->wwwroot";
125                  if (forum_is_subscribed($USER->id, $newsforum->id)) {
126                      $subtext = get_string("unsubscribe", "forum");
127                  } else {
128                      $subtext = get_string("subscribe", "forum");
129                  }
130                  $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0 class=headingblockcontent><tr>
131                                 <td>$newsforum->name</td>
132                                 <td align=right><font size=1>
133                                 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
134                                 </td></tr></table>";
135              } else {
136                  $headertext = $newsforum->name;
137              }
138              print_heading_block($headertext);
139              print_spacer(8,1);
140              forum_print_latest_discussions($newsforum->id, $site->newsitems);
141          break;
142     
143          case FRONTPAGECOURSELIST:
144          case FRONTPAGECATEGORYNAMES:
145              if (isset($USER->id) and !isset($USER->admin)) {
146                  print_heading_block(get_string("mycourses"));
147                  print_spacer(8,1);
148                  print_my_moodle();
149              } else {
150                  if (count_records("course_categories") > 1) {
151                      if ($CFG->frontpage == FRONTPAGECOURSELIST) {
152                          print_heading_block(get_string("availablecourses"));
153                      } else {
154                          print_heading_block(get_string("categories"));
155                      }
156                      print_spacer(8,1);
157                      print_simple_box_start("center", "100%");
158                      print_whole_category_list();
159                      print_simple_box_end();
160                      print_course_search("", false, "short");
161                  } else {
162                      print_heading_block(get_string("availablecourses"));
163                      print_spacer(8,1);
164                      print_courses(0, "100%");
165                  }
166              }
167          break;
169      }
171      echo "</td>";
173      if ($lastcolumn) {
174          echo "<td width=\"30%\" valign=\"top\">";
175          print_simple_box(format_text($site->summary, FORMAT_HTML).$site_summary_editbuttons, 
176                           "", "100%", $THEME->cellcontent2, 5, "siteinfo");
177          print_spacer(1,$side);
178          echo "</td>";
179      }
180   ?>
182   </tr>
183 </table>
185 <?PHP print_footer("home");     // Please do not modify this line ?>