Skip to content

Commit

Permalink
Change the semantics of blocks_print_adminblock() to make life easier to
Browse files Browse the repository at this point in the history
developers who use pages. Conversely simplified the code a bit in courses.
  • Loading branch information
defacer committed Feb 2, 2005
1 parent 7c6c051 commit c1d8705
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions course/format/social/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing && !empty($missingblocks)) {
blocks_print_adminblock($PAGE, $missingblocks);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
echo '</td>';
}
Expand Down
4 changes: 2 additions & 2 deletions course/format/topics/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing && !empty($missingblocks)) {
blocks_print_adminblock($PAGE, $missingblocks);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
echo '</td>';
}
Expand Down
4 changes: 2 additions & 2 deletions course/format/weeks/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@
if(blocks_have_content($pageblocks[BLOCK_POS_RIGHT]) || $editing) {
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;" id="right-column">';
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing && !empty($missingblocks)) {
blocks_print_adminblock($PAGE, $missingblocks);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
echo '</td>';
}
Expand Down
6 changes: 2 additions & 4 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
// but I'm not sure if it's worth the complexity increase...
$pageblocks = blocks_get_by_page($PAGE);
}

$missingblocks = blocks_get_missing($PAGE, $pageblocks);
}

optional_variable($preferred_width_left, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]));
Expand Down Expand Up @@ -216,8 +214,8 @@
echo '<br />';
}
blocks_print_group($PAGE, $pageblocks[BLOCK_POS_RIGHT]);
if ($editing && !empty($missingblocks)) {
blocks_print_adminblock($PAGE, $missingblocks);
if ($editing) {
blocks_print_adminblock($PAGE, $pageblocks);
}
echo '</td>';
}
Expand Down
8 changes: 5 additions & 3 deletions lib/blocklib.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,14 @@ function blocks_get_by_page($page) {
}

//This function prints the block to admin blocks as necessary
function blocks_print_adminblock($page, $missingblocks) {
function blocks_print_adminblock(&$page, &$pageblocks) {
global $USER;

$strblocks = get_string('blocks');
$stradd = get_string('add');
$missingblocks = blocks_get_missing($page, $pageblocks);

if (!empty($missingblocks)) {
$strblocks = get_string('blocks');
$stradd = get_string('add');
foreach ($missingblocks as $blockid) {
$block = blocks_get_record($blockid);
$blockobject = block_instance($block->name);
Expand Down

0 comments on commit c1d8705

Please sign in to comment.