function _fe_block_save_box in Features Extra 6
Same name and namespace in other branches
- 7 fe_block/fe_block.module \_fe_block_save_box()
Save a box.
Parameters
$settings:
Return value
array
2 calls to _fe_block_save_box()
- fe_block_boxes_features_rebuild in ./
fe_block.module - Implementation of hook_features_rebuild().
- fe_block_boxes_features_revert in ./
fe_block.module - Implementation of hook_features_revert().
File
- ./
fe_block.module, line 478
Code
function _fe_block_save_box($settings = array()) {
if (empty($settings['info'])) {
return FALSE;
}
// 'info' must be unique.
if (empty($settings['bid'])) {
$conflict = db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $settings['info']));
}
else {
$conflict = db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s' AND bid <> %d", $settings['info'], $settings['bid']));
}
if (!empty($conflict)) {
return FALSE;
}
// Defaults
$default_settings = array(
'info' => '',
'body' => '',
'format' => FILTER_FORMAT_DEFAULT,
);
$settings = array_merge($default_settings, $settings);
// Save
if (empty($settings['bid'])) {
drupal_write_record('boxes', $settings);
}
else {
drupal_write_record('boxes', $settings, 'bid');
}
return $settings;
}