"REPOSITORY/MDL-17466, display which plugin is valid"
[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
0d6b9d4f 10 require_login();
11
fdaa6006 12 $mymoodlestr = get_string('mymoodle','my');
13
14 if (isguest()) {
fdaa6006 15 print_header($mymoodlestr);
16 notice_yesno(get_string('noguest', 'my').'<br /><br />'.get_string('liketologin'),
93f66983 17 get_login_url(), $CFG->wwwroot);
fdaa6006 18 print_footer();
19 die();
20 }
21
22
d2b23346 23 $edit = optional_param('edit', -1, PARAM_BOOL);
24 $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
0d6b9d4f 25
26 $PAGE = page_create_instance($USER->id);
27
ee6055eb 28 $pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
0d6b9d4f 29
d2b23346 30 if (($edit != -1) and $PAGE->user_allowed_editing()) {
31 $USER->editing = $edit;
0d6b9d4f 32 }
33
fdaa6006 34 $PAGE->print_header($mymoodlestr);
0d6b9d4f 35
355bf907 36 echo '<table id="layout-table">';
0d6b9d4f 37 echo '<tr valign="top">';
38
355bf907 39 $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable;
40 foreach ($lt as $column) {
41 switch ($column) {
42 case 'left':
0d6b9d4f 43
44 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
45
46 if(blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
47 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="left-column">';
9f7f1a74 48 print_container_start();
0d6b9d4f 49 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
9f7f1a74 50 print_container_end();
0d6b9d4f 51 echo '</td>';
52 }
355bf907 53
54 break;
55 case 'middle':
56
a06c8c2c 57 echo '<td valign="top" id="middle-column">';
9f7f1a74 58 print_container_start(TRUE);
3131d5c6 59
60/// The main overview in the middle of the page
797c881a 61
62 // limits the number of courses showing up
0a5a5755 63 $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, 21);
3131d5c6 64 $site = get_site();
9b02b534 65 $course = $site; //just in case we need the old global $course hack
3131d5c6 66
67 if (array_key_exists($site->id,$courses)) {
68 unset($courses[$site->id]);
69 }
70
9b02b534 71 foreach ($courses as $c) {
40cab82e 72 if (isset($USER->lastcourseaccess[$c->id])) {
73 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
3131d5c6 74 } else {
9b02b534 75 $courses[$c->id]->lastaccess = 0;
3131d5c6 76 }
77 }
78
79 if (empty($courses)) {
80 print_simple_box(get_string('nocourses','my'),'center');
81 } else {
82 print_overview($courses);
83 }
797c881a 84
85 // if more than 20 courses
86 if (count($courses) > 20) {
87 echo '<br />...';
88 }
3131d5c6 89
9f7f1a74 90 print_container_end();
0d6b9d4f 91 echo '</td>';
355bf907 92
93 break;
94 case 'right':
95
0d6b9d4f 96 $blocks_preferred_width = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
97
3131d5c6 98 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing()) {
0d6b9d4f 99 echo '<td style="vertical-align: top; width: '.$blocks_preferred_width.'px;" id="right-column">';
9f7f1a74 100 print_container_start();
0d6b9d4f 101 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
9f7f1a74 102 print_container_end();
0d6b9d4f 103 echo '</td>';
104 }
355bf907 105 break;
106 }
107 }
0d6b9d4f 108
109 /// Finish the page
110 echo '</tr></table>';
111
112 print_footer();
113
3131d5c6 114?>