Merge branch 'MDL-64419-36' of git://github.com/bmbrands/moodle into MOODLE_36_STABLE
[moodle.git] / my / indexsys.php
bloba7bcdc27e0367450b7efd45d63a350a4f3c0be49
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
18 /**
19 * My Moodle -- a user's personal dashboard
21 * - each user can currently have their own page (cloned from system and then customised)
22 * - only the user can see their own dashboard
23 * - users can add any blocks they want
24 * - the administrators can define a default site dashboard for users who have
25 * not created their own dashboard
27 * This script implements the user's view of the dashboard, and allows editing
28 * of the dashboard.
30 * @package moodlecore
31 * @subpackage my
32 * @copyright 2010 Remote-Learner.net
33 * @author Hubert Chathi <hubert@remote-learner.net>
34 * @author Olav Jordan <olav.jordan@remote-learner.net>
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 require_once(__DIR__ . '/../config.php');
39 require_once($CFG->dirroot . '/my/lib.php');
40 require_once($CFG->libdir.'/adminlib.php');
42 $resetall = optional_param('resetall', null, PARAM_BOOL);
44 $header = "$SITE->shortname: ".get_string('myhome')." (".get_string('mypage', 'admin').")";
46 $PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
47 admin_externalpage_setup('mypage', '', null, '', array('pagelayout' => 'mydashboard'));
49 if ($resetall && confirm_sesskey()) {
50 my_reset_page_for_all_users(MY_PAGE_PRIVATE, 'my-index');
51 redirect($PAGE->url, get_string('alldashboardswerereset', 'my'));
54 // Override pagetype to show blocks properly.
55 $PAGE->set_pagetype('my-index');
57 $PAGE->set_title($header);
58 $PAGE->set_heading($header);
59 $PAGE->blocks->add_region('content');
61 // Get the My Moodle page info. Should always return something unless the database is broken.
62 if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) {
63 print_error('mymoodlesetup');
65 $PAGE->set_subpage($currentpage->id);
67 // Display a button to reset everyone's dashboard.
68 $url = new moodle_url($PAGE->url, array('resetall' => 1));
69 $button = $OUTPUT->single_button($url, get_string('reseteveryonesdashboard', 'my'));
70 $PAGE->set_button($button . $PAGE->button);
72 echo $OUTPUT->header();
74 echo $OUTPUT->custom_block_region('content');
76 echo $OUTPUT->footer();