You are here

function prepare_menus_button_submit in GlobalLink Connect for Drupal 7.7

Menu batch sets .

1 string reference to 'prepare_menus_button_submit'
globallink_useful_tools in ./globallink_settings.inc
Globallink Useful Tools form.

File

./globallink_settings.inc, line 729

Code

function prepare_menus_button_submit($form, &$form_state) {
  $batch = array(
    'operations' => array(),
    'finished' => 'globallink_settings_menus_batch_finished',
    'title' => t('Updating Menus'),
    'init_message' => t('Update Menus is starting.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Update Menus has encountered an error.'),
    'file' => drupal_get_path('module', 'globallink') . '/globallink_settings.inc',
  );
  $progress = 0;
  $limit = 200;
  $result = db_query("SELECT * FROM {menu_custom}")
    ->fetchAll();
  $resultLinks = db_query("SELECT * FROM {menu_links}")
    ->fetchAll();
  if ($result > $resultLinks) {
    $totalResult = $result;
  }
  else {
    $totalResult = $resultLinks;
  }
  $max = count($totalResult);
  while ($progress <= $max) {
    $batch['operations'][] = array(
      'globallink_settings_menus_process_batch1',
      array(
        $progress,
        $limit,
        $result,
        $resultLinks,
      ),
    );
    $progress = $progress + $limit;
  }
  batch_set($batch);
}