blocklib: MDL-19010 once again you can add blocks, at least on the coures page.

This commit is contained in:
tjhunt
2009-05-08 03:30:58 +00:00
parent 1d00ec6a6a
commit 7130fb212c
2 changed files with 13 additions and 13 deletions
+6 -9
View File
@@ -1051,7 +1051,7 @@ function blocks_execute_action($page, &$blockmanager, $blockaction, $instanceori
}
$region = $page->blocks->get_default_region();
$weight = $DB->get_field_sql("SELECT MAX(weight) FROM {block_instances}
$weight = $DB->get_field_sql("SELECT MAX(defaultweight) FROM {block_instances}
WHERE contextid = ? AND defaultregion = ?", array($page->context->id, $region));
$pagetypepattern = $page->pagetype;
if (strpos($pagetypepattern, 'course-view') === 0) {
@@ -1295,21 +1295,18 @@ function blocks_print_adminblock($page, $blockmanager) {
$strblocks = '<div class="title"><h2>';
$strblocks .= get_string('blocks');
$strblocks .= '</h2></div>';
$stradd = get_string('add');
foreach ($missingblocks as $blockid) {
$block = blocks_get_record($blockid);
$blockobject = block_instance($block->name);
if ($blockobject === false) {
continue;
if ($blockobject !== false && $blockobject->user_can_addto($page)) {
$menu[$block->id] = $blockobject->get_title();
}
if(!$blockobject->user_can_addto($page)) {
continue;
}
$menu[$block->id] = $blockobject->get_title();
}
asort($menu);
asort($menu, SORT_LOCALE_STRING);
$target = $page->url->out(array('sesskey' => sesskey(), 'blockaction' => 'add'));
$target = $page->url->out(false, array('sesskey' => sesskey(), 'blockaction' => 'add'));
$content = popup_form($target.'&amp;blockid=', $menu, 'add_block', '', $stradd .'...', '', '', true);
print_side_block($strblocks, $content, NULL, NULL, NULL, array('class' => 'block_adminblock'));
}