You are here

function piwik_stats_piwik_admin_settings_batch_submit in Piwik Statistic Integration 7.2

Submit callback for filling piwik_stats fields manually by batch.

1 string reference to 'piwik_stats_piwik_admin_settings_batch_submit'
piwik_stats_form_piwik_admin_settings_form_alter in ./piwik_stats.module
Implements hook_form_FORM_ID_alter().

File

./piwik_stats.module, line 440
Integrates piwik statistics as entity fields.

Code

function piwik_stats_piwik_admin_settings_batch_submit($form, &$form_state) {

  // We want some fresh data here, remove cached data.
  cache_clear_all('piwik_stats:xml:', 'cache_piwik_stats', TRUE);

  // Get the queue of fields to fill.
  $queue = piwik_stats_get_queue_items();
  if ($queue === FALSE) {
    drupal_set_message(t('There was an error during the requests. Further information can be found in the logs.'), 'error');
  }
  elseif (empty($queue)) {
    drupal_set_message(t('There are no fields to process.'));
  }
  else {
    $operations = array();
    foreach ($queue as $item) {
      $operations[] = array(
        'piwik_stats_process_queue_item',
        array(
          $item,
        ),
      );
    }
    batch_set(array(
      'operations' => $operations,
      'title' => t('Processing all piwik field instances..'),
    ));
  }
}