MDL-10689:
[moodle-linuxchix.git] / my / index.php
blobb83209292bb928b83ddc834e5bb56358c4437982
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 border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
46 echo '<tr valign="top">';
49 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
51 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
52 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
53 if (!empty($THEME->customcorners)) print_custom_corners_start();
54 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
55 if (!empty($THEME->customcorners)) print_custom_corners_end();
56 echo '</td>';
59 echo '<td valign="top" id="middle-column">';
60 if (!empty($THEME->customcorners)) print_custom_corners_start(TRUE);
62 /// The main overview in the middle of the page
64 // limits the number of courses showing up
65 $courses = get_my_courses($USER->id, null, '*', false, 21);
66 $site = get_site();
67 $course = $site; //just in case we need the old global $course hack
69 if (array_key_exists($site->id,$courses)) {
70 unset($courses[$site->id]);
73 foreach ($courses as $c) {
74 if (isset($USER->lastcourseaccess[$c->id])) {
75 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
76 } else {
77 $courses[$c->id]->lastaccess = 0;
81 if (empty($courses)) {
82 print_simple_box(get_string('nocourses','my'),'center');
83 } else {
84 print_overview($courses);
87 // if more than 20 courses
88 if (count($courses) > 20) {
89 echo '<br />...';
92 if (!empty($THEME->customcorners)) print_custom_corners_end();
93 echo '</td>';
95 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
97 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
98 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
99 if (!empty($THEME->customcorners)) print_custom_corners_start();
100 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
101 if (!empty($THEME->customcorners)) print_custom_corners_end();
102 echo '</td>';
106 /// Finish the page
107 echo '</tr></table>';
109 print_footer();