]> git.mjollnir.org Git - moodle.git/commitdiff
Updated the configuration-handling logic to the same level as the new instance-
authordefacer <defacer>
Fri, 19 Nov 2004 03:01:31 +0000 (03:01 +0000)
committerdefacer <defacer>
Fri, 19 Nov 2004 03:01:31 +0000 (03:01 +0000)
configuration handlers. Much more easy to use and precise.

admin/block.php

index 755a3c141e60a08e8f8d856753083be3706a56de..def37dd39ab31d68cbc13388b773103ae73b2f30 100644 (file)
         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');
     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();
 
 ?>