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');
12 $mymoodlestr = get_string('mymoodle','my');
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
);
27 // Bounds for block widths
28 // more flexible for theme designers taken from theme config.php
29 $lmin = (empty($THEME->block_l_min_width
)) ?
100 : $THEME->block_l_min_width
;
30 $lmax = (empty($THEME->block_l_max_width
)) ?
210 : $THEME->block_l_max_width
;
31 $rmin = (empty($THEME->block_r_min_width
)) ?
100 : $THEME->block_r_min_width
;
32 $rmax = (empty($THEME->block_r_max_width
)) ?
210 : $THEME->block_r_max_width
;
34 define('BLOCK_L_MIN_WIDTH', $lmin);
35 define('BLOCK_L_MAX_WIDTH', $lmax);
36 define('BLOCK_R_MIN_WIDTH', $rmin);
37 define('BLOCK_R_MAX_WIDTH', $rmax);
39 $edit = optional_param('edit', -1, PARAM_BOOL
);
40 $blockaction = optional_param('blockaction', '', PARAM_ALPHA
);
42 $PAGE = page_create_instance($USER->id
);
44 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH
);
46 if (($edit != -1) and $PAGE->user_allowed_editing()) {
47 $USER->editing
= $edit;
50 $PAGE->print_header($mymoodlestr);
52 echo '<table id="layout-table">';
53 echo '<tr valign="top">';
55 $lt = (empty($THEME->layouttable
)) ?
array('left', 'middle', 'right') : $THEME->layouttable
;
56 foreach ($lt as $column) {
60 $blocks_preferred_width = bounded_number(BLOCK_L_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]), BLOCK_L_MAX_WIDTH
);
62 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT
) ||
$PAGE->user_is_editing()) {
63 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
64 print_container_start();
65 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT
);
66 print_container_end();
73 echo '<td valign="top" id="middle-column">';
74 print_container_start(TRUE);
76 /// The main overview in the middle of the page
78 if (isset($CFG->mycoursesperpage
)) {
79 $courses_limit = $CFG->mycoursesperpage
;
83 if ($courses_limit > 0) {
84 $courses_limit = $courses_limit +
1;
87 $courses = get_my_courses($USER->id
, 'visible DESC,sortorder ASC', '*', false, $courses_limit);
89 $course = $site; //just in case we need the old global $course hack
91 if (($courses_limit > 0) && (count($courses) >= $courses_limit)) {
92 //remove the 'marker' course that we retrieve just to see if we have more than $courses_limit
97 if (array_key_exists($site->id
,$courses)) {
98 unset($courses[$site->id
]);
101 foreach ($courses as $c) {
102 if (isset($USER->lastcourseaccess
[$c->id
])) {
103 $courses[$c->id
]->lastaccess
= $USER->lastcourseaccess
[$c->id
];
105 $courses[$c->id
]->lastaccess
= 0;
109 if (empty($courses)) {
110 print_simple_box(get_string('nocourses','my'),'center');
112 print_overview($courses);
115 // if more than 20 courses
120 print_container_end();
126 $blocks_preferred_width = bounded_number(BLOCK_R_MIN_WIDTH
, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]), BLOCK_R_MAX_WIDTH
);
128 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT
) ||
$PAGE->user_is_editing()) {
129 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
130 print_container_start();
131 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT
);
132 print_container_end();
140 echo '</tr></table>';