There's no function for disabling or rearranging blocks? Would it be worth adding something like...

function install_assign_block($module, $delta, $region, $theme) {
  db_query("UPDATE {blocks} SET region = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $region, $module, $delta, $theme);
}

This might also be useful for setting region to NULL? Haven't tried it.

Comments

Christopher Herberte’s picture

oops, this is sort of a dupe of http://drupal.org/node/163260 anyhow, it would be nice get some ideas.

Christopher Herberte’s picture

StatusFileSize
new879 bytes

I propose 2 new functions for block.inc I could not see the sense in install_enable_block() function as an active but unassigned block is not useful.

/**
 * Disable a block.
 */
function install_disable_block($module, $delta, $theme) {
  db_query("UPDATE {blocks} SET region = '', status = 0 WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme);
}

/**
 * Assign region and enable block.
 */
function install_assign_block($module, $delta, $theme, $region = '', $weight = 0) {
  db_query("UPDATE {blocks} SET region = '%s', status = 1, weight = %d WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $region, $weight, $module, $delta, $theme);
}

quicksketch’s picture

Status: Active » Fixed

Thanks, I've added these two functions with two small changes:
- Renamed "install_assign_block" to "install_set_block", since that's what it was called in the Drupal 5 version.
- I made the $region parameter required in install_set_block(), since it doesn't make much sense to set the region to '' but have the block be enabled.

quicksketch’s picture

I've backported these changes to the DRUPAL-5--2 branch. Note that this changed the parameter order of install_set_block() for Drupal 5--2. This makes it more consistent with other functions, which all use the order ($block, $module, $theme, ...).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.