Merge branch 'MDL-33554' of git://github.com/mouneyrac/moodle
[moodle.git] / user / profilesys.php
blob79740ef311e8c9ce99d3fa1c8a19cbd05e419379
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 * System Public Profile.
21 * This script allows the site administrator to edit the default site
22 * profile.
24 * @package moodlecore
25 * @subpackage my
26 * @copyright 2010 Remote-Learner.net
27 * @author Hubert Chathi <hubert@remote-learner.net>
28 * @author Olav Jordan <olav.jordan@remote-learner.net>
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 require_once(dirname(__FILE__) . '/../config.php');
33 require_once($CFG->dirroot . '/my/lib.php');
34 require_once($CFG->libdir.'/adminlib.php');
36 $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off
38 require_login();
40 $context = get_context_instance(CONTEXT_SYSTEM);
41 require_capability('moodle/my:configsyspages', $context);
42 $PAGE->set_blocks_editing_capability('moodle/my:configsyspages');
43 $header = "$SITE->shortname: ".get_string('publicprofile')." (".get_string('myprofile', 'admin').")";
45 // Start setting up the page
46 $params = array();
47 $PAGE->set_url('/user/profilesys.php', $params);
48 $PAGE->set_pagelayout('mydashboard');
49 $PAGE->set_pagetype('user-profile');
50 $PAGE->set_context($context);
51 $PAGE->set_title($header);
52 $PAGE->set_heading($header);
53 $PAGE->blocks->add_region('content');
55 // TODO: Make the page be selected properly in the Settings block
57 // Get the Public Profile page info. Should always return something unless the database is broken.
58 if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) {
59 print_error('publicprofilesetup');
61 $PAGE->set_subpage($currentpage->id);
64 // Toggle the editing state and switches
65 if ($PAGE->user_allowed_editing()) {
66 if ($edit !== null) { // Editing state was specified
67 $USER->editing = $edit; // Change editing state
68 } else { // Editing state is in session
69 if (!empty($USER->editing)) {
70 $edit = 1;
71 } else {
72 $edit = 0;
76 // Add button for editing page
77 $params['edit'] = !$edit;
79 if (empty($edit)) {
80 $editstring = get_string('updatemymoodleon');
81 } else {
82 $editstring = get_string('updatemymoodleoff');
85 $url = new moodle_url("$CFG->wwwroot/user/profilesys.php", $params);
86 $button = $OUTPUT->single_button($url, $editstring);
87 $PAGE->set_button($button);
89 } else {
90 $USER->editing = $edit = 0;
93 echo $OUTPUT->header();
95 echo $OUTPUT->blocks_for_region('content');
97 echo $OUTPUT->footer();