function _fe_block_save_box in Features Extra 7
Same name and namespace in other branches
- 6 fe_block.module \_fe_block_save_box()
Save a box.
Parameters
array $settings: A box settings array.
Return value
array Updated settings array.
1 call to _fe_block_save_box()
- fe_block_boxes_features_revert in fe_block/
fe_block.module - Implements hook_features_revert().
File
- fe_block/
fe_block.module, line 1086 - Provide features components for exporting core blocks and settings.
Code
function _fe_block_save_box($settings = array()) {
if (empty($settings['info'])) {
return FALSE;
}
// 'info' must be unique.
if (empty($settings['bid'])) {
$conflict = db_query("SELECT COUNT(*) as count FROM {block_custom} WHERE info = :info", array(
'info' => $settings['info'],
));
}
else {
$conflict = db_query("SELECT COUNT(*) as count FROM {block_custom} WHERE info = :info AND bid <> :bid", array(
'info' => $settings['info'],
':bid' => $settings['bid'],
));
}
if (!empty($conflict
->fetch()->count)) {
return FALSE;
}
// Provide some default settings.
$default_settings = array(
'info' => '',
'body' => '',
'format' => 'FILTER_FORMAT_DEFAULT',
);
$settings = array_merge($default_settings, $settings);
// Save the block settings.
if (empty($settings['bid'])) {
drupal_write_record('block_custom', $settings);
}
else {
drupal_write_record('block_custom', $settings, 'bid');
}
return $settings;
}