You are here

function fe_nodequeue_queue_features_revert in Features Extra 6

Implementation of hook_features_revert().

File

./fe_nodequeue.module, line 163

Code

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

  // Revert.
  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);
      }
    }
    else {
      $object->qid = $qid;
      $result = _fe_nodequeue_save_queue((array) $object);
    }
  }
  return TRUE;
}