2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2004-04-18 23:20:53 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
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
|
|
|
|
2010-03-31 08:05:53 +00:00
|
|
|
echo $OUTPUT->header();
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2009-08-06 08:17:12 +00:00
|
|
|
echo $OUTPUT->heading($strblockname);
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
|
2009-07-15 08:52:33 +00:00
|
|
|
'It must be updated by a developer to use a settings.php file.');
|
|
|
|
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
|
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>';
|
2009-07-15 08:52:33 +00:00
|
|
|
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2009-07-15 08:52:33 +00:00
|
|
|
include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
|
2009-08-10 04:53:22 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2009-07-15 08:52:33 +00:00
|
|
|
|
2004-11-19 03:01:31 +00:00
|
|
|
echo '</form>';
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|
2004-04-18 23:20:53 +00:00
|
|
|
|
2009-11-01 10:57:00 +00:00
|
|
|
|