3 // block.php - allows admin to edit all local configuration variables for a block
5 require_once('../config.php');
6 require_once($CFG->libdir
.'/blocklib.php');
11 error('Only an admin can use this page');
13 if (!$site = get_site()) {
14 error("Site isn't defined!");
17 $blockid = required_param( 'block',PARAM_INT
);
19 if(($blockrecord = blocks_get_record($blockid)) === false) {
20 error('This block does not exist');
23 $block = block_instance($blockrecord->name
);
24 if($block === false) {
25 error('Problem in instantiating block object');
28 // Define the data we're going to silently include in the instance config form here,
29 // so we can strip them from the submitted data BEFORE handling it.
32 'sesskey' => $USER->sesskey
35 /// If data submitted, then process and store.
37 if ($config = data_submitted()) {
39 if (!confirm_sesskey()) {
40 error(get_string('confirmsesskeybad', 'error'));
42 if(!$block->has_config()) {
43 error('This block does not support global configuration');
45 $remove = array_keys($hiddendata);
46 foreach($remove as $item) {
47 unset($config->$item);
49 $block->config_save($config);
50 redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
54 /// Otherwise print the form.
56 $stradmin = get_string('administration');
57 $strconfiguration = get_string('configuration');
58 $strmanageblocks = get_string('manageblocks');
59 $strblockname = $block->get_title();
61 print_header($site->shortname
.': '.$strblockname.": $strconfiguration", $site->fullname
,
62 "<a href=\"index.php\">$stradmin</a> -> ".
63 "<a href=\"configure.php\">$strconfiguration</a> -> ".
64 "<a href=\"blocks.php\">$strmanageblocks</a> -> ".$strblockname);
66 print_heading($strblockname);
68 print_simple_box('<center>'.get_string('configwarning', 'admin').'</center>', 'center', '50%');
71 echo '<form method="post" action="block.php">';
73 foreach($hiddendata as $name => $val) {
74 echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
77 $block->config_print();