You are here

function skinr_context_ui_mass_update in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_context/skinr_context_ui.admin.inc \skinr_context_ui_mass_update()

Mass update skin configuration groups, updating all skin configuration grouos in the $groups array with the field values in $updates.

IMPORTANT NOTE: This function is intended to work when called from a form submit handler. Calling it outside of the form submission process may not work correctly.

Parameters

array $groups: Array of skin configuration gids to update.

array $updates: Array of key/value pairs with skin configuration group field names and the value to update that field to.

1 string reference to 'skinr_context_ui_mass_update'
skinr_context_ui_skinr_context_ui_operations in skinr_context/skinr_context_ui.admin.inc
Implements hook_skinr_context_ui_operations().

File

skinr_context/skinr_context_ui.admin.inc, line 105
Admin page callbacks for the Skinr Context UI module.

Code

function skinr_context_ui_mass_update($groups, $updates) {

  // We use batch processing to prevent timeout when updating a large number
  // of groups.
  if (count($groups) > 10) {
    $batch = array(
      'operations' => array(
        array(
          '_skinr_context_ui_mass_update_batch_process',
          array(
            $groups,
            $updates,
          ),
        ),
      ),
      'finished' => '_skinr_context_ui_mass_update_batch_finished',
      'title' => t('Processing'),
      // We use a single multi-pass operation, so the default
      // 'Remaining x of y operations' message will be confusing here.
      'progress_message' => '',
      'error_message' => t('The update has encountered an error.'),
      // The operations do not live in the .module file, so we need to
      // tell the batch engine which file to load before calling them.
      'file' => drupal_get_path('module', 'skinr_context_ui') . '/skinr_context_ui.admin.inc',
    );
    batch_set($batch);
  }
  else {
    foreach ($groups as $gid) {
      _skinr_context_ui_mass_update_helper($gid, $updates);
    }
    drupal_set_message(t('The update has been performed.'));
  }
}