Fixing up the my moodle blocks to use blocks_setup instead of the old way.
This commit is contained in:
+1
-11
@@ -13,18 +13,8 @@
|
||||
define('OVERRIDE_PAGE_TYPE',PAGE_MY_MOODLE);
|
||||
|
||||
$PAGE = page_create_object(PAGE_MY_MOODLE,0);
|
||||
|
||||
$blockaction = optional_param('blockaction');
|
||||
|
||||
$blocks = blocks_get_pinned($PAGE);
|
||||
|
||||
if (!empty($blockaction)) {
|
||||
blocks_execute_url_action($PAGE, $blocks,true);
|
||||
// This re-query could be eliminated by judicious programming in blocks_execute_action(),
|
||||
// but I 'm not sure if it's worth the complexity increase...
|
||||
$blocks = blocks_get_pinned($PAGE);
|
||||
}
|
||||
|
||||
$blocks = blocks_setup($PAGE,BLOCKS_PINNED_TRUE);
|
||||
|
||||
$strtitle = get_string('pinblocks','my');
|
||||
|
||||
|
||||
+18
-3
@@ -11,6 +11,10 @@ define('BLOCK_CONFIGURE', 0x10);
|
||||
define('BLOCK_POS_LEFT', 'l');
|
||||
define('BLOCK_POS_RIGHT', 'r');
|
||||
|
||||
define('BLOCKS_PINNED_TRUE',0);
|
||||
define('BLOCKS_PINNED_FALSE',1);
|
||||
define('BLOCKS_PINNED_BOTH',2);
|
||||
|
||||
require_once($CFG->libdir.'/pagelib.php');
|
||||
|
||||
|
||||
@@ -378,9 +382,20 @@ function blocks_find_instance($instanceid, $blocksarray) {
|
||||
}
|
||||
|
||||
// Simple entry point for anyone that wants to use blocks
|
||||
function blocks_setup(&$PAGE) {
|
||||
$pageblocks = blocks_get_by_page($PAGE);
|
||||
blocks_execute_url_action($PAGE, $pageblocks);
|
||||
function blocks_setup(&$PAGE,$pinned=BLOCKS_PINNED_FALSE) {
|
||||
switch ($pinned) {
|
||||
case BLOCKS_PINNED_TRUE:
|
||||
$pageblocks = blocks_get_pinned($PAGE);
|
||||
break;
|
||||
case BLOCKS_PINNED_BOTH:
|
||||
$pageblocks = blocks_get_by_page_pinned($PAGE);
|
||||
break;
|
||||
case BLOCKS_PINNED_FALSE:
|
||||
default:
|
||||
$pageblocks = blocks_get_by_page($PAGE);
|
||||
break;
|
||||
}
|
||||
blocks_execute_url_action($PAGE, $pageblocks,($pinned==BLOCKS_PINNED_TRUE));
|
||||
return $pageblocks;
|
||||
}
|
||||
|
||||
|
||||
+1
-8
@@ -13,14 +13,7 @@
|
||||
|
||||
$PAGE = page_create_instance($USER->id);
|
||||
|
||||
$pageblocks = blocks_get_by_page_pinned($PAGE);
|
||||
if (!empty($blockaction)) {
|
||||
blocks_execute_url_action($PAGE, $pageblocks);
|
||||
// This re-query could be eliminated by judicious programming in blocks_execute_action(),
|
||||
// but I 'm not sure if it's worth the complexity increase...
|
||||
$pageblocks = blocks_get_by_page_pinned($PAGE);
|
||||
}
|
||||
|
||||
$pageblocks = blocks_setup($PAGE,BLOCKS_PINNED_BOTH);
|
||||
|
||||
if (!empty($edit) && $PAGE->user_allowed_editing()) {
|
||||
if ($edit == 'on') {
|
||||
|
||||
Reference in New Issue
Block a user