diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-01-15 10:59:21 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-01-15 10:59:21 +0000 |
commit | dce07ab353cb71a317296d2566fad3c814bdc6c3 (patch) | |
tree | f1c73422c8163bfb2bb51f2c487660a9537124d5 /modules/node | |
parent | 3cf9f1d29564b94b73fee1a5a8dfe1b4eab1892d (diff) | |
download | brdo-dce07ab353cb71a317296d2566fad3c814bdc6c3.tar.gz brdo-dce07ab353cb71a317296d2566fad3c814bdc6c3.tar.bz2 |
- Patch #684774 by sun: block visibility settings cannot be properly extended.
Diffstat (limited to 'modules/node')
-rw-r--r-- | modules/node/node.module | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/node/node.module b/modules/node/node.module index 0195df5d2..bae087596 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2180,6 +2180,64 @@ function theme_node_recent_content($variables) { } /** + * Implements hook_form_FORMID_alter(). + * + * Adds node-type specific visibility options to add block form. + */ +function node_form_block_add_block_form_alter(&$form, &$form_state) { + node_form_block_admin_configure_alter($form, $form_state); +} + +/** + * Implements hook_form_FORMID_alter(). + * + * Adds node-type specific visibility options to block configuration form. + */ +function node_form_block_admin_configure_alter(&$form, &$form_state) { + $default_type_options = db_query("SELECT type FROM {block_node_type} WHERE module = :module AND delta = :delta", array( + ':module' => $form['module']['#value'], + ':delta' => $form['delta']['#value'], + ))->fetchCol(); + $form['visibility']['node_type'] = array( + '#type' => 'fieldset', + '#title' => t('Content types'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#group' => 'visibility', + '#weight' => 5, + ); + $form['visibility']['node_type']['types'] = array( + '#type' => 'checkboxes', + '#title' => t('Show block for specific content types'), + '#default_value' => $default_type_options, + '#options' => node_type_get_names(), + '#description' => t('Show this block only on pages that display content of the given type(s). If you select no types, there will be no type-specific limitation.'), + ); + $form['#submit'][] = 'node_block_admin_configure_submit'; +} + +/** + * Form submit handler for block configuration form. + */ +function node_block_admin_configure_submit($form, &$form_state) { + if (isset($form_state['values']['delta'])) { + db_delete('block_node_type') + ->condition('module', $form_state['values']['module']) + ->condition('delta', $form_state['values']['delta']) + ->execute(); + } + $query = db_insert('block_node_type')->fields(array('type', 'module', 'delta')); + foreach (array_filter($form_state['values']['types']) as $type) { + $query->values(array( + 'type' => $type, + 'module' => $form_state['values']['module'], + 'delta' => $form_state['values']['delta'], + )); + } + $query->execute(); +} + +/** * A generic function for generating RSS feeds from a set of nodes. * * @param $nids |