Commit dce07ab3 authored by Dries's avatar Dries

- Patch #684774 by sun: block visibility settings cannot be properly extended.

parent 3cf9f1d2
......@@ -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')
......
......@@ -2179,6 +2179,64 @@ function theme_node_recent_content($variables) {
return $output;
}
/**
* 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.
*
......
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment