3 // block.php - allows admin to edit all local configuration variables for a block
5 require_once('../config.php');
6 require_once($CFG->libdir
.'/adminlib.php');
8 $blockid = required_param('block', PARAM_INT
);
10 if(!$blockrecord = blocks_get_record($blockid)) {
11 print_error('blockdoesnotexist', 'error');
14 admin_externalpage_setup('blocksetting'.$blockrecord->name
);
16 $block = block_instance($blockrecord->name
);
17 if($block === false) {
18 print_error('blockcannotinistantiate', 'error');
21 // Define the data we're going to silently include in the instance config form here,
22 // so we can strip them from the submitted data BEFORE handling it.
25 'sesskey' => sesskey()
28 /// If data submitted, then process and store.
30 if ($config = data_submitted()) {
32 if (!confirm_sesskey()) {
33 print_error('confirmsesskeybad', 'error');
35 if(!$block->has_config()) {
36 print_error('blockcannotconfig', 'error');
38 $remove = array_keys($hiddendata);
39 foreach($remove as $item) {
40 unset($config->$item);
42 $block->config_save($config);
43 redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
47 /// Otherwise print the form.
49 $strmanageblocks = get_string('manageblocks');
50 $strblockname = $block->get_title();
52 echo $OUTPUT->header();
54 echo $OUTPUT->heading($strblockname);
56 echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
57 'It must be updated by a developer to use a settings.php file.');
59 echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
62 echo '<form method="post" action="block.php">';
64 foreach($hiddendata as $name => $val) {
65 echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
69 echo $OUTPUT->box_start();
70 include($CFG->dirroot
.'/blocks/'. $block->name() .'/config_global.html');
71 echo $OUTPUT->box_end();
74 echo $OUTPUT->footer();