diff --git a/htdocs/admin/prelevement.php b/htdocs/admin/prelevement.php index 91d73931155..9fc4f46e54f 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -232,13 +232,13 @@ print ''; print ''; //EntToEnd -print ''.$langs->trans("END_TO_END").''; +print ''.$langs->trans("END_TO_END").''; print ''; print ''; print ''; //USTRD -print ''.$langs->trans("USTRD").''; +print ''.$langs->trans("USTRD").''; print ''; print ''; print ''; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 0c9a43d5ca9..9d3bc24bd76 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1731,7 +1731,7 @@ function email_admin_prepare_head() $h = 0; $head = array(); - if ($user->admin && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) + if (! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { $head[$h][0] = DOL_URL_ROOT."/admin/mails.php"; $head[$h][1] = $langs->trans("OutGoingEmailSetup"); @@ -1752,7 +1752,7 @@ function email_admin_prepare_head() $head[$h][2] = 'templates'; $h++; - if ($conf->global->MAIN_FEATURES_LEVEL >= 1) + if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && ! empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { $head[$h][0] = DOL_URL_ROOT."/admin/mails_senderprofile_list.php"; $head[$h][1] = $langs->trans("EmailSenderProfiles"); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5ec9e40518f..7bb634cde2a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2837,35 +2837,50 @@ function isValidPhone($phone) * @param string $stringencoding Encoding of string * @return int Length of string */ -function dol_strlen($string,$stringencoding='UTF-8') +function dol_strlen($string, $stringencoding='UTF-8') { if (function_exists('mb_strlen')) return mb_strlen($string,$stringencoding); else return strlen($string); } /** - * Make a substring. Works even in mbstring module is not enabled. + * Make a substring. Works even if mbstring module is not enabled for better compatibility. * * @param string $string String to scan * @param string $start Start position - * @param int $length Length + * @param int $length Length (in nb of characters or nb of bytes depending on trunconbytes param) * @param string $stringencoding Page code used for input string encoding + * @param int $trunconbytes 1=Length is max of bytes instead of max of characters * @return string substring */ -function dol_substr($string,$start,$length,$stringencoding='') +function dol_substr($string, $start, $length, $stringencoding='', $trunconbytes=0) { global $langs; if (empty($stringencoding)) $stringencoding=$langs->charset_output; $ret=''; - if (function_exists('mb_substr')) + if (empty($trunconbytes)) { - $ret=mb_substr($string,$start,$length,$stringencoding); + if (function_exists('mb_substr')) + { + $ret=mb_substr($string, $start, $length, $stringencoding); + } + else + { + $ret=substr($string, $start, $length); + } } else { - $ret=substr($string,$start,$length); + if (function_exists('mb_strcut')) + { + $ret=mb_strcut($string, $start, $length, $stringencoding); + } + else + { + $ret=substr($string, $start, $length); + } } return $ret; } @@ -3063,7 +3078,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie', * @param string $trunc Where to trunc: right, left, middle (size must be a 2 power), wrap * @param string $stringencoding Tell what is source string encoding * @param int $nodot Truncation do not add ... after truncation. So it's an exact truncation. - * @param int $display Trunc is use to display and can be changed for small screen. TODO Remove this param (must be dealt with CSS) + * @param int $display Trunc is used to display data and can be changed for small screen. TODO Remove this param (must be dealt with CSS) * @return string Truncated string. WARNING: length is never higher than $size if $nodot is set, but can be 3 chars higher otherwise. */ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodot=0, $display=0) @@ -6782,26 +6797,27 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id if ($key == '') return ''; // Check in cache - if (isset($cache_codes[$tablename][$key])) // Can be defined to 0 or '' + if (isset($cache_codes[$tablename][$key][$fieldid])) // Can be defined to 0 or '' { - return $cache_codes[$tablename][$key]; // Found in cache + return $cache_codes[$tablename][$key][$fieldid]; // Found in cache } + dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG); + $sql = "SELECT ".$fieldid." as valuetoget"; $sql.= " FROM ".MAIN_DB_PREFIX.$tablename; $sql.= " WHERE ".$fieldkey." = '".$db->escape($key)."'"; if (! empty($entityfilter)) $sql.= " AND entity IN (" . getEntity($tablename) . ")"; - dol_syslog('dol_getIdFromCode', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); - if ($obj) $cache_codes[$tablename][$key]=$obj->valuetoget; - else $cache_codes[$tablename][$key]=''; + if ($obj) $cache_codes[$tablename][$key][$fieldid]=$obj->valuetoget; + else $cache_codes[$tablename][$key][$fieldid]=''; $db->free($resql); - return $cache_codes[$tablename][$key]; + return $cache_codes[$tablename][$key][$fieldid]; } else { @@ -6889,8 +6905,6 @@ function picto_from_langcode($codelang, $moreatt = '') if (empty($codelang)) return ''; - if (empty($codelang)) return ''; - if ($codelang == 'auto') { return ''; @@ -7061,6 +7075,7 @@ function printCommonFooter($zone='private') if (! empty($conf->use_javascript_ajax)) { print '