Updated the HEAD build version to 20090805
[moodle.git] / my / index.php
CommitLineData
9b02b534 1<?php // $Id$
0d6b9d4f 2
3 // this is the 'my moodle' page
4
1b6b9400 5 require_once(dirname(__FILE__) . '/../config.php');
3131d5c6 6 require_once($CFG->dirroot.'/course/lib.php');
ad52c04f 7
0d6b9d4f 8 require_login();
9
1b6b9400 10 $strmymoodle = get_string('mymoodle','my');
fdaa6006 11
12 if (isguest()) {
1b6b9400 13 print_header($strmymoodle);
14 notice_yesno(get_string('noguest', 'my') . '<br /><br />' .
15 get_string('liketologin'), get_login_url(), $CFG->wwwroot);
fdaa6006 16 print_footer();
1b6b9400 17 die;
fdaa6006 18 }
19
1b6b9400 20 $edit = optional_param('edit', -1, PARAM_BOOL);
d2b23346 21 $blockaction = optional_param('blockaction', '', PARAM_ALPHA);
0d6b9d4f 22
1b6b9400 23 $PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
ad52c04f 24 $PAGE->set_url('my/index.php');
cfcfb9f3 25 $PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
0d6b9d4f 26
d2b23346 27 if (($edit != -1) and $PAGE->user_allowed_editing()) {
28 $USER->editing = $edit;
0d6b9d4f 29 }
30
1b6b9400 31 $button = update_mymoodle_icon($USER->id);
32 $header = $SITE->shortname . ': ' . $strmymoodle;
33 $navigation = build_navigation($strmymoodle);
34 $loggedinas = user_login_string();
35
36 if (empty($CFG->langmenu)) {
37 $langmenu = '';
38 } else {
39 $currlang = current_language();
40 $langs = get_list_of_languages();
41 $langlabel = get_accesshide(get_string('language'));
42 $langmenu = popup_form($CFG->wwwroot . '/my/index.php?lang=', $langs,
43 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
44 }
45
46 print_header($strmymoodle, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
0d6b9d4f 47
3131d5c6 48/// The main overview in the middle of the page
d4a03c00 49
797c881a 50 // limits the number of courses showing up
ebb1a1e8 51 $courses_limit = 21;
8b8ff6ff 52 if (!empty($CFG->mycoursesperpage)) {
ebb1a1e8 53 $courses_limit = $CFG->mycoursesperpage;
54 }
497bad90 55 $courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, $courses_limit);
3131d5c6 56 $site = get_site();
9b02b534 57 $course = $site; //just in case we need the old global $course hack
3131d5c6 58
59 if (array_key_exists($site->id,$courses)) {
60 unset($courses[$site->id]);
61 }
62
9b02b534 63 foreach ($courses as $c) {
40cab82e 64 if (isset($USER->lastcourseaccess[$c->id])) {
65 $courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
3131d5c6 66 } else {
9b02b534 67 $courses[$c->id]->lastaccess = 0;
3131d5c6 68 }
69 }
d4a03c00 70
3131d5c6 71 if (empty($courses)) {
d4a03c00 72 print_box(get_string('nocourses','my'));
3131d5c6 73 } else {
74 print_overview($courses);
75 }
d4a03c00 76
797c881a 77 // if more than 20 courses
78 if (count($courses) > 20) {
79 echo '<br />...';
80 }
0d6b9d4f 81
82 print_footer();
83
3131d5c6 84?>