Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/block.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // block.php - allows admin to edit all local configuration variables for a block
00004 
00005     require_once('../config.php');
00006     require_once($CFG->libdir.'/adminlib.php');
00007 
00008     $blockid = required_param('block', PARAM_INT);
00009 
00010     if(!$blockrecord = blocks_get_record($blockid)) {
00011         print_error('blockdoesnotexist', 'error');
00012     }
00013 
00014     admin_externalpage_setup('blocksetting'.$blockrecord->name);
00015 
00016     $block = block_instance($blockrecord->name);
00017     if($block === false) {
00018         print_error('blockcannotinistantiate', 'error');
00019     }
00020 
00021     // Define the data we're going to silently include in the instance config form here,
00022     // so we can strip them from the submitted data BEFORE handling it.
00023     $hiddendata = array(
00024         'block' => $blockid,
00025         'sesskey' => sesskey()
00026     );
00027 
00029 
00030     if ($config = data_submitted()) {
00031 
00032         if (!confirm_sesskey()) {
00033              print_error('confirmsesskeybad', 'error');
00034         }
00035         if(!$block->has_config()) {
00036             print_error('blockcannotconfig', 'error');
00037         }
00038         $remove = array_keys($hiddendata);
00039         foreach($remove as $item) {
00040             unset($config->$item);
00041         }
00042         $block->config_save($config);
00043         redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
00044         exit;
00045     }
00046 
00048 
00049     $strmanageblocks = get_string('manageblocks');
00050     $strblockname = $block->get_title();
00051 
00052     echo $OUTPUT->header();
00053 
00054     echo $OUTPUT->heading($strblockname);
00055 
00056     echo $OUTPUT->notification('This block still uses an old-style config_global.html file. ' .
00057             'It must be updated by a developer to use a settings.php file.');
00058 
00059     echo $OUTPUT->box(get_string('configwarning', 'admin'), 'generalbox boxwidthnormal boxaligncenter');
00060     echo '<br />';
00061 
00062     echo '<form method="post" action="block.php">';
00063     echo '<p>';
00064     foreach($hiddendata as $name => $val) {
00065         echo '<input type="hidden" name="'. $name .'" value="'. $val .'" />';
00066     }
00067     echo '</p>';
00068 
00069     echo $OUTPUT->box_start();
00070     include($CFG->dirroot.'/blocks/'. $block->name() .'/config_global.html');
00071     echo $OUTPUT->box_end();
00072 
00073     echo '</form>';
00074     echo $OUTPUT->footer();
00075 
00076 
 All Data Structures Namespaces Files Functions Variables Enumerations