2006-05-29 05:56:28 +00:00
|
|
|
<?php // $Id$
|
2005-08-16 00:25:39 +00:00
|
|
|
|
|
|
|
// this is the 'my moodle' page
|
|
|
|
|
2009-05-06 09:23:37 +00:00
|
|
|
require_once(dirname(__FILE__) . '/../config.php');
|
2006-04-25 13:19:52 +00:00
|
|
|
require_once($CFG->dirroot.'/course/lib.php');
|
2009-05-06 08:55:53 +00:00
|
|
|
|
2005-08-16 00:25:39 +00:00
|
|
|
require_login();
|
|
|
|
|
2009-05-06 09:23:37 +00:00
|
|
|
$strmymoodle = get_string('mymoodle','my');
|
2005-10-30 20:10:43 +00:00
|
|
|
|
|
|
|
if (isguest()) {
|
2009-05-06 09:23:37 +00:00
|
|
|
print_header($strmymoodle);
|
|
|
|
notice_yesno(get_string('noguest', 'my') . '<br /><br />' .
|
|
|
|
get_string('liketologin'), get_login_url(), $CFG->wwwroot);
|
2005-10-30 20:10:43 +00:00
|
|
|
print_footer();
|
2009-05-06 09:23:37 +00:00
|
|
|
die;
|
2005-10-30 20:10:43 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:23:37 +00:00
|
|
|
$edit = optional_param('edit', -1, PARAM_BOOL);
|
2006-04-23 20:58:06 +00:00
|
|
|
$blockaction = optional_param('blockaction', '', PARAM_ALPHA);
|
2005-08-16 00:25:39 +00:00
|
|
|
|
2009-05-06 09:23:37 +00:00
|
|
|
$PAGE->set_context(get_context_instance(CONTEXT_USER, $USER->id));
|
2009-05-06 08:55:53 +00:00
|
|
|
$PAGE->set_url('my/index.php');
|
2009-05-06 09:02:48 +00:00
|
|
|
$PAGE->set_blocks_editing_capability('moodle/my:manageblocks');
|
2005-08-16 00:25:39 +00:00
|
|
|
|
2006-04-23 20:58:06 +00:00
|
|
|
if (($edit != -1) and $PAGE->user_allowed_editing()) {
|
|
|
|
$USER->editing = $edit;
|
2005-08-16 00:25:39 +00:00
|
|
|
}
|
|
|
|
|
2009-05-06 09:23:37 +00:00
|
|
|
$button = update_mymoodle_icon($USER->id);
|
|
|
|
$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);
|
2005-08-16 00:25:39 +00:00
|
|
|
|
2006-04-25 13:19:52 +00:00
|
|
|
/// The main overview in the middle of the page
|
2009-07-09 07:35:03 +00:00
|
|
|
|
2007-02-13 04:09:11 +00:00
|
|
|
// limits the number of courses showing up
|
2009-04-01 07:32:57 +00:00
|
|
|
$courses_limit = 21;
|
2009-04-02 02:49:54 +00:00
|
|
|
if (!empty($CFG->mycoursesperpage)) {
|
2009-04-01 07:32:57 +00:00
|
|
|
$courses_limit = $CFG->mycoursesperpage;
|
|
|
|
}
|
2009-04-01 07:38:32 +00:00
|
|
|
$courses = get_my_courses($USER->id, 'visible DESC,sortorder ASC', '*', false, $courses_limit);
|
2006-04-25 13:19:52 +00:00
|
|
|
$site = get_site();
|
2006-05-29 05:56:28 +00:00
|
|
|
$course = $site; //just in case we need the old global $course hack
|
2006-04-25 13:19:52 +00:00
|
|
|
|
|
|
|
if (array_key_exists($site->id,$courses)) {
|
|
|
|
unset($courses[$site->id]);
|
|
|
|
}
|
|
|
|
|
2006-05-29 05:56:28 +00:00
|
|
|
foreach ($courses as $c) {
|
2006-12-05 07:00:43 +00:00
|
|
|
if (isset($USER->lastcourseaccess[$c->id])) {
|
|
|
|
$courses[$c->id]->lastaccess = $USER->lastcourseaccess[$c->id];
|
2006-04-25 13:19:52 +00:00
|
|
|
} else {
|
2006-05-29 05:56:28 +00:00
|
|
|
$courses[$c->id]->lastaccess = 0;
|
2006-04-25 13:19:52 +00:00
|
|
|
}
|
|
|
|
}
|
2009-07-09 07:35:03 +00:00
|
|
|
|
2006-04-25 13:19:52 +00:00
|
|
|
if (empty($courses)) {
|
2009-07-09 07:35:03 +00:00
|
|
|
print_box(get_string('nocourses','my'));
|
2006-04-25 13:19:52 +00:00
|
|
|
} else {
|
|
|
|
print_overview($courses);
|
|
|
|
}
|
2009-07-09 07:35:03 +00:00
|
|
|
|
2007-02-13 04:09:11 +00:00
|
|
|
// if more than 20 courses
|
|
|
|
if (count($courses) > 20) {
|
|
|
|
echo '<br />...';
|
|
|
|
}
|
2005-08-16 00:25:39 +00:00
|
|
|
|
|
|
|
print_footer();
|
|
|
|
|
2006-04-25 13:19:52 +00:00
|
|
|
?>
|