diff --git a/admin/blocks.php b/admin/blocks.php
index b4aab549967..9ecee1d0da6 100644
--- a/admin/blocks.php
+++ b/admin/blocks.php
@@ -4,8 +4,9 @@
require_once('../config.php');
require_once($CFG->libdir.'/blocklib.php');
+ require_once($CFG->libdir.'/tablelib.php');
- optional_variable($_GET['confirm'], 0);
+ $confirm = optional_param('confirm', 0, PARAM_INT);
$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_INT);
@@ -42,7 +43,6 @@
print_heading($strmanageblocks);
-
/// If data submitted, then process and store.
if (!empty($hide) && confirm_sesskey()) {
@@ -73,12 +73,17 @@
error("Block doesn't exist!");
}
- $blockobject = block_instance($block->name);
- $strblockname = $blockobject->get_title();
+ if (!block_is_compatible($block->name)) {
+ $strblockname = $block->name;
+ }
+ else {
+ $blockobject = block_instance($block->name);
+ $strblockname = $blockobject->get_title();
+ }
- if (!$_GET['confirm']) {
+ if (!$confirm) {
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
- 'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
+ 'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
'blocks.php');
print_footer();
exit;
@@ -123,9 +128,12 @@
error('No blocks found!'); // Should never happen
}
+ $incompatible = array();
+
foreach ($blocks as $block) {
if(!block_is_compatible($block->name)) {
notify('Block '. $block->name .' is not compatible with the current version of Mooodle and needs to be updated by a programmer.');
+ $incompatible[] = $block;
continue;
}
if(($blockobject = block_instance($block->name)) === false) {
@@ -144,17 +152,23 @@
/// Print the table of all blocks
- $table->head = array ($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings);
- $table->align = array ('left', 'right', 'left', 'center', 'center', 'center', 'center');
- $table->wrap = array ('nowrap', '', '', '', '', '', '');
- $table->size = array ('100%', '10', '10', '10', '10','12');
- $table->width = '100';
+ $table = new flexible_table('admin-blocks-compatible');
+
+ $table->define_columns(array('name', 'instances', 'version', 'hideshow', 'multiple', 'delete', 'settings'));
+ $table->define_headers(array($strname, $strcourses, $strversion, $strhide.'/'.$strshow, $strmultiple, $strdelete, $strsettings));
+ $table->define_baseurl($CFG->wwwroot.'/admin/blocks.php');
+
+ $table->set_attribute('cellspacing', '0');
+ $table->set_attribute('id', 'blocks');
+ $table->set_attribute('class', 'generaltable generalbox');
+
+ $table->setup();
foreach ($blockbyname as $blockname => $blockid) {
$blockobject = $blockobjects[$blockid];
- $delete = ''.$strdelete.'';
+ $delete = ''.$strdelete.'';
$settings = ''; // By default, no configuration
if($blockobject->has_config()) {
@@ -165,26 +179,26 @@
$class = ''; // Nothing fancy, by default
if ($blocks[$blockid]->visible) {
- $visible = ''.
+ $visible = ''.
'
';
} else {
- $visible = ''.
+ $visible = ''.
'
';
$class = ' class="dimmed_text"'; // Leading space required!
}
if ($blockobject->instance_allow_multiple()) {
if($blocks[$blockid]->multiple) {
- $multiple = ''.get_string('yes').' ('.get_string('change', 'admin').')';
+ $multiple = ''.get_string('yes').' ('.get_string('change', 'admin').')';
}
else {
- $multiple = ''.get_string('no').' ('.get_string('change', 'admin').')';
+ $multiple = ''.get_string('no').' ('.get_string('change', 'admin').')';
}
}
else {
$multiple = '';
}
- $table->data[] = array(
+ $table->add_data(array(
''.$blockobject->get_title().'',
$count,
$blockobject->get_version(),
@@ -192,10 +206,34 @@
$multiple,
$delete,
$settings
- );
+ ));
}
- print_table($table);
+ $table->print_html();
+
+ if(!empty($incompatible)) {
+ print_heading(get_string('incompatibleblocks', 'admin'));
+
+ $table = new flexible_table('admin-blocks-incompatible');
+
+ $table->define_columns(array('block', 'delete'));
+ $table->define_headers(array($strname, $strdelete));
+ $table->define_baseurl($CFG->wwwroot.'/admin/blocks.php');
+
+ $table->set_attribute('cellspacing', '0');
+ $table->set_attribute('id', 'incompatible');
+ $table->set_attribute('class', 'generaltable generalbox');
+
+ $table->setup();
+
+ foreach ($incompatible as $block) {
+ $table->add_data(array(
+ $block->name,
+ ''.$strdelete.'',
+ ));
+ }
+ $table->print_html();
+ }
print_footer();