|
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 00038 require_once(dirname(__FILE__) . '/../config.php'); 00039 require_once($CFG->dirroot . '/my/lib.php'); 00040 require_once($CFG->libdir.'/adminlib.php'); 00041 00042 $edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off 00043 00044 require_login(); 00045 00046 $context = get_context_instance(CONTEXT_SYSTEM); 00047 require_capability('moodle/my:configsyspages', $context); 00048 $PAGE->set_blocks_editing_capability('moodle/my:configsyspages'); 00049 $header = "$SITE->shortname: ".get_string('myhome')." (".get_string('mypage', 'admin').")"; 00050 00051 // Start setting up the page 00052 $params = array(); 00053 $PAGE->set_url('/my/indexsys.php', $params); 00054 $PAGE->set_pagelayout('mydashboard'); 00055 $PAGE->set_pagetype('my-index'); 00056 $PAGE->set_context($context); 00057 $PAGE->set_title($header); 00058 $PAGE->set_heading($header); 00059 $PAGE->blocks->add_region('content'); 00060 00061 // TODO: Make the page be selected properly in the Settings block 00062 00063 // Get the My Moodle page info. Should always return something unless the database is broken. 00064 if (!$currentpage = my_get_page(null, MY_PAGE_PRIVATE)) { 00065 print_error('mymoodlesetup'); 00066 } 00067 $PAGE->set_subpage($currentpage->id); 00068 00069 00070 // Toggle the editing state and switches 00071 if ($PAGE->user_allowed_editing()) { 00072 if ($edit !== null) { // Editing state was specified 00073 $USER->editing = $edit; // Change editing state 00074 } else { // Editing state is in session 00075 if (!empty($USER->editing)) { 00076 $edit = 1; 00077 } else { 00078 $edit = 0; 00079 } 00080 } 00081 00082 // Add button for editing page 00083 $params['edit'] = !$edit; 00084 00085 if (empty($edit)) { 00086 $editstring = get_string('updatemymoodleon'); 00087 } else { 00088 $editstring = get_string('updatemymoodleoff'); 00089 } 00090 00091 $url = new moodle_url("$CFG->wwwroot/my/indexsys.php", $params); 00092 $button = $OUTPUT->single_button($url, $editstring); 00093 $PAGE->set_button($button); 00094 00095 } else { 00096 $USER->editing = $edit = 0; 00097 } 00098 00099 echo $OUTPUT->header(); 00100 00101 echo $OUTPUT->blocks_for_region('content'); 00102 00103 echo $OUTPUT->footer();