new string merged from stable
[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
45 echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
46 echo '<tr valign="top">';
47
48
49 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
50
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">';
eb1ed650 53 if (!empty($THEME->customcorners)) print_custom_corners_start();
0d6b9d4f 54 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
eb1ed650 55 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 56 echo '</td>';
57 }
58
a06c8c2c 59 echo '<td valign="top" id="middle-column">';
8986786c 60 if (!empty($THEME->customcorners)) print_custom_corners_start(TRUE);
3131d5c6 61
62/// The main overview in the middle of the page
797c881a 63
64 // limits the number of courses showing up
374bb2b6 65 $courses = get_my_courses($USER->id, null, '*', false, 21);
3131d5c6 66 $site = get_site();
9b02b534 67 $course = $site; //just in case we need the old global $course hack
3131d5c6 68
69 if (array_key_exists($site->id,$courses)) {
70 unset($courses[$site->id]);
71 }
72
9b02b534 73 foreach ($courses as $c) {
40cab82e 74 if (isset($USER->lastcourseaccess[$c->id])) {
75 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
3131d5c6 76 } else {
9b02b534 77 $courses[$c->id]->lastaccess = 0;
3131d5c6 78 }
79 }
80
81 if (empty($courses)) {
82 print_simple_box(get_string('nocourses','my'),'center');
83 } else {
84 print_overview($courses);
85 }
797c881a 86
87 // if more than 20 courses
88 if (count($courses) > 20) {
89 echo '<br />...';
90 }
3131d5c6 91
eb1ed650 92 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 93 echo '</td>';
94
95 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
96
3131d5c6 97 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
0d6b9d4f 98 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
eb1ed650 99 if (!empty($THEME->customcorners)) print_custom_corners_start();
0d6b9d4f 100 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
eb1ed650 101 if (!empty($THEME->customcorners)) print_custom_corners_end();
0d6b9d4f 102 echo '</td>';
103 }
104
105
106 /// Finish the page
107 echo '</tr></table>';
108
109 print_footer();
110
3131d5c6 111?>