| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: settings.php,v 1.40.2.4 2008/04/02 06:09:57 dongsheng Exp $ 2 3 require_once ('../config.php'); 4 require_once($CFG->libdir.'/adminlib.php'); 5 require_once($CFG->libdir.'/blocklib.php'); 6 require_once($CFG->dirroot.'/'.$CFG->admin.'/pagelib.php'); 7 8 $section = required_param('section', PARAM_SAFEDIR); 9 $return = optional_param('return','', PARAM_ALPHA); 10 $adminediting = optional_param('adminedit', -1, PARAM_BOOL); 11 12 /// no guest autologin 13 require_login(0, false); 14 15 $adminroot =& admin_get_root(); // need all settings 16 $page =& $adminroot->locate($section); 17 18 if (empty($page) or !is_a($page, 'admin_settingpage')) { 19 print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/"); 20 die; 21 } 22 23 if (!($page->check_access())) { 24 print_error('accessdenied', 'admin'); 25 die; 26 } 27 28 /// WRITING SUBMITTED DATA (IF ANY) ------------------------------------------------------------------------------- 29 30 $statusmsg = ''; 31 $errormsg = ''; 32 $focus = ''; 33 34 if ($data = data_submitted() and confirm_sesskey()) { 35 if (admin_write_settings($data)) { 36 $statusmsg = get_string('changessaved'); 37 } 38 39 if (empty($adminroot->errors)) { 40 switch ($return) { 41 case 'site': redirect("$CFG->wwwroot/"); 42 case 'admin': redirect("$CFG->wwwroot/$CFG->admin/"); 43 } 44 } else { 45 $errormsg = get_string('errorwithsettings', 'admin'); 46 $firsterror = reset($adminroot->errors); 47 $focus = $firsterror->id; 48 } 49 $adminroot =& admin_get_root(true); //reload tree 50 $page =& $adminroot->locate($section); 51 } 52 53 /// very hacky page setup 54 page_map_class(PAGE_ADMIN, 'page_admin'); 55 $PAGE = page_create_object(PAGE_ADMIN, 0); // there must be any constant id number 56 $PAGE->init_extra($section); 57 $CFG->pagepath = 'admin/setting/'.$section; 58 59 if (!isset($USER->adminediting)) { 60 $USER->adminediting = false; 61 } 62 63 if ($PAGE->user_allowed_editing()) { 64 if ($adminediting == 1) { 65 $USER->adminediting = true; 66 } elseif ($adminediting == 0) { 67 $USER->adminediting = false; 68 } 69 } 70 71 72 /// print header stuff ------------------------------------------------------------ 73 74 if (empty($SITE->fullname)) { 75 print_header($page->visiblename, $page->visiblename, '', $focus); 76 print_simple_box(get_string('configintrosite', 'admin'), 'center', '50%'); 77 78 if ($errormsg !== '') { 79 notify ($errormsg); 80 81 } else if ($statusmsg !== '') { 82 notify ($statusmsg, 'notifysuccess'); 83 } 84 85 // --------------------------------------------------------------------------------------------------------------- 86 87 echo '<form action="settings.php" method="post" id="adminsettings">'; 88 echo '<div class="settingsform clearfix">'; 89 echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />'; 90 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'; 91 echo '<input type="hidden" name="return" value="'.$return.'" />'; 92 93 echo $page->output_html(); 94 95 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>'; 96 97 echo '</div>'; 98 echo '</form>'; 99 100 } else { 101 $pageblocks = blocks_setup($PAGE); 102 103 $preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 104 BLOCK_L_MAX_WIDTH); 105 $preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 106 BLOCK_R_MAX_WIDTH); 107 108 $PAGE->print_header('', $focus); 109 110 echo '<table id="layout-table"><tr>'; 111 $lt = (empty($THEME->layouttable)) ? array('left', 'middle', 'right') : $THEME->layouttable; 112 foreach ($lt as $column) { 113 switch ($column) { 114 case 'left': 115 echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">'; 116 print_container_start(); 117 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT); 118 print_container_end(); 119 echo '</td>'; 120 break; 121 case 'middle': 122 echo '<td id="middle-column">'; 123 print_container_start(); 124 echo '<a name="startofcontent"></a>'; 125 126 if ($errormsg !== '') { 127 notify ($errormsg); 128 129 } else if ($statusmsg !== '') { 130 notify ($statusmsg, 'notifysuccess'); 131 } 132 133 // --------------------------------------------------------------------------------------------------------------- 134 135 echo '<form action="settings.php" method="post" id="adminsettings">'; 136 echo '<div class="settingsform clearfix">'; 137 echo '<input type="hidden" name="section" value="'.$PAGE->section.'" />'; 138 echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'; 139 echo '<input type="hidden" name="return" value="'.$return.'" />'; 140 print_heading($page->visiblename); 141 142 echo $page->output_html(); 143 144 echo '<div class="form-buttons"><input class="form-submit" type="submit" value="'.get_string('savechanges','admin').'" /></div>'; 145 146 echo '</div>'; 147 echo '</form>'; 148 149 print_container_end(); 150 echo '</td>'; 151 break; 152 case 'right': 153 if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT)) { 154 echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">'; 155 print_container_start(); 156 blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT); 157 print_container_end(); 158 echo '</td>'; 159 } 160 break; 161 } 162 } 163 echo '</tr></table>'; 164 } 165 166 if (!empty($CFG->adminusehtmleditor)) { 167 use_html_editor(); 168 } 169 170 print_footer(); 171 172 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |