Skip to content

Commit

Permalink
Updated the configuration-handling logic to the same level as the new…
Browse files Browse the repository at this point in the history
… instance-

configuration handlers. Much more easy to use and precise.
  • Loading branch information
defacer committed Nov 19, 2004
1 parent 482dbe0 commit a177631
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions admin/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,30 @@
error('Problem in instantiating block object');
}

/// If data submitted, then process and store.
// Define the data we're going to silently include in the instance config form here,
// so we can strip them from the submitted data BEFORE handling it.
$hiddendata = array(
'block' => $blockid,
'sesskey' => $USER->sesskey
);

/// If data submitted, then process and store.

if ($config = data_submitted()) {
unset($config->block); // This will always be set if we have reached this point
$block->handle_config($config);
if(!$block->has_config()) {
error('This block does not support global configuration');
}
$remove = array_keys($hiddendata);
foreach($remove as $item) {
unset($config->$item);
}
$block->config_save($config);
print_header();
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
exit;
}

/// Otherwise print the form.
/// Otherwise print the form.

$stradmin = get_string('administration');
$strconfiguration = get_string('configuration');
Expand All @@ -57,8 +70,14 @@
print_simple_box('<center>'.get_string('configwarning').'</center>', 'center', '50%');
echo '<br />';

$block->print_config();

echo '<form method="post" action="block.php">';
echo '<p>';
foreach($hiddendata as $name => $val) {
echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
}
echo '</p>';
$block->config_print();
echo '</form>';
print_footer();

?>

0 comments on commit a177631

Please sign in to comment.