|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00032 require_once(dirname(__FILE__) . '/../config.php'); 00033 require_once($CFG->dirroot . '/my/lib.php'); 00034 require_once($CFG->libdir.'/adminlib.php'); 00035 00036 $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off 00037 00038 require_login(); 00039 00040 $context = get_context_instance(CONTEXT_SYSTEM); 00041 require_capability('moodle/my:configsyspages', $context); 00042 $PAGE->set_blocks_editing_capability('moodle/my:configsyspages'); 00043 $header = "$SITE->shortname: ".get_string('publicprofile')." (".get_string('myprofile', 'admin').")"; 00044 00045 // Start setting up the page 00046 $params = array(); 00047 $PAGE->set_url('/user/profilesys.php', $params); 00048 $PAGE->set_pagelayout('mydashboard'); 00049 $PAGE->set_pagetype('user-profile'); 00050 $PAGE->set_context($context); 00051 $PAGE->set_title($header); 00052 $PAGE->set_heading($header); 00053 $PAGE->blocks->add_region('content'); 00054 00055 // TODO: Make the page be selected properly in the Settings block 00056 00057 // Get the Public Profile page info. Should always return something unless the database is broken. 00058 if (!$currentpage = my_get_page(null, MY_PAGE_PUBLIC)) { 00059 print_error('publicprofilesetup'); 00060 } 00061 $PAGE->set_subpage($currentpage->id); 00062 00063 00064 // Toggle the editing state and switches 00065 if ($PAGE->user_allowed_editing()) { 00066 if ($edit !== null) { // Editing state was specified 00067 $USER->editing = $edit; // Change editing state 00068 } else { // Editing state is in session 00069 if (!empty($USER->editing)) { 00070 $edit = 1; 00071 } else { 00072 $edit = 0; 00073 } 00074 } 00075 00076 // Add button for editing page 00077 $params['edit'] = !$edit; 00078 00079 if (empty($edit)) { 00080 $editstring = get_string('updatemymoodleon'); 00081 } else { 00082 $editstring = get_string('updatemymoodleoff'); 00083 } 00084 00085 $url = new moodle_url("$CFG->wwwroot/user/profilesys.php", $params); 00086 $button = $OUTPUT->single_button($url, $editstring); 00087 $PAGE->set_button($button); 00088 00089 } else { 00090 $USER->editing = $edit = 0; 00091 } 00092 00093 echo $OUTPUT->header(); 00094 00095 echo $OUTPUT->blocks_for_region('content'); 00096 00097 echo $OUTPUT->footer();