MDL-12296:
[moodle-linuxchix.git] / my / index.php
blob151e230b9b72211ee8d8cdc7ac3e2711267a490a
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 if (!empty($THEME->customcorners)) {
11 require_once($CFG->dirroot.'/lib/custom_corners_lib.php');
14 require_login();
16 $mymoodlestr = get_string('mymoodle','my');
18 if (isguest()) {
19 $wwwroot = $CFG->wwwroot.'/login/index.php';
20 if (!empty($CFG->loginhttps)) {
21 $wwwroot = str_replace('http:','https:', $wwwroot);
24 print_header($mymoodlestr);
25 notice_yesno(get_string('noguest', 'my').'<br /><br />'.get_string('liketologin'),
26 $wwwroot, $CFG->wwwroot);
27 print_footer();
28 die();
32 $edit = optional_param('edit', -1, PARAM_BOOL);
33 $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
35 $PAGE = page_create_instance($USER->id);
37 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
39 if (($edit != -1) and $PAGE->user_allowed_editing()) {
40 $USER->editing = $edit;
43 $PAGE->print_header($mymoodlestr);
45 echo '<table id="layout-table">';
46 echo '<tr valign="top">';
48 $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
49 foreach ($lt as $column) {
50 switch ($column) {
51 case 'left':
53 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
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">';
57 if (!empty($THEME->customcorners)) print_custom_corners_start();
58 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
59 if (!empty($THEME->customcorners)) print_custom_corners_end();
60 echo '</td>';
63 break;
64 case 'middle':
66 echo '<td valign="top" id="middle-column">';
67 if (!empty($THEME->customcorners)) print_custom_corners_start(TRUE);
69 /// The main overview in the middle of the page
71 // limits the number of courses showing up
72 $courses = get_my_courses($USER->id, null, '*', false, 21);
73 $site = get_site();
74 $course = $site; //just in case we need the old global $course hack
76 if (array_key_exists($site->id,$courses)) {
77 unset($courses[$site->id]);
80 foreach ($courses as $c) {
81 if (isset($USER->lastcourseaccess[$c->id])) {
82 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
83 } else {
84 $courses[$c->id]->lastaccess = 0;
88 if (empty($courses)) {
89 print_simple_box(get_string('nocourses','my'),'center');
90 } else {
91 print_overview($courses);
94 // if more than 20 courses
95 if (count($courses) > 20) {
96 echo '<br />...';
99 if (!empty($THEME->customcorners)) print_custom_corners_end();
100 echo '</td>';
102 break;
103 case 'right':
105 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
107 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
108 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
109 if (!empty($THEME->customcorners)) print_custom_corners_start();
110 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
111 if (!empty($THEME->customcorners)) print_custom_corners_end();
112 echo '</td>';
114 break;
118 /// Finish the page
119 echo '</tr></table>';
121 print_footer();