| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?PHP // $Id: block.php,v 1.18.4.2 2008/04/02 06:09:57 dongsheng Exp $ 2 3 // block.php - allows admin to edit all local configuration variables for a block 4 5 require_once ('../config.php'); 6 require_once($CFG->libdir.'/adminlib.php'); 7 require_once($CFG->libdir.'/blocklib.php'); 8 9 $blockid = required_param('block', PARAM_INT); 10 11 if(!$blockrecord = blocks_get_record($blockid)) { 12 error('This block does not exist'); 13 } 14 15 admin_externalpage_setup('blocksetting'.$blockrecord->name); 16 17 $block = block_instance($blockrecord->name); 18 if($block === false) { 19 error('Problem in instantiating block object'); 20 } 21 22 // Define the data we're going to silently include in the instance config form here, 23 // so we can strip them from the submitted data BEFORE handling it. 24 $hiddendata = array( 25 'block' => $blockid, 26 'sesskey' => $USER->sesskey 27 ); 28 29 /// If data submitted, then process and store. 30 31 if ($config = data_submitted()) { 32 33 if (!confirm_sesskey()) { 34 print_error('confirmsesskeybad', 'error'); 35 } 36 if(!$block->has_config()) { 37 error('This block does not support global configuration'); 38 } 39 $remove = array_keys($hiddendata); 40 foreach($remove as $item) { 41 unset($config->$item); 42 } 43 $block->config_save($config); 44 redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1); 45 exit; 46 } 47 48 /// Otherwise print the form. 49 50 $strmanageblocks = get_string('manageblocks'); 51 $strblockname = $block->get_title(); 52 53 admin_externalpage_print_header(); 54 55 print_heading($strblockname); 56 57 print_simple_box(get_string('configwarning', 'admin'), 'center', '50%'); 58 echo '<br />'; 59 60 echo '<form method="post" action="block.php">'; 61 echo '<p>'; 62 foreach($hiddendata as $name => $val) { 63 echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />'; 64 } 65 echo '</p>'; 66 $block->config_print(); 67 echo '</form>'; 68 print_footer(); 69 70 ?>
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 |