You are here

function pmperson_migrate_fix_existing_users_form_submit in Drupal PM (Project Management) 7.2

Same name and namespace in other branches
  1. 8 pmperson/includes/pmperson.migrate.inc \pmperson_migrate_fix_existing_users_form_submit()
  2. 7.3 pmperson/includes/pmperson.migrate.inc \pmperson_migrate_fix_existing_users_form_submit()

Form submit function for automatching Drupal users to PM Persons.

File

pmperson/includes/pmperson.migrate.inc, line 205
Migration functions for the PM Person module.

Code

function pmperson_migrate_fix_existing_users_form_submit($form, $form_state) {
  $unmapped_results = db_select('pmperson', 'pmp')
    ->fields('pmp')
    ->condition('pmp.user_uid', '0')
    ->execute();
  foreach ($unmapped_results as $record) {
    if ($account = user_load_by_mail($record->email)) {
      if (_pmperson_migrate_get_pmperson_from_uid($account->uid) == FALSE) {
        _pmperson_migrate_associate_user_with_pmperson($record, $account);
      }
    }
  }
}