function fe_block_boxes_features_revert in Features Extra 6
Same name and namespace in other branches
- 7 fe_block/fe_block.module \fe_block_boxes_features_revert()
Implementation of hook_features_revert().
File
- ./
fe_block.module, line 291
Code
function fe_block_boxes_features_revert($module_name = NULL) {
$table = 'fe_block_boxes';
$defaults = features_get_default($table, $module_name);
if (empty($defaults)) {
return;
}
// Revert.
foreach ($defaults as $object) {
if (empty($object->machine_name)) {
continue;
}
$bid = _fe_block_get_bid($object->machine_name);
if (empty($bid) || !($box = block_box_get($bid))) {
$result = _fe_block_save_box((array) $object);
if (!empty($result['bid'])) {
db_query("DELETE FROM {{$table}} WHERE bid = %d OR machine_name = '%s'", $result['bid'], $object->machine_name);
db_query("INSERT INTO {{$table}} (bid, machine_name) VALUES (%d, '%s')", $result['bid'], $object->machine_name);
}
}
else {
$object->bid = $bid;
$result = _fe_block_save_box((array) $object);
}
}
return TRUE;
}