You are here

function lingotek_delete_target_language in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.2 lingotek.util.inc \lingotek_delete_target_language()
  2. 7.3 lingotek.util.inc \lingotek_delete_target_language()
  3. 7.4 lingotek.util.inc \lingotek_delete_target_language()
  4. 7.5 lingotek.util.inc \lingotek_delete_target_language()
  5. 7.6 lingotek.util.inc \lingotek_delete_target_language()

Flags a target language as active:FALSE in the Target Language tracking.

1 call to lingotek_delete_target_language()
lingotek_dashboard_command_ajax in ./lingotek.dashboard.inc
Ajax Command Processing for the Lingotek dashboard.

File

./lingotek.util.inc, line 1014
Utility functions.

Code

function lingotek_delete_target_language($lingotek_locale) {
  $result = FALSE;
  if (is_string($lingotek_locale) && strlen($lingotek_locale)) {
    db_update('languages')
      ->fields(array(
      //'enabled' => 0,
      'lingotek_enabled' => 0,
    ))
      ->condition('lingotek_locale', $lingotek_locale)
      ->execute();
    LingotekLog::info("Target language removed: @lingotek_locale", array(
      '@lingotek_locale' => $lingotek_locale,
    ));

    // Remove the Target Language from the entire Lingotek Project
    // if language-specific profiles aren't in use.  (If language-
    // specific profiles are in use, then we assume a more sophisticated
    // user that may want old translations preserved on the TMS even if
    // the Lingotek module is no longer managing that language.)
    if (!variable_get('lingotek_enable_language_specific_profiles')) {
      $project_id = variable_get('lingotek_project', '');
      $api = LingotekApi::instance();
      $result = $api
        ->removeTranslationTarget(NULL, $project_id, $lingotek_locale);
    }

    // Remove from profiles and entity-profiles mappings
    $profiles = variable_get('lingotek_profiles', array());
    foreach ($profiles as &$profile_attribs) {
      if (isset($profile_attribs['target_language_overrides'][$lingotek_locale])) {
        unset($profile_attribs['target_language_overrides'][$lingotek_locale]);
      }
    }
    variable_set('lingotek_profiles', $profiles);
    $entity_profiles = variable_get('lingotek_entity_profiles', array());
    foreach ($entity_profiles as &$bundles) {
      foreach (array_keys($bundles) as $bundle_handle) {
        if (strpos($bundle_handle, '__')) {
          list($bundle_name, $locale) = explode('__', $bundle_handle);
          if ($locale == $lingotek_locale) {
            unset($bundles[$bundle_handle]);
          }
        }
      }
    }
    variable_set('lingotek_entity_profiles', $entity_profiles);
  }
  return $result;
}