FIX: Check valid mail server record correction. (#28197)

# FIX: Check valid mail server record correction.

The test for isValidMXRecord did not pass on Windows platform:

```bash
php -r '$a=getmxrr("yhaoo.com", $mxhosts, $weight);var_dump([$a,$mxhosts]);'

array(2) {
  [0] =>
  bool(true)
  [1] =>
  array(1) {
    [0] =>
    string(1) "."
  }
}

array(2) {
  [0] =>
  bool(true)
  [1] =>
  array(3) {
    [0] =>
    string(21) "mta5.am0.yahoodns.net"
    [1] =>
    string(21) "mta7.am0.yahoodns.net"
    [2] =>
    string(21) "mta6.am0.yahoodns.net"
  }
}

```

So an "invalid" MX record can be returned as a dot '.'.
This commit is contained in:
MDW 2024-02-16 13:03:16 +01:00 committed by GitHub
parent aabe3c528c
commit 844bc42240
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,6 +21,7 @@
* Copyright (C) 2022 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2022 Charlene Benke <charlene@patas-monkey.com>
* Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -1531,7 +1532,7 @@ function dol_string_unaccent($str)
iiiidnooooo
uuuuyy"
);
$string = strtr($string, array("\xC4"=>"Ae", "\xC6"=>"AE", "\xD6"=>"Oe", "\xDC"=>"Ue", "\xDE"=>"TH", "\xDF"=>"ss", "\xE4"=>"ae", "\xE6"=>"ae", "\xF6"=>"oe", "\xFC"=>"ue", "\xFE"=>"th"));
$string = strtr($string, array("\xC4" => "Ae", "\xC6" => "AE", "\xD6" => "Oe", "\xDC" => "Ue", "\xDE" => "TH", "\xDF" => "ss", "\xE4" => "ae", "\xE6" => "ae", "\xF6" => "oe", "\xFC" => "ue", "\xFE" => "th"));
return $string;
}
}
@ -1606,7 +1607,7 @@ function dol_escape_js($stringtoescape, $mode = 0, $noescapebackslashn = 0)
}
// escape quotes and backslashes, newlines, etc.
$substitjs = array("&#039;"=>"\\'", "\r"=>'\\r');
$substitjs = array("&#039;" => "\\'", "\r" => '\\r');
//$substitjs['</']='<\/'; // We removed this. Should be useless.
if (empty($noescapebackslashn)) {
$substitjs["\n"] = '\\n';
@ -1763,12 +1764,12 @@ function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0, $noescapeta
$tmp = html_entity_decode((string) $stringtoescape, ENT_COMPAT, 'UTF-8');
}
if (!$keepb) {
$tmp = strtr($tmp, array("<b>"=>'', '</b>'=>'', '<strong>'=>'', '</strong>'=>''));
$tmp = strtr($tmp, array("<b>" => '', '</b>' => '', '<strong>' => '', '</strong>' => ''));
}
if (!$keepn) {
$tmp = strtr($tmp, array("\r"=>'\\r', "\n"=>'\\n'));
$tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
} elseif ($keepn == -1) {
$tmp = strtr($tmp, array("\r"=>'', "\n"=>''));
$tmp = strtr($tmp, array("\r" => '', "\n" => ''));
}
if ($escapeonlyhtmltags) {
@ -1922,7 +1923,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename =
if (!empty($message)) {
// Test log level
$logLevels = array(LOG_EMERG=>'EMERG', LOG_ALERT=>'ALERT', LOG_CRIT=>'CRITICAL', LOG_ERR=>'ERR', LOG_WARNING=>'WARN', LOG_NOTICE=>'NOTICE', LOG_INFO=>'INFO', LOG_DEBUG=>'DEBUG');
$logLevels = array(LOG_EMERG => 'EMERG', LOG_ALERT => 'ALERT', LOG_CRIT => 'CRITICAL', LOG_ERR => 'ERR', LOG_WARNING => 'WARN', LOG_NOTICE => 'NOTICE', LOG_INFO => 'INFO', LOG_DEBUG => 'DEBUG');
if (!array_key_exists($level, $logLevels)) {
throw new Exception('Incorrect log level');
}
@ -2659,7 +2660,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi
$morehtmlref .= '</div>';
}
$parameters=array('morehtmlref'=>$morehtmlref);
$parameters = array('morehtmlref' => $morehtmlref);
$reshook = $hookmanager->executeHooks('formDolBanner', $parameters, $object, $action);
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@ -3117,15 +3118,15 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
$datetimeobj->setTimezone(new DateTimeZone($forcetimezone == 'gmt' ? 'UTC' : $forcetimezone)); // (add timezone relative to the date entered)
}
$arrayinfo = array(
'year'=>((int) date_format($datetimeobj, 'Y')),
'mon'=>((int) date_format($datetimeobj, 'm')),
'mday'=>((int) date_format($datetimeobj, 'd')),
'wday'=>((int) date_format($datetimeobj, 'w')),
'yday'=>((int) date_format($datetimeobj, 'z')),
'hours'=>((int) date_format($datetimeobj, 'H')),
'minutes'=>((int) date_format($datetimeobj, 'i')),
'seconds'=>((int) date_format($datetimeobj, 's')),
'0'=>$timestamp
'year' => ((int) date_format($datetimeobj, 'Y')),
'mon' => ((int) date_format($datetimeobj, 'm')),
'mday' => ((int) date_format($datetimeobj, 'd')),
'wday' => ((int) date_format($datetimeobj, 'w')),
'yday' => ((int) date_format($datetimeobj, 'z')),
'hours' => ((int) date_format($datetimeobj, 'H')),
'minutes' => ((int) date_format($datetimeobj, 'i')),
'seconds' => ((int) date_format($datetimeobj, 's')),
'0' => $timestamp
);
return $arrayinfo;
@ -3839,10 +3840,10 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
// This line is for backward compatibility
$url = sprintf($urlmask, urlencode($phone), $clicktodial_poste, $clicktodial_login, $clicktodial_password);
// Thoose lines are for substitution
$substitarray = array('__PHONEFROM__'=>$clicktodial_poste,
'__PHONETO__'=>urlencode($phone),
'__LOGIN__'=>$clicktodial_login,
'__PASS__'=>$clicktodial_password);
$substitarray = array('__PHONEFROM__' => $clicktodial_poste,
'__PHONETO__' => urlencode($phone),
'__LOGIN__' => $clicktodial_login,
'__PASS__' => $clicktodial_password);
$url = make_substitutions($url, $substitarray);
if (!getDolGlobalString('CLICKTODIAL_DO_NOT_USE_AJAX_CALL')) {
// Default and recommended: New method using ajax without submitting a page making a javascript history.go(-1) back
@ -4170,7 +4171,7 @@ function isValidMXRecord($domain)
if (count($mxhosts) > 1) {
return 1;
}
if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
if (count($mxhosts) == 1 && !in_array((string) $mxhosts[0], array('', '.'))) {
return 1;
}
@ -4350,28 +4351,28 @@ function getPictoForType($key)
{
// Set array with type -> picto
$type2picto = array(
'varchar'=>'font',
'text'=>'font',
'html'=>'code',
'int'=>'sort-numeric-down',
'double'=>'sort-numeric-down',
'price'=>'currency',
'pricecy'=>'multicurrency',
'varchar' => 'font',
'text' => 'font',
'html' => 'code',
'int' => 'sort-numeric-down',
'double' => 'sort-numeric-down',
'price' => 'currency',
'pricecy' => 'multicurrency',
'password' => 'key',
'boolean'=>'check-square',
'date'=>'calendar',
'datetime'=>'calendar',
'phone'=> 'phone',
'mail'=> 'email',
'url'=> 'url',
'ip'=> 'country',
'boolean' => 'check-square',
'date' => 'calendar',
'datetime' => 'calendar',
'phone' => 'phone',
'mail' => 'email',
'url' => 'url',
'ip' => 'country',
'select' => 'list',
'sellist' => 'list',
'radio' => 'check-circle',
'checkbox' => 'check-square',
'chkbxlst' => 'check-square',
'link' => 'link',
'separate'=> 'minus'
'separate' => 'minus'
);
if (!empty($type2picto[$key])) {
@ -4529,46 +4530,46 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
}
$arrayconvpictotofa = array(
'account'=>'university', 'accounting_account'=>'clipboard-list', 'accountline'=>'receipt', 'accountancy'=>'search-dollar', 'action'=>'calendar-alt', 'add'=>'plus-circle', 'address'=> 'address-book', 'asset'=>'money-check-alt', 'autofill'=>'fill',
'bank_account'=>'university',
'bill'=>'file-invoice-dollar', 'billa'=>'file-excel', 'billr'=>'file-invoice-dollar', 'billd'=>'file-medical',
'supplier_invoice'=>'file-invoice-dollar', 'supplier_invoicea'=>'file-excel', 'supplier_invoicer'=>'file-invoice-dollar', 'supplier_invoiced'=>'file-medical',
'bom'=>'shapes',
'card'=>'address-card', 'chart'=>'chart-line', 'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'collab'=>'people-arrows', 'conversation'=>'comments', 'country'=>'globe-americas', 'cron'=>'business-time', 'cross'=>'times',
'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd',
'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins',
'accounting'=>'search-dollar', 'category'=>'tag', 'dollyrevert'=>'dolly',
'file-o'=>'file', 'generate'=>'plus-square', 'hrm'=>'user-tie', 'incoterm'=>'truck-loading',
'margin'=>'calculator', 'members'=>'user-friends', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
'email'=>'at', 'establishment'=>'building', 'edit'=>'pencil-alt', 'entity'=>'globe',
'graph'=>'chart-line', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach',
'info'=>'info-circle', 'inventory'=>'boxes', 'intracommreport'=>'globe-europe', 'jobprofile'=>'cogs',
'knowledgemanagement'=>'ticket-alt', 'label'=>'layer-group', 'line'=>'bars', 'loan'=>'money-bill-alt',
'member'=>'user-alt', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right',
'trip'=>'wallet', 'expensereport'=>'wallet', 'group'=>'users', 'movement'=>'people-carry',
'sign-out'=>'sign-out-alt',
'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'switch_on_warning'=>'toggle-on', 'switch_on_red'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star',
'bank'=>'university', 'close_title'=>'times', 'delete'=>'trash', 'filter'=>'filter',
'list-alt'=>'list-alt', 'calendarlist'=>'bars', 'calendar'=>'calendar-alt', 'calendarmonth'=>'calendar-alt', 'calendarweek'=>'calendar-week', 'calendarday'=>'calendar-day', 'calendarperuser'=>'table',
'intervention'=>'ambulance', 'invoice'=>'file-invoice-dollar', 'order'=>'file-invoice',
'error'=>'exclamation-triangle', 'warning'=>'exclamation-triangle',
'other'=>'square',
'playdisabled'=>'play', 'pdf'=>'file-pdf', 'poll'=>'check-double', 'pos'=>'cash-register', 'preview'=>'binoculars', 'project'=>'project-diagram', 'projectpub'=>'project-diagram', 'projecttask'=>'tasks', 'propal'=>'file-signature', 'proposal'=>'file-signature',
'partnership'=>'handshake', 'payment'=>'money-check-alt', 'payment_vat'=>'money-check-alt', 'pictoconfirm'=>'check-square', 'phoning'=>'phone', 'phoning_mobile'=>'mobile-alt', 'phoning_fax'=>'fax', 'previous'=>'arrow-alt-circle-left', 'printer'=>'print', 'product'=>'cube', 'puce'=>'angle-right',
'recent' => 'check-square', 'reception'=>'dolly', 'recruitmentjobposition'=>'id-card-alt', 'recruitmentcandidature'=>'id-badge',
'resize'=>'crop', 'supplier_order'=>'dol-order_supplier', 'supplier_proposal'=>'file-signature',
'refresh'=>'redo', 'region'=>'map-marked', 'replacement'=>'exchange-alt', 'resource'=>'laptop-house', 'recurring'=>'history',
'service'=>'concierge-bell',
'skill'=>'shapes', 'state'=>'map-marked-alt', 'security'=>'key', 'salary'=>'wallet', 'shipment'=>'dolly', 'stock'=>'box-open', 'stats' => 'chart-bar', 'split'=>'code-branch', 'stripe'=>'stripe-s',
'supplier'=>'building', 'technic'=>'cogs',
'timespent'=>'clock', 'title_setup'=>'tools', 'title_accountancy'=>'money-check-alt', 'title_bank'=>'university', 'title_hrm'=>'umbrella-beach',
'title_agenda'=>'calendar-alt',
'uncheck'=>'times', 'uparrow'=>'share', 'url'=>'external-link-alt', 'vat'=>'money-check-alt', 'vcard'=>'arrow-alt-circle-down',
'jabber'=>'comment-o',
'website'=>'globe-americas', 'workstation'=>'pallet', 'webhook'=>'bullseye', 'world'=>'globe', 'private'=>'user-lock',
'conferenceorbooth'=>'chalkboard-teacher', 'eventorganization'=>'project-diagram',
'webportal'=>'door-open'
'account' => 'university', 'accounting_account' => 'clipboard-list', 'accountline' => 'receipt', 'accountancy' => 'search-dollar', 'action' => 'calendar-alt', 'add' => 'plus-circle', 'address' => 'address-book', 'asset' => 'money-check-alt', 'autofill' => 'fill',
'bank_account' => 'university',
'bill' => 'file-invoice-dollar', 'billa' => 'file-excel', 'billr' => 'file-invoice-dollar', 'billd' => 'file-medical',
'supplier_invoice' => 'file-invoice-dollar', 'supplier_invoicea' => 'file-excel', 'supplier_invoicer' => 'file-invoice-dollar', 'supplier_invoiced' => 'file-medical',
'bom' => 'shapes',
'card' => 'address-card', 'chart' => 'chart-line', 'company' => 'building', 'contact' => 'address-book', 'contract' => 'suitcase', 'collab' => 'people-arrows', 'conversation' => 'comments', 'country' => 'globe-americas', 'cron' => 'business-time', 'cross' => 'times',
'donation' => 'file-alt', 'dynamicprice' => 'hand-holding-usd',
'setup' => 'cog', 'companies' => 'building', 'products' => 'cube', 'commercial' => 'suitcase', 'invoicing' => 'coins',
'accounting' => 'search-dollar', 'category' => 'tag', 'dollyrevert' => 'dolly',
'file-o' => 'file', 'generate' => 'plus-square', 'hrm' => 'user-tie', 'incoterm' => 'truck-loading',
'margin' => 'calculator', 'members' => 'user-friends', 'ticket' => 'ticket-alt', 'globe' => 'external-link-alt', 'lot' => 'barcode',
'email' => 'at', 'establishment' => 'building', 'edit' => 'pencil-alt', 'entity' => 'globe',
'graph' => 'chart-line', 'grip_title' => 'arrows-alt', 'grip' => 'arrows-alt', 'help' => 'question-circle',
'generic' => 'file', 'holiday' => 'umbrella-beach',
'info' => 'info-circle', 'inventory' => 'boxes', 'intracommreport' => 'globe-europe', 'jobprofile' => 'cogs',
'knowledgemanagement' => 'ticket-alt', 'label' => 'layer-group', 'line' => 'bars', 'loan' => 'money-bill-alt',
'member' => 'user-alt', 'meeting' => 'chalkboard-teacher', 'mrp' => 'cubes', 'next' => 'arrow-alt-circle-right',
'trip' => 'wallet', 'expensereport' => 'wallet', 'group' => 'users', 'movement' => 'people-carry',
'sign-out' => 'sign-out-alt',
'switch_off' => 'toggle-off', 'switch_on' => 'toggle-on', 'switch_on_warning' => 'toggle-on', 'switch_on_red' => 'toggle-on', 'check' => 'check', 'bookmark' => 'star',
'bank' => 'university', 'close_title' => 'times', 'delete' => 'trash', 'filter' => 'filter',
'list-alt' => 'list-alt', 'calendarlist' => 'bars', 'calendar' => 'calendar-alt', 'calendarmonth' => 'calendar-alt', 'calendarweek' => 'calendar-week', 'calendarday' => 'calendar-day', 'calendarperuser' => 'table',
'intervention' => 'ambulance', 'invoice' => 'file-invoice-dollar', 'order' => 'file-invoice',
'error' => 'exclamation-triangle', 'warning' => 'exclamation-triangle',
'other' => 'square',
'playdisabled' => 'play', 'pdf' => 'file-pdf', 'poll' => 'check-double', 'pos' => 'cash-register', 'preview' => 'binoculars', 'project' => 'project-diagram', 'projectpub' => 'project-diagram', 'projecttask' => 'tasks', 'propal' => 'file-signature', 'proposal' => 'file-signature',
'partnership' => 'handshake', 'payment' => 'money-check-alt', 'payment_vat' => 'money-check-alt', 'pictoconfirm' => 'check-square', 'phoning' => 'phone', 'phoning_mobile' => 'mobile-alt', 'phoning_fax' => 'fax', 'previous' => 'arrow-alt-circle-left', 'printer' => 'print', 'product' => 'cube', 'puce' => 'angle-right',
'recent' => 'check-square', 'reception' => 'dolly', 'recruitmentjobposition' => 'id-card-alt', 'recruitmentcandidature' => 'id-badge',
'resize' => 'crop', 'supplier_order' => 'dol-order_supplier', 'supplier_proposal' => 'file-signature',
'refresh' => 'redo', 'region' => 'map-marked', 'replacement' => 'exchange-alt', 'resource' => 'laptop-house', 'recurring' => 'history',
'service' => 'concierge-bell',
'skill' => 'shapes', 'state' => 'map-marked-alt', 'security' => 'key', 'salary' => 'wallet', 'shipment' => 'dolly', 'stock' => 'box-open', 'stats' => 'chart-bar', 'split' => 'code-branch', 'stripe' => 'stripe-s',
'supplier' => 'building', 'technic' => 'cogs',
'timespent' => 'clock', 'title_setup' => 'tools', 'title_accountancy' => 'money-check-alt', 'title_bank' => 'university', 'title_hrm' => 'umbrella-beach',
'title_agenda' => 'calendar-alt',
'uncheck' => 'times', 'uparrow' => 'share', 'url' => 'external-link-alt', 'vat' => 'money-check-alt', 'vcard' => 'arrow-alt-circle-down',
'jabber' => 'comment-o',
'website' => 'globe-americas', 'workstation' => 'pallet', 'webhook' => 'bullseye', 'world' => 'globe', 'private' => 'user-lock',
'conferenceorbooth' => 'chalkboard-teacher', 'eventorganization' => 'project-diagram',
'webportal' => 'door-open'
);
if ($conf->currency == 'EUR') {
$arrayconvpictotofa['currency'] = 'euro-sign';
@ -4593,7 +4594,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$fakey = 'fa-sticky-note';
$marginleftonlyshort = 1;
} elseif (in_array($pictowithouttext, array('1uparrow', '1downarrow', '1leftarrow', '1rightarrow', '1uparrow_selected', '1downarrow_selected', '1leftarrow_selected', '1rightarrow_selected'))) {
$convertarray = array('1uparrow'=>'caret-up', '1downarrow'=>'caret-down', '1leftarrow'=>'caret-left', '1rightarrow'=>'caret-right', '1uparrow_selected'=>'caret-up', '1downarrow_selected'=>'caret-down', '1leftarrow_selected'=>'caret-left', '1rightarrow_selected'=>'caret-right');
$convertarray = array('1uparrow' => 'caret-up', '1downarrow' => 'caret-down', '1leftarrow' => 'caret-left', '1rightarrow' => 'caret-right', '1uparrow_selected' => 'caret-up', '1downarrow_selected' => 'caret-down', '1leftarrow_selected' => 'caret-left', '1rightarrow_selected' => 'caret-right');
$fakey = 'fa-'.$convertarray[$pictowithouttext];
if (preg_match('/selected/', $pictowithouttext)) {
$facolor = '#888';
@ -4627,32 +4628,32 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
// Add CSS
$arrayconvpictotomorcess = array(
'action'=>'infobox-action', 'account'=>'infobox-bank_account', 'accounting_account'=>'infobox-bank_account', 'accountline'=>'infobox-bank_account', 'accountancy'=>'infobox-bank_account', 'asset'=>'infobox-bank_account',
'bank_account'=>'infobox-bank_account',
'bill'=>'infobox-commande', 'billa'=>'infobox-commande', 'billr'=>'infobox-commande', 'billd'=>'infobox-commande',
'margin'=>'infobox-bank_account', 'conferenceorbooth'=>'infobox-project',
'cash-register'=>'infobox-bank_account', 'contract'=>'infobox-contrat', 'check'=>'font-status4', 'collab'=>'infobox-action', 'conversation'=>'infobox-contrat',
'donation'=>'infobox-commande', 'dolly'=>'infobox-commande', 'dollyrevert'=>'flip infobox-order_supplier',
'ecm'=>'infobox-action', 'eventorganization'=>'infobox-project',
'hrm'=>'infobox-adherent', 'group'=>'infobox-adherent', 'intervention'=>'infobox-contrat',
'incoterm'=>'infobox-supplier_proposal',
'currency'=>'infobox-bank_account', 'multicurrency'=>'infobox-bank_account',
'members'=>'infobox-adherent', 'member'=>'infobox-adherent', 'money-bill-alt'=>'infobox-bank_account',
'order'=>'infobox-commande',
'user'=>'infobox-adherent', 'users'=>'infobox-adherent',
'error'=>'pictoerror', 'warning'=>'pictowarning', 'switch_on'=>'font-status4', 'switch_on_warning'=>'font-status4 warning', 'switch_on_red'=>'font-status8',
'holiday'=>'infobox-holiday', 'info'=>'opacityhigh', 'invoice'=>'infobox-commande',
'knowledgemanagement'=>'infobox-contrat rotate90', 'loan'=>'infobox-bank_account',
'payment'=>'infobox-bank_account', 'payment_vat'=>'infobox-bank_account', 'poll'=>'infobox-adherent', 'pos'=>'infobox-bank_account', 'project'=>'infobox-project', 'projecttask'=>'infobox-project',
'propal'=>'infobox-propal', 'proposal'=>'infobox-propal','private'=>'infobox-project',
'reception'=>'flip', 'recruitmentjobposition'=>'infobox-adherent', 'recruitmentcandidature'=>'infobox-adherent',
'resource'=>'infobox-action',
'salary'=>'infobox-bank_account', 'shapes'=>'infobox-adherent', 'shipment'=>'infobox-commande', 'supplier_invoice'=>'infobox-order_supplier', 'supplier_invoicea'=>'infobox-order_supplier', 'supplier_invoiced'=>'infobox-order_supplier',
'supplier'=>'infobox-order_supplier', 'supplier_order'=>'infobox-order_supplier', 'supplier_proposal'=>'infobox-supplier_proposal',
'ticket'=>'infobox-contrat', 'title_accountancy'=>'infobox-bank_account', 'title_hrm'=>'infobox-holiday', 'expensereport'=>'infobox-expensereport', 'trip'=>'infobox-expensereport', 'title_agenda'=>'infobox-action',
'vat'=>'infobox-bank_account',
'action' => 'infobox-action', 'account' => 'infobox-bank_account', 'accounting_account' => 'infobox-bank_account', 'accountline' => 'infobox-bank_account', 'accountancy' => 'infobox-bank_account', 'asset' => 'infobox-bank_account',
'bank_account' => 'infobox-bank_account',
'bill' => 'infobox-commande', 'billa' => 'infobox-commande', 'billr' => 'infobox-commande', 'billd' => 'infobox-commande',
'margin' => 'infobox-bank_account', 'conferenceorbooth' => 'infobox-project',
'cash-register' => 'infobox-bank_account', 'contract' => 'infobox-contrat', 'check' => 'font-status4', 'collab' => 'infobox-action', 'conversation' => 'infobox-contrat',
'donation' => 'infobox-commande', 'dolly' => 'infobox-commande', 'dollyrevert' => 'flip infobox-order_supplier',
'ecm' => 'infobox-action', 'eventorganization' => 'infobox-project',
'hrm' => 'infobox-adherent', 'group' => 'infobox-adherent', 'intervention' => 'infobox-contrat',
'incoterm' => 'infobox-supplier_proposal',
'currency' => 'infobox-bank_account', 'multicurrency' => 'infobox-bank_account',
'members' => 'infobox-adherent', 'member' => 'infobox-adherent', 'money-bill-alt' => 'infobox-bank_account',
'order' => 'infobox-commande',
'user' => 'infobox-adherent', 'users' => 'infobox-adherent',
'error' => 'pictoerror', 'warning' => 'pictowarning', 'switch_on' => 'font-status4', 'switch_on_warning' => 'font-status4 warning', 'switch_on_red' => 'font-status8',
'holiday' => 'infobox-holiday', 'info' => 'opacityhigh', 'invoice' => 'infobox-commande',
'knowledgemanagement' => 'infobox-contrat rotate90', 'loan' => 'infobox-bank_account',
'payment' => 'infobox-bank_account', 'payment_vat' => 'infobox-bank_account', 'poll' => 'infobox-adherent', 'pos' => 'infobox-bank_account', 'project' => 'infobox-project', 'projecttask' => 'infobox-project',
'propal' => 'infobox-propal', 'proposal' => 'infobox-propal','private' => 'infobox-project',
'reception' => 'flip', 'recruitmentjobposition' => 'infobox-adherent', 'recruitmentcandidature' => 'infobox-adherent',
'resource' => 'infobox-action',
'salary' => 'infobox-bank_account', 'shapes' => 'infobox-adherent', 'shipment' => 'infobox-commande', 'supplier_invoice' => 'infobox-order_supplier', 'supplier_invoicea' => 'infobox-order_supplier', 'supplier_invoiced' => 'infobox-order_supplier',
'supplier' => 'infobox-order_supplier', 'supplier_order' => 'infobox-order_supplier', 'supplier_proposal' => 'infobox-supplier_proposal',
'ticket' => 'infobox-contrat', 'title_accountancy' => 'infobox-bank_account', 'title_hrm' => 'infobox-holiday', 'expensereport' => 'infobox-expensereport', 'trip' => 'infobox-expensereport', 'title_agenda' => 'infobox-action',
'vat' => 'infobox-bank_account',
//'title_setup'=>'infobox-action', 'tools'=>'infobox-action',
'list-alt'=>'imgforviewmode', 'calendar'=>'imgforviewmode', 'calendarweek'=>'imgforviewmode', 'calendarmonth'=>'imgforviewmode', 'calendarday'=>'imgforviewmode', 'calendarperuser'=>'imgforviewmode'
'list-alt' => 'imgforviewmode', 'calendar' => 'imgforviewmode', 'calendarweek' => 'imgforviewmode', 'calendarmonth' => 'imgforviewmode', 'calendarday' => 'imgforviewmode', 'calendarperuser' => 'imgforviewmode'
);
if (!empty($arrayconvpictotomorcess[$pictowithouttext]) && strpos($picto, '_nocolor') === false) {
$morecss .= ($morecss ? ' ' : '').$arrayconvpictotomorcess[$pictowithouttext];
@ -4660,19 +4661,19 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
// Define $color
$arrayconvpictotocolor = array(
'address'=>'#6c6aa8', 'building'=>'#6c6aa8', 'bom'=>'#a69944',
'clone'=>'#999', 'cog'=>'#999', 'companies'=>'#6c6aa8', 'company'=>'#6c6aa8', 'contact'=>'#6c6aa8', 'cron'=>'#555',
'dynamicprice'=>'#a69944',
'edit'=>'#444', 'note'=>'#999', 'error'=>'', 'help'=>'#bbb', 'listlight'=>'#999', 'language'=>'#555',
'address' => '#6c6aa8', 'building' => '#6c6aa8', 'bom' => '#a69944',
'clone' => '#999', 'cog' => '#999', 'companies' => '#6c6aa8', 'company' => '#6c6aa8', 'contact' => '#6c6aa8', 'cron' => '#555',
'dynamicprice' => '#a69944',
'edit' => '#444', 'note' => '#999', 'error' => '', 'help' => '#bbb', 'listlight' => '#999', 'language' => '#555',
//'dolly'=>'#a69944', 'dollyrevert'=>'#a69944',
'lock'=>'#ddd', 'lot'=>'#a69944',
'map-marker-alt'=>'#aaa', 'mrp'=>'#a69944', 'product'=>'#a69944', 'service'=>'#a69944', 'inventory'=>'#a69944', 'stock'=>'#a69944', 'movement'=>'#a69944',
'other'=>'#ddd', 'world'=>'#986c6a',
'partnership'=>'#6c6aa8', 'playdisabled'=>'#ccc', 'printer'=>'#444', 'projectpub'=>'#986c6a', 'reception'=>'#a69944', 'resize'=>'#444', 'rss'=>'#cba',
'lock' => '#ddd', 'lot' => '#a69944',
'map-marker-alt' => '#aaa', 'mrp' => '#a69944', 'product' => '#a69944', 'service' => '#a69944', 'inventory' => '#a69944', 'stock' => '#a69944', 'movement' => '#a69944',
'other' => '#ddd', 'world' => '#986c6a',
'partnership' => '#6c6aa8', 'playdisabled' => '#ccc', 'printer' => '#444', 'projectpub' => '#986c6a', 'reception' => '#a69944', 'resize' => '#444', 'rss' => '#cba',
//'shipment'=>'#a69944',
'security'=>'#999', 'square'=>'#888', 'stop-circle'=>'#888', 'stats'=>'#444', 'switch_off'=>'#999', 'technic'=>'#999', 'timespent'=>'#555',
'uncheck'=>'#800', 'uparrow'=>'#555', 'user-cog'=>'#999', 'country'=>'#aaa', 'globe-americas'=>'#aaa', 'region'=>'#aaa', 'state'=>'#aaa',
'website'=>'#304', 'workstation'=>'#a69944'
'security' => '#999', 'square' => '#888', 'stop-circle' => '#888', 'stats' => '#444', 'switch_off' => '#999', 'technic' => '#999', 'timespent' => '#555',
'uncheck' => '#800', 'uparrow' => '#555', 'user-cog' => '#999', 'country' => '#aaa', 'globe-americas' => '#aaa', 'region' => '#aaa', 'state' => '#aaa',
'website' => '#304', 'workstation' => '#a69944'
);
if (isset($arrayconvpictotocolor[$pictowithouttext]) && strpos($picto, '_nocolor') === false) {
$facolor = $arrayconvpictotocolor[$pictowithouttext];
@ -6652,16 +6653,16 @@ function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid
$obj = $db->fetch_object($resql);
if ($obj) {
return array(
'rowid'=>$obj->rowid,
'code'=>$obj->code,
'rate'=>$obj->rate,
'localtax1'=>$obj->localtax1,
'localtax1_type'=>$obj->localtax1_type,
'localtax2'=>$obj->localtax2,
'localtax2_type'=>$obj->localtax2_type,
'npr'=>$obj->npr,
'accountancy_code_sell'=>$obj->accountancy_code_sell,
'accountancy_code_buy'=>$obj->accountancy_code_buy
'rowid' => $obj->rowid,
'code' => $obj->code,
'rate' => $obj->rate,
'localtax1' => $obj->localtax1,
'localtax1_type' => $obj->localtax1_type,
'localtax2' => $obj->localtax2,
'localtax2_type' => $obj->localtax2_type,
'npr' => $obj->npr,
'accountancy_code_sell' => $obj->accountancy_code_sell,
'accountancy_code_buy' => $obj->accountancy_code_buy
);
} else {
return array();
@ -7496,7 +7497,7 @@ function dol_string_onlythesehtmlattributes($stringtoclean, $allowed_attributes
// Warning: loadHTML does not support HTML5 on old libxml versions.
$dom = new DOMDocument(null, 'UTF-8');
$dom->loadHTML($stringtoclean, LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_HTML_NODEFDTD|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
$dom->loadHTML($stringtoclean, LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
if (is_object($dom)) {
for ($els = $dom->getElementsByTagname('*'), $i = $els->length - 1; $i >= 0; $i--) {
@ -7621,7 +7622,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
$lastaddediscontent = 1;
while ($countline < $nboflines && isset($a[$i])) {
if (preg_match('/<br[^>]*>/', $a[$i])) {
if (array_key_exists($i+1, $a) && !empty($a[$i+1])) {
if (array_key_exists($i + 1, $a) && !empty($a[$i + 1])) {
$firstline .= ($ishtml ? "<br>\n" : "\n");
// Is it a br for a new line of after a printed line ?
if (!$lastaddediscontent) {
@ -7637,7 +7638,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
$i++;
}
$adddots = (isset($a[$i]) && (!preg_match('/<br[^>]*>/', $a[$i]) || (array_key_exists($i+1, $a) && !empty($a[$i+1]))));
$adddots = (isset($a[$i]) && (!preg_match('/<br[^>]*>/', $a[$i]) || (array_key_exists($i + 1, $a) && !empty($a[$i + 1]))));
//unset($a);
$ret = $firstline.($adddots ? '...' : '');
//exit;
@ -7709,7 +7710,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
// like 'abc' that wrongly ends up, without the trick, with '<p>abc</p>'
$out = '<?xml encoding="UTF-8"><div class="tricktoremove">'.$out.'</div>';
$dom->loadHTML($out, LIBXML_HTML_NODEFDTD|LIBXML_ERR_NONE|LIBXML_HTML_NOIMPLIED|LIBXML_NONET|LIBXML_NOWARNING|LIBXML_NOXMLDECL);
$dom->loadHTML($out, LIBXML_HTML_NODEFDTD | LIBXML_ERR_NONE | LIBXML_HTML_NOIMPLIED | LIBXML_NONET | LIBXML_NOWARNING | LIBXML_NOXMLDECL);
$out = trim($dom->saveHTML());
// Remove the trick added to solve pb with text without parent tag
@ -7862,9 +7863,9 @@ function dol_htmlentitiesbr($stringtoencode, $nl2brmode = 0, $pagecodefrom = 'UT
if ($removelasteolbr) {
$newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
}
$newstring = strtr($newstring, array('&'=>'__and__', '<'=>'__lt__', '>'=>'__gt__', '"'=>'__dquot__'));
$newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
$newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding
$newstring = strtr($newstring, array('__and__'=>'&', '__lt__'=>'<', '__gt__'=>'>', '__dquot__'=>'"'));
$newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
} else {
if ($removelasteolbr) {
$newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
@ -7919,11 +7920,11 @@ function dol_html_entity_decode($a, $b, $c = 'UTF-8', $keepsomeentities = 0)
{
$newstring = $a;
if ($keepsomeentities) {
$newstring = strtr($newstring, array('&amp;'=>'__andamp__', '&lt;'=>'__andlt__', '&gt;'=>'__andgt__', '"'=>'__dquot__'));
$newstring = strtr($newstring, array('&amp;' => '__andamp__', '&lt;' => '__andlt__', '&gt;' => '__andgt__', '"' => '__dquot__'));
}
$newstring = html_entity_decode((string) $newstring, (int) $b, (string) $c);
if ($keepsomeentities) {
$newstring = strtr($newstring, array('__andamp__'=>'&amp;', '__andlt__'=>'&lt;', '__andgt__'=>'&gt;', '__dquot__'=>'"'));
$newstring = strtr($newstring, array('__andamp__' => '&amp;', '__andlt__' => '&lt;', '__andgt__' => '&gt;', '__dquot__' => '"'));
}
return $newstring;
}
@ -7939,7 +7940,7 @@ function dol_html_entity_decode($a, $b, $c = 'UTF-8', $keepsomeentities = 0)
* @return string $ret Encoded string
* @see dol_htmlentitiesbr()
*/
function dol_htmlentities($string, $flags = ENT_QUOTES|ENT_SUBSTITUTE, $encoding = 'UTF-8', $double_encode = false)
function dol_htmlentities($string, $flags = ENT_QUOTES | ENT_SUBSTITUTE, $encoding = 'UTF-8', $double_encode = false)
{
return htmlentities($string, $flags, $encoding, $double_encode);
}
@ -10184,7 +10185,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
if ($posstart > 0) {
$posend = strpos($str, ')');
if ($posstart > 0) {
$res1 = substr($str, $posstart + 1, $posend - $posstart -1);
$res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
if (is_numeric($res1)) {
$postab = (int) $res1;
$values[1] = '+' . substr($str, $posend + 1);
@ -10217,7 +10218,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
// If label is "SUBSTITUION_..."
$substitutionarray = array();
complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey'=>$values[2]));
complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
$label = make_substitutions($reg[1], $substitutionarray);
} else {
// If label is "Label,Class,File,Method", we call the method to show content inside the badge
@ -10267,7 +10268,7 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
}
if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
$substitutionarray = array();
complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey'=>$values[2]));
complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
$label = make_substitutions($reg[1], $substitutionarray);
} else {
$label = $langs->trans($values[2]);
@ -10873,7 +10874,7 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param
if ($alldata == 1) {
if ($isAllowedForPreview) {
return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime'=>dol_mimetype($relativepath));
return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart).'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime' => dol_mimetype($relativepath));
} else {
return array();
}
@ -11418,7 +11419,7 @@ function roundUpToNextMultiple($n, $x = 5)
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
{
$attr = array(
'class'=>'badge '.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css'])
'class' => 'badge '.(!empty($mode) ? ' badge-'.$mode : '').(!empty($type) ? ' badge-'.$type : '').(empty($params['css']) ? '' : ' '.$params['css'])
);
if (empty($html)) {
@ -11683,7 +11684,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
// automatic add tooltip when title is detected
if (!empty($attr['title']) && !empty($attr['class']) && strpos($attr['class'], 'classfortooltip') === false) {
$attr['class'].= ' classfortooltip';
$attr['class'] .= ' classfortooltip';
}
// Js Confirm button
@ -11705,7 +11706,7 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url =
$attr['data-confirm-cancel-btn-label'] = !empty($params['confirm']['cancel-btn-label']) ? $params['confirm']['cancel-btn-label'] : $langs->trans('CloseDialog');
$attr['data-confirm-modal'] = !empty($params['confirm']['modal']) ? $params['confirm']['modal'] : true;
$attr['class'].= ' butActionConfirm';
$attr['class'] .= ' butActionConfirm';
}
if (isset($attr['href']) && empty($attr['href'])) {
@ -11776,9 +11777,9 @@ function getFieldErrorIcon($fieldValidationErrorMsg)
{
$out = '';
if (!empty($fieldValidationErrorMsg)) {
$out.= '<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).'" role="alert" >'; // role alert is used for accessibility
$out.= '<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>'; // For accessibility icon is separated and aria-hidden
$out.= '</span>';
$out .= '<span class="field-error-icon classfortooltip" title="'.dol_escape_htmltag($fieldValidationErrorMsg, 1).'" role="alert" >'; // role alert is used for accessibility
$out .= '<span class="fa fa-exclamation-circle" aria-hidden="true" ></span>'; // For accessibility icon is separated and aria-hidden
$out .= '</span>';
}
return $out;
@ -12596,8 +12597,8 @@ function dolForgeExplodeAnd($sqlfilters)
}
if ($countparenthesis == 0) {
$char2 = dol_substr($sqlfilters, $i+1, 1);
$char3 = dol_substr($sqlfilters, $i+2, 1);
$char2 = dol_substr($sqlfilters, $i + 1, 1);
$char3 = dol_substr($sqlfilters, $i + 2, 1);
if ($char == 'A' && $char2 == 'N' && $char3 == 'D') {
// We found a AND
$s = trim($s);
@ -12606,7 +12607,7 @@ function dolForgeExplodeAnd($sqlfilters)
}
$arrayofandtags[] = $s;
$s = '';
$i+=2;
$i += 2;
} else {
$s .= $char;
}
@ -13144,51 +13145,51 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
}
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>$tododone,
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'type' => $obj->type,
'tododone' => $tododone,
'id' => $obj->id,
'datestart' => $db->jdate($obj->dp),
'dateend' => $db->jdate($obj->dp2),
'note' => $obj->label,
'message' => $obj->message,
'percent' => $obj->percent,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo,
'msg_from'=>$obj->msg_from,
'userid' => $obj->user_id,
'login' => $obj->user_login,
'userfirstname' => $obj->user_firstname,
'userlastname' => $obj->user_lastname,
'userphoto' => $obj->user_photo,
'msg_from' => $obj->msg_from,
'contact_id'=>$obj->fk_contact,
'contact_id' => $obj->fk_contact,
'socpeopleassigned' => $contactaction->socpeopleassigned,
'lastname' => (empty($obj->lastname) ? '' : $obj->lastname),
'firstname' => (empty($obj->firstname) ? '' : $obj->firstname),
'fk_element'=>$obj->fk_element,
'elementtype'=>$obj->elementtype,
'fk_element' => $obj->fk_element,
'elementtype' => $obj->elementtype,
// Type of event
'acode'=>$obj->acode,
'alabel'=>$obj->alabel,
'libelle'=>$obj->alabel, // deprecated
'apicto'=>$obj->apicto
'acode' => $obj->acode,
'alabel' => $obj->alabel,
'libelle' => $obj->alabel, // deprecated
'apicto' => $obj->apicto
);
} else {
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>'done',
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'acode'=>$obj->acode,
'type' => $obj->type,
'tododone' => 'done',
'id' => $obj->id,
'datestart' => $db->jdate($obj->dp),
'dateend' => $db->jdate($obj->dp2),
'note' => $obj->label,
'message' => $obj->message,
'percent' => $obj->percent,
'acode' => $obj->acode,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo
'userid' => $obj->user_id,
'login' => $obj->user_login,
'userfirstname' => $obj->user_firstname,
'userlastname' => $obj->user_lastname,
'userphoto' => $obj->user_photo
);
}