MDL-12296:
[moodle.git] / my / index.php
CommitLineData
9b02b534 1<?php // $Id$
0d6b9d4f 2
3 // this is the 'my moodle' page
4
5 require_once('../config.php');
6 require_once($CFG->libdir.'/blocklib.php');
3131d5c6 7 require_once($CFG->dirroot.'/course/lib.php');
0d6b9d4f 8 require_once('pagelib.php');
eb1ed650 9
10 if (!empty($THEME->customcorners)) {
11 require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
12 }
0d6b9d4f 13
14 require_login();
15
fdaa6006 16 $mymoodlestr = get_string('mymoodle','my');
17
18 if (isguest()) {
19 $wwwroot = $CFG->wwwroot.'/login/index.php';
20 if (!empty($CFG->loginhttps)) {
2c3432e6 21 $wwwroot = str_replace('http:','https:', $wwwroot);
fdaa6006 22 }
23
24 print_header($mymoodlestr);
25 notice_yesno(get_string('noguest', 'my').'<br /><br />'.get_string('liketologin'),
092dcfa4 26 $wwwroot, $CFG->wwwroot);
fdaa6006 27 print_footer();
28 die();
29 }
30
31
d2b23346 32 $edit = optional_param('edit', -1, PARAM_BOOL);
33 $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
0d6b9d4f 34
35 $PAGE = page_create_instance($USER->id);
36
ee6055eb 37 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
0d6b9d4f 38
d2b23346 39 if (($edit != -1) and $PAGE->user_allowed_editing()) {
40 $USER->editing = $edit;
0d6b9d4f 41 }
42
fdaa6006 43 $PAGE->print_header($mymoodlestr);
0d6b9d4f 44
355bf907 45 echo '<table id="layout-table">';
0d6b9d4f 46 echo '<tr valign="top">';
47
355bf907 48 $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
49 foreach ($lt as $column) {
50 switch ($column) {
51 case 'left':
0d6b9d4f 52
53 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
54
55 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
56 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
eb1ed650 57 if (!empty($THEME->customcorners)) print_custom_corners_start();
0d6b9d4f 58 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
eb1ed650 59 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 60 echo '</td>';
61 }
355bf907 62
63 break;
64 case 'middle':
65
a06c8c2c 66 echo '<td valign="top" id="middle-column">';
8986786c 67 if (!empty($THEME->customcorners)) print_custom_corners_start(TRUE);
3131d5c6 68
69/// The main overview in the middle of the page
797c881a 70
71 // limits the number of courses showing up
374bb2b6 72 $courses = get_my_courses($USER->id, null, '*', false, 21);
3131d5c6 73 $site = get_site();
9b02b534 74 $course = $site; //just in case we need the old global $course hack
3131d5c6 75
76 if (array_key_exists($site->id,$courses)) {
77 unset($courses[$site->id]);
78 }
79
9b02b534 80 foreach ($courses as $c) {
40cab82e 81 if (isset($USER->lastcourseaccess[$c->id])) {
82 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
3131d5c6 83 } else {
9b02b534 84 $courses[$c->id]->lastaccess = 0;
3131d5c6 85 }
86 }
87
88 if (empty($courses)) {
89 print_simple_box(get_string('nocourses','my'),'center');
90 } else {
91 print_overview($courses);
92 }
797c881a 93
94 // if more than 20 courses
95 if (count($courses) > 20) {
96 echo '<br />...';
97 }
3131d5c6 98
eb1ed650 99 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 100 echo '</td>';
355bf907 101
102 break;
103 case 'right':
104
0d6b9d4f 105 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
106
3131d5c6 107 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
0d6b9d4f 108 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
eb1ed650 109 if (!empty($THEME->customcorners)) print_custom_corners_start();
0d6b9d4f 110 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
eb1ed650 111 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 112 echo '</td>';
113 }
355bf907 114 break;
115 }
116 }
0d6b9d4f 117
118 /// Finish the page
119 echo '</tr></table>';
120
121 print_footer();
122
3131d5c6 123?>