function taxonomy_facets_add_block_form_submit in Taxonomy Facets 7.3
Same name and namespace in other branches
- 7.2 taxonomy_facets.module \taxonomy_facets_add_block_form_submit()
Save the new taxo faceted block.
1 string reference to 'taxonomy_facets_add_block_form_submit'
- taxonomy_facets_add_block_form in ./
taxonomy_facets.module - Menu callback: display the taxo faceted block addition form.
File
- ./
taxonomy_facets.module, line 117
Code
function taxonomy_facets_add_block_form_submit($form, array &$form_state) {
// Determine the delta of the new block.
$block_ids = variable_get('taxo_faceted_block_ids', array());
$delta = empty($block_ids) ? 1 : max($block_ids) + 1;
$form_state['values']['delta'] = $delta;
// Add new delta to array of exsisting deltas.
$block_ids[] = $delta;
// Save the new array of blocks IDs.
variable_set('taxo_faceted_block_ids', $block_ids);
// Save the block configuration.
taxonomy_facets_block_save($delta, $form_state['values']);
// Run the normal new block submission.
$query = db_insert('block')
->fields(array(
'visibility',
'pages',
'custom',
'title',
'module',
'theme',
'region',
'status',
'weight',
'delta',
'cache',
));
foreach (list_themes() as $key => $theme) {
if ($theme->status) {
$region = !empty($form_state['values']['regions'][$theme->name]) ? $form_state['values']['regions'][$theme->name] : BLOCK_REGION_NONE;
$query
->values(array(
'visibility' => (int) $form_state['values']['visibility'],
'pages' => trim($form_state['values']['pages']),
'custom' => (int) $form_state['values']['custom'],
'title' => $form_state['values']['title'],
'module' => $form_state['values']['module'],
'theme' => $theme->name,
'region' => $region == BLOCK_REGION_NONE ? '' : $region,
'status' => 0,
'status' => (int) ($region != BLOCK_REGION_NONE),
'weight' => 0,
'delta' => $delta,
'cache' => DRUPAL_CACHE_PER_PAGE,
));
}
}
$query
->execute();
$query = db_insert('block_role')
->fields(array(
'rid',
'module',
'delta',
));
foreach (array_filter($form_state['values']['roles']) as $rid) {
$query
->values(array(
'rid' => $rid,
'module' => $form_state['values']['module'],
'delta' => $delta,
));
}
$query
->execute();
drupal_set_message(t('The taxofaceted block has been created.'));
cache_clear_all();
$form_state['redirect'] = 'admin/structure/block';
}