You are here

function pathauto_i18n_user_pathauto_alias_alter in Pathauto i18n 8

Same name and namespace in other branches
  1. 7 modules/pathauto_i18n_user/pathauto_i18n_user.module \pathauto_i18n_user_pathauto_alias_alter()

Implements hook_pathauto_alias_alter().

File

modules/pathauto_i18n_user/pathauto_i18n_user.module, line 78
Provides tools for creating multilanguage aliases for users.

Code

function pathauto_i18n_user_pathauto_alias_alter(&$alias, &$context) {
  $operations = array(
    'insert',
    'update',
    'bulkupdate',
  );

  // Skip insert of alias for all languages.
  if (!empty($context['module']) && $context['module'] == 'user' && in_array($context['op'], $operations)) {
    $entity = $context['data']['user'];

    // Run bulk update.
    $settings = pathauto_i18n_load_settings_single($entity->uid, 'user');
    if ($context['op'] == 'bulkupdate' && !empty($settings['path_status'])) {
      $entity->pathauto_i18n_status = $settings['path_status'];
      pathauto_i18n_process_entity_object($entity, 'user', $entity->pathauto_i18n_status, 'update');
    }
    if (isset($entity->pathauto_i18n_status) && $entity->pathauto_i18n_status && $context['language'] == LANGUAGE_NONE) {
      $alias = '';
    }
  }
}