You are here

function cas_batch_user_finished in CAS 7

CAS user creation 'finished' callback. Consolidates message output.

1 string reference to 'cas_batch_user_finished'
cas_add_user_form_submit in ./cas.user.inc

File

./cas.batch.inc, line 48
Provides CAS batch functions.

Code

function cas_batch_user_finished($success, $results, $operations) {
  if ($success) {
    if (!empty($results['messages']['error'])) {
      drupal_set_message(t('Error occurred during account creation of %count CAS username(s): !usernames', array(
        '%count' => count($results['messages']['error']),
        '!usernames' => implode(', ', $results['messages']['error']),
      )), 'warning');
    }
    if (!empty($results['messages']['already_exist'])) {
      drupal_set_message(t('The following %count CAS username(s) are already in use on this site: !usernames', array(
        '%count' => count($results['messages']['already_exist']),
        '!usernames' => implode(', ', $results['messages']['already_exist']),
      )), 'warning');
    }
    if (!empty($results['messages']['newly_created'])) {
      drupal_set_message(t('The following %count CAS usernames were created: !usernames', array(
        '%count' => count($results['messages']['newly_created']),
        '!usernames' => implode(', ', $results['messages']['newly_created']),
      )));
    }
  }
  else {

    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array(
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    )));
  }
}