summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-01-15 10:59:21 +0000
committerDries Buytaert <dries@buytaert.net>2010-01-15 10:59:21 +0000
commitdce07ab353cb71a317296d2566fad3c814bdc6c3 (patch)
treef1c73422c8163bfb2bb51f2c487660a9537124d5
parent3cf9f1d29564b94b73fee1a5a8dfe1b4eab1892d (diff)
downloadbrdo-dce07ab353cb71a317296d2566fad3c814bdc6c3.tar.gz
brdo-dce07ab353cb71a317296d2566fad3c814bdc6c3.tar.bz2
- Patch #684774 by sun: block visibility settings cannot be properly extended.
-rw-r--r--modules/block/block.admin.inc47
-rw-r--r--modules/node/node.module58
-rw-r--r--modules/simpletest/simpletest.install4
3 files changed, 63 insertions, 46 deletions
diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc
index ba85dda9c..41bf322e6 100644
--- a/modules/block/block.admin.inc
+++ b/modules/block/block.admin.inc
@@ -265,6 +265,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'visibility',
+ '#weight' => 0,
);
$access = user_access('use PHP for settings');
@@ -307,26 +308,6 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
);
}
- // Per-content type visibility.
- $default_type_options = db_query("SELECT type FROM {block_node_type} WHERE module = :module AND delta = :delta", array(
- ':module' => $block->module,
- ':delta' => $block->delta,
- ))->fetchCol();
- $form['visibility']['node_type'] = array(
- '#type' => 'fieldset',
- '#title' => t('Content types'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#group' => 'visibility',
- );
- $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.'),
- );
-
// Per-role visibility.
$default_role_options = db_query("SELECT rid FROM {block_role} WHERE module = :module AND delta = :delta", array(
':module' => $block->module,
@@ -339,6 +320,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'visibility',
+ '#weight' => 10,
);
$form['visibility']['role']['roles'] = array(
'#type' => 'checkboxes',
@@ -355,6 +337,7 @@ function block_admin_configure($form, &$form_state, $module, $delta) {
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#group' => 'visibility',
+ '#weight' => 20,
);
$form['visibility']['user']['custom'] = array(
'#type' => 'radios',
@@ -418,20 +401,6 @@ function block_admin_configure_submit($form, &$form_state) {
}
$query->execute();
- 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();
-
// Store regions per theme for this block
foreach ($form_state['values']['regions'] as $theme => $region) {
db_merge('block')
@@ -507,16 +476,6 @@ function block_add_block_form_submit($form, &$form_state) {
}
$query->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' => $delta,
- ));
- }
- $query->execute();
-
// Store regions per theme for this block
foreach ($form_state['values']['regions'] as $theme => $region) {
db_merge('block')
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
diff --git a/modules/simpletest/simpletest.install b/modules/simpletest/simpletest.install
index 055c9b2c6..903e8dc39 100644
--- a/modules/simpletest/simpletest.install
+++ b/modules/simpletest/simpletest.install
@@ -46,7 +46,7 @@ function simpletest_requirements($phase) {
);
if (!$has_curl) {
$requirements['curl']['severity'] = REQUIREMENT_ERROR;
- $requirements['curl']['description'] = $t('Simpletest could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
+ $requirements['curl']['description'] = $t('The testing framework could not be installed because the PHP <a href="@curl_url">cURL</a> library is not available.', array('@curl_url' => 'http://php.net/manual/en/curl.setup.php'));
}
$requirements['hash'] = array(
'title' => $t('hash'),
@@ -54,7 +54,7 @@ function simpletest_requirements($phase) {
);
if (!$has_hash) {
$requirements['hash']['severity'] = REQUIREMENT_ERROR;
- $requirements['hash']['description'] = $t('Simpletest could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array('@hash_url' => 'http://php.net/manual/en/book.hash.php'));
+ $requirements['hash']['description'] = $t('The testing framework could not be installed because the PHP <a href="@hash_url">hash</a> extension is disabled.', array('@hash_url' => 'http://php.net/manual/en/book.hash.php'));
}
$requirements['php_domdocument'] = array(