From: hickert Date: Tue, 22 Mar 2011 06:30:51 +0000 (+0000) Subject: Applied patch from kirill.k2, tahnks! X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f5ec9c33ac07e13197e082a45cd93e92bd82ea1e;p=gosa.git Applied patch from kirill.k2, tahnks! git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20628 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_core.inc b/gosa-core/include/class_core.inc index 919d887ea..9fb384654 100644 --- a/gosa-core/include/class_core.inc +++ b/gosa-core/include/class_core.inc @@ -1051,7 +1051,16 @@ DEBUG_SI = 256"), "check" => "", "migrate" => "", "group" => "snapshot", - "mandatory" => FALSE) + "mandatory" => FALSE), + array( + "name" => "forceTranslit", + "type" => "bool", + "default" => "false", + "description" => _("Force to use internal translate function (fix for generation of uid for cyrillic sn and givenName)."), + "check" => "gosaProperty::isBool", + "migrate" => "", + "group" => "core", + "mandatory" => TRUE) ))); } } diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 1e13afa0f..a04310fe6 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -119,6 +119,23 @@ $REWRITE= array( "ä" => "ae", "ñ" => "ny", "Ñ" => "Ny" ); +/*! \brief Cyrillic (russian) fonetic transliteration (converts russian letters to ASCII and backward according to GOST 7.79-2000 ) + * \param string 'str' Source string in russian codepage + * \return string Translitered string value. + */ +function cyrillic2ascii($str) { + $ru = array('а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я', + 'А', 'Б', 'В', 'Г', 'Д', 'Е', 'Ё', 'Ж', 'З', 'И', 'Й', 'К', 'Л', 'М', 'H', 'О', 'П', 'Р', 'С', 'Т', 'У', 'Ф', 'Х', 'Ц', 'Ч', 'Ш', 'Щ', 'Ъ', 'Ы', 'Ь', 'Э', 'Ю', 'Я', + 'ґ', 'є', 'ї', 'Ґ', 'Є', 'Ї' + ); + $en = array('a', 'b', 'v', 'g', 'd', 'e', 'jo','zh','z', 'i', 'jj','k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'f', 'kh','c', 'ch','sh','shh','"', 'y', '\'','eh','ju','ja', + 'A', 'B', 'V', 'G', 'D', 'E', 'Jo','Je','Z', 'I', 'Jj','K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'U', 'F', 'Kh','C', 'CH','SH','Shh','"', 'Y', '\'','Eh','Ju','Ja', + 'g', 'ye','yi','G', 'Ye','Yi' + ); + + return str_replace($ru, $en, $str); +} + /*! \brief Does autoloading for classes used in GOsa. * @@ -197,9 +214,9 @@ function make_seed() { } -/*! \brief Debug level action +/*! \brief DEBUG level action * - * Print a DEBUG level if specified debug level of the level matches the + * print a DEBUG level if specified debug level of the level matches the * the configured debug level. * * \param int 'level' The log level of the message (should use the constants, @@ -3762,13 +3779,20 @@ function gen_uids($rule, $attributes) $ldap = $config->get_ldap_link(); $ldap->cd($config->current['BASE']); - + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $rule, "Processing"); + // Strip out non ascii chars foreach($attributes as $name => $value){ - $value = iconv('UTF-8', 'US-ASCII//TRANSLIT', $value); + if ( $config->get_cfg_value("core", "forceTranslit") == "true" ) { + $value = cyrillic2ascii($value); + } else { + $value = iconv('UTF-8', 'US-ASCII//TRANSLIT', $value); + } $value = preg_replace('/[^(\x20-\x7F)]*/','',$value); $attributes[$name] = strtolower($value); } + + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $attributes, "Prepare"); // Search for '{%...[n-m]} // Get all matching parts of the given string and sort them by @@ -3805,12 +3829,12 @@ function gen_uids($rule, $attributes) // Create proposal array $rules = array($rule); foreach($replacements as $tag => $values){ - $rules = gen_uid_proposals($rules, $tag,$values); + $rules = gen_uid_proposals($rules, $tag, $values); } // Search for id tags {id:3} / {id#3} - preg_match_all('/\{id(#|:)([0-9])+\}/i', $rule ,$matches, PREG_SET_ORDER); + preg_match_all('/\{id(#|:)([0-9])+\}/i', $rule, $matches, PREG_SET_ORDER); $idReplacements = array(); foreach($matches as $match){ if(count($match) != 3) continue;