You are here

function ldap_user_cron in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.2 ldap_user/ldap_user.module \ldap_user_cron()
  2. 8.3 ldap_user/ldap_user.module \ldap_user_cron()
  3. 7.2 ldap_user/ldap_user.module \ldap_user_cron()

Implements hook_cron().

File

ldap_user/ldap_user.module, line 25

Code

function ldap_user_cron() {
  $check_orphans = \Drupal::config('ldap_user.settings')
    ->get('orphanedDrupalAcctBehavior');
  if ($check_orphans !== 'ldap_user_orphan_do_not_check') {

    /** @var \Drupal\ldap_user\Processor\OrphanProcessor $processor */
    $processor = \Drupal::service('ldap.orphan_processor');
    $processor
      ->checkOrphans();
  }
  $ldapUpdateQuery = \Drupal::config('ldap_user.settings')
    ->get('userUpdateCronQuery');
  if (\Drupal::moduleHandler()
    ->moduleExists('ldap_query') && $ldapUpdateQuery != NULL && $ldapUpdateQuery !== 'none') {

    /** @var \Drupal\ldap_user\Processor\GroupUserUpdateProcessor $processor */
    $processor = \Drupal::service('ldap.group_user_update_processor');
    if ($processor
      ->updateDue()) {
      $processor
        ->runQuery($ldapUpdateQuery);
    }
  }
}