You are here

function _pmperson_migrate_get_conflicting_email_with_existing_users_table in Drupal PM (Project Management) 8

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

Get list of pmnodes that has conlficting email with existing Drupal user.

1 call to _pmperson_migrate_get_conflicting_email_with_existing_users_table()
pmperson_migrate_page_callback in pmperson/includes/pmperson.migrate.inc
Page callback for PM_PMPERSON_RESOLVE_DEPENDENCIES_LINK.

File

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

Code

function _pmperson_migrate_get_conflicting_email_with_existing_users_table() {
  $header = array(
    'person' => array(
      'data' => t('PM Person'),
      'field' => 'email',
    ),
    'user' => array(
      'data' => t('Drupal User'),
      'field' => 'mail',
    ),
    'help' => array(
      'data' => t('Help'),
    ),
  );
  if (db_table_exists('pmperson')) {
    $query = db_select('pmperson', 'p')
      ->extend('PagerDefault')
      ->limit(10);
    $query
      ->join('users', 'u', 'p.email = u.mail AND p.user_uid <> u.uid');
    $query
      ->fields('p', array(
      'nid',
      'email',
    ))
      ->fields('u', array(
      'mail',
      'uid',
      'name',
    ))
      ->condition('p.user_uid', '0');
    $query = $query
      ->extend('TableSort')
      ->orderByHeader($header);
    $result = $query
      ->execute()
      ->fetchAllAssoc('nid');
  }
  else {
    $result = array();
  }
  $render = array(
    'table' => array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => array_map(function ($row) {
        return _pmperson_migrate_adjust_row($row);
      }, $result),
      '#sticky' => TRUE,
      '#caption' => t("Suggested Matches."),
      '#empty' => t('No issues found.'),
    ),
    'pager' => array(
      '#theme' => 'pager',
    ),
  );
  return $render;
}