You are here

function fe_block_boxes_features_rebuild in Features Extra 6

Same name and namespace in other branches
  1. 7 fe_block/fe_block.module \fe_block_boxes_features_rebuild()

Implementation of hook_features_rebuild().

File

./fe_block.module, line 262

Code

function fe_block_boxes_features_rebuild($module_name = NULL) {
  $table = 'fe_block_boxes';
  $defaults = features_get_default($table, $module_name);
  if (empty($defaults)) {
    return;
  }

  // Rebuild.
  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);
      }
    }
  }
  return TRUE;
}