OKAY! THIS IS IT! MOODLE 1.6!
[moodle.git] / my / index.php
blob919a0e1abfbe9baeba9e7881f32deb5815021333
1 <?php // $Id$
3 // this is the 'my moodle' page
5 require_once('../config.php');
6 require_once($CFG->libdir.'/blocklib.php');
7 require_once($CFG->dirroot.'/course/lib.php');
8 require_once('pagelib.php');
10 require_login();
12 $mymoodlestr = get_string('mymoodle','my');
14 if (isguest()) {
15 $wwwroot = $CFG->wwwroot.'/login/index.php';
16 if (!empty($CFG->loginhttps)) {
17 $wwwroot = str_replace('http:','https:', $wwwroot);
20 print_header($mymoodlestr);
21 notice_yesno(get_string('noguest', 'my').'<br /><br />'.get_string('liketologin'),
22 $wwwroot, $CFG->wwwroot);
23 print_footer();
24 die();
28 $edit = optional_param('edit', -1, PARAM_BOOL);
29 $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
31 $PAGE = page_create_instance($USER->id);
33 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
35 if (($edit != -1) and $PAGE->user_allowed_editing()) {
36 $USER->editing = $edit;
39 $PAGE->print_header($mymoodlestr);
41 echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
42 echo '<tr valign="top">';
45 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
47 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
48 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
49 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
50 echo '</td>';
53 echo '<td valign="top" width="*" id="middle-column">';
55 /// The main overview in the middle of the page
56 $courses = get_my_courses($USER->id);
57 $site = get_site();
58 $course = $site; //just in case we need the old global $course hack
60 if (array_key_exists($site->id,$courses)) {
61 unset($courses[$site->id]);
64 foreach ($courses as $c) {
65 if (isset($USER->timeaccess) && array_key_exists($c->id,$USER->timeaccess)) {
66 $courses[$c->id]->lastaccess = $USER->timeaccess[$c->id];
67 } else {
68 $courses[$c->id]->lastaccess = 0;
72 if (empty($courses)) {
73 print_simple_box(get_string('nocourses','my'),'center');
74 } else {
75 print_overview($courses);
79 echo '</td>';
81 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
83 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
84 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
85 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
86 echo '</td>';
90 /// Finish the page
91 echo '</tr></table>';
93 print_footer();