forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
96 lines (75 loc) · 2.83 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php // $Id$
// this is the 'my moodle' page
require_once(dirname(__FILE__) . '/../config.php');
require_once($CFG->dirroot.'/course/lib.php');
require_login();
$strmymoodle = get_string('mymoodle','my');
if (isguest()) {
print_header($strmymoodle);
notice_yesno(get_string('noguest', 'my') . '<br /><br />' .
get_string('liketologin'), get_login_url(), $CFG->wwwroot);
echo $OUTPUT->footer();
die;
}
$edit = optional_param('edit', -1, PARAM_BOOL);
$blockaction = optional_param('blockaction', '', PARAM_ALPHA);
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
$PAGE->set_url('my/index.php');
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
if (($edit != -1) and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
if (!empty($USER->editing)) {
$string = get_string('updatemymoodleoff');
$edit = '0';
} else {
$string = get_string('updatemymoodleon');
$edit = '1';
}
$form = new html_form();
$form->url = new moodle_url("$CFG->wwwroot/my/index.php", array('edit' => $edit));
$form->button->text = $string;
$button = $OUTPUT->button($form);
$header = $SITE->shortname . ': ' . $strmymoodle;
$navigation = build_navigation($strmymoodle);
$loggedinas = user_login_string();
if (empty($CFG->langmenu)) {
$langmenu = '';
} else {
$currlang = current_language();
$langs = get_list_of_languages();
$langlabel = get_accesshide(get_string('language'));
$langmenu = popup_form($CFG->wwwroot . '/my/index.php?lang=', $langs,
'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
}
print_header($strmymoodle, $header, $navigation, '', '', true, $button, $loggedinas . $langmenu);
/// The main overview in the middle of the page
// limits the number of courses showing up
$courses_limit = 21;
if (!empty($CFG->mycoursesperpage)) {
$courses_limit = $CFG->mycoursesperpage;
}
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, $courses_limit);
$site = get_site();
$course = $site; //just in case we need the old global $course hack
if (array_key_exists($site->id,$courses)) {
unset($courses[$site->id]);
}
foreach ($courses as $c) {
if (isset($USER->lastcourseaccess[$c->id])) {
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
} else {
$courses[$c->id]->lastaccess = 0;
}
}
if (empty($courses)) {
print_box(get_string('nocourses','my'));
} else {
print_overview($courses);
}
// if more than 20 courses
if (count($courses) > 20) {
echo '<br />...';
}
echo $OUTPUT->footer();
?>