summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/menu.inc9
-rw-r--r--modules/block/block.admin.inc11
-rw-r--r--modules/block/block.module30
3 files changed, 27 insertions, 23 deletions
diff --git a/includes/menu.inc b/includes/menu.inc
index 580d2ad3f..ecdd15075 100644
--- a/includes/menu.inc
+++ b/includes/menu.inc
@@ -191,6 +191,14 @@ define('MENU_LOCAL_ACTION', MENU_IS_LOCAL_TASK | MENU_IS_LOCAL_ACTION);
*/
/**
+ * Internal menu flag: Invisible local task.
+ *
+ * This flag may be used for local tasks like "Delete", so custom modules and
+ * themes can alter the default context and expose the task by altering menu.
+ */
+define('MENU_CONTEXT_NONE', 0x0000);
+
+/**
* Internal menu flag: Local task should be displayed in page context.
*/
define('MENU_CONTEXT_PAGE', 0x0001);
@@ -1859,6 +1867,7 @@ function menu_contextual_links($module, $parent_path, $args) {
$data[$root_path] = db_select('menu_router', 'm')
->fields('m')
->condition('tab_parent', $router_item['tab_root'])
+ ->condition('context', MENU_CONTEXT_NONE, '<>')
->condition('context', MENU_CONTEXT_PAGE, '<>')
->orderBy('weight')
->orderBy('title')
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index e6b737c8f..c605424a8 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -176,7 +176,8 @@ function _block_compare($a, $b) {
/**
* Menu callback; displays the block configuration form.
*/
-function block_admin_configure($form, &$form_state, $block) {
+function block_admin_configure($form, &$form_state, $module, $delta) {
+ $block = block_load($module, $delta);
$form['module'] = array(
'#type' => 'value',
'#value' => $block->module,
@@ -426,10 +427,7 @@ function block_admin_configure_submit($form, &$form_state) {
* Menu callback: display the custom block addition form.
*/
function block_add_block_form($form, &$form_state) {
- $block = new stdClass;
- $block->module = 'block';
- $block->delta = NULL;
- return block_admin_configure($form, $form_state, $block);
+ return block_admin_configure($form, $form_state, 'block', NULL);
}
function block_add_block_form_validate($form, &$form_state) {
@@ -511,7 +509,8 @@ function block_add_block_form_submit($form, &$form_state) {
/**
* Menu callback; confirm deletion of custom blocks.
*/
-function block_custom_block_delete($form, &$form_state, $block) {
+function block_custom_block_delete($form, &$form_state, $module, $delta) {
+ $block = block_load($module, $delta);
$custom_block = block_custom_block_get($block->delta);
$form['info'] = array('#type' => 'hidden', '#value' => $custom_block['info'] ? $custom_block['info'] : $custom_block['title']);
$form['bid'] = array('#type' => 'hidden', '#value' => $block->delta);
diff --git a/modules/block/block.module b/modules/block/block.module
index 4dd9e4855..306870b99 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -88,27 +88,25 @@ function block_menu() {
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
- $items['admin/structure/block/manage/%block/%'] = array(
+ $items['admin/structure/block/manage/%/%'] = array(
'title' => 'Configure block',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('block_admin_configure', 4),
- 'load arguments' => array(5),
+ 'page arguments' => array('block_admin_configure', 4, 5),
'access arguments' => array('administer blocks'),
'file' => 'block.admin.inc',
);
- $items['admin/structure/block/manage/%block/%/configure'] = array(
+ $items['admin/structure/block/manage/%/%/configure'] = array(
'title' => 'Configure block',
- 'load arguments' => array(5),
'type' => MENU_DEFAULT_LOCAL_TASK,
'context' => MENU_CONTEXT_INLINE,
);
- $items['admin/structure/block/manage/%block/%/delete'] = array(
+ $items['admin/structure/block/manage/%/%/delete'] = array(
'title' => 'Delete block',
'page callback' => 'drupal_get_form',
- 'page arguments' => array('block_custom_block_delete', 4),
- 'load arguments' => array(5),
+ 'page arguments' => array('block_custom_block_delete', 4, 5),
'access arguments' => array('administer blocks'),
- 'type' => MENU_CALLBACK,
+ 'type' => MENU_LOCAL_TASK,
+ 'context' => MENU_CONTEXT_NONE,
'file' => 'block.admin.inc',
);
$items['admin/structure/block/add'] = array(
@@ -598,22 +596,20 @@ function block_list($region) {
* @param $module
* Name of the module that implements the block to load.
* @param $delta
- * Unique ID of the block within the context of $module.
+ * Unique ID of the block within the context of $module. Pass NULL to return
+ * an empty $block object for $module.
*
* @return
* A block object.
*/
function block_load($module, $delta) {
- $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta',
- array(
- ':module' => $module,
- ':delta' => $delta
- ))
- ->fetchObject();
+ if (isset($delta)) {
+ $block = db_query('SELECT * FROM {block} WHERE module = :module AND delta = :delta', array(':module' => $module, ':delta' => $delta))->fetchObject();
+ }
// If the block does not exist in the database yet return a stub block
// object.
- if (!$block) {
+ if (empty($block)) {
$block = new stdClass;
$block->module = $module;
$block->delta = $delta;