You are here

function quickupdate_manager_update_form_submit in Quick update 7

Same name and namespace in other branches
  1. 8 quickupdate.module \quickupdate_manager_update_form_submit()

Form submission handler for quickupdate_manager_update_form().

Sets up a batch that downloads, extracts, and verifies the selected releases.

See also

quickupdate_manager_update_form_validate()

1 string reference to 'quickupdate_manager_update_form_submit'
quickupdate_form_update_manager_update_form_alter in ./quickupdate.module
Implements hook_form_FORM_ID_alter().

File

./quickupdate.module, line 172
Primarily Drupal hooks and global API functions.

Code

function quickupdate_manager_update_form_submit($form, &$form_state) {
  $projects = array();
  foreach (array(
    'projects',
    'disabled_projects',
    'missing_dependency_projects',
    'other_projects',
  ) as $type) {
    if (isset($form_state['values'][$type]) && !empty($form_state['values'][$type])) {
      if ($type == 'other_projects') {
        $other_projects = array();
        foreach (explode("\n", $form_state['values'][$type]) as $v) {
          $v = trim($v);
          $other_projects[$v] = $v;
        }
        $projects = array_merge($projects, array_keys(array_filter($other_projects)));
      }
      else {
        $projects = array_merge($projects, array_keys(array_filter($form_state['values'][$type])));
      }
    }
  }
  $operations = array();
  foreach ($projects as $project) {
    $operations[] = array(
      'quickupdate_manager_batch_project_get',
      array(
        $project,
        isset($form_state['values']['project_downloads'][$project]) ? $form_state['values']['project_downloads'][$project] : '',
      ),
    );
  }
  $batch = array(
    'title' => t('Downloading updates'),
    'init_message' => t('Preparing to download selected updates'),
    'operations' => $operations,
    'finished' => 'quickupdate_manager_download_batch_finished',
  );
  batch_set($batch);
}