Automatically generated installer lang files
[moodle.git] / my / indexsys.php
CommitLineData
03d9401e
MD
1<?php
2
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.
14//
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/>.
17
18/**
19 * My Moodle -- a user's personal dashboard
20 *
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
26 *
27 * This script implements the user's view of the dashboard, and allows editing
28 * of the dashboard.
29 *
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
36 */
37
38require_once(dirname(__FILE__) . '/../config.php');
39require_once($CFG->dirroot . '/my/lib.php');
40require_once($CFG->libdir.'/adminlib.php');
41
42$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off
43
44require_login();
45
03d9401e
MD
46$context = get_context_instance(CONTEXT_SYSTEM);
47require_capability('moodle/my:configsyspages', $context);
48$PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
bfe6fe45 49$header = "$SITE->shortname: ".get_string('myhome')." (".get_string('mypage', 'admin').")";
03d9401e
MD
50
51// Start setting up the page
52$params = array();
53$PAGE->set_url('/my/indexsys.php', $params);
54$PAGE->set_pagelayout('mydashboard');
55$PAGE->set_pagetype('my-index');
56$PAGE->set_context($context);
57$PAGE->set_title($header);
58$PAGE->set_heading($header);
59$PAGE->blocks->add_region('content');
60
bed59ff6 61// TODO: Make the page be selected properly in the Settings block
03d9401e
MD
62
63// Get the My Moodle page info. Should always return something unless the database is broken.
b8fa1826 64if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) {
03d9401e
MD
65 print_error('mymoodlesetup');
66}
67$PAGE->set_subpage($currentpage->id);
68
69
70// Toggle the editing state and switches
71if ($PAGE->user_allowed_editing()) {
72 if ($edit !== null) { // Editing state was specified
73 $USER->editing = $edit; // Change editing state
74 } else { // Editing state is in session
75 if (!empty($USER->editing)) {
76 $edit = 1;
77 } else {
78 $edit = 0;
79 }
80 }
81
82 // Add button for editing page
83 $params['edit'] = !$edit;
84
85 if (empty($edit)) {
86 $editstring = get_string('updatemymoodleon');
87 } else {
88 $editstring = get_string('updatemymoodleoff');
89 }
90
91 $url = new moodle_url("$CFG->wwwroot/my/indexsys.php", $params);
92 $button = $OUTPUT->single_button($url, $editstring);
93 $PAGE->set_button($button);
94
95} else {
96 $USER->editing = $edit = 0;
97}
98
03d9401e
MD
99echo $OUTPUT->header();
100
101echo $OUTPUT->blocks_for_region('content');
102
103echo $OUTPUT->footer();