You are here

function language_hierarchy_set_parent in Language Hierarchy 7

Sets a parent of specified language

Parameters

$language: Code of the language you want to set parent for

$parent_langcode: Code of the language to set parent to

File

./language_hierarchy.module, line 452

Code

function language_hierarchy_set_parent($langcode, $parent_langcode) {
  $languages = language_list();

  // Check if the language requested as new parent exists and is not one of the descendants of $langcode
  if (empty($languages[$parent_langcode])) {
    return FALSE;
  }
  if (!empty($languages[$langcode])) {
    db_update('languages')
      ->fields(array(
      'parent' => $parent_langcode,
    ))
      ->condition('language', $langcode)
      ->execute();
    return TRUE;
  }
  else {
    return FALSE;
  }
}