You are here

function skinr_ui_mass_update in Skinr 7.2

Same name and namespace in other branches
  1. 8.2 skinr_ui/skinr_ui.admin.inc \skinr_ui_mass_update()

Mass update skin configurations, updating all skin configurations in the $skins 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 $skins: Array of skin configuration sids to update.

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

1 string reference to 'skinr_ui_mass_update'
skinr_ui_skinr_ui_operations in ./skinr_ui.admin.inc
Implements hook_skinr_ui_operations().

File

./skinr_ui.admin.inc, line 251
Admin page callbacks for the Skinr UI module.

Code

function skinr_ui_mass_update($skins, $updates) {

  // We use batch processing to prevent timeout when updating a large number
  // of skins.
  if (count($skins) > 10) {
    $batch = array(
      'operations' => array(
        array(
          '_skinr_ui_mass_update_batch_process',
          array(
            $skins,
            $updates,
          ),
        ),
      ),
      'finished' => '_skinr_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_ui') . '/skinr_ui.admin.inc',
    );
    batch_set($batch);
  }
  else {
    foreach ($skins as $sid) {
      _skinr_ui_mass_update_helper($sid, $updates);
    }
    drupal_set_message(t('The update has been performed.'));
  }
}