2004-04-18 23:20:53 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
|
|
|
|
// block.php - allows admin to edit all local configuration variables for a block
|
|
|
|
|
|
|
|
require_once('../config.php');
|
2006-09-02 13:14:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2004-04-18 23:20:53 +00:00
|
|
|
require_once($CFG->libdir.'/blocklib.php');
|
|
|
|
|
2006-03-06 10:02:59 +00:00
|
|
|
$blockid = required_param('block', PARAM_INT);
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
if(!$blockrecord = blocks_get_record($blockid)) {
|
2008-04-09 08:21:51 +00:00
|
|
|
print_error('blockdoesnotexist', 'error');
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2007-12-19 17:35:20 +00:00
|
|
|
admin_externalpage_setup('blocksetting'.$blockrecord->name);
|
|
|
|
|
2004-10-19 21:04:28 +00:00
|
|
|
$block = block_instance($blockrecord->name);
|
2004-04-18 23:20:53 +00:00
|
|
|
if($block === false) {
|
2008-04-09 08:21:51 +00:00
|
|
|
print_error('blockcannotinistantiate', 'error');
|
2004-04-18 23:20:53 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 03:01:31 +00:00
|
|
|
// 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,
|
2009-01-02 10:43:12 +00:00
|
|
|
'sesskey' => sesskey()
|
2004-11-19 03:01:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
/// If data submitted, then process and store.
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-10-02 23:15:51 +00:00
|
|
|
if ($config = data_submitted()) {
|
2005-01-22 19:53:28 +00:00
|
|
|
|
|
|
|
if (!confirm_sesskey()) {
|
2008-04-04 02:54:20 +00:00
|
|
|
print_error('confirmsesskeybad', 'error');
|
2005-01-22 19:53:28 +00:00
|
|
|
}
|
2004-11-19 03:01:31 +00:00
|
|
|
if(!$block->has_config()) {
|
2008-04-09 08:21:51 +00:00
|
|
|
print_error('blockcannotconfig', 'error');
|
2004-11-19 03:01:31 +00:00
|
|
|
}
|
|
|
|
$remove = array_keys($hiddendata);
|
|
|
|
foreach($remove as $item) {
|
|
|
|
unset($config->$item);
|
|
|
|
}
|
|
|
|
$block->config_save($config);
|
2004-04-18 23:20:53 +00:00
|
|
|
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
|
|
|
exit;
|
2004-10-02 23:15:51 +00:00
|
|
|
}
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2004-11-19 03:01:31 +00:00
|
|
|
/// Otherwise print the form.
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
$strmanageblocks = get_string('manageblocks');
|
|
|
|
$strblockname = $block->get_title();
|
2006-09-20 21:00:45 +00:00
|
|
|
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_print_header();
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
print_heading($strblockname);
|
|
|
|
|
2007-04-20 07:54:42 +00:00
|
|
|
print_simple_box(get_string('configwarning', 'admin'), 'center', '50%');
|
2004-04-18 23:20:53 +00:00
|
|
|
echo '<br />';
|
|
|
|
|
2004-11-19 03:01:31 +00:00
|
|
|
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>';
|
2007-12-19 17:35:20 +00:00
|
|
|
print_footer();
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
?>
|