Displays all user pictures on one page.
[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/admin/index.php");
11     }
13     if (isadmin()) {
14         if (moodle_needs_upgrading()) {
15             redirect("$CFG->wwwroot/admin/index.php");
16         }
17     }
19     if (empty($USER->id)) {
20         $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>";
23     }
25     if (empty($CFG->langmenu)) {
26         $langmenu = "";
27     } else {
28         $currlang = current_language();
29         $langs = get_list_of_languages();
30         $langmenu = popup_form ("$CFG->wwwroot/?lang=", $langs, "chooselang", $currlang, "", "", "", true);
31     }
33     print_header(strip_tags($site->fullname), "$site->fullname", "home", "",
34                  "<meta name=\"description\" content=\"".s(strip_tags($site->summary))."\">",
35                  true, "", "<div align=right>$loginstring$langmenu</div>");
37     $firstcolumn = false;  // for now
38     $lastcolumn = false;   // for now
39     $side = 175;
41     if (isediting($site->id)) {
42         $site->summary .= "<br><center><a href=\"admin/site.php\"><img src=\"pix/i/edit.gif\" border=0></a>";
43     }
45     if ($site->summary) {
46         $lastcolumn = true;
47     }
50 ?>
53 <table width="100%" border="0" cellspacing="5" cellpadding="5">
54   <tr>
55   <?PHP 
56      $sections = get_all_sections($site->id);
57   
58      if ($site->newsitems > 0 or $sections[0]->sequence or isediting($site->id) or isadmin()) {
60          echo "<td width=\"$side\" valign=top nowrap>"; 
61          $firstcolumn=true;
62   
63          if ($sections[0]->sequence or isediting($site->id)) {
64              get_all_mods($site->id, $mods, $modnames, $modnamesplural, $modnamesused);
65              print_section_block(get_string("mainmenu"), $site, $sections[0], 
66                                  $mods, $modnames, $modnamesused, true, $side);
67          }
69          if (isadmin()) {
70              echo "<div align=\"center\">".update_course_icon($site->id)."</div>";
71              echo "<br />";
72          }
74          switch ($CFG->frontpage) {
75              case FRONTPAGENEWS:       // print news links on the side
76                  print_courses_sideblock(0, "$side");
77              break;
78     
79              case FRONTPAGECOURSELIST:
80              case FRONTPAGECATEGORYNAMES:
81                  if ($site->newsitems) {
82                      if ($news = forum_get_course_forum($site->id, "news")) {
83                          print_side_block_start(get_string("latestnews"), $side, "sideblocklatestnews");
84                          echo "<font size=\"-2\">";
85                          forum_print_latest_discussions($news->id, $site->newsitems, "minimal", "", false);
86                          echo "</font>";
87                          print_side_block_end();
88                      }
89                  }
90              break;
91          } 
92          print_spacer(1,$side);
93      }
94  
95      if (iscreator()) {
96          if (!$firstcolumn) {
97              echo "<td width=\"$side\" valign=top nowrap>"; 
98              $firstcolumn=true;
99          }
100          print_admin_links($site->id, $side);
101      }
103      if ($firstcolumn) {
104          echo "</td>";
105      }
106      if ($lastcolumn) {
107          echo "<td width=\"70%\" valign=\"top\">";
108      } else {
109          echo "<td width=\"100%\" valign=\"top\">";
110      }
112      switch ($CFG->frontpage) {     /// Display the main part of the front page.
113          case FRONTPAGENEWS:
114              if (! $newsforum = forum_get_course_forum($site->id, "news")) {
115                  error("Could not find or create a main news forum for the site");
116              }
117     
118              if (isset($USER->id)) {
119                  $SESSION->fromdiscussion = "$CFG->wwwroot";
120                  if (forum_is_subscribed($USER->id, $newsforum->id)) {
121                      $subtext = get_string("unsubscribe", "forum");
122                  } else {
123                      $subtext = get_string("subscribe", "forum");
124                  }
125                  $headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0><tr>
126                                 <td>$newsforum->name</td>
127                                 <td align=right><font size=1>
128                                 <a href=\"mod/forum/subscribe.php?id=$newsforum->id\">$subtext</a>
129                                 </td></tr></table>";
130              } else {
131                  $headertext = $newsforum->name;
132              }
133              print_heading_block($headertext);
134              print_spacer(8,1);
135              forum_print_latest_discussions($newsforum->id, $site->newsitems);
136          break;
137     
138          case FRONTPAGECOURSELIST:
139          case FRONTPAGECATEGORYNAMES:
140              if (isset($USER->id) and !isset($USER->admin)) {
141                  print_heading_block(get_string("mycourses"));
142                  print_spacer(8,1);
143                  print_my_moodle();
144              } else {
145                  print_heading_block(get_string("availablecourses"));
146                  print_spacer(8,1);
147                  if (count_records("course_categories") > 1) {
148                      print_simple_box_start("center", "100%");
149                      print_whole_category_list();
150                      print_simple_box_end();
151                  } else {
152                      print_courses(0, "100%");
153                  }
154              }
155          break;
157      }
159      echo "</td>";
161      if ($lastcolumn) {
162          echo "<td width=\"30%\" valign=\"top\">";
163          print_simple_box($site->summary, "", "100%", $THEME->cellcontent2, 5, "siteinfo");
164          print_spacer(1,$side);
165          echo "</td>";
166      }
167   ?>
169   </tr>
170 </table>
172 <?PHP print_footer("home");     // Please do not modify this line ?>