You are here

function _fe_nodequeue_save_queue in Features Extra 7

Same name and namespace in other branches
  1. 6 fe_nodequeue.module \_fe_nodequeue_save_queue()

Save a nodequeue queue.

Parameters

array $settings: A nodequeue settings array.

Return value

array The updated settings array.

1 call to _fe_nodequeue_save_queue()
fe_nodequeue_features_revert in fe_nodequeue/fe_nodequeue.module
Implements hook_features_revert().

File

fe_nodequeue/fe_nodequeue.module, line 180
Main functions and hook implementations of the FE Nodequeue module.

Code

function _fe_nodequeue_save_queue(array $settings) {

  // Convert roles from names to rids.
  $roles = array_flip(user_roles());
  foreach ((array) $settings['roles'] as $index => $role) {

    // In case we are dealing with an old export with rids, don't do anything.
    if (is_int($role)) {
      continue;
    }
    if (isset($roles[$role])) {
      $settings['roles'][$index] = $roles[$role];
    }
    else {

      // Do not attempt to assign a role which does not exist.
      unset($settings['roles'][$index]);
    }
  }

  // Simulate checkboxes.
  $settings['roles'] = drupal_map_assoc($settings['roles']);
  $settings['types'] = drupal_map_assoc($settings['types']);

  // Simulate submitting.
  $form_state = array();
  $form_state['values'] = $settings;
  module_load_include('inc', 'nodequeue', 'includes/nodequeue.admin');
  nodequeue_edit_queue_form_submit(NULL, $form_state);

  // Reset static caches.
  // Note: we are currently using a variant of nodequeue_get_qid_map() that uses
  // drupal_static() instead of a static variable to cache the results.
  // @see http://drupal.org/node/1666556
  drupal_static_reset('_fe_nodequeue_get_qid_map');
  return $settings;
}