Incorrect variable name - not sure why this worked!
[moodle-linuxchix.git] / admin / block.php
blob597530f56bb14ac4bec17355f27f59c315dd1382
1 <?PHP // $Id$
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');
8 require_login();
10 if (!isadmin()) {
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.
30 $hiddendata = array(
31 'block' => $blockid,
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);
51 exit;
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%');
69 echo '<br />';
71 echo '<form method="post" action="block.php">';
72 echo '<p>';
73 foreach($hiddendata as $name => $val) {
74 echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
76 echo '</p>';
77 $block->config_print();
78 echo '</form>';
79 print_footer();