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