You are here

function subscribed_user_import_after_save in User Import 7.2

Same name and namespace in other branches
  1. 8 supported/subscribed.inc \subscribed_user_import_after_save()
  2. 5.2 supported/subscribed.inc \subscribed_user_import_after_save()
  3. 5 supported/subscribed.inc \subscribed_user_import_after_save()
  4. 6.4 supported/subscribed.inc \subscribed_user_import_after_save()
  5. 6.2 supported/subscribed.inc \subscribed_user_import_after_save()
  6. 7 supported/subscribed.inc \subscribed_user_import_after_save()

Implementation of hook_user_import_after_save().

File

supported/subscribed.inc, line 73

Code

function subscribed_user_import_after_save($settings, $account, $password, $fields, $updated) {

  /**
   * @todo change to new update architecture
   */
  if (!module_exists('publication') || !module_exists('schedule') || !module_exists('identity_hash') || empty($settings['options']['subscribed'])) {
    return;
  }
  $subscribed_settings = $settings['options']['subscribed'];
  $uid = $account->uid;
  if (is_array($subscribed_settings)) {
    foreach ($subscribed_settings as $type => $type_subscriptions) {
      $subscriptions = $type_subscriptions;
      foreach ($type_subscriptions as $publication_id => $schedule) {
        if (empty($schedule[0])) {
          unset($subscriptions[$publication_id]);
        }
      }
      $publications = publication_select_publications_and_terms($type);
      if (!empty($publications) && !empty($subscriptions)) {
        subscribed_set_subscriptions($type, $uid, $publications, $subscriptions);
        subscribed_set_subscriptions_terms($type, $uid, $publications, $subscriptions);
        identity_hash_set_hash($uid);
      }
    }
  }
  return;
}