You are here

function fe_nodequeue_queue_features_rebuild in Features Extra 6

Implementation of hook_features_rebuild().

File

./fe_nodequeue.module, line 134

Code

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

  // Rebuild.
  foreach ($defaults as $object) {
    if (empty($object->machine_name)) {
      continue;
    }
    $qid = db_result(db_query("SELECT qid FROM {{$table}} WHERE machine_name = '%s'", $object->machine_name));
    if (empty($qid) || !($nodequeue_queue = nodequeue_load($qid))) {
      $result = _fe_nodequeue_save_queue((array) $object);
      if (!empty($result['qid'])) {
        db_query("DELETE FROM {{$table}} WHERE qid = %d OR machine_name = '%s'", $result['qid'], $object->machine_name);
        db_query("INSERT INTO {{$table}} (qid, machine_name) VALUES (%d, '%s')", $result['qid'], $object->machine_name);
      }
    }
  }
  return TRUE;
}