Passed
Push — master ( 65bdac...4e88da )
by Alxarafe
32:38
created
Helpers/login/functions_openid.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,13 +34,13 @@  discard block
 block discarded – undo
34 34
  * @param   int		$entitytotest   Number of instance (always 1 if module multicompany not enabled)
35 35
  * @return	string					Login if OK, '' if KO
36 36
  */
37
-function check_user_password_openid($usertotest,$passwordtotest,$entitytotest)
37
+function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
38 38
 {
39
-    global $_POST,$db,$conf,$langs;
39
+    global $_POST, $db, $conf, $langs;
40 40
 
41 41
     dol_syslog("functions_openid::check_user_password_openid usertotest=".$usertotest);
42 42
 
43
-    $login='';
43
+    $login = '';
44 44
 
45 45
     // Get identity from user and redirect browser to OpenID Server
46 46
     if (isset($_POST['username']))
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         $openid = new SimpleOpenID();
49 49
         $openid->SetIdentity($_POST['username']);
50 50
         $protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
51
-        $openid->SetTrustRoot($protocol . $_SERVER["HTTP_HOST"]);
52
-        $openid->SetRequiredFields(array('email','fullname'));
51
+        $openid->SetTrustRoot($protocol.$_SERVER["HTTP_HOST"]);
52
+        $openid->SetRequiredFields(array('email', 'fullname'));
53 53
         $_SESSION['dol_entity'] = $_POST["entity"];
54 54
         //$openid->SetOptionalFields(array('dob','gender','postcode','country','language','timezone'));
55 55
         if ($openid->sendDiscoveryRequestToGetXRDS())
56 56
         {
57
-            $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58
-            $openid->Redirect();     // This will redirect user to OpenID Server
57
+            $openid->SetApprovedURL($protocol.$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]); // Send Response from OpenID server to this script
58
+            $openid->Redirect(); // This will redirect user to OpenID Server
59 59
         }
60 60
         else
61 61
         {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         return false;
66 66
     }
67 67
     // Perform HTTP Request to OpenID server to validate key
68
-    elseif($_GET['openid_mode'] == 'id_res')
68
+    elseif ($_GET['openid_mode'] == 'id_res')
69 69
     {
70 70
         $openid = new SimpleOpenID();
71 71
         $openid->SetIdentity($_GET['openid_identity']);
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
         {
75 75
             // OK HERE KEY IS VALID
76 76
 
77
-            $sql ="SELECT login";
78
-            $sql.=" FROM ".MAIN_DB_PREFIX."user";
79
-            $sql.=" WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
80
-            $sql.=" AND entity IN (0," . ($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1) . ")";
77
+            $sql = "SELECT login";
78
+            $sql .= " FROM ".MAIN_DB_PREFIX."user";
79
+            $sql .= " WHERE openid = '".$db->escape($_GET['openid_identity'])."'";
80
+            $sql .= " AND entity IN (0,".($_SESSION["dol_entity"] ? $_SESSION["dol_entity"] : 1).")";
81 81
 
82 82
             dol_syslog("functions_openid::check_user_password_openid", LOG_DEBUG);
83
-            $resql=$db->query($sql);
83
+            $resql = $db->query($sql);
84 84
             if ($resql)
85 85
             {
86
-                $obj=$db->fetch_object($resql);
86
+                $obj = $db->fetch_object($resql);
87 87
                 if ($obj)
88 88
                 {
89
-                    $login=$obj->login;
89
+                    $login = $obj->login;
90 90
                 }
91 91
             }
92 92
         }
93
-        else if($openid->IsError() === true)
93
+        else if ($openid->IsError() === true)
94 94
         {
95 95
             // ON THE WAY, WE GOT SOME ERROR
96 96
             $error = $openid->GetError();
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
56 56
         {
57 57
             $openid->SetApprovedURL($protocol . $_SERVER["HTTP_HOST"] . $_SERVER["SCRIPT_NAME"]);      // Send Response from OpenID server to this script
58 58
             $openid->Redirect();     // This will redirect user to OpenID Server
59
-        }
60
-        else
59
+        } else
61 60
         {
62 61
             $error = $openid->GetError();
63 62
             return false;
@@ -89,21 +88,18 @@  discard block
 block discarded – undo
89 88
                     $login=$obj->login;
90 89
                 }
91 90
             }
92
-        }
93
-        else if($openid->IsError() === true)
91
+        } else if($openid->IsError() === true)
94 92
         {
95 93
             // ON THE WAY, WE GOT SOME ERROR
96 94
             $error = $openid->GetError();
97 95
             return false;
98
-        }
99
-        else
96
+        } else
100 97
         {
101 98
             // Signature Verification Failed
102 99
             //echo "INVALID AUTHORIZATION";
103 100
             return false;
104 101
         }
105
-    }
106
-    else if ($_GET['openid_mode'] == 'cancel')
102
+    } else if ($_GET['openid_mode'] == 'cancel')
107 103
     {
108 104
         // User Canceled your Request
109 105
         //echo "USER CANCELED REQUEST";
Please login to merge, or discard this patch.
Helpers/login/functions_empty.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@
 block discarded – undo
33 33
  */
34 34
 function check_user_password_empty($usertotest,$passwordtotest,$entitytotest)
35 35
 {
36
-	global $langs;
36
+    global $langs;
37 37
 
38
-	dol_syslog("functions_empty::check_user_password_empty usertotest=".$usertotest);
38
+    dol_syslog("functions_empty::check_user_password_empty usertotest=".$usertotest);
39 39
 
40
-	$login='';
41
-	$_SESSION["dol_loginmesg"]=$langs->trans("FailedToLogin");
40
+    $login='';
41
+    $_SESSION["dol_loginmesg"]=$langs->trans("FailedToLogin");
42 42
 
43
-	return $login;
43
+    return $login;
44 44
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,14 +31,14 @@
 block discarded – undo
31 31
  * @param   int		$entitytotest   Number of instance (always 1 if module multicompany not enabled)
32 32
  * @return	string					Login if OK, '' if KO
33 33
  */
34
-function check_user_password_empty($usertotest,$passwordtotest,$entitytotest)
34
+function check_user_password_empty($usertotest, $passwordtotest, $entitytotest)
35 35
 {
36 36
 	global $langs;
37 37
 
38 38
 	dol_syslog("functions_empty::check_user_password_empty usertotest=".$usertotest);
39 39
 
40
-	$login='';
41
-	$_SESSION["dol_loginmesg"]=$langs->trans("FailedToLogin");
40
+	$login = '';
41
+	$_SESSION["dol_loginmesg"] = $langs->trans("FailedToLogin");
42 42
 
43 43
 	return $login;
44 44
 }
Please login to merge, or discard this patch.
Helpers/AlixarDispatcher.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
     public function __construct()
14 14
     {
15
-        $this->searchDir[] = BASE_PATH . '/plugins';
15
+        $this->searchDir[] = BASE_PATH.'/plugins';
16 16
         $this->nameSpaces[] = 'Alixar';
17 17
 
18 18
         parent::__construct();
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
           define('SITE_URL', APP_PROTOCOL . '://' . SERVER_NAME);
42 42
           define('BASE_URI', SITE_URL . APP_URI);
43 43
          */
44
-        define('DOL_BASE_PATH', BASE_PATH . '/dolibarr/htdocs');
45
-        define('DOL_BASE_URI', BASE_URI . '/dolibarr/htdocs');
44
+        define('DOL_BASE_PATH', BASE_PATH.'/dolibarr/htdocs');
45
+        define('DOL_BASE_URI', BASE_URI.'/dolibarr/htdocs');
46 46
         define('DOL_DOCUMENT_ROOT', DOL_BASE_PATH);
47 47
 
48 48
         define('CORE_FOLDER', '/core');
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
         define('CACHE_FOLDER', '/../cache');
57 57
         //define('VENDOR_FOLDER', BASE_URI . '/vendor');
58 58
 
59
-        define('CORE_PATH', BASE_PATH . CORE_FOLDER);
60
-        define('CONFIG_PATH', BASE_PATH . CONFIG_FOLDER);
61
-        define('CONTROLLERS_PATH', BASE_PATH . CONTROLLERS_FOLDER);
62
-        define('HELPERS_PATH', BASE_PATH . HELPERS_FOLDER);
63
-        define('MODELS_PATH', BASE_PATH . MODELS_FOLDER);
64
-        define('SKINS_PATH', BASE_PATH . SKINS_FOLDER);
65
-        define('TEMPLATES_PATH', BASE_PATH . TEMPLATES_FOLDER);
66
-        define('PLUGINS_PATH', BASE_PATH . PLUGINS_FOLDER);
67
-        define('CACHE_PATH', BASE_PATH . CACHE_FOLDER);
59
+        define('CORE_PATH', BASE_PATH.CORE_FOLDER);
60
+        define('CONFIG_PATH', BASE_PATH.CONFIG_FOLDER);
61
+        define('CONTROLLERS_PATH', BASE_PATH.CONTROLLERS_FOLDER);
62
+        define('HELPERS_PATH', BASE_PATH.HELPERS_FOLDER);
63
+        define('MODELS_PATH', BASE_PATH.MODELS_FOLDER);
64
+        define('SKINS_PATH', BASE_PATH.SKINS_FOLDER);
65
+        define('TEMPLATES_PATH', BASE_PATH.TEMPLATES_FOLDER);
66
+        define('PLUGINS_PATH', BASE_PATH.PLUGINS_FOLDER);
67
+        define('CACHE_PATH', BASE_PATH.CACHE_FOLDER);
68 68
         //define('VENDOR_PATH', BASE_PATH . VENDOR_FOLDER);
69 69
 
70 70
         /**
Please login to merge, or discard this patch.
Helpers/DolUtils.php 3 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
      */
259 259
     static function dol_shutdown()
260 260
     {
261
-       // global Globals::$conf, $user, $langs, $db;
261
+        // global Globals::$conf, $user, $langs, $db;
262 262
         $disconnectdone = false;
263 263
         $depth = 0;
264 264
         if (is_object($db) && !empty($db->connected)) {
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
      */
306 306
     static function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $options = null, $noreplace = 0)
307 307
     {
308
-       // global $mysoc, $user, Globals::$conf;
308
+        // global $mysoc, $user, Globals::$conf;
309 309
 
310 310
         if (empty($paramname))
311 311
             return 'BadFirstParameterForDolUtils::GETPOST';
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
             elseif (!isset($_GET['sortfield'])) { // If we did a click on a field to sort, we do no apply default values. Same if option MAIN_ENABLE_DEFAULT_VALUES is not set
365 365
                 if (!empty($_GET['action']) && $_GET['action'] == 'create' && !isset($_GET[$paramname]) && !isset($_POST[$paramname])) {
366 366
                     // Search default value from $object->field
367
-                   // global $object;
367
+                    // global $object;
368 368
                     if (is_object($object) && isset($object->fields[$paramname]['default'])) {
369 369
                         $out = $object->fields[$paramname]['default'];
370 370
                     }
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
      */
708 708
     static function dol_include_once($relpath, $classname = '')
709 709
     {
710
-       // global Globals::$conf, $langs, $user, $mysoc;   // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var']
710
+        // global Globals::$conf, $langs, $user, $mysoc;   // Do not remove this. They must be defined for files we include. Other globals var must be retreived with $GLOBALS['var']
711 711
 
712 712
         $fullpath = dol_buildpath($relpath);
713 713
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
      */
736 736
     static function dol_buildpath($path, $type = 0, $returnemptyifnotfound = 0)
737 737
     {
738
-       // global Globals::$conf;
738
+        // global Globals::$conf;
739 739
 
740 740
         $path = preg_replace('/^\//', '', $path);
741 741
 
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
             foreach (Globals::$conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
778 778
                 if ($key == 'main') {
779 779
                     if ($type == 3) {
780
-                       // global $dolibarr_main_url_root;
780
+                        // global $dolibarr_main_url_root;
781 781
                         // Define $urlwithroot
782 782
 
783 783
                         // $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_BASE_URI, '/') . '$/i', '', trim($dolibarr_main_url_root));
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
                             $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT) . Globals::$conf->file->dol_url_root[$key] . '/' . $path;
802 802
                         }
803 803
                         if ($type == 3) {
804
-                           // global $dolibarr_main_url_root;
804
+                            // global $dolibarr_main_url_root;
805 805
                             // Define $urlwithroot
806 806
                             $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_BASE_URI, '/') . '$/i', '', trim($dolibarr_main_url_root));
807 807
                             $urlwithroot = $urlwithouturlroot . DOL_BASE_URI;  // This is to use external domain name found into config file
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
      */
1072 1072
     static function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename = '', $restricttologhandler = '')
1073 1073
     {
1074
-       // global Globals::$conf, $user;
1074
+        // global Globals::$conf, $user;
1075 1075
 // If syslog module enabled
1076 1076
         if (empty(Globals::$conf->syslog->enabled))
1077 1077
             return;
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
      */
1178 1178
     static function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab = 0, $picto = '', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '')
1179 1179
     {
1180
-       // global Globals::$conf, $langs, $hookmanager;
1180
+        // global Globals::$conf, $langs, $hookmanager;
1181 1181
 
1182 1182
         $out = "\n" . '<div class="tabs" data-role="controlgroup" data-type="horizontal">' . "\n";
1183 1183
 
@@ -1360,7 +1360,7 @@  discard block
 block discarded – undo
1360 1360
      */
1361 1361
     static function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $onlybanner = 0, $morehtmlright = '')
1362 1362
     {
1363
-       // global Globals::$conf, $form, $user, $langs;
1363
+        // global Globals::$conf, $form, $user, $langs;
1364 1364
 
1365 1365
         $error = 0;
1366 1366
 
@@ -1639,7 +1639,7 @@  discard block
 block discarded – undo
1639 1639
      */
1640 1640
     static function fieldLabel($langkey, $fieldkey, $fieldrequired = 0)
1641 1641
     {
1642
-       // global Globals::$conf, $langs;
1642
+        // global Globals::$conf, $langs;
1643 1643
         $ret = '';
1644 1644
         if ($fieldrequired)
1645 1645
             $ret .= '<span class="fieldrequired">';
@@ -1662,7 +1662,7 @@  discard block
 block discarded – undo
1662 1662
      */
1663 1663
     static function dol_bc($var, $moreclass = '')
1664 1664
     {
1665
-       // global $bc;
1665
+        // global $bc;
1666 1666
         $ret = ' ' . $bc[$var];
1667 1667
         if ($moreclass)
1668 1668
             $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
      */
1683 1683
     static function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0)
1684 1684
     {
1685
-       // global Globals::$conf, $langs;
1685
+        // global Globals::$conf, $langs;
1686 1686
 
1687 1687
         $ret = '';
1688 1688
         $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR');    // See also MAIN_FORCE_STATE_INTO_ADDRESS
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
      */
1774 1774
     static function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false)
1775 1775
     {
1776
-       // global Globals::$conf, $langs;
1776
+        // global Globals::$conf, $langs;
1777 1777
 // Clean parameters
1778 1778
         $to_gmt = false;
1779 1779
         $offsettz = $offsetdst = 0;
@@ -1984,7 +1984,7 @@  discard block
 block discarded – undo
1984 1984
      */
1985 1985
     static function dol_getdate($timestamp, $fast = false)
1986 1986
     {
1987
-       // global Globals::$conf;
1987
+        // global Globals::$conf;
1988 1988
 
1989 1989
         $usealternatemethod = false;
1990 1990
         if ($timestamp <= 0)
@@ -2022,7 +2022,7 @@  discard block
 block discarded – undo
2022 2022
      */
2023 2023
     static function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1)
2024 2024
     {
2025
-       // global Globals::$conf;
2025
+        // global Globals::$conf;
2026 2026
 //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
2027 2027
 // Clean parameters
2028 2028
         if ($hour == -1 || empty($hour))
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
      */
2135 2135
     static function dol_print_size($size, $shortvalue = 0, $shortunit = 0)
2136 2136
     {
2137
-       // global Globals::$conf, $langs;
2137
+        // global Globals::$conf, $langs;
2138 2138
         $level = 1024;
2139 2139
 
2140 2140
         if (!empty(Globals::$conf->dol_optimize_smallscreen))
@@ -2171,7 +2171,7 @@  discard block
 block discarded – undo
2171 2171
      */
2172 2172
     static function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0)
2173 2173
     {
2174
-       // global $langs;
2174
+        // global $langs;
2175 2175
 
2176 2176
         if (empty($url))
2177 2177
             return '';
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
      */
2206 2206
     static function dol_print_email($email, $cid = 0, $socid = 0, $addlink = 0, $max = 64, $showinvalid = 1, $withpicto = 0)
2207 2207
     {
2208
-       // global Globals::$conf, $user, $langs, $hookmanager;
2208
+        // global Globals::$conf, $user, $langs, $hookmanager;
2209 2209
 
2210 2210
         $newemail = $email;
2211 2211
 
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
      */
2263 2263
     static function dol_print_socialnetworks($value, $cid, $socid, $type)
2264 2264
     {
2265
-       // global Globals::$conf, $user, $langs;
2265
+        // global Globals::$conf, $user, $langs;
2266 2266
 
2267 2267
         $newskype = $value;
2268 2268
 
@@ -2317,7 +2317,7 @@  discard block
 block discarded – undo
2317 2317
      */
2318 2318
     static function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addlink = '', $separ = "&nbsp;", $withpicto = '', $titlealt = '', $adddivfloat = 0)
2319 2319
     {
2320
-       // global Globals::$conf, $user, $langs, $mysoc, $hookmanager;
2320
+        // global Globals::$conf, $user, $langs, $mysoc, $hookmanager;
2321 2321
 // Clean phone parameter
2322 2322
         $phone = preg_replace("/[\s.-]/", "", trim($phone));
2323 2323
         if (empty($phone)) {
@@ -2581,7 +2581,7 @@  discard block
 block discarded – undo
2581 2581
      */
2582 2582
     static function dol_print_ip($ip, $mode = 0)
2583 2583
     {
2584
-       // global Globals::$conf, $langs;
2584
+        // global Globals::$conf, $langs;
2585 2585
 
2586 2586
         $ret = '';
2587 2587
 
@@ -2626,7 +2626,7 @@  discard block
 block discarded – undo
2626 2626
      */
2627 2627
     static function dolGetCountryCodeFromIp($ip)
2628 2628
     {
2629
-       // global Globals::$conf;
2629
+        // global Globals::$conf;
2630 2630
 
2631 2631
         $countrycode = '';
2632 2632
 
@@ -2653,7 +2653,7 @@  discard block
 block discarded – undo
2653 2653
      */
2654 2654
     static function dol_user_country()
2655 2655
     {
2656
-       // global Globals::$conf, $langs, $user;
2656
+        // global Globals::$conf, $langs, $user;
2657 2657
 //$ret=$user->xxx;
2658 2658
         $ret = '';
2659 2659
         if (!empty(Globals::$conf->geoipmaxmind->enabled)) {
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
      */
2684 2684
     static function dol_print_address($address, $htmlid, $mode, $id, $noprint = 0, $charfornl = '')
2685 2685
     {
2686
-       // global Globals::$conf, $user, $langs, $hookmanager;
2686
+        // global Globals::$conf, $user, $langs, $hookmanager;
2687 2687
 
2688 2688
         $out = '';
2689 2689
 
@@ -2815,7 +2815,7 @@  discard block
 block discarded – undo
2815 2815
      */
2816 2816
     static function dol_substr($string, $start, $length, $stringencoding = '', $trunconbytes = 0)
2817 2817
     {
2818
-       // global $langs;
2818
+        // global $langs;
2819 2819
 
2820 2820
         if (empty($stringencoding))
2821 2821
             $stringencoding = $langs->charset_output;
@@ -2852,7 +2852,7 @@  discard block
 block discarded – undo
2852 2852
      */
2853 2853
     static function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF-8', $nodot = 0, $display = 0)
2854 2854
     {
2855
-       // global Globals::$conf;
2855
+        // global Globals::$conf;
2856 2856
 
2857 2857
         if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC))
2858 2858
             return $string;
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
      */
2919 2919
     static function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0, $alt = '', $morecss = '')
2920 2920
     {
2921
-       // global Globals::$conf, $langs;
2921
+        // global Globals::$conf, $langs;
2922 2922
 // We forge fullpathpicto for image to $path/img/$picto. By default, we take DOL_BASE_URI/theme/$conf->theme/img/$picto
2923 2923
 //$url = DOL_BASE_URI;
2924 2924
         $url = DOL_BASE_URI;
@@ -3103,7 +3103,7 @@  discard block
 block discarded – undo
3103 3103
      */
3104 3104
     static function img_weather($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0)
3105 3105
     {
3106
-       // global Globals::$conf;
3106
+        // global Globals::$conf;
3107 3107
 
3108 3108
         if (!preg_match('/(\.png|\.gif)$/i', $picto))
3109 3109
             $picto .= '.png';
@@ -3126,7 +3126,7 @@  discard block
 block discarded – undo
3126 3126
      */
3127 3127
     static function img_picto_common($titlealt, $picto, $moreatt = '', $pictoisfullpath = 0)
3128 3128
     {
3129
-       // global Globals::$conf;
3129
+        // global Globals::$conf;
3130 3130
 
3131 3131
         if (!preg_match('/(\.png|\.gif)$/i', $picto))
3132 3132
             $picto .= '.png';
@@ -3157,7 +3157,7 @@  discard block
 block discarded – undo
3157 3157
      */
3158 3158
     static function img_action($titlealt, $numaction)
3159 3159
     {
3160
-       // global Globals::$conf, $langs;
3160
+        // global Globals::$conf, $langs;
3161 3161
 
3162 3162
         if (empty($titlealt) || $titlealt == 'default') {
3163 3163
             if ($numaction == '-1' || $numaction == 'ST_NO') {
@@ -3195,7 +3195,7 @@  discard block
 block discarded – undo
3195 3195
      */
3196 3196
     static function img_pdf($titlealt = 'default', $size = 3)
3197 3197
     {
3198
-       // global Globals::$conf, $langs;
3198
+        // global Globals::$conf, $langs;
3199 3199
 
3200 3200
         if ($titlealt == 'default')
3201 3201
             $titlealt = $langs->trans('Show');
@@ -3212,7 +3212,7 @@  discard block
 block discarded – undo
3212 3212
      */
3213 3213
     static function img_edit_add($titlealt = 'default', $other = '')
3214 3214
     {
3215
-       // global Globals::$conf, $langs;
3215
+        // global Globals::$conf, $langs;
3216 3216
 
3217 3217
         if ($titlealt == 'default')
3218 3218
             $titlealt = $langs->trans('Add');
@@ -3229,7 +3229,7 @@  discard block
 block discarded – undo
3229 3229
      */
3230 3230
     static function img_edit_remove($titlealt = 'default', $other = '')
3231 3231
     {
3232
-       // global Globals::$conf, $langs;
3232
+        // global Globals::$conf, $langs;
3233 3233
 
3234 3234
         if ($titlealt == 'default')
3235 3235
             $titlealt = $langs->trans('Remove');
@@ -3247,7 +3247,7 @@  discard block
 block discarded – undo
3247 3247
      */
3248 3248
     static function img_edit($titlealt = 'default', $float = 0, $other = 'class="pictoedit"')
3249 3249
     {
3250
-       // global Globals::$conf, $langs;
3250
+        // global Globals::$conf, $langs;
3251 3251
 
3252 3252
         if ($titlealt == 'default')
3253 3253
             $titlealt = $langs->trans('Modify');
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
      */
3266 3266
     static function img_view($titlealt = 'default', $float = 0, $other = '')
3267 3267
     {
3268
-       // global Globals::$conf, $langs;
3268
+        // global Globals::$conf, $langs;
3269 3269
 
3270 3270
         if ($titlealt == 'default')
3271 3271
             $titlealt = $langs->trans('View');
@@ -3284,7 +3284,7 @@  discard block
 block discarded – undo
3284 3284
      */
3285 3285
     static function img_delete($titlealt = 'default', $other = 'class="pictodelete"')
3286 3286
     {
3287
-       // global Globals::$conf, $langs;
3287
+        // global Globals::$conf, $langs;
3288 3288
 
3289 3289
         if ($titlealt == 'default')
3290 3290
             $titlealt = $langs->trans('Delete');
@@ -3302,7 +3302,7 @@  discard block
 block discarded – undo
3302 3302
      */
3303 3303
     static function img_printer($titlealt = "default", $other = '')
3304 3304
     {
3305
-       // global Globals::$conf, $langs;
3305
+        // global Globals::$conf, $langs;
3306 3306
         if ($titlealt == "default")
3307 3307
             $titlealt = $langs->trans("Print");
3308 3308
         return img_picto($titlealt, 'printer.png', $other);
@@ -3317,7 +3317,7 @@  discard block
 block discarded – undo
3317 3317
      */
3318 3318
     static function img_split($titlealt = 'default', $other = 'class="pictosplit"')
3319 3319
     {
3320
-       // global Globals::$conf, $langs;
3320
+        // global Globals::$conf, $langs;
3321 3321
 
3322 3322
         if ($titlealt == 'default')
3323 3323
             $titlealt = $langs->trans('Split');
@@ -3334,7 +3334,7 @@  discard block
 block discarded – undo
3334 3334
      */
3335 3335
     static function img_help($usehelpcursor = 1, $usealttitle = 1)
3336 3336
     {
3337
-       // global Globals::$conf, $langs;
3337
+        // global Globals::$conf, $langs;
3338 3338
 
3339 3339
         if ($usealttitle) {
3340 3340
             if (is_string($usealttitle))
@@ -3354,7 +3354,7 @@  discard block
 block discarded – undo
3354 3354
      */
3355 3355
     static function img_info($titlealt = 'default')
3356 3356
     {
3357
-       // global Globals::$conf, $langs;
3357
+        // global Globals::$conf, $langs;
3358 3358
 
3359 3359
         if ($titlealt == 'default')
3360 3360
             $titlealt = $langs->trans('Informations');
@@ -3371,7 +3371,7 @@  discard block
 block discarded – undo
3371 3371
      */
3372 3372
     static function img_warning($titlealt = 'default', $moreatt = '')
3373 3373
     {
3374
-       // global Globals::$conf, $langs;
3374
+        // global Globals::$conf, $langs;
3375 3375
 
3376 3376
         if ($titlealt == 'default')
3377 3377
             $titlealt = $langs->trans('Warning');
@@ -3388,7 +3388,7 @@  discard block
 block discarded – undo
3388 3388
      */
3389 3389
     static function img_error($titlealt = 'default')
3390 3390
     {
3391
-       // global Globals::$conf, $langs;
3391
+        // global Globals::$conf, $langs;
3392 3392
 
3393 3393
         if ($titlealt == 'default')
3394 3394
             $titlealt = $langs->trans('Error');
@@ -3405,7 +3405,7 @@  discard block
 block discarded – undo
3405 3405
      */
3406 3406
     static function img_next($titlealt = 'default', $moreatt = '')
3407 3407
     {
3408
-       // global Globals::$conf, $langs;
3408
+        // global Globals::$conf, $langs;
3409 3409
 
3410 3410
         if ($titlealt == 'default')
3411 3411
             $titlealt = $langs->trans('Next');
@@ -3423,7 +3423,7 @@  discard block
 block discarded – undo
3423 3423
      */
3424 3424
     static function img_previous($titlealt = 'default', $moreatt = '')
3425 3425
     {
3426
-       // global Globals::$conf, $langs;
3426
+        // global Globals::$conf, $langs;
3427 3427
 
3428 3428
         if ($titlealt == 'default')
3429 3429
             $titlealt = $langs->trans('Previous');
@@ -3442,7 +3442,7 @@  discard block
 block discarded – undo
3442 3442
      */
3443 3443
     static function img_down($titlealt = 'default', $selected = 0, $moreclass = '')
3444 3444
     {
3445
-       // global Globals::$conf, $langs;
3445
+        // global Globals::$conf, $langs;
3446 3446
 
3447 3447
         if ($titlealt == 'default')
3448 3448
             $titlealt = $langs->trans('Down');
@@ -3460,7 +3460,7 @@  discard block
 block discarded – undo
3460 3460
      */
3461 3461
     static function img_up($titlealt = 'default', $selected = 0, $moreclass = '')
3462 3462
     {
3463
-       // global Globals::$conf, $langs;
3463
+        // global Globals::$conf, $langs;
3464 3464
 
3465 3465
         if ($titlealt == 'default')
3466 3466
             $titlealt = $langs->trans('Up');
@@ -3478,7 +3478,7 @@  discard block
 block discarded – undo
3478 3478
      */
3479 3479
     static function img_left($titlealt = 'default', $selected = 0, $moreatt = '')
3480 3480
     {
3481
-       // global Globals::$conf, $langs;
3481
+        // global Globals::$conf, $langs;
3482 3482
 
3483 3483
         if ($titlealt == 'default')
3484 3484
             $titlealt = $langs->trans('Left');
@@ -3496,7 +3496,7 @@  discard block
 block discarded – undo
3496 3496
      */
3497 3497
     static function img_right($titlealt = 'default', $selected = 0, $moreatt = '')
3498 3498
     {
3499
-       // global Globals::$conf, $langs;
3499
+        // global Globals::$conf, $langs;
3500 3500
 
3501 3501
         if ($titlealt == 'default')
3502 3502
             $titlealt = $langs->trans('Right');
@@ -3513,7 +3513,7 @@  discard block
 block discarded – undo
3513 3513
      */
3514 3514
     static function img_allow($allow, $titlealt = 'default')
3515 3515
     {
3516
-       // global Globals::$conf, $langs;
3516
+        // global Globals::$conf, $langs;
3517 3517
 
3518 3518
         if ($titlealt == 'default')
3519 3519
             $titlealt = $langs->trans('Active');
@@ -3588,7 +3588,7 @@  discard block
 block discarded – undo
3588 3588
     {
3589 3589
         dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
3590 3590
 
3591
-       // global Globals::$conf, $langs;
3591
+        // global Globals::$conf, $langs;
3592 3592
 
3593 3593
         if ($titlealt == 'default')
3594 3594
             $titlealt = $langs->trans('Call');
@@ -3610,7 +3610,7 @@  discard block
 block discarded – undo
3610 3610
      */
3611 3611
     static function img_search($titlealt = 'default', $other = '')
3612 3612
     {
3613
-       // global Globals::$conf, $langs;
3613
+        // global Globals::$conf, $langs;
3614 3614
 
3615 3615
         if ($titlealt == 'default')
3616 3616
             $titlealt = $langs->trans('Search');
@@ -3632,7 +3632,7 @@  discard block
 block discarded – undo
3632 3632
      */
3633 3633
     static function img_searchclear($titlealt = 'default', $other = '')
3634 3634
     {
3635
-       // global Globals::$conf, $langs;
3635
+        // global Globals::$conf, $langs;
3636 3636
 
3637 3637
         if ($titlealt == 'default')
3638 3638
             $titlealt = $langs->trans('Search');
@@ -3657,7 +3657,7 @@  discard block
 block discarded – undo
3657 3657
      */
3658 3658
     static function info_admin($text, $infoonimgalt = 0, $nodiv = 0, $admin = '1', $morecss = '')
3659 3659
     {
3660
-       // global Globals::$conf, $langs;
3660
+        // global Globals::$conf, $langs;
3661 3661
 
3662 3662
         if ($infoonimgalt) {
3663 3663
             return img_picto($text, 'info', 'class="hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '"');
@@ -3680,7 +3680,7 @@  discard block
 block discarded – undo
3680 3680
      */
3681 3681
     static function dol_print_error($db = '', $error = '', $errors = null)
3682 3682
     {
3683
-       // global Globals::$conf, $langs, $argv;
3683
+        // global Globals::$conf, $langs, $argv;
3684 3684
         // global $dolibarr_main_prod;
3685 3685
 
3686 3686
         $out = '';
@@ -3799,7 +3799,7 @@  discard block
 block discarded – undo
3799 3799
      */
3800 3800
     static function dol_print_error_email($prefixcode, $errormessage = '', $errormessages = array(), $morecss = 'error', $email = '')
3801 3801
     {
3802
-       // global $langs, Globals::$conf;
3802
+        // global $langs, Globals::$conf;
3803 3803
 
3804 3804
         if (empty($email))
3805 3805
             $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL;
@@ -3858,7 +3858,7 @@  discard block
 block discarded – undo
3858 3858
      */
3859 3859
     static function getTitleFieldOfList($name, $thead = 0, $file = "", $field = "", $begin = "", $moreparam = "", $moreattrib = "", $sortfield = "", $sortorder = "", $prefix = "", $disablesortlink = 0, $tooltip = '')
3860 3860
     {
3861
-       // global Globals::$conf, $langs, $form;
3861
+        // global Globals::$conf, $langs, $form;
3862 3862
 //print "$name, $file, $field, $begin, $options, $moreattrib, $sortfield, $sortorder<br>\n";
3863 3863
 
3864 3864
         $sortorder = strtoupper($sortorder);
@@ -3997,7 +3997,7 @@  discard block
 block discarded – undo
3997 3997
      */
3998 3998
     static function load_fiche_titre($titre, $morehtmlright = '', $picto = 'title_generic.png', $pictoisfullpath = 0, $id = '', $morecssontable = '', $morehtmlcenter = '')
3999 3999
     {
4000
-       // global Globals::$conf;
4000
+        // global Globals::$conf;
4001 4001
 
4002 4002
         $return = '';
4003 4003
 
@@ -4047,7 +4047,7 @@  discard block
 block discarded – undo
4047 4047
      */
4048 4048
     static function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '', $sortorder = '', $morehtmlcenter = '', $num = -1, $totalnboflines = '', $picto = 'title_generic.png', $pictoisfullpath = 0, $morehtmlright = '', $morecss = '', $limit = -1, $hideselectlimit = 0, $hidenavigation = 0)
4049 4049
     {
4050
-       // global Globals::$conf, $langs;
4050
+        // global Globals::$conf, $langs;
4051 4051
 
4052 4052
         $savlimit = $limit;
4053 4053
         $savtotalnboflines = $totalnboflines;
@@ -4160,7 +4160,7 @@  discard block
 block discarded – undo
4160 4160
      */
4161 4161
     static function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $betweenarrows = '', $afterarrows = '', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0)
4162 4162
     {
4163
-       // global Globals::$conf, $langs;
4163
+        // global Globals::$conf, $langs;
4164 4164
 
4165 4165
         print '<div class="pagination"><ul>';
4166 4166
         if ((int) $limit >= 0 && empty($hideselectlimit)) {
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
      */
4284 4284
     static function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $forcerounding = -1, $currency_code = '')
4285 4285
     {
4286
-       // global $langs, Globals::$conf;
4286
+        // global $langs, Globals::$conf;
4287 4287
 // Clean parameters
4288 4288
         if (empty($amount))
4289 4289
             $amount = 0; // To have a numeric value if amount not defined or = ''
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
      */
4377 4377
     static function price2num($amount, $rounding = '', $alreadysqlnb = 0)
4378 4378
     {
4379
-       // global $langs, Globals::$conf;
4379
+        // global $langs, Globals::$conf;
4380 4380
 // Round PHP static function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56'
4381 4381
 // Numbers must be '1234.56'
4382 4382
 // Decimal delimiter for PHP and database SQL requests must be '.'
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
      */
4500 4500
     static function get_localtax($vatrate, $local, $thirdparty_buyer = "", $thirdparty_seller = "", $vatnpr = 0)
4501 4501
     {
4502
-       // global $db, Globals::$conf, $mysoc;
4502
+        // global $db, Globals::$conf, $mysoc;
4503 4503
 
4504 4504
         if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4505 4505
             $thirdparty_seller = $mysoc;
@@ -4639,7 +4639,7 @@  discard block
 block discarded – undo
4639 4639
      */
4640 4640
     static function get_localtax_by_third($local)
4641 4641
     {
4642
-       // global $db, $mysoc;
4642
+        // global $db, $mysoc;
4643 4643
         $sql = "SELECT t.localtax1, t.localtax2 ";
4644 4644
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=t.fk_pays";
4645 4645
         $sql .= " WHERE c.code = '" . $mysoc->country_code . "' AND t.active = 1 AND t.taux=(";
@@ -4672,7 +4672,7 @@  discard block
 block discarded – undo
4672 4672
      */
4673 4673
     static function getTaxesFromId($vatrate, $buyer = null, $seller = null, $firstparamisid = 1)
4674 4674
     {
4675
-       // global $db, $mysoc;
4675
+        // global $db, $mysoc;
4676 4676
 
4677 4677
         dol_syslog("getTaxesFromId vat id or rate = " . $vatrate);
4678 4678
 
@@ -4729,7 +4729,7 @@  discard block
 block discarded – undo
4729 4729
      */
4730 4730
     static function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid = 0)
4731 4731
     {
4732
-       // global $db, $mysoc;
4732
+        // global $db, $mysoc;
4733 4733
 
4734 4734
         dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
4735 4735
 
@@ -4783,7 +4783,7 @@  discard block
 block discarded – undo
4783 4783
      */
4784 4784
     static function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournprice = 0)
4785 4785
     {
4786
-       // global $db, Globals::$conf, $mysoc;
4786
+        // global $db, Globals::$conf, $mysoc;
4787 4787
 
4788 4788
         require_once DOL_BASE_PATH . '/product/class/product.class.php';
4789 4789
 
@@ -4854,7 +4854,7 @@  discard block
 block discarded – undo
4854 4854
      */
4855 4855
     static function get_product_localtax_for_country($idprod, $local, $thirdparty_seller)
4856 4856
     {
4857
-       // global $db, $mysoc;
4857
+        // global $db, $mysoc;
4858 4858
 
4859 4859
         if (!class_exists('Product')) {
4860 4860
             require_once DOL_BASE_PATH . 'product/class/product.class.php';
@@ -4922,7 +4922,7 @@  discard block
 block discarded – undo
4922 4922
      */
4923 4923
     static function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
4924 4924
     {
4925
-       // global Globals::$conf;
4925
+        // global Globals::$conf;
4926 4926
 
4927 4927
         require_once DOL_BASE_PATH . '/core/lib/company.lib.php';
4928 4928
 
@@ -4997,7 +4997,7 @@  discard block
 block discarded – undo
4997 4997
      */
4998 4998
     static function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod = 0, $idprodfournprice = 0)
4999 4999
     {
5000
-       // global $db;
5000
+        // global $db;
5001 5001
 
5002 5002
         if ($idprodfournprice > 0) {
5003 5003
             if (!class_exists('ProductFournisseur'))
@@ -5032,7 +5032,7 @@  discard block
 block discarded – undo
5032 5032
      */
5033 5033
     static function get_default_localtax($thirdparty_seller, $thirdparty_buyer, $local, $idprod = 0)
5034 5034
     {
5035
-       // global $mysoc;
5035
+        // global $mysoc;
5036 5036
 
5037 5037
         if (!is_object($thirdparty_seller))
5038 5038
             return -1;
@@ -5077,7 +5077,7 @@  discard block
 block discarded – undo
5077 5077
      */
5078 5078
     static function yn($yesno, $case = 1, $color = 0)
5079 5079
     {
5080
-       // global $langs;
5080
+        // global $langs;
5081 5081
         $result = 'unknown';
5082 5082
         $classname = '';
5083 5083
         if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') {  // A mettre avant test sur no a cause du == 0
@@ -5127,7 +5127,7 @@  discard block
 block discarded – undo
5127 5127
      */
5128 5128
     static function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
5129 5129
     {
5130
-       // global Globals::$conf;
5130
+        // global Globals::$conf;
5131 5131
 
5132 5132
         $path = '';
5133 5133
 
@@ -5175,7 +5175,7 @@  discard block
 block discarded – undo
5175 5175
      */
5176 5176
     static function dol_mkdir($dir, $dataroot = '', $newmask = null)
5177 5177
     {
5178
-       // global Globals::$conf;
5178
+        // global Globals::$conf;
5179 5179
 
5180 5180
         dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5181 5181
 
@@ -5722,7 +5722,7 @@  discard block
 block discarded – undo
5722 5722
      */
5723 5723
     static function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $object = null)
5724 5724
     {
5725
-       // global $db, Globals::$conf, $mysoc, $user, $extrafields;
5725
+        // global $db, Globals::$conf, $mysoc, $user, $extrafields;
5726 5726
 
5727 5727
         $substitutionarray = array();
5728 5728
 
@@ -6028,7 +6028,7 @@  discard block
 block discarded – undo
6028 6028
      */
6029 6029
     static function make_substitutions($text, $substitutionarray, $outputlangs = null)
6030 6030
     {
6031
-       // global Globals::$conf, $langs;
6031
+        // global Globals::$conf, $langs;
6032 6032
 
6033 6033
         if (!is_array($substitutionarray))
6034 6034
             return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
@@ -6094,7 +6094,7 @@  discard block
 block discarded – undo
6094 6094
      */
6095 6095
     static function complete_substitutions_array(&$substitutionarray, $outputlangs, $object = null, $parameters = null, $callfunc = "completesubstitutionarray")
6096 6096
     {
6097
-       // global Globals::$conf, $user;
6097
+        // global Globals::$conf, $user;
6098 6098
 
6099 6099
         require_once DOL_BASE_PATH . '/core/lib/files.lib.php';
6100 6100
 
@@ -6164,7 +6164,7 @@  discard block
 block discarded – undo
6164 6164
      */
6165 6165
     static function get_date_range($date_start, $date_end, $format = '', $outputlangs = '', $withparenthesis = 1)
6166 6166
     {
6167
-       // global $langs;
6167
+        // global $langs;
6168 6168
 
6169 6169
         $out = '';
6170 6170
 
@@ -6194,7 +6194,7 @@  discard block
 block discarded – undo
6194 6194
      */
6195 6195
     static function dolGetFirstLastname($firstname, $lastname, $nameorder = -1)
6196 6196
     {
6197
-       // global Globals::$conf;
6197
+        // global Globals::$conf;
6198 6198
 
6199 6199
         $ret = '';
6200 6200
 // If order not defined, we use the setup
@@ -6318,7 +6318,7 @@  discard block
 block discarded – undo
6318 6318
      */
6319 6319
     static function get_htmloutput_mesg($mesgstring = '', $mesgarray = '', $style = 'ok', $keepembedded = 0)
6320 6320
     {
6321
-       // global Globals::$conf, $langs;
6321
+        // global Globals::$conf, $langs;
6322 6322
 
6323 6323
         $ret = 0;
6324 6324
         $return = '';
@@ -6554,7 +6554,7 @@  discard block
 block discarded – undo
6554 6554
      */
6555 6555
     function dol_osencode($str)
6556 6556
     {
6557
-       // global Globals::$conf;
6557
+        // global Globals::$conf;
6558 6558
 
6559 6559
         $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6560 6560
         if (empty($tmp) && !empty($_SERVER["WINDIR"]))
@@ -6584,7 +6584,7 @@  discard block
 block discarded – undo
6584 6584
      */
6585 6585
     static function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0)
6586 6586
     {
6587
-       // global $cache_codes;
6587
+        // global $cache_codes;
6588 6588
 // If key empty
6589 6589
         if ($key == '')
6590 6590
             return '';
@@ -6625,7 +6625,7 @@  discard block
 block discarded – undo
6625 6625
      */
6626 6626
     static function verifCond($strRights)
6627 6627
     {
6628
-       // global $user, Globals::$conf, $langs;
6628
+        // global $user, Globals::$conf, $langs;
6629 6629
         // global $leftmenu;
6630 6630
         // global $rights;    // To export to dol_eval function
6631 6631
 //print $strRights."<br>\n";
@@ -6691,7 +6691,7 @@  discard block
 block discarded – undo
6691 6691
      */
6692 6692
     static function picto_from_langcode($codelang, $moreatt = '')
6693 6693
     {
6694
-       // global $langs;
6694
+        // global $langs;
6695 6695
 
6696 6696
         if (empty($codelang))
6697 6697
             return '';
@@ -6726,7 +6726,7 @@  discard block
 block discarded – undo
6726 6726
      */
6727 6727
     static function getLanguageCodeFromCountryCode($countrycode)
6728 6728
     {
6729
-       // global $mysoc;
6729
+        // global $mysoc;
6730 6730
 
6731 6731
         if (strtoupper($countrycode) == 'MQ')
6732 6732
             return 'fr_CA';
@@ -6960,7 +6960,7 @@  discard block
 block discarded – undo
6960 6960
      */
6961 6961
     static function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode = 'add')
6962 6962
     {
6963
-       // global $hookmanager;
6963
+        // global $hookmanager;
6964 6964
 
6965 6965
         if (isset(Globals::$conf->modules_parts['tabs'][$type]) && is_array(Globals::$conf->modules_parts['tabs'][$type])) {
6966 6966
             foreach (Globals::$conf->modules_parts['tabs'][$type] as $value) {
@@ -7049,7 +7049,7 @@  discard block
 block discarded – undo
7049 7049
      */
7050 7050
     static function printCommonFooter($zone = 'private')
7051 7051
     {
7052
-       // global Globals::$conf, $hookmanager, $user;
7052
+        // global Globals::$conf, $hookmanager, $user;
7053 7053
         // global $action;
7054 7054
         // global $micro_start_time;
7055 7055
 
@@ -7289,7 +7289,7 @@  discard block
 block discarded – undo
7289 7289
      */
7290 7290
     static function natural_search($fields, $value, $mode = 0, $nofirstand = 0)
7291 7291
     {
7292
-       // global $db, $langs;
7292
+        // global $db, $langs;
7293 7293
 
7294 7294
         $value = trim($value);
7295 7295
 
@@ -7422,7 +7422,7 @@  discard block
 block discarded – undo
7422 7422
      */
7423 7423
     static function showDirectDownloadLink($object)
7424 7424
     {
7425
-       // global Globals::$conf, $langs;
7425
+        // global Globals::$conf, $langs;
7426 7426
 
7427 7427
         $out = '';
7428 7428
         $url = $object->getLastMainDocLink($object->element);
@@ -7484,7 +7484,7 @@  discard block
 block discarded – undo
7484 7484
      */
7485 7485
     static function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param = '')
7486 7486
     {
7487
-       // global Globals::$conf, $langs;
7487
+        // global Globals::$conf, $langs;
7488 7488
 
7489 7489
         if (empty(Globals::$conf->use_javascript_ajax))
7490 7490
             return '';
@@ -7517,7 +7517,7 @@  discard block
 block discarded – undo
7517 7517
      */
7518 7518
     static function ajax_autoselect($htmlname, $addlink = '')
7519 7519
     {
7520
-       // global $langs;
7520
+        // global $langs;
7521 7521
         $out = '<script type="text/javascript">
7522 7522
                jQuery(document).ready(static function () {
7523 7523
 				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
@@ -7901,7 +7901,7 @@  discard block
 block discarded – undo
7901 7901
      */
7902 7902
     static function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield = 'rowid')
7903 7903
     {
7904
-       // global $dictvalues, $db, $langs;
7904
+        // global $dictvalues, $db, $langs;
7905 7905
 
7906 7906
         if (!isset($dictvalues[$tablename])) {
7907 7907
             $dictvalues[$tablename] = array();
@@ -7969,7 +7969,7 @@  discard block
 block discarded – undo
7969 7969
      */
7970 7970
     static function isVisibleToUserType($type_user, &$menuentry, &$listofmodulesforexternal)
7971 7971
     {
7972
-       // global Globals::$conf;
7972
+        // global Globals::$conf;
7973 7973
 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
7974 7974
 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
7975 7975
         if (empty($menuentry['enabled']))
Please login to merge, or discard this patch.
Spacing   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     static function getStaticMember($class, $member)
54 54
     {
55
-        dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
55
+        dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
56 56
 
57 57
         // This part is deprecated. Uncomment if for php 5.2.*, and comment next isset class::member
58 58
         /* if (version_compare(phpversion(), '5.3.0', '<'))
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         if (isset($class::$member))
79 79
             return $class::$member;
80
-        dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
80
+        dol_print_error('', 'Try to get a static member "'.$member.'" in class "'.$class.'" that does not exists or is not static.');
81 81
         return null;
82 82
     }
83 83
 
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      */
95 95
     static function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
96 96
     {
97
-        require_once DOL_BASE_PATH . "/core/db/" . $type . '.class.php';
97
+        require_once DOL_BASE_PATH."/core/db/".$type.'.class.php';
98 98
 
99
-        $class = 'DoliDB' . ucfirst($type);
99
+        $class = 'DoliDB'.ucfirst($type);
100 100
         $dolidb = new $class($type, $host, $user, $pass, $name, $port);
101 101
         return $dolidb;
102 102
     }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
             $depth = $db->transaction_opened;
266 266
             $disconnectdone = $db->close();
267 267
         }
268
-        dol_syslog("--- End access to " . $_SERVER["PHP_SELF"] . (($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was ' . $depth . ')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
268
+        dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].(($disconnectdone && $depth) ? ' (Warn: db disconnection forced, transaction depth was '.$depth.')' : ''), (($disconnectdone && $depth) ? LOG_WARNING : LOG_INFO));
269 269
     }
270 270
 
271 271
     /**
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         if (empty($paramname))
311 311
             return 'BadFirstParameterForDolUtils::GETPOST';
312 312
         if (empty($check)) {
313
-            dol_syslog("Deprecated use of DolUtils::GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
313
+            dol_syslog("Deprecated use of DolUtils::GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
314 314
         // Enable this line to know who call the DolUtils::GETPOST with '' $check parameter.
315 315
         //var_dump(debug_backtrace()[0]);
316 316
         }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
             $relativepathstring = $_SERVER["PHP_SELF"];
333 333
             // Clean $relativepathstring
334 334
             if (constant('DOL_BASE_URI'))
335
-                $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
335
+                $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_BASE_URI'), '/').'/', '', $relativepathstring);
336 336
             $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
337 337
             $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
338 338
             //var_dump($relativepathstring);
@@ -340,8 +340,8 @@  discard block
 block discarded – undo
340 340
             // Code for search criteria persistence.
341 341
             // Retrieve values if restore_lastsearch_values
342 342
             if (!empty($_GET['restore_lastsearch_values'])) {        // Use $_GET here and not DolUtils::GETPOST
343
-                if (!empty($_SESSION['lastsearch_values_' . $relativepathstring])) { // If there is saved values
344
-                    $tmp = json_decode($_SESSION['lastsearch_values_' . $relativepathstring], true);
343
+                if (!empty($_SESSION['lastsearch_values_'.$relativepathstring])) { // If there is saved values
344
+                    $tmp = json_decode($_SESSION['lastsearch_values_'.$relativepathstring], true);
345 345
                     if (is_array($tmp)) {
346 346
                         foreach ($tmp as $key => $val) {
347 347
                             if ($key == $paramname) { // We are on the requested parameter
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
                     }
353 353
                 }
354 354
                 // If there is saved contextpage, page or limit
355
-                if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_' . $relativepathstring])) {
356
-                    $out = $_SESSION['lastsearch_contextpage_' . $relativepathstring];
357
-                } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_' . $relativepathstring])) {
358
-                    $out = $_SESSION['lastsearch_page_' . $relativepathstring];
359
-                } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_' . $relativepathstring])) {
360
-                    $out = $_SESSION['lastsearch_limit_' . $relativepathstring];
355
+                if ($paramname == 'contextpage' && !empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) {
356
+                    $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
357
+                } elseif ($paramname == 'page' && !empty($_SESSION['lastsearch_page_'.$relativepathstring])) {
358
+                    $out = $_SESSION['lastsearch_page_'.$relativepathstring];
359
+                } elseif ($paramname == 'limit' && !empty($_SESSION['lastsearch_limit_'.$relativepathstring])) {
360
+                    $out = $_SESSION['lastsearch_limit_'.$relativepathstring];
361 361
                 }
362 362
             }
363 363
             // Else, retreive default values if we are not doing a sort
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
                                             $qualified = 1;
426 426
 
427 427
                                         if ($qualified) {
428
-                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
428
+                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
429 429
                                             foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
430 430
                                                 if ($out)
431 431
                                                     $out .= ', ';
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
                                         if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
462 462
                                             // We made a search from quick search menu, do we still use default filter ?
463 463
                                             if (empty(Globals::$conf->global->MAIN_DISABLE_DEFAULT_FILTER_FOR_QUICK_SEARCH)) {
464
-                                                $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
464
+                                                $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
465 465
                                                 $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
466 466
                                             }
467 467
                                         } else {
468
-                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
468
+                                            $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and ,
469 469
                                             $out = dol_string_nospecial($user->default_values[$relativepathstring]['filters'][$defkey][$paramname], '', $forbidden_chars_to_replace);
470 470
                                         }
471 471
                                         break;
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
         // We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
484 484
         if (!is_array($out) && empty($_POST[$paramname]) && empty($noreplace)) {
485 485
             $maxloop = 20;
486
-            $loopnb = 0;    // Protection against infinite loop
486
+            $loopnb = 0; // Protection against infinite loop
487 487
             while (preg_match('/__([A-Z0-9]+_?[A-Z0-9]+)__/i', $out, $reg) && ($loopnb < $maxloop)) {    // Detect '__ABCDEF__' as key 'ABCDEF' and '__ABC_DEF__' as key 'ABC_DEF'. Detection is also correct when 2 vars are side by side.
488 488
                 $loopnb++;
489 489
                 $newout = '';
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
                 } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
529 529
                     $newout = Globals::$conf->entity;
530 530
                 } else
531
-                    $newout = '';     // Key not found, we replace with empty string
531
+                    $newout = ''; // Key not found, we replace with empty string
532 532
 
533 533
 
534 534
 
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
                     
565 565
 //var_dump('__'.$reg[1].'__ -> '.$newout);
566
-                $out = preg_replace('/__' . preg_quote($reg[1], '/') . '__/', $newout, $out);
566
+                $out = preg_replace('/__'.preg_quote($reg[1], '/').'__/', $newout, $out);
567 567
             }
568 568
         }
569 569
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
         // If prefix is for email
674 674
         if ($mode == 'email') {
675 675
             if (empty(Globals::$conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) {
676
-                return Security::dol_hash(DOL_DOCUMENT_ROOT . DOL_BASE_URI);
676
+                return Security::dol_hash(DOL_DOCUMENT_ROOT.DOL_BASE_URI);
677 677
             }
678 678
             // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended)
679 679
             if (Globals::$conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') {
@@ -683,16 +683,16 @@  discard block
 block discarded – undo
683 683
                 return $_SERVER["SERVER_NAME"];
684 684
             }
685 685
 
686
-            return Security::dol_hash(DOL_DOCUMENT_ROOT . DOL_BASE_URI);
686
+            return Security::dol_hash(DOL_DOCUMENT_ROOT.DOL_BASE_URI);
687 687
         }
688 688
 
689 689
         if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) {
690
-            return Security::dol_hash($_SERVER["SERVER_NAME"] . $_SERVER["DOCUMENT_ROOT"] . DOL_DOCUMENT_ROOT . DOL_BASE_URI);
690
+            return Security::dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_BASE_URI);
691 691
 
692 692
             // Use this for a "readable" cookie name
693 693
             //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_BASE_URI);
694 694
         }
695
-        return Security::dol_hash(DOL_DOCUMENT_ROOT . DOL_BASE_URI);
695
+        return Security::dol_hash(DOL_DOCUMENT_ROOT.DOL_BASE_URI);
696 696
     }
697 697
 
698 698
     /**
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
         $fullpath = dol_buildpath($relpath);
713 713
 
714 714
         if (!file_exists($fullpath)) {
715
-            dol_syslog('functions::dol_include_once Tried to load unexisting file: ' . $relpath, LOG_ERR);
715
+            dol_syslog('functions::dol_include_once Tried to load unexisting file: '.$relpath, LOG_ERR);
716 716
             return false;
717 717
         }
718 718
 
@@ -741,14 +741,14 @@  discard block
 block discarded – undo
741 741
 
742 742
         if ($type == 0 /* empty($type) */) { // For a filesystem path
743 743
 //$res = DOL_BASE_PATH . '' . $path;  // Standard default path
744
-            $res = DOL_BASE_PATH . '/' . $path;  // Standard default path
744
+            $res = DOL_BASE_PATH.'/'.$path; // Standard default path
745 745
             if (isset(Globals::$conf->file->dol_document_root)) {
746 746
                 foreach (Globals::$conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
747 747
                     if ($key == 'main') {
748 748
                         continue;
749 749
                     }
750
-                    if (file_exists($dirroot . '/' . $path)) {
751
-                        $res = $dirroot . '/' . $path;
750
+                    if (file_exists($dirroot.'/'.$path)) {
751
+                        $res = $dirroot.'/'.$path;
752 752
                         return $res;
753 753
                     }
754 754
                 }
@@ -765,13 +765,13 @@  discard block
 block discarded – undo
765 765
 // using proxy, rewriting, virtual path, etc...
766 766
             $res = '';
767 767
             if ($type == 1) {
768
-                $res = /* DOL_BASE_URI */ DOL_BASE_URI . '/' . $path;   // Standard value
768
+                $res = /* DOL_BASE_URI */ DOL_BASE_URI.'/'.$path; // Standard value
769 769
             }
770 770
             if ($type == 2) {
771
-                $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path;  // Standard value
771
+                $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH.'/'.$path; // Standard value
772 772
             }
773 773
             if ($type == 3) {
774
-                $res = DOL_BASE_URI . '/' . $path;
774
+                $res = DOL_BASE_URI.'/'.$path;
775 775
             }
776 776
 
777 777
             foreach (Globals::$conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
@@ -781,33 +781,33 @@  discard block
 block discarded – undo
781 781
                         // Define $urlwithroot
782 782
 
783 783
                         // $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_BASE_URI, '/') . '$/i', '', trim($dolibarr_main_url_root));
784
-                        $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_BASE_URI, '/') . '$/i', '', trim(DOL_BASE_URI));
784
+                        $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_BASE_URI, '/').'$/i', '', trim(DOL_BASE_URI));
785 785
 
786
-                        $urlwithroot = $urlwithouturlroot . DOL_BASE_URI;  // This is to use external domain name found into config file
786
+                        $urlwithroot = $urlwithouturlroot.DOL_BASE_URI; // This is to use external domain name found into config file
787 787
                         //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
788 788
 
789
-                        $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . '/' . $path;     // Test on start with http is for old conf syntax
789
+                        $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : $urlwithroot).'/'.$path; // Test on start with http is for old conf syntax
790 790
                     }
791 791
                     continue;
792 792
                 }
793
-                preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs);    // Take part before '?'
793
+                preg_match('/^([^\?]+(\.css\.php|\.css|\.js\.php|\.js|\.png|\.jpg|\.php)?)/i', $path, $regs); // Take part before '?'
794 794
                 if (!empty($regs[1])) {
795 795
                     //print $key.'-'.$dirroot.'/'.$path.'-'.$conf->file->dol_url_root[$type].'<br>'."\n";
796
-                    if (file_exists($dirroot . '/' . $regs[1])) {
796
+                    if (file_exists($dirroot.'/'.$regs[1])) {
797 797
                         if ($type == 1) {
798
-                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : DOL_BASE_URI) . Globals::$conf->file->dol_url_root[$key] . '/' . $path;
798
+                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : DOL_BASE_URI).Globals::$conf->file->dol_url_root[$key].'/'.$path;
799 799
                         }
800 800
                         if ($type == 2) {
801
-                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT) . Globals::$conf->file->dol_url_root[$key] . '/' . $path;
801
+                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : DOL_MAIN_URL_ROOT).Globals::$conf->file->dol_url_root[$key].'/'.$path;
802 802
                         }
803 803
                         if ($type == 3) {
804 804
                            // global $dolibarr_main_url_root;
805 805
                             // Define $urlwithroot
806
-                            $urlwithouturlroot = preg_replace('/' . preg_quote(DOL_BASE_URI, '/') . '$/i', '', trim($dolibarr_main_url_root));
807
-                            $urlwithroot = $urlwithouturlroot . DOL_BASE_URI;  // This is to use external domain name found into config file
806
+                            $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_BASE_URI, '/').'$/i', '', trim($dolibarr_main_url_root));
807
+                            $urlwithroot = $urlwithouturlroot.DOL_BASE_URI; // This is to use external domain name found into config file
808 808
                             //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
809 809
 
810
-                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : $urlwithroot) . Globals::$conf->file->dol_url_root[$key] . '/' . $path;     // Test on start with http is for old conf syntax
810
+                            $res = (preg_match('/^http/i', Globals::$conf->file->dol_url_root[$key]) ? '' : $urlwithroot).Globals::$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax
811 811
                         }
812 812
                         break;
813 813
                     }
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
         if (empty($native)) {
836 836
             $myclone = unserialize(serialize($object));
837 837
         } else {
838
-            $myclone = clone $object;     // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
838
+            $myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
839 839
         }
840 840
 
841 841
         return $myclone;
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
      */
957 957
     static function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '')
958 958
     {
959
-        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
959
+        $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName
960 960
         $forbidden_chars_to_remove = array();
961 961
         if (is_array($badcharstoreplace))
962 962
             $forbidden_chars_to_replace = $badcharstoreplace;
@@ -1019,12 +1019,12 @@  discard block
 block discarded – undo
1019 1019
     static function dol_escape_htmltag($stringtoescape, $keepb = 0, $keepn = 0)
1020 1020
     {
1021 1021
 // escape quotes and backslashes, newlines, etc.
1022
-        $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8');  // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1022
+        $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1023 1023
         if (!$keepb)
1024 1024
             $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1025 1025
         if (!$keepn)
1026 1026
             $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1027
-        return htmlentities($tmp, ENT_COMPAT, 'UTF-8');      // TODO Use htmlspecialchars instead, that make only required change for html tags
1027
+        return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags
1028 1028
     }
1029 1029
 
1030 1030
     /**
@@ -1094,14 +1094,14 @@  discard block
 block discarded – undo
1094 1094
             $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
1095 1095
 // If adding log inside HTML page is required
1096 1096
             if (!empty($_REQUEST['logtohtml']) && (!empty(Globals::$conf->global->MAIN_ENABLE_LOG_TO_HTML) || !empty(Globals::$conf->global->MAIN_LOGTOHTML))) {   // MAIN_LOGTOHTML kept for backward compatibility
1097
-                Globals::$conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S") . " " . $message;
1097
+                Globals::$conf->logbuffer[] = dol_print_date(time(), "%Y-%m-%d %H:%M:%S")." ".$message;
1098 1098
             }
1099 1099
 
1100 1100
 //TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
1101 1101
 // If html log tag enabled and url parameter log defined, we show output log on HTML comments
1102 1102
             if (!empty(Globals::$conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && !empty($_GET["log"])) {
1103 1103
                 print "\n\n<!-- Log start\n";
1104
-                print $message . "\n";
1104
+                print $message."\n";
1105 1105
                 print "Log end -->\n";
1106 1106
             }
1107 1107
 
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 // This is when server run behind a reverse proxy
1117 1117
             if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
1118
-                $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1118
+                $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'].(empty($_SERVER["REMOTE_ADDR"]) ? '' : '->'.$_SERVER['REMOTE_ADDR']);
1119 1119
 // This is when server run normally on a server
1120 1120
             else if (!empty($_SERVER["REMOTE_ADDR"]))
1121 1121
                 $data['ip'] = $_SERVER['REMOTE_ADDR'];
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
                 $data['ip'] = $_SERVER['SERVER_ADDR'];
1125 1125
 // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
1126 1126
             else if (!empty($_SERVER['COMPUTERNAME']))
1127
-                $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1127
+                $data['ip'] = $_SERVER['COMPUTERNAME'].(empty($_SERVER['USERNAME']) ? '' : '@'.$_SERVER['USERNAME']);
1128 1128
 // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
1129 1129
             else if (!empty($_SERVER['LOGNAME']))
1130
-                $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1130
+                $data['ip'] = '???@'.$_SERVER['LOGNAME'];
1131 1131
 // Loop on each log handler and send output
1132 1132
             foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
1133 1133
                 if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
@@ -1179,10 +1179,10 @@  discard block
 block discarded – undo
1179 1179
     {
1180 1180
        // global Globals::$conf, $langs, $hookmanager;
1181 1181
 
1182
-        $out = "\n" . '<div class="tabs" data-role="controlgroup" data-type="horizontal">' . "\n";
1182
+        $out = "\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
1183 1183
 
1184 1184
         if ($morehtmlright) {
1185
-            $out .= '<div class="inline-block floatright tabsElem">' . $morehtmlright . '</div>'; // Output right area first so when space is missing, text is in front of tabs and not under.
1185
+            $out .= '<div class="inline-block floatright tabsElem">'.$morehtmlright.'</div>'; // Output right area first so when space is missing, text is in front of tabs and not under.
1186 1186
         }
1187 1187
 
1188 1188
 // Show title
@@ -1193,8 +1193,8 @@  discard block
 block discarded – undo
1193 1193
             $limittitle = 30;
1194 1194
             $out .= '<a class="tabTitle">';
1195 1195
             if ($picto)
1196
-                $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1197
-            $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>';
1196
+                $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_').$picto, '', $pictoisfullpath).' ';
1197
+            $out .= '<span class="tabTitleText">'.dol_trunc($title, $limittitle).'</span>';
1198 1198
             $out .= '</a>';
1199 1199
         }
1200 1200
 
@@ -1234,23 +1234,23 @@  discard block
 block discarded – undo
1234 1234
             }
1235 1235
 
1236 1236
             if ($i < $limittoshow || $isactive) {
1237
-                $out .= '<div class="inline-block tabsElem' . ($isactive ? ' tabsElemActive' : '') . ((!$isactive && !empty(Globals::$conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '') . '"><!-- id tab = ' . (empty($links[$i][2]) ? '' : $links[$i][2]) . ' -->';
1237
+                $out .= '<div class="inline-block tabsElem'.($isactive ? ' tabsElemActive' : '').((!$isactive && !empty(Globals::$conf->global->MAIN_HIDE_INACTIVETAB_ON_PRINT)) ? ' hideonprint' : '').'"><!-- id tab = '.(empty($links[$i][2]) ? '' : $links[$i][2]).' -->';
1238 1238
                 if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1239 1239
                     if (!empty($links[$i][0])) {
1240
-                        $out .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1240
+                        $out .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
1241 1241
                     } else {
1242
-                        $out .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1242
+                        $out .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n";
1243 1243
                     }
1244 1244
                 } else if (!empty($links[$i][1])) {
1245 1245
                     //print "x $i $active ".$links[$i][2]." z";
1246 1246
                     if ($isactive) {
1247
-                        $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1247
+                        $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1248 1248
                         $out .= $links[$i][1];
1249
-                        $out .= '</a>' . "\n";
1249
+                        $out .= '</a>'."\n";
1250 1250
                     } else {
1251
-                        $out .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="tabunactive tab inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1251
+                        $out .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="tabunactive tab inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1252 1252
                         $out .= $links[$i][1];
1253
-                        $out .= '</a>' . "\n";
1253
+                        $out .= '</a>'."\n";
1254 1254
                     }
1255 1255
                 }
1256 1256
                 $out .= '</div>';
@@ -1263,14 +1263,14 @@  discard block
 block discarded – undo
1263 1263
                 $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">';
1264 1264
                 if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1265 1265
                     if (!empty($links[$i][0]))
1266
-                        $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1266
+                        $outmore .= '<a class="tabimage'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">'.$links[$i][1].'</a>'."\n";
1267 1267
                     else
1268
-                        $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1268
+                        $outmore .= '<span class="tabspan">'.$links[$i][1].'</span>'."\n";
1269 1269
                 }
1270 1270
                 else if (!empty($links[$i][1])) {
1271
-                    $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1271
+                    $outmore .= '<a'.(!empty($links[$i][2]) ? ' id="'.$links[$i][2].'"' : '').' class="wordwrap inline-block'.($morecss ? ' '.$morecss : '').'" href="'.$links[$i][0].'">';
1272 1272
                     $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
1273
-                    $outmore .= '</a>' . "\n";
1273
+                    $outmore .= '</a>'."\n";
1274 1274
                 }
1275 1275
                 $outmore .= '</div>';
1276 1276
 
@@ -1286,24 +1286,24 @@  discard block
 block discarded – undo
1286 1286
             $right = ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right');
1287 1287
 
1288 1288
             $tabsname = str_replace("@", "", $picto);
1289
-            $out .= '<div id="moretabs' . $tabsname . '" class="inline-block tabsElem">';
1290
-            $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">' . $langs->trans("More") . '... (' . $nbintab . ')</a>';
1291
-            $out .= '<div id="moretabsList' . $tabsname . '" style="position: absolute; ' . $left . ': -999em; text-align: ' . $left . '; margin:0px; padding:2px">';
1289
+            $out .= '<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
1290
+            $out .= '<a href="#" class="tab moretab inline-block tabunactive reposition">'.$langs->trans("More").'... ('.$nbintab.')</a>';
1291
+            $out .= '<div id="moretabsList'.$tabsname.'" style="position: absolute; '.$left.': -999em; text-align: '.$left.'; margin:0px; padding:2px">';
1292 1292
             $out .= $outmore;
1293 1293
             $out .= '</div>';
1294 1294
             $out .= '<div></div>';
1295 1295
             $out .= "</div>\n";
1296 1296
 
1297 1297
             $out .= "<script>";
1298
-            $out .= "$('#moretabs" . $tabsname . "').mouseenter( function() { console.log('mouseenter " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','auto');});";
1299
-            $out .= "$('#moretabs" . $tabsname . "').mouseleave( function() { console.log('mouseleave " . $left . "'); $('#moretabsList" . $tabsname . "').css('" . $left . "','-999em');});";
1298
+            $out .= "$('#moretabs".$tabsname."').mouseenter( function() { console.log('mouseenter ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','auto');});";
1299
+            $out .= "$('#moretabs".$tabsname."').mouseleave( function() { console.log('mouseleave ".$left."'); $('#moretabsList".$tabsname."').css('".$left."','-999em');});";
1300 1300
             $out .= "</script>";
1301 1301
         }
1302 1302
 
1303 1303
         $out .= "</div>\n";
1304 1304
 
1305 1305
         if (!$notab || $notab == -1)
1306
-            $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1306
+            $out .= "\n".'<div class="tabBar'.($notab == -1 ? '' : ' tabBarWithBottom').'">'."\n";
1307 1307
 
1308 1308
         $parameters = array('tabname' => $active, 'out' => $out);
1309 1309
         $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
             if (Globals::$conf->browser->layout == 'phone')
1413 1413
                 $maxvisiblephotos = 1;
1414 1414
             if ($showimage)
1415
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1415
+                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'</div>';
1416 1416
             else {
1417 1417
                 if (!empty(Globals::$conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
1418 1418
                     $nophoto = '';
@@ -1421,18 +1421,18 @@  discard block
 block discarded – undo
1421 1421
 //elseif (Globals::$conf->browser->layout != 'phone') {    // Show no photo link
1422 1422
                 $nophoto = '/public/theme/common/nophoto.png';
1423 1423
 // $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1424
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1424
+                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>';
1425 1425
 //}
1426 1426
             }
1427 1427
         } elseif ($object->element == 'ticket') {
1428 1428
             $width = 80;
1429 1429
             $cssclass = 'photoref';
1430
-            $showimage = $object->is_photo_available(Globals::$conf->ticket->multidir_output[$entity] . '/' . $object->track_id);
1430
+            $showimage = $object->is_photo_available(Globals::$conf->ticket->multidir_output[$entity].'/'.$object->track_id);
1431 1431
             $maxvisiblephotos = (isset(Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2);
1432 1432
             if (Globals::$conf->browser->layout == 'phone')
1433 1433
                 $maxvisiblephotos = 1;
1434 1434
             if ($showimage)
1435
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1435
+                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0).'</div>';
1436 1436
             else {
1437 1437
                 if (!empty(Globals::$conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
1438 1438
                     $nophoto = '';
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 //elseif (Globals::$conf->browser->layout != 'phone') {    // Show no photo link
1442 1442
                 $nophoto = '/public/theme/common/nophoto.png';
1443 1443
 //$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1444
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . DOL_BASE_URI . $nophoto . '"></div>';
1444
+                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.DOL_BASE_URI.$nophoto.'"></div>';
1445 1445
 //}
1446 1446
             }
1447 1447
         } else {
@@ -1451,25 +1451,25 @@  discard block
 block discarded – undo
1451 1451
                     // Check if a preview file is available
1452 1452
                     if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) {
1453 1453
                         $objectref = dol_sanitizeFileName($object->ref);
1454
-                        $dir_output = (empty(Globals::$conf->$modulepart->multidir_output[$entity]) ? Globals::$conf->$modulepart->dir_output : Globals::$conf->$modulepart->multidir_output[$entity]) . "/";
1454
+                        $dir_output = (empty(Globals::$conf->$modulepart->multidir_output[$entity]) ? Globals::$conf->$modulepart->dir_output : Globals::$conf->$modulepart->multidir_output[$entity])."/";
1455 1455
                         if (in_array($modulepart, array('invoice_supplier', 'supplier_invoice'))) {
1456 1456
                             $subdir = get_exdir($object->id, 2, 0, 1, $object, $modulepart);
1457
-                            $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '') . $objectref;  // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
1457
+                            $subdir .= ((!empty($subdir) && !preg_match('/\/$/', $subdir)) ? '/' : '').$objectref; // the objectref dir is not included into get_exdir when used with level=2, so we add it at end
1458 1458
                         } else {
1459 1459
                             $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1460 1460
                         }
1461 1461
                         if (empty($subdir))
1462 1462
                             $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
1463 1463
 
1464
-                        $filepath = $dir_output . $subdir . "/";
1464
+                        $filepath = $dir_output.$subdir."/";
1465 1465
 
1466
-                        $file = $filepath . $objectref . ".pdf";
1467
-                        $relativepath = $subdir . '/' . $objectref . '.pdf';
1466
+                        $file = $filepath.$objectref.".pdf";
1467
+                        $relativepath = $subdir.'/'.$objectref.'.pdf';
1468 1468
 
1469 1469
                         // Define path to preview pdf file (preview precompiled "file.ext" are "file.ext_preview.png")
1470
-                        $fileimage = $file . '_preview.png';              // If PDF has 1 page
1471
-                        $fileimagebis = $file . '_preview-0.png';         // If PDF has more than one page
1472
-                        $relativepathimage = $relativepath . '_preview.png';
1470
+                        $fileimage = $file.'_preview.png'; // If PDF has 1 page
1471
+                        $fileimagebis = $file.'_preview-0.png'; // If PDF has more than one page
1472
+                        $relativepathimage = $relativepath.'_preview.png';
1473 1473
 
1474 1474
                         // Si fichier PDF existe
1475 1475
                         if (file_exists($file)) {
@@ -1478,7 +1478,7 @@  discard block
 block discarded – undo
1478 1478
                             if ((!file_exists($fileimage) || (filemtime($fileimage) < filemtime($file))) && (!file_exists($fileimagebis) || (filemtime($fileimagebis) < filemtime($file)))
1479 1479
                             ) {
1480 1480
                                 if (empty(Globals::$conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
1481
-                                    include_once DOL_BASE_PATH . '/core/lib/files.lib.php';
1481
+                                    include_once DOL_BASE_PATH.'/core/lib/files.lib.php';
1482 1482
                                     $ret = dol_convert_file($file, 'png', $fileimage);
1483 1483
                                     if ($ret < 0)
1484 1484
                                         $error++;
@@ -1491,14 +1491,14 @@  discard block
 block discarded – undo
1491 1491
                             // Si fichier png PDF d'1 page trouve
1492 1492
                             if (file_exists($fileimage)) {
1493 1493
                                 $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1494
-                                $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_BASE_URI . '/viewimage.php?modulepart=apercu' . $modulepart . '&amp;file=' . urlencode($relativepathimage) . '">';
1494
+                                $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_BASE_URI.'/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($relativepathimage).'">';
1495 1495
                                 $phototoshow .= '</div></div>';
1496 1496
                             }
1497 1497
                             // Si fichier png PDF de plus d'1 page trouve
1498 1498
                             elseif (file_exists($fileimagebis)) {
1499
-                                $preview = preg_replace('/\.png/', '', $relativepathimage) . "-0.png";
1499
+                                $preview = preg_replace('/\.png/', '', $relativepathimage)."-0.png";
1500 1500
                                 $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
1501
-                                $phototoshow .= '<img height="' . $heightforphotref . '" class="photo photowithmargin photowithborder" src="' . DOL_BASE_URI . '/viewimage.php?modulepart=apercu' . $modulepart . '&amp;file=' . urlencode($preview) . '"><p>';
1501
+                                $phototoshow .= '<img height="'.$heightforphotref.'" class="photo photowithmargin photowithborder" src="'.DOL_BASE_URI.'/viewimage.php?modulepart=apercu'.$modulepart.'&amp;file='.urlencode($preview).'"><p>';
1502 1502
                                 $phototoshow .= '</div></div>';
1503 1503
                             }
1504 1504
                         }
@@ -1525,10 +1525,10 @@  discard block
 block discarded – undo
1525 1525
                         $picto = $object->picto;
1526 1526
                         if ($object->element == 'project' && !$object->public)
1527 1527
                             $picto = 'project'; // instead of projectpub
1528
-                        $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
1528
+                        $nophoto = img_picto('', 'object_'.$picto, '', false, 1);
1529 1529
                     }
1530 1530
                     $morehtmlleft .= '<!-- No photo to show -->';
1531
-                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ' src="' . $nophoto . '"></div></div>';
1531
+                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass ? ' '.$cssclass : '').'" alt="No photo" border="0"'.($width ? ' width="'.$width.'"' : '').' src="'.$nophoto.'"></div></div>';
1532 1532
 
1533 1533
                     $morehtmlleft .= '</div>';
1534 1534
                 }
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
         }
1537 1537
 
1538 1538
         if ($showbarcode)
1539
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1539
+            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
1540 1540
 
1541 1541
         if ($object->element == 'societe') {
1542 1542
             if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->societe->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
@@ -1549,14 +1549,14 @@  discard block
 block discarded – undo
1549 1549
             if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->produit->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1550 1550
                 $morehtmlstatus .= ajax_object_onoff($object, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell');
1551 1551
             } else {
1552
-                $morehtmlstatus .= '<span class="statusrefsell">' . $object->getLibStatut(5, 0) . '</span>';
1552
+                $morehtmlstatus .= '<span class="statusrefsell">'.$object->getLibStatut(5, 0).'</span>';
1553 1553
             }
1554 1554
             $morehtmlstatus .= ' &nbsp; ';
1555 1555
 //$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Buy").') ';
1556 1556
             if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->produit->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1557 1557
                 $morehtmlstatus .= ajax_object_onoff($object, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy');
1558 1558
             } else {
1559
-                $morehtmlstatus .= '<span class="statusrefbuy">' . $object->getLibStatut(5, 1) . '</span>';
1559
+                $morehtmlstatus .= '<span class="statusrefbuy">'.$object->getLibStatut(5, 1).'</span>';
1560 1560
             }
1561 1561
         } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
1562 1562
             $tmptxt = $object->getLibStatut(6, $object->totalpaye);
@@ -1583,7 +1583,7 @@  discard block
 block discarded – undo
1583 1583
             if ($object->progress >= 100)
1584 1584
                 $object->fk_statut = 3;
1585 1585
             $tmptxt = $object->getLibStatut(5);
1586
-            $morehtmlstatus .= $tmptxt;  // No status on task
1586
+            $morehtmlstatus .= $tmptxt; // No status on task
1587 1587
         }
1588 1588
         else { // Generic case
1589 1589
             $tmptxt = $object->getLibStatut(6);
@@ -1597,18 +1597,18 @@  discard block
 block discarded – undo
1597 1597
             if (method_exists($object, 'getVentilExportCompta')) {
1598 1598
                 $accounted = $object->getVentilExportCompta();
1599 1599
                 $langs->load("accountancy");
1600
-                $morehtmlstatus .= '</div><div class="statusref statusrefbis">' . ($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
1600
+                $morehtmlstatus .= '</div><div class="statusref statusrefbis">'.($accounted > 0 ? $langs->trans("Accounted") : $langs->trans("NotYetAccounted"));
1601 1601
             }
1602 1602
         }
1603 1603
 
1604 1604
 // Add alias for thirdparty
1605 1605
         if (!empty($object->name_alias))
1606
-            $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1606
+            $morehtmlref .= '<div class="refidno">'.$object->name_alias.'</div>';
1607 1607
 
1608 1608
 // Add label
1609 1609
         if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
1610 1610
             if (!empty($object->label))
1611
-                $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1611
+                $morehtmlref .= '<div class="refidno">'.$object->label.'</div>';
1612 1612
         }
1613 1613
 
1614 1614
         if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
@@ -1618,11 +1618,11 @@  discard block
 block discarded – undo
1618 1618
         }
1619 1619
         if (!empty(Globals::$conf->global->MAIN_SHOW_TECHNICAL_ID) && in_array($object->element, array('societe', 'contact', 'member', 'product'))) {
1620 1620
             $morehtmlref .= '<div style="clear: both;"></div><div class="refidno">';
1621
-            $morehtmlref .= $langs->trans("TechnicalID") . ': ' . $object->id;
1621
+            $morehtmlref .= $langs->trans("TechnicalID").': '.$object->id;
1622 1622
             $morehtmlref .= '</div>';
1623 1623
         }
1624 1624
 
1625
-        print '<div class="' . ($onlybanner ? 'arearefnobottom ' : 'arearef ') . 'heightref valignmiddle" width="100%">';
1625
+        print '<div class="'.($onlybanner ? 'arearefnobottom ' : 'arearef ').'heightref valignmiddle" width="100%">';
1626 1626
         print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
1627 1627
         print '</div>';
1628 1628
         print '<div class="underrefbanner clearboth"></div>';
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
         if ($fieldrequired)
1645 1645
             $ret .= '<span class="fieldrequired">';
1646 1646
         if ((Globals::$conf->dol_use_jmobile != 4))
1647
-            $ret .= '<label for="' . $fieldkey . '">';
1647
+            $ret .= '<label for="'.$fieldkey.'">';
1648 1648
         $ret .= $langs->trans($langkey);
1649 1649
         if ((Globals::$conf->dol_use_jmobile != 4))
1650 1650
             $ret .= '</label>';
@@ -1663,9 +1663,9 @@  discard block
 block discarded – undo
1663 1663
     static function dol_bc($var, $moreclass = '')
1664 1664
     {
1665 1665
        // global $bc;
1666
-        $ret = ' ' . $bc[$var];
1666
+        $ret = ' '.$bc[$var];
1667 1667
         if ($moreclass)
1668
-            $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1668
+            $ret = preg_replace('/class=\"/', 'class="'.$moreclass.' ', $ret);
1669 1669
         return $ret;
1670 1670
     }
1671 1671
 
@@ -1685,50 +1685,50 @@  discard block
 block discarded – undo
1685 1685
        // global Globals::$conf, $langs;
1686 1686
 
1687 1687
         $ret = '';
1688
-        $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR');    // See also MAIN_FORCE_STATE_INTO_ADDRESS
1688
+        $countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
1689 1689
 // Address
1690 1690
         if (empty($mode)) {
1691 1691
             $ret .= $object->address;
1692 1692
         }
1693 1693
 // Zip/Town/State
1694 1694
         if (in_array($object->country_code, array('AU', 'CA', 'US')) || !empty(Globals::$conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {    // US: title firstname name \n address lines \n town, state, zip \n country
1695
-            $ret .= ($ret ? $sep : '' ) . $object->town;
1695
+            $ret .= ($ret ? $sep : '').$object->town;
1696 1696
             if ($object->state) {
1697
-                $ret .= ($ret ? ", " : '') . $object->state;
1697
+                $ret .= ($ret ? ", " : '').$object->state;
1698 1698
             }
1699 1699
             if ($object->zip)
1700
-                $ret .= ($ret ? ", " : '') . $object->zip;
1700
+                $ret .= ($ret ? ", " : '').$object->zip;
1701 1701
         }
1702 1702
         else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1703
-            $ret .= ($ret ? $sep : '' ) . $object->town;
1703
+            $ret .= ($ret ? $sep : '').$object->town;
1704 1704
             if ($object->state) {
1705
-                $ret .= ($ret ? ", " : '') . $object->state;
1705
+                $ret .= ($ret ? ", " : '').$object->state;
1706 1706
             }
1707 1707
             if ($object->zip)
1708
-                $ret .= ($ret ? $sep : '' ) . $object->zip;
1708
+                $ret .= ($ret ? $sep : '').$object->zip;
1709 1709
         }
1710 1710
         else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1711
-            $ret .= ($ret ? $sep : '' ) . $object->zip;
1712
-            $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1711
+            $ret .= ($ret ? $sep : '').$object->zip;
1712
+            $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : '');
1713 1713
             if ($object->state) {
1714
-                $ret .= "\n" . $object->state;
1714
+                $ret .= "\n".$object->state;
1715 1715
             }
1716 1716
         } else if (in_array($object->country_code, array('IT'))) { // IT: tile firstname name\n address lines \n zip (Code Departement) \n country
1717
-            $ret .= ($ret ? $sep : '' ) . $object->zip;
1718
-            $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1719
-            $ret .= ($object->departement_id ? (' (' . ($object->departement_id) . ')') : '');
1717
+            $ret .= ($ret ? $sep : '').$object->zip;
1718
+            $ret .= ($object->town ? (($object->zip ? ' ' : '').$object->town) : '');
1719
+            $ret .= ($object->departement_id ? (' ('.($object->departement_id).')') : '');
1720 1720
         } else {                                          // Other: title firstname name \n address lines \n zip town \n country
1721
-            $ret .= $object->zip ? (($ret ? $sep : '' ) . $object->zip) : '';
1722
-            $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '' )) . $object->town) : '');
1721
+            $ret .= $object->zip ? (($ret ? $sep : '').$object->zip) : '';
1722
+            $ret .= ($object->town ? (($object->zip ? ' ' : ($ret ? $sep : '')).$object->town) : '');
1723 1723
             if ($object->state && in_array($object->country_code, $countriesusingstate)) {
1724
-                $ret .= ($ret ? ", " : '') . $object->state;
1724
+                $ret .= ($ret ? ", " : '').$object->state;
1725 1725
             }
1726 1726
         }
1727 1727
         if (!is_object($outputlangs))
1728 1728
             $outputlangs = $langs;
1729 1729
         if ($withcountry) {
1730 1730
             $langs->load("dict");
1731
-            $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
1731
+            $ret .= ($object->country_code ? ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)) : '');
1732 1732
         }
1733 1733
 
1734 1734
         return $ret;
@@ -1782,13 +1782,13 @@  discard block
 block discarded – undo
1782 1782
             if (is_string($tzoutput)) {
1783 1783
                 if ($tzoutput == 'tzserver') {
1784 1784
                     $to_gmt = false;
1785
-                    $offsettzstring = @date_default_timezone_get();  // Example 'Europe/Berlin' or 'Indian/Reunion'
1785
+                    $offsettzstring = @date_default_timezone_get(); // Example 'Europe/Berlin' or 'Indian/Reunion'
1786 1786
                     $offsettz = 0;
1787 1787
                     $offsetdst = 0;
1788 1788
                 } elseif ($tzoutput == 'tzuser' || $tzoutput == 'tzuserrel') {
1789 1789
                     $to_gmt = true;
1790 1790
                     $offsettzstring = (empty($_SESSION['dol_tz_string']) ? 'UTC' : $_SESSION['dol_tz_string']); // Example 'Europe/Berlin' or 'Indian/Reunion'
1791
-                    $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;  // Will not be used anymore
1791
+                    $offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60; // Will not be used anymore
1792 1792
                     $offsetdst = (empty($_SESSION['dol_dst']) ? 0 : $_SESSION['dol_dst']) * 60 * 60; // Will not be used anymore
1793 1793
                 }
1794 1794
             }
@@ -1834,9 +1834,9 @@  discard block
 block discarded – undo
1834 1834
         else if ($format == 'dayxcard')
1835 1835
             $format = '%Y%m%d';
1836 1836
         else if ($format == 'dayrfc')
1837
-            $format = '%Y-%m-%d';             // DATE_RFC3339
1837
+            $format = '%Y-%m-%d'; // DATE_RFC3339
1838 1838
         else if ($format == 'dayhourrfc')
1839
-            $format = '%Y-%m-%dT%H:%M:%SZ';   // DATETIME RFC3339
1839
+            $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339
1840 1840
         else if ($format == 'standard')
1841 1841
             $format = '%Y-%m-%d %H:%M:%S';
1842 1842
 
@@ -1847,7 +1847,7 @@  discard block
 block discarded – undo
1847 1847
 
1848 1848
 // If date undefined or "", we return ""
1849 1849
         if (dol_strlen($time) == 0)
1850
-            return '';  // $time=0 allowed (it means 01/01/1970 00:00:00)
1850
+            return ''; // $time=0 allowed (it means 01/01/1970 00:00:00)
1851 1851
 
1852 1852
 
1853 1853
 
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
         if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+) ?([0-9]+)?:?([0-9]+)?:?([0-9]+)?/i', $time, $reg) || preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])$/i', $time, $reg)) { // Deprecated. Ex: 1970-01-01, 1970-01-01 01:00:00, 19700101010000
1899 1899
 // TODO Remove this.
1900 1900
 // This part of code should not be used.
1901
-            dol_syslog("Functions.lib::dol_print_date static function call with deprecated value of time in page " . $_SERVER["PHP_SELF"], LOG_ERR);
1901
+            dol_syslog("Functions.lib::dol_print_date static function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_ERR);
1902 1902
 // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS'
1903 1903
             $syear = (!empty($reg[1]) ? $reg[1] : '');
1904 1904
             $smonth = (!empty($reg[2]) ? $reg[2] : '');
@@ -1916,7 +1916,7 @@  discard block
 block discarded – undo
1916 1916
 
1917 1917
                 $ret = adodb_strftime($format, $timetouse, $to_gmt);
1918 1918
             } else
1919
-                $ret = 'Bad value ' . $time . ' for date';
1919
+                $ret = 'Bad value '.$time.' for date';
1920 1920
         }
1921 1921
 
1922 1922
         if (preg_match('/__b__/i', $format)) {
@@ -1925,11 +1925,11 @@  discard block
 block discarded – undo
1925 1925
             $month = adodb_strftime('%m', $timetouse);
1926 1926
             $month = sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
1927 1927
             if ($encodetooutput) {
1928
-                $monthtext = $outputlangs->transnoentities('Month' . $month);
1929
-                $monthtextshort = $outputlangs->transnoentities('MonthShort' . $month);
1928
+                $monthtext = $outputlangs->transnoentities('Month'.$month);
1929
+                $monthtextshort = $outputlangs->transnoentities('MonthShort'.$month);
1930 1930
             } else {
1931
-                $monthtext = $outputlangs->transnoentitiesnoconv('Month' . $month);
1932
-                $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort' . $month);
1931
+                $monthtext = $outputlangs->transnoentitiesnoconv('Month'.$month);
1932
+                $monthtextshort = $outputlangs->transnoentitiesnoconv('MonthShort'.$month);
1933 1933
             }
1934 1934
 //print 'monthtext='.$monthtext.' monthtextshort='.$monthtextshort;
1935 1935
             $ret = str_replace('__b__', $monthtextshort, $ret);
@@ -1940,8 +1940,8 @@  discard block
 block discarded – undo
1940 1940
         if (preg_match('/__a__/i', $format)) {
1941 1941
             $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1942 1942
 
1943
-            $w = adodb_strftime('%w', $timetouse);      // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1944
-            $dayweek = $outputlangs->transnoentitiesnoconv('Day' . $w);
1943
+            $w = adodb_strftime('%w', $timetouse); // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1944
+            $dayweek = $outputlangs->transnoentitiesnoconv('Day'.$w);
1945 1945
             $ret = str_replace('__A__', $dayweek, $ret);
1946 1946
             $ret = str_replace('__a__', dol_substr($dayweek, 0, 3), $ret);
1947 1947
         }
@@ -1988,9 +1988,9 @@  discard block
 block discarded – undo
1988 1988
 
1989 1989
         $usealternatemethod = false;
1990 1990
         if ($timestamp <= 0)
1991
-            $usealternatemethod = true;    // <= 1970
1991
+            $usealternatemethod = true; // <= 1970
1992 1992
         if ($timestamp >= 2145913200)
1993
-            $usealternatemethod = true;  // >= 2038
1993
+            $usealternatemethod = true; // >= 2038
1994 1994
 
1995 1995
         if ($usealternatemethod) {
1996 1996
             $arrayinfo = adodb_getdate($timestamp, $fast);
@@ -2050,23 +2050,23 @@  discard block
 block discarded – undo
2050 2050
 
2051 2051
         if (method_exists('DateTime', 'getTimestamp')) {
2052 2052
             if (empty($gm) || $gm === 'server') {
2053
-                $default_timezone = @date_default_timezone_get();  // Example 'Europe/Berlin'
2053
+                $default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin'
2054 2054
                 $localtz = new DateTimeZone($default_timezone);
2055 2055
             } else if ($gm === 'user') {
2056 2056
 // We use dol_tz_string first because it is more reliable.
2057
-                $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]);  // Example 'Europe/Berlin'
2057
+                $default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin'
2058 2058
                 try {
2059 2059
                     $localtz = new DateTimeZone($default_timezone);
2060 2060
                 } catch (Exception $e) {
2061
-                    dol_syslog("Warning dol_tz_string contains an invalid value " . $_SESSION["dol_tz_string"], LOG_WARNING);
2061
+                    dol_syslog("Warning dol_tz_string contains an invalid value ".$_SESSION["dol_tz_string"], LOG_WARNING);
2062 2062
                     $default_timezone = @date_default_timezone_get();
2063 2063
                 }
2064 2064
             } else if (strrpos($gm, "tz,") !== false) {
2065
-                $timezone = str_replace("tz,", "", $gm);  // Example 'tz,Europe/Berlin'
2065
+                $timezone = str_replace("tz,", "", $gm); // Example 'tz,Europe/Berlin'
2066 2066
                 try {
2067 2067
                     $localtz = new DateTimeZone($timezone);
2068 2068
                 } catch (Exception $e) {
2069
-                    dol_syslog("Warning passed timezone contains an invalid value " . $timezone, LOG_WARNING);
2069
+                    dol_syslog("Warning passed timezone contains an invalid value ".$timezone, LOG_WARNING);
2070 2070
                 }
2071 2071
             }
2072 2072
 
@@ -2105,8 +2105,8 @@  discard block
 block discarded – undo
2105 2105
         if ($mode == 'gmt')
2106 2106
             $ret = time(); // Time for now at greenwich.
2107 2107
         else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
2108
-            require_once DOL_BASE_PATH . '/core/lib/date.lib.php';
2109
-            $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
2108
+            require_once DOL_BASE_PATH.'/core/lib/date.lib.php';
2109
+            $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time
2110 2110
             $ret = (int) (dol_now('gmt') + ($tzsecond * 3600));
2111 2111
         }
2112 2112
         /* else if ($mode == 'tzref')				// Time for now with parent company timezone is added
@@ -2152,9 +2152,9 @@  discard block
 block discarded – undo
2152 2152
         }
2153 2153
 // Use long or short text unit
2154 2154
         if (empty($shortunit)) {
2155
-            $ret .= ' ' . $textunitlong;
2155
+            $ret .= ' '.$textunitlong;
2156 2156
         } else {
2157
-            $ret .= ' ' . $textunitshort;
2157
+            $ret .= ' '.$textunitshort;
2158 2158
         }
2159 2159
 
2160 2160
         return $ret;
@@ -2182,13 +2182,13 @@  discard block
 block discarded – undo
2182 2182
         $link .= $url;
2183 2183
         $link .= '"';
2184 2184
         if ($target)
2185
-            $link .= ' target="' . $target . '"';
2185
+            $link .= ' target="'.$target.'"';
2186 2186
         $link .= '>';
2187 2187
         if (!preg_match('/^http/i', $url))
2188 2188
             $link .= 'http://';
2189 2189
         $link .= dol_trunc($url, $max);
2190 2190
         $link .= '</a>';
2191
-        return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
2191
+        return '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png').' ' : '').$link.'</div>';
2192 2192
     }
2193 2193
 
2194 2194
     /**
@@ -2229,9 +2229,9 @@  discard block
 block discarded – undo
2229 2229
                 $type = 'AC_EMAIL';
2230 2230
                 $link = '';
2231 2231
                 if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL))
2232
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2232
+                    $link = '<a href="'.DOL_BASE_URI.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$type.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2233 2233
                 if ($link)
2234
-                    $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2234
+                    $newemail = '<div>'.$newemail.' '.$link.'</div>';
2235 2235
             }
2236 2236
         }
2237 2237
         else {
@@ -2241,7 +2241,7 @@  discard block
 block discarded – undo
2241 2241
             }
2242 2242
         }
2243 2243
 
2244
-        $rep = '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png') . ' ' : '') . $newemail . '</div>';
2244
+        $rep = '<div class="nospan float" style="margin-right: 10px">'.($withpicto ? img_picto($langs->trans("EMail"), 'object_email.png').' ' : '').$newemail.'</div>';
2245 2245
         if ($hookmanager) {
2246 2246
             $parameters = array('cid' => $cid, 'socid' => $socid, 'addlink' => $addlink, 'picto' => $withpicto);
2247 2247
             $reshook = $hookmanager->executeHooks('printEmail', $parameters, $email);
@@ -2271,26 +2271,26 @@  discard block
 block discarded – undo
2271 2271
 
2272 2272
         if (!empty($type)) {
2273 2273
             $newskype = '<div class="divsocialnetwork inline-block valignmiddle">';
2274
-            $newskype .= img_picto($langs->trans(strtoupper($type)), $type . '.png', '', false, 0, 0, '', 'paddingright');
2274
+            $newskype .= img_picto($langs->trans(strtoupper($type)), $type.'.png', '', false, 0, 0, '', 'paddingright');
2275 2275
             $newskype .= $value;
2276 2276
             if ($type == 'skype') {
2277 2277
                 $newskype .= '&nbsp;';
2278 2278
                 $newskype .= '<a href="skype:';
2279 2279
                 $newskype .= $value;
2280
-                $newskype .= '?call" alt="' . $langs->trans("Call") . '&nbsp;' . $value . '" title="' . $langs->trans("Call") . '&nbsp;' . $value . '">';
2281
-                $newskype .= '<img src="' . DOL_BASE_URI . '/theme/common/skype_callbutton.png" border="0">';
2280
+                $newskype .= '?call" alt="'.$langs->trans("Call").'&nbsp;'.$value.'" title="'.$langs->trans("Call").'&nbsp;'.$value.'">';
2281
+                $newskype .= '<img src="'.DOL_BASE_URI.'/theme/common/skype_callbutton.png" border="0">';
2282 2282
                 $newskype .= '</a><a href="skype:';
2283 2283
                 $newskype .= $value;
2284
-                $newskype .= '?chat" alt="' . $langs->trans("Chat") . '&nbsp;' . $value . '" title="' . $langs->trans("Chat") . '&nbsp;' . $value . '">';
2285
-                $newskype .= '<img class="paddingleft" src="' . DOL_BASE_URI . '/theme/common/skype_chatbutton.png" border="0">';
2284
+                $newskype .= '?chat" alt="'.$langs->trans("Chat").'&nbsp;'.$value.'" title="'.$langs->trans("Chat").'&nbsp;'.$value.'">';
2285
+                $newskype .= '<img class="paddingleft" src="'.DOL_BASE_URI.'/theme/common/skype_chatbutton.png" border="0">';
2286 2286
                 $newskype .= '</a>';
2287 2287
             }
2288 2288
             if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
2289 2289
                 $addlink = 'AC_SKYPE';
2290 2290
                 $link = '';
2291 2291
                 if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE))
2292
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2293
-                $newskype .= ($link ? ' ' . $link : '');
2292
+                    $link = '<a href="'.DOL_BASE_URI.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$addlink.'&amp;contactid='.$cid.'&amp;socid='.$socid.'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2293
+                $newskype .= ($link ? ' '.$link : '');
2294 2294
             }
2295 2295
             $newskype .= '</div>';
2296 2296
         }
@@ -2334,165 +2334,165 @@  discard block
 block discarded – undo
2334 2334
         if (strtoupper($countrycode) == "FR") {
2335 2335
 // France
2336 2336
             if (dol_strlen($phone) == 10) {
2337
-                $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 2) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2);
2337
+                $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 2).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2);
2338 2338
             } elseif (dol_strlen($phone) == 7) {
2339
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2);
2339
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2);
2340 2340
             } elseif (dol_strlen($phone) == 9) {
2341
-                $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2);
2341
+                $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2);
2342 2342
             } elseif (dol_strlen($phone) == 11) {
2343
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2343
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2344 2344
             } elseif (dol_strlen($phone) == 12) {
2345
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2345
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2346 2346
             }
2347 2347
         } elseif (strtoupper($countrycode) == "CA") {
2348 2348
             if (dol_strlen($phone) == 10) {
2349
-                $newphone = ($separ != '' ? '(' : '') . substr($newphone, 0, 3) . ($separ != '' ? ')' : '') . $separ . substr($newphone, 3, 3) . ($separ != '' ? '-' : '') . substr($newphone, 6, 4);
2349
+                $newphone = ($separ != '' ? '(' : '').substr($newphone, 0, 3).($separ != '' ? ')' : '').$separ.substr($newphone, 3, 3).($separ != '' ? '-' : '').substr($newphone, 6, 4);
2350 2350
             }
2351 2351
         } elseif (strtoupper($countrycode) == "PT") {//Portugal
2352 2352
             if (dol_strlen($phone) == 13) {//ex: +351_ABC_DEF_GHI
2353
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2353
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2354 2354
             }
2355 2355
         } elseif (strtoupper($countrycode) == "SR") {//Suriname
2356 2356
             if (dol_strlen($phone) == 10) {//ex: +597_ABC_DEF
2357
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3);
2357
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3);
2358 2358
             } elseif (dol_strlen($phone) == 11) {//ex: +597_ABC_DEFG
2359
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 4);
2359
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 4);
2360 2360
             }
2361 2361
         } elseif (strtoupper($countrycode) == "DE") {//Allemagne
2362 2362
             if (dol_strlen($phone) == 14) {//ex:  +49_ABCD_EFGH_IJK
2363
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 4) . $separ . substr($newphone, 11, 3);
2363
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 4).$separ.substr($newphone, 11, 3);
2364 2364
             } elseif (dol_strlen($phone) == 13) {//ex: +49_ABC_DEFG_HIJ
2365
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 4) . $separ . substr($newphone, 10, 3);
2365
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 4).$separ.substr($newphone, 10, 3);
2366 2366
             }
2367 2367
         } elseif (strtoupper($countrycode) == "ES") {//Espagne
2368 2368
             if (dol_strlen($phone) == 12) {//ex:  +34_ABC_DEF_GHI
2369
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2369
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2370 2370
             }
2371 2371
         } elseif (strtoupper($countrycode) == "BF") {// Burkina Faso
2372 2372
             if (dol_strlen($phone) == 12) {//ex :  +22 A BC_DE_FG_HI
2373
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2373
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2374 2374
             }
2375 2375
         } elseif (strtoupper($countrycode) == "RO") {// Roumanie
2376 2376
             if (dol_strlen($phone) == 12) {//ex :  +40 AB_CDE_FG_HI
2377
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2377
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2378 2378
             }
2379 2379
         } elseif (strtoupper($countrycode) == "TR") {//Turquie
2380 2380
             if (dol_strlen($phone) == 13) {//ex :  +90 ABC_DEF_GHIJ
2381
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4);
2381
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2382 2382
             }
2383 2383
         } elseif (strtoupper($countrycode) == "US") {//Etat-Unis
2384 2384
             if (dol_strlen($phone) == 12) {//ex: +1 ABC_DEF_GHIJ
2385
-                $newphone = substr($newphone, 0, 2) . $separ . substr($newphone, 2, 3) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 4);
2385
+                $newphone = substr($newphone, 0, 2).$separ.substr($newphone, 2, 3).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 4);
2386 2386
             }
2387 2387
         } elseif (strtoupper($countrycode) == "MX") {//Mexique
2388 2388
             if (dol_strlen($phone) == 12) {//ex: +52 ABCD_EFG_HI
2389
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2);
2389
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2390 2390
             } elseif (dol_strlen($phone) == 11) {//ex: +52 AB_CD_EF_GH
2391
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 2) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2391
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 2).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2392 2392
             } elseif (dol_strlen($phone) == 13) {//ex: +52 ABC_DEF_GHIJ
2393
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 4);
2393
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 4);
2394 2394
             }
2395 2395
         } elseif (strtoupper($countrycode) == "ML") {//Mali
2396 2396
             if (dol_strlen($phone) == 12) {//ex: +223 AB_CD_EF_GH
2397
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2397
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2398 2398
             }
2399 2399
         } elseif (strtoupper($countrycode) == "TH") {//Thaïlande
2400 2400
             if (dol_strlen($phone) == 11) {//ex: +66_ABC_DE_FGH
2401
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3);
2401
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2402 2402
             } elseif (dol_strlen($phone) == 12) {//ex: +66_A_BCD_EF_GHI
2403
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 3);
2403
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 3);
2404 2404
             }
2405 2405
         } elseif (strtoupper($countrycode) == "MU") {//Maurice
2406 2406
             if (dol_strlen($phone) == 11) {//ex: +230_ABC_DE_FG
2407
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2407
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2408 2408
             } elseif (dol_strlen($phone) == 12) {//ex: +230_ABCD_EF_GH
2409
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2409
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2410 2410
             }
2411 2411
         } elseif (strtoupper($countrycode) == "ZA") {//Afrique du sud
2412 2412
             if (dol_strlen($phone) == 12) {//ex: +27_AB_CDE_FG_HI
2413
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2413
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2414 2414
             }
2415 2415
         } elseif (strtoupper($countrycode) == "SY") {//Syrie
2416 2416
             if (dol_strlen($phone) == 12) {//ex: +963_AB_CD_EF_GH
2417
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2417
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2418 2418
             } elseif (dol_strlen($phone) == 13) {//ex: +963_AB_CD_EF_GHI
2419
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3);
2419
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
2420 2420
             }
2421 2421
         } elseif (strtoupper($countrycode) == "AE") {//Emirats Arabes Unis
2422 2422
             if (dol_strlen($phone) == 12) {//ex: +971_ABC_DEF_GH
2423
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 2);
2423
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 2);
2424 2424
             } elseif (dol_strlen($phone) == 13) {//ex: +971_ABC_DEF_GHI
2425
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2425
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2426 2426
             } elseif (dol_strlen($phone) == 14) {//ex: +971_ABC_DEF_GHIK
2427
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 4);
2427
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 4);
2428 2428
             }
2429 2429
         } elseif (strtoupper($countrycode) == "DZ") {//Algérie
2430 2430
             if (dol_strlen($phone) == 13) {//ex: +213_ABC_DEF_GHI
2431
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2431
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2432 2432
             }
2433 2433
         } elseif (strtoupper($countrycode) == "BE") {//Belgique
2434 2434
             if (dol_strlen($phone) == 11) {//ex: +32_ABC_DE_FGH
2435
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 3);
2435
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 3);
2436 2436
             } elseif (dol_strlen($phone) == 12) {//ex: +32_ABC_DEF_GHI
2437
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2437
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2438 2438
             }
2439 2439
         } elseif (strtoupper($countrycode) == "PF") {//Polynésie française
2440 2440
             if (dol_strlen($phone) == 12) {//ex: +689_AB_CD_EF_GH
2441
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2441
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2442 2442
             }
2443 2443
         } elseif (strtoupper($countrycode) == "CO") {//Colombie
2444 2444
             if (dol_strlen($phone) == 13) {//ex: +57_ABC_DEF_GH_IJ
2445
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2445
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2446 2446
             }
2447 2447
         } elseif (strtoupper($countrycode) == "JO") {//Jordanie
2448 2448
             if (dol_strlen($phone) == 12) {//ex: +962_A_BCD_EF_GH
2449
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 1) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2);
2449
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 1).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2);
2450 2450
             }
2451 2451
         } elseif (strtoupper($countrycode) == "MG") {//Madagascar
2452 2452
             if (dol_strlen($phone) == 13) {//ex: +261_AB_CD_EF_GHI
2453
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 2) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 3);
2453
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 2).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 3);
2454 2454
             }
2455 2455
         } elseif (strtoupper($countrycode) == "GB") {//Royaume uni
2456 2456
             if (dol_strlen($phone) == 13) {//ex: +44_ABCD_EFG_HIJ
2457
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 4) . $separ . substr($newphone, 7, 3) . $separ . substr($newphone, 10, 3);
2457
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 4).$separ.substr($newphone, 7, 3).$separ.substr($newphone, 10, 3);
2458 2458
             }
2459 2459
         } elseif (strtoupper($countrycode) == "CH") {//Suisse
2460 2460
             if (dol_strlen($phone) == 12) {//ex: +41_AB_CDE_FG_HI
2461
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 2) . $separ . substr($newphone, 10, 2);
2461
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 2).$separ.substr($newphone, 10, 2);
2462 2462
             } elseif (dol_strlen($phone) == 15) {// +41_AB_CDE_FGH_IJKL
2463
-                $newphone = $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 2) . $separ . substr($newphone, 5, 3) . $separ . substr($newphone, 8, 3) . $separ . substr($newphone, 11, 4);
2463
+                $newphone = $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 2).$separ.substr($newphone, 5, 3).$separ.substr($newphone, 8, 3).$separ.substr($newphone, 11, 4);
2464 2464
             }
2465 2465
         } elseif (strtoupper($countrycode) == "TN") {//Tunisie
2466 2466
             if (dol_strlen($phone) == 12) {//ex: +216_AB_CDE_FGH
2467
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 2) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2467
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 2).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2468 2468
             }
2469 2469
         } elseif (strtoupper($countrycode) == "GF") {//Guyane francaise
2470 2470
             if (dol_strlen($phone) == 13) {//ex: +594_ABC_DE_FG_HI  (ABC=594 de nouveau)
2471
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2471
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2472 2472
             }
2473 2473
         } elseif (strtoupper($countrycode) == "GP") {//Guadeloupe
2474 2474
             if (dol_strlen($phone) == 13) {//ex: +590_ABC_DE_FG_HI  (ABC=590 de nouveau)
2475
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2475
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2476 2476
             }
2477 2477
         } elseif (strtoupper($countrycode) == "MQ") {//Martinique
2478 2478
             if (dol_strlen($phone) == 13) {//ex: +596_ABC_DE_FG_HI  (ABC=596 de nouveau)
2479
-                $newphone = substr($newphone, 0, 4) . $separ . substr($newphone, 4, 3) . $separ . substr($newphone, 7, 2) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2479
+                $newphone = substr($newphone, 0, 4).$separ.substr($newphone, 4, 3).$separ.substr($newphone, 7, 2).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2480 2480
             }
2481 2481
         } elseif (strtoupper($countrycode) == "IT") {//Italie
2482 2482
             if (dol_strlen($phone) == 12) {//ex: +39_ABC_DEF_GHI
2483
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 3);
2483
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 3);
2484 2484
             } elseif (dol_strlen($phone) == 13) {//ex: +39_ABC_DEF_GH_IJ
2485
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 3) . $separ . substr($newphone, 6, 3) . $separ . substr($newphone, 9, 2) . $separ . substr($newphone, 11, 2);
2485
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 3).$separ.substr($newphone, 6, 3).$separ.substr($newphone, 9, 2).$separ.substr($newphone, 11, 2);
2486 2486
             }
2487 2487
         } elseif (strtoupper($countrycode) == "AU") {//Australie
2488 2488
             if (dol_strlen($phone) == 12) {//ex: +61_A_BCDE_FGHI
2489
-                $newphone = substr($newphone, 0, 3) . $separ . substr($newphone, 3, 1) . $separ . substr($newphone, 4, 4) . $separ . substr($newphone, 8, 4);
2489
+                $newphone = substr($newphone, 0, 3).$separ.substr($newphone, 3, 1).$separ.substr($newphone, 4, 4).$separ.substr($newphone, 8, 4);
2490 2490
             }
2491 2491
         }
2492 2492
         if (!empty($addlink)) { // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
2493 2493
             if (Globals::$conf->browser->layout == 'phone' || (!empty(Globals::$conf->clicktodial->enabled) && !empty(Globals::$conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) { // If phone or option for, we use link of phone
2494
-                $newphone = '<a href="tel:' . $phone . '"';
2495
-                $newphone .= '>' . $phone . '</a>';
2494
+                $newphone = '<a href="tel:'.$phone.'"';
2495
+                $newphone .= '>'.$phone.'</a>';
2496 2496
             } else if (!empty(Globals::$conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
2497 2497
                 if (empty($user->clicktodial_loaded))
2498 2498
                     $user->fetch_clicktodial();
@@ -2516,10 +2516,10 @@  discard block
 block discarded – undo
2516 2516
                     '__PASS__' => $clicktodial_password);
2517 2517
                 $url = make_substitutions($url, $substitarray);
2518 2518
                 $newphonesav = $newphone;
2519
-                $newphone = '<a href="' . $url . '"';
2519
+                $newphone = '<a href="'.$url.'"';
2520 2520
                 if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET))
2521 2521
                     $newphone .= ' target="_blank"';
2522
-                $newphone .= '>' . $newphonesav . '</a>';
2522
+                $newphone .= '>'.$newphonesav.'</a>';
2523 2523
             }
2524 2524
 
2525 2525
 //if (($cid || $socid) && ! empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create)
@@ -2529,9 +2529,9 @@  discard block
 block discarded – undo
2529 2529
                 if ($addlink == 'AC_FAX')
2530 2530
                     $type = 'AC_FAX';
2531 2531
                 if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE))
2532
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2532
+                    $link = '<a href="'.DOL_BASE_URI.'/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode='.$type.($cid ? '&amp;contactid='.$cid : '').($socid ? '&amp;socid='.$socid : '').'">'.img_object($langs->trans("AddAction"), "calendar").'</a>';
2533 2533
                 if ($link)
2534
-                    $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2534
+                    $newphone = '<div>'.$newphone.' '.$link.'</div>';
2535 2535
             }
2536 2536
         }
2537 2537
 
@@ -2562,7 +2562,7 @@  discard block
 block discarded – undo
2562 2562
                 $rep .= '<div class="nospan float" style="margin-right: 10px">';
2563 2563
             else
2564 2564
                 $rep .= '<span style="margin-right: 10px;">';
2565
-            $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone;
2565
+            $rep .= ($withpicto ? img_picto($titlealt, 'object_'.$picto.'.png').' ' : '').$newphone;
2566 2566
             if ($adddivfloat)
2567 2567
                 $rep .= '</div>';
2568 2568
             else
@@ -2589,15 +2589,15 @@  discard block
 block discarded – undo
2589 2589
             $ret .= $ip;
2590 2590
         }
2591 2591
 
2592
-        echo ('<p>DOL_BASE_PATH: ' . DOL_BASE_PATH . '/DOL_BASE_URI: ' . DOL_BASE_URI . '</p>');
2592
+        echo ('<p>DOL_BASE_PATH: '.DOL_BASE_PATH.'/DOL_BASE_URI: '.DOL_BASE_URI.'</p>');
2593 2593
 
2594 2594
         if ($mode != 2) {
2595 2595
             $countrycode = dolGetCountryCodeFromIp($ip);
2596 2596
             if ($countrycode) { // If success, countrycode is us, fr, ...
2597
-                if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
2598
-                    $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
2597
+                if (file_exists(DOL_BASE_PATH.'/theme/common/flags/'.$countrycode.'.png')) {
2598
+                    $ret .= ' '.img_picto($countrycode.' '.$langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI.'/theme/common/flags/'.$countrycode.'.png', '', 1);
2599 2599
                 } else
2600
-                    $ret .= ' (' . $countrycode . ')';
2600
+                    $ret .= ' ('.$countrycode.')';
2601 2601
             }
2602 2602
         }
2603 2603
 
@@ -2635,7 +2635,7 @@  discard block
 block discarded – undo
2635 2635
 //$ip='24.24.24.24';
2636 2636
 //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';    Note that this must be downloaded datafile (not same than datafile provided with ubuntu packages)
2637 2637
 
2638
-            include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php';
2638
+            include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php';
2639 2639
             $geoip = new DolGeoIP('country', $datafile);
2640 2640
 //print 'ip='.$ip.' databaseType='.$geoip->gi->databaseType." GEOIP_CITY_EDITION_REV1=".GEOIP_CITY_EDITION_REV1."\n";
2641 2641
 //print "geoip_country_id_by_addr=".geoip_country_id_by_addr($geoip->gi,$ip)."\n";
@@ -2661,7 +2661,7 @@  discard block
 block discarded – undo
2661 2661
             $datafile = Globals::$conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE;
2662 2662
 //$ip='24.24.24.24';
2663 2663
 //$datafile='E:\Mes Sites\Web\Admin1\awstats\maxmind\GeoIP.dat';
2664
-            include_once DOL_BASE_PATH . '/core/class/dolgeoip.class.php';
2664
+            include_once DOL_BASE_PATH.'/core/class/dolgeoip.class.php';
2665 2665
             $geoip = new DolGeoIP('country', $datafile);
2666 2666
             $countrycode = $geoip->getCountryCodeFromIP($ip);
2667 2667
             $ret = $countrycode;
@@ -2716,12 +2716,12 @@  discard block
 block discarded – undo
2716 2716
                     $showomap = 1;
2717 2717
 
2718 2718
                 if ($showgmap) {
2719
-                    $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
2720
-                    $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '" class="valigntextbottom" src="' . DOL_BASE_URI . '/theme/common/gmap.png"></a>';
2719
+                    $url = dol_buildpath('/google/gmaps.php?mode='.$mode.'&id='.$id, 1);
2720
+                    $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'" class="valigntextbottom" src="'.DOL_BASE_URI.'/theme/common/gmap.png"></a>';
2721 2721
                 }
2722 2722
                 if ($showomap) {
2723
-                    $url = dol_buildpath('/openstreetmap/maps.php?mode=' . $mode . '&id=' . $id, 1);
2724
-                    $out .= ' <a href="' . $url . '" target="_gmaps"><img id="' . $htmlid . '_openstreetmap" class="valigntextbottom" src="' . DOL_BASE_URI . '/theme/common/gmap.png"></a>';
2723
+                    $url = dol_buildpath('/openstreetmap/maps.php?mode='.$mode.'&id='.$id, 1);
2724
+                    $out .= ' <a href="'.$url.'" target="_gmaps"><img id="'.$htmlid.'_openstreetmap" class="valigntextbottom" src="'.DOL_BASE_URI.'/theme/common/gmap.png"></a>';
2725 2725
                 }
2726 2726
             }
2727 2727
         }
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
         if ($trunc == 'right') {
2868 2868
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2869 2869
             if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2870
-                return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
2870
+                return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '...');
2871 2871
             else
2872 2872
 //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
2873 2873
                 return $string;
@@ -2877,21 +2877,21 @@  discard block
 block discarded – undo
2877 2877
             if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
2878 2878
                 $size1 = round($size / 2);
2879 2879
                 $size2 = round($size / 2);
2880
-                return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2880
+                return dol_substr($newstring, 0, $size1, $stringencoding).'...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2881 2881
             } else
2882 2882
                 return $string;
2883 2883
         }
2884 2884
         elseif ($trunc == 'left') {
2885 2885
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2886 2886
             if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2887
-                return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2887
+                return '...'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2888 2888
             else
2889 2889
                 return $string;
2890 2890
         }
2891 2891
         elseif ($trunc == 'wrap') {
2892 2892
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2893 2893
             if (dol_strlen($newstring, $stringencoding) > ($size + 1))
2894
-                return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2894
+                return dol_substr($newstring, 0, $size, $stringencoding)."\n".dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2895 2895
             else
2896 2896
                 return $string;
2897 2897
         } else
@@ -2924,7 +2924,7 @@  discard block
 block discarded – undo
2924 2924
         $url = DOL_BASE_URI;
2925 2925
 
2926 2926
         $theme = Globals::$conf->theme;
2927
-        $path = 'theme/' . $theme;
2927
+        $path = 'theme/'.$theme;
2928 2928
 
2929 2929
 // Define fullpathpicto to use into src
2930 2930
         if ($pictoisfullpath) {
@@ -2973,7 +2973,7 @@  discard block
 block discarded – undo
2973 2973
                     $fakey = 'fa-pencil';
2974 2974
                     $facolor = '#444';
2975 2975
                 } elseif ($pictowithoutext == 'filter') {
2976
-                    $fakey = 'fa-' . $pictowithoutext;
2976
+                    $fakey = 'fa-'.$pictowithoutext;
2977 2977
                 } elseif ($pictowithoutext == 'grip_title' || $pictowithoutext == 'grip') {
2978 2978
                     $fakey = 'fa-arrows';
2979 2979
                 } elseif ($pictowithoutext == 'listlight') {
@@ -3012,15 +3012,15 @@  discard block
 block discarded – undo
3012 3012
                 } elseif ($pictowithoutext == 'jabber') {
3013 3013
                     $fakey = 'fa-comment-o';
3014 3014
                 } else {
3015
-                    $fakey = 'fa-' . $pictowithoutext;
3015
+                    $fakey = 'fa-'.$pictowithoutext;
3016 3016
                     $facolor = '#444';
3017 3017
                     $marginleftonlyshort = 0;
3018 3018
                 }
3019 3019
 
3020 3020
                 if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
3021
-                    $morecss .= ($morecss ? ' ' : '') . $reg[1];
3021
+                    $morecss .= ($morecss ? ' ' : '').$reg[1];
3022 3022
                 }
3023
-                $enabledisablehtml = '<span class="fa ' . $fakey . ' ' . ($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '') . ' valignmiddle' . ($morecss ? ' ' . $morecss : '') . '" style="' . ($fasize ? ('font-size: ' . $fasize . ';') : '') . ($facolor ? (' color: ' . $facolor . ';') : '') . '" alt="' . dol_escape_htmltag($titlealt) . '"' . (($notitle || empty($title)) ? '' : ' title="' . dol_escape_htmltag($title) . '"') . ($moreatt ? ' ' . $moreatt : '') . '>';
3023
+                $enabledisablehtml = '<span class="fa '.$fakey.' '.($marginleftonlyshort ? ($marginleftonlyshort == 1 ? 'marginleftonlyshort' : 'marginleftonly') : '').' valignmiddle'.($morecss ? ' '.$morecss : '').'" style="'.($fasize ? ('font-size: '.$fasize.';') : '').($facolor ? (' color: '.$facolor.';') : '').'" alt="'.dol_escape_htmltag($titlealt).'"'.(($notitle || empty($title)) ? '' : ' title="'.dol_escape_htmltag($title).'"').($moreatt ? ' '.$moreatt : '').'>';
3024 3024
                 if (!empty(Globals::$conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
3025 3025
                     $enabledisablehtml .= $titlealt;
3026 3026
                 }
@@ -3030,11 +3030,11 @@  discard block
 block discarded – undo
3030 3030
             }
3031 3031
 
3032 3032
             if (!empty(Globals::$conf->global->MAIN_OVERWRITE_THEME_PATH)) {
3033
-                $path = Globals::$conf->global->MAIN_OVERWRITE_THEME_PATH . '/theme/' . $theme; // If the theme does not have the same name as the module
3033
+                $path = Globals::$conf->global->MAIN_OVERWRITE_THEME_PATH.'/theme/'.$theme; // If the theme does not have the same name as the module
3034 3034
             } else if (!empty(Globals::$conf->global->MAIN_OVERWRITE_THEME_RES)) {
3035
-                $path = Globals::$conf->global->MAIN_OVERWRITE_THEME_RES . '/theme/' . Globals::$conf->global->MAIN_OVERWRITE_THEME_RES;  // To allow an external module to overwrite image resources whatever is activated theme
3035
+                $path = Globals::$conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.Globals::$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme
3036 3036
             } else if (!empty(Globals::$conf->modules_parts['theme']) && array_key_exists($theme, Globals::$conf->modules_parts['theme'])) {
3037
-                $path = $theme . '/theme/' . $theme; // If the theme have the same name as the module
3037
+                $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module
3038 3038
             }
3039 3039
 
3040 3040
 // If we ask an image into $url/$mymodule/img (instead of default path)
@@ -3054,15 +3054,15 @@  discard block
 block discarded – undo
3054 3054
                     continue;
3055 3055
                 }
3056 3056
 // This need a lot of time, that's why enabling alternative dir like "custom" dir is not recommanded
3057
-                if (file_exists($dirroot . '/' . $path . '/img/' . $picto)) {
3057
+                if (file_exists($dirroot.'/'.$path.'/img/'.$picto)) {
3058 3058
                     //$url = DOL_BASE_URI . Globals::$conf->file->dol_url_root[$type];
3059
-                    $url = DOL_BASE_URI . Globals::$conf->file->dol_url_root[$type];
3059
+                    $url = DOL_BASE_URI.Globals::$conf->file->dol_url_root[$type];
3060 3060
                     break;
3061 3061
                 }
3062 3062
             }
3063 3063
 
3064 3064
 // $url is '' or '/custom', $path is current theme or
3065
-            $fullpathpicto = $url . '/' . $path . '/img/' . $picto;
3065
+            $fullpathpicto = $url.'/'.$path.'/img/'.$picto;
3066 3066
         }
3067 3067
 
3068 3068
         if ($srconly) {
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
         }
3071 3071
 
3072 3072
 // tag title is used for tooltip on <a>, tag alt can be used with very simple text on image for bind people
3073
-        return '<img src="' . $fullpathpicto . '" alt="' . dol_escape_htmltag($alt) . '"' . (($notitle || empty($titlealt)) ? '' : ' title="' . dol_escape_htmltag($titlealt) . '"') . ($moreatt ? ' ' . $moreatt : ' class="inline-block' . ($morecss ? ' ' . $morecss : '') . '"') . '>'; // Alt is used for accessibility, title for popup
3073
+        return '<img src="'.$fullpathpicto.'" alt="'.dol_escape_htmltag($alt).'"'.(($notitle || empty($titlealt)) ? '' : ' title="'.dol_escape_htmltag($titlealt).'"').($moreatt ? ' '.$moreatt : ' class="inline-block'.($morecss ? ' '.$morecss : '').'"').'>'; // Alt is used for accessibility, title for popup
3074 3074
     }
3075 3075
 
3076 3076
     /**
@@ -3088,7 +3088,7 @@  discard block
 block discarded – undo
3088 3088
      */
3089 3089
     static function img_object($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $srconly = 0, $notitle = 0)
3090 3090
     {
3091
-        return img_picto($titlealt, 'object_' . $picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
3091
+        return img_picto($titlealt, 'object_'.$picto, $moreatt, $pictoisfullpath, $srconly, $notitle);
3092 3092
     }
3093 3093
 
3094 3094
     /**
@@ -3109,7 +3109,7 @@  discard block
 block discarded – undo
3109 3109
             $picto .= '.png';
3110 3110
 
3111 3111
 //$path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
3112
-        $path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
3112
+        $path = DOL_BASE_URI.'/theme/'.Globals::$conf->theme.'/img/weather/'.$picto;
3113 3113
 
3114 3114
         return img_picto($titlealt, $path, $moreatt, 1);
3115 3115
     }
@@ -3135,10 +3135,10 @@  discard block
 block discarded – undo
3135 3135
             $path = $picto;
3136 3136
         else {
3137 3137
 //$path = DOL_BASE_URI . '/theme/common/' . $picto;
3138
-            $path = DOL_BASE_URI . '/theme/common/' . $picto;
3138
+            $path = DOL_BASE_URI.'/theme/common/'.$picto;
3139 3139
 
3140 3140
             if (!empty(Globals::$conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
3141
-                $themepath = DOL_BASE_PATH . 'theme/' . Globals::$conf->theme . '/img/' . $picto;
3141
+                $themepath = DOL_BASE_PATH.'theme/'.Globals::$conf->theme.'/img/'.$picto;
3142 3142
 
3143 3143
                 if (file_exists($themepath))
3144 3144
                     $path = $themepath;
@@ -3176,14 +3176,14 @@  discard block
 block discarded – undo
3176 3176
                 $numaction = 3;
3177 3177
                 $titlealt = $langs->transnoentitiesnoconv('ChangeContactDone');
3178 3178
             } else {
3179
-                $titlealt = $langs->transnoentitiesnoconv('ChangeStatus ' . $numaction);
3179
+                $titlealt = $langs->transnoentitiesnoconv('ChangeStatus '.$numaction);
3180 3180
                 $numaction = 0;
3181 3181
             }
3182 3182
         }
3183 3183
         if (!is_numeric($numaction))
3184 3184
             $numaction = 0;
3185 3185
 
3186
-        return img_picto($titlealt, 'stcomm' . $numaction . '.png');
3186
+        return img_picto($titlealt, 'stcomm'.$numaction.'.png');
3187 3187
     }
3188 3188
 
3189 3189
     /**
@@ -3200,7 +3200,7 @@  discard block
 block discarded – undo
3200 3200
         if ($titlealt == 'default')
3201 3201
             $titlealt = $langs->trans('Show');
3202 3202
 
3203
-        return img_picto($titlealt, 'pdf' . $size . '.png');
3203
+        return img_picto($titlealt, 'pdf'.$size.'.png');
3204 3204
     }
3205 3205
 
3206 3206
     /**
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
         if ($titlealt == 'default')
3253 3253
             $titlealt = $langs->trans('Modify');
3254 3254
 
3255
-        return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : ''));
3255
+        return img_picto($titlealt, 'edit.png', ($float ? 'style="float: '.($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right').'"' : "").($other ? ' '.$other : ''));
3256 3256
     }
3257 3257
 
3258 3258
     /**
@@ -3270,7 +3270,7 @@  discard block
 block discarded – undo
3270 3270
         if ($titlealt == 'default')
3271 3271
             $titlealt = $langs->trans('View');
3272 3272
 
3273
-        $moreatt = ($float ? 'style="float: right" ' : '') . $other;
3273
+        $moreatt = ($float ? 'style="float: right" ' : '').$other;
3274 3274
 
3275 3275
         return img_picto($titlealt, 'view.png', $moreatt);
3276 3276
     }
@@ -3343,7 +3343,7 @@  discard block
 block discarded – undo
3343 3343
                 $usealttitle = $langs->trans('Info');
3344 3344
         }
3345 3345
 
3346
-        return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"');
3346
+        return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;'.($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')).'"');
3347 3347
     }
3348 3348
 
3349 3349
     /**
@@ -3377,7 +3377,7 @@  discard block
 block discarded – undo
3377 3377
             $titlealt = $langs->trans('Warning');
3378 3378
 
3379 3379
 //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>';
3380
-        return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : ''));
3380
+        return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt) : ''));
3381 3381
     }
3382 3382
 
3383 3383
     /**
@@ -3411,7 +3411,7 @@  discard block
 block discarded – undo
3411 3411
             $titlealt = $langs->trans('Next');
3412 3412
 
3413 3413
 //return img_picto($titlealt, 'next.png', $moreatt);
3414
-        return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
3414
+        return '<span class="fa fa-chevron-right paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>';
3415 3415
     }
3416 3416
 
3417 3417
     /**
@@ -3429,7 +3429,7 @@  discard block
 block discarded – undo
3429 3429
             $titlealt = $langs->trans('Previous');
3430 3430
 
3431 3431
 //return img_picto($titlealt, 'previous.png', $moreatt);
3432
-        return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
3432
+        return '<span class="fa fa-chevron-left paddingright paddingleft" title="'.dol_escape_htmltag($titlealt).'"></span>';
3433 3433
     }
3434 3434
 
3435 3435
     /**
@@ -3447,7 +3447,7 @@  discard block
 block discarded – undo
3447 3447
         if ($titlealt == 'default')
3448 3448
             $titlealt = $langs->trans('Down');
3449 3449
 
3450
-        return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"');
3450
+        return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown'.($moreclass ? " ".$moreclass : "").'"');
3451 3451
     }
3452 3452
 
3453 3453
     /**
@@ -3465,7 +3465,7 @@  discard block
 block discarded – undo
3465 3465
         if ($titlealt == 'default')
3466 3466
             $titlealt = $langs->trans('Up');
3467 3467
 
3468
-        return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"');
3468
+        return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup'.($moreclass ? " ".$moreclass : "").'"');
3469 3469
     }
3470 3470
 
3471 3471
     /**
@@ -3548,7 +3548,7 @@  discard block
 block discarded – undo
3548 3548
             $brand = 'credit-card';
3549 3549
         }
3550 3550
 
3551
-        return '<span class="fa fa-' . $brand . ' fa-2x fa-fw"></span>';
3551
+        return '<span class="fa fa-'.$brand.' fa-2x fa-fw"></span>';
3552 3552
     }
3553 3553
 
3554 3554
     /**
@@ -3561,17 +3561,17 @@  discard block
 block discarded – undo
3561 3561
      */
3562 3562
     static function img_mime($file, $titlealt = '', $morecss = '')
3563 3563
     {
3564
-        require_once DOL_BASE_PATH . '/core/lib/files.lib.php';
3564
+        require_once DOL_BASE_PATH.'/core/lib/files.lib.php';
3565 3565
 
3566 3566
         $mimetype = dol_mimetype($file, '', 1);
3567 3567
         $mimeimg = dol_mimetype($file, '', 2);
3568 3568
         $mimefa = dol_mimetype($file, '', 4);
3569 3569
 
3570 3570
         if (empty($titlealt))
3571
-            $titlealt = 'Mime type: ' . $mimetype;
3571
+            $titlealt = 'Mime type: '.$mimetype;
3572 3572
 
3573 3573
 //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
3574
-        return '<i class="fa fa-' . $mimefa . ' paddingright"></i>';
3574
+        return '<i class="fa fa-'.$mimefa.' paddingright"></i>';
3575 3575
     }
3576 3576
 
3577 3577
     /**
@@ -3586,7 +3586,7 @@  discard block
 block discarded – undo
3586 3586
      */
3587 3587
     static function img_phone($titlealt = 'default', $option = 0)
3588 3588
     {
3589
-        dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
3589
+        dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
3590 3590
 
3591 3591
        // global Globals::$conf, $langs;
3592 3592
 
@@ -3617,8 +3617,8 @@  discard block
 block discarded – undo
3617 3617
 
3618 3618
         $img = img_picto($titlealt, 'search.png', $other, false, 1);
3619 3619
 
3620
-        $input = '<input type="image" class="liste_titre" name="button_search" src="' . $img . '" ';
3621
-        $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >';
3620
+        $input = '<input type="image" class="liste_titre" name="button_search" src="'.$img.'" ';
3621
+        $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
3622 3622
 
3623 3623
         return $input;
3624 3624
     }
@@ -3639,8 +3639,8 @@  discard block
 block discarded – undo
3639 3639
 
3640 3640
         $img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
3641 3641
 
3642
-        $input = '<input type="image" class="liste_titre" name="button_removefilter" src="' . $img . '" ';
3643
-        $input .= 'value="' . dol_escape_htmltag($titlealt) . '" title="' . dol_escape_htmltag($titlealt) . '" >';
3642
+        $input = '<input type="image" class="liste_titre" name="button_removefilter" src="'.$img.'" ';
3643
+        $input .= 'value="'.dol_escape_htmltag($titlealt).'" title="'.dol_escape_htmltag($titlealt).'" >';
3644 3644
 
3645 3645
         return $input;
3646 3646
     }
@@ -3660,10 +3660,10 @@  discard block
 block discarded – undo
3660 3660
        // global Globals::$conf, $langs;
3661 3661
 
3662 3662
         if ($infoonimgalt) {
3663
-            return img_picto($text, 'info', 'class="hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '"');
3663
+            return img_picto($text, 'info', 'class="hideonsmartphone'.($morecss ? ' '.$morecss : '').'"');
3664 3664
         }
3665 3665
 
3666
-        return ($nodiv ? '' : '<div class="' . (empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)) . ' hideonsmartphone' . ($morecss ? ' ' . $morecss : '') . '">') . '<span class="fa fa-info-circle" title="' . dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')) . '"></span> ' . $text . ($nodiv ? '' : '</div>');
3666
+        return ($nodiv ? '' : '<div class="'.(empty($admin) ? '' : ($admin == '1' ? 'info' : $admin)).' hideonsmartphone'.($morecss ? ' '.$morecss : '').'">').'<span class="fa fa-info-circle" title="'.dol_escape_htmltag($admin ? $langs->trans('InfoAdmin') : $langs->trans('Note')).'"></span> '.$text.($nodiv ? '' : '</div>');
3667 3667
     }
3668 3668
 
3669 3669
     /**
@@ -3688,7 +3688,7 @@  discard block
 block discarded – undo
3688 3688
 
3689 3689
 // Si erreur intervenue avant chargement langue
3690 3690
         if (!$langs) {
3691
-            require_once DOL_BASE_PATH . '/core/class/translate.class.php';
3691
+            require_once DOL_BASE_PATH.'/core/class/translate.class.php';
3692 3692
             $langs = new Translate('', Globals::$conf);
3693 3693
             $langs->load("main");
3694 3694
         }
@@ -3696,51 +3696,51 @@  discard block
 block discarded – undo
3696 3696
         $langs->loadLangs(array('main', 'errors'));
3697 3697
 
3698 3698
         if ($_SERVER['DOCUMENT_ROOT']) {    // Mode web
3699
-            $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
3699
+            $out .= $langs->trans("DolibarrHasDetectedError").".<br>\n";
3700 3700
             if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL))
3701 3701
                 $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3702
-            $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
3702
+            $out .= $langs->trans("InformationToHelpDiagnose").":<br>\n";
3703 3703
 
3704
-            $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
3705
-            $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
3704
+            $out .= "<b>".$langs->trans("Date").":</b> ".dol_print_date(time(), 'dayhourlog')."<br>\n";
3705
+            $out .= "<b>".$langs->trans("Dolibarr").":</b> ".DOL_VERSION."<br>\n";
3706 3706
             if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL))
3707
-                $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3707
+                $out .= "<b>".$langs->trans("LevelOfFeature").":</b> ".Globals::$conf->global->MAIN_FEATURES_LEVEL."<br>\n";
3708 3708
             if (function_exists("phpversion")) {
3709
-                $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
3709
+                $out .= "<b>".$langs->trans("PHP").":</b> ".phpversion()."<br>\n";
3710 3710
             }
3711
-            $out .= "<b>" . $langs->trans("Server") . ":</b> " . $_SERVER["SERVER_SOFTWARE"] . "<br>\n";
3711
+            $out .= "<b>".$langs->trans("Server").":</b> ".$_SERVER["SERVER_SOFTWARE"]."<br>\n";
3712 3712
             if (function_exists("php_uname")) {
3713
-                $out .= "<b>" . $langs->trans("OS") . ":</b> " . php_uname() . "<br>\n";
3713
+                $out .= "<b>".$langs->trans("OS").":</b> ".php_uname()."<br>\n";
3714 3714
             }
3715
-            $out .= "<b>" . $langs->trans("UserAgent") . ":</b> " . $_SERVER["HTTP_USER_AGENT"] . "<br>\n";
3715
+            $out .= "<b>".$langs->trans("UserAgent").":</b> ".$_SERVER["HTTP_USER_AGENT"]."<br>\n";
3716 3716
             $out .= "<br>\n";
3717
-            $out .= "<b>" . $langs->trans("RequestedUrl") . ":</b> " . dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8') . "<br>\n";
3718
-            $out .= "<b>" . $langs->trans("Referer") . ":</b> " . (isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '') . "<br>\n";
3719
-            $out .= "<b>" . $langs->trans("MenuManager") . ":</b> " . (isset(Globals::$conf->standard_menu) ? Globals::$conf->standard_menu : '') . "<br>\n";
3717
+            $out .= "<b>".$langs->trans("RequestedUrl").":</b> ".dol_htmlentities($_SERVER["REQUEST_URI"], ENT_COMPAT, 'UTF-8')."<br>\n";
3718
+            $out .= "<b>".$langs->trans("Referer").":</b> ".(isset($_SERVER["HTTP_REFERER"]) ? dol_htmlentities($_SERVER["HTTP_REFERER"], ENT_COMPAT, 'UTF-8') : '')."<br>\n";
3719
+            $out .= "<b>".$langs->trans("MenuManager").":</b> ".(isset(Globals::$conf->standard_menu) ? Globals::$conf->standard_menu : '')."<br>\n";
3720 3720
             $out .= "<br>\n";
3721
-            $syslog .= "url=" . dol_escape_htmltag($_SERVER["REQUEST_URI"]);
3722
-            $syslog .= ", query_string=" . dol_escape_htmltag($_SERVER["QUERY_STRING"]);
3721
+            $syslog .= "url=".dol_escape_htmltag($_SERVER["REQUEST_URI"]);
3722
+            $syslog .= ", query_string=".dol_escape_htmltag($_SERVER["QUERY_STRING"]);
3723 3723
         } else {                              // Mode CLI
3724
-            $out .= '> ' . $langs->transnoentities("ErrorInternalErrorDetected") . ":\n" . $argv[0] . "\n";
3725
-            $syslog .= "pid=" . dol_getmypid();
3724
+            $out .= '> '.$langs->transnoentities("ErrorInternalErrorDetected").":\n".$argv[0]."\n";
3725
+            $syslog .= "pid=".dol_getmypid();
3726 3726
         }
3727 3727
 
3728 3728
         if (is_object($db)) {
3729 3729
             if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3730
-                $out .= "<b>" . $langs->trans("DatabaseTypeManager") . ":</b> " . $db->type . "<br>\n";
3731
-                $out .= "<b>" . $langs->trans("RequestLastAccessInError") . ":</b> " . ($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3732
-                $out .= "<b>" . $langs->trans("ReturnCodeLastAccessInError") . ":</b> " . ($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3733
-                $out .= "<b>" . $langs->trans("InformationLastAccessInError") . ":</b> " . ($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError")) . "<br>\n";
3730
+                $out .= "<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n";
3731
+                $out .= "<b>".$langs->trans("RequestLastAccessInError").":</b> ".($db->lastqueryerror() ? dol_escape_htmltag($db->lastqueryerror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3732
+                $out .= "<b>".$langs->trans("ReturnCodeLastAccessInError").":</b> ".($db->lasterrno() ? dol_escape_htmltag($db->lasterrno()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3733
+                $out .= "<b>".$langs->trans("InformationLastAccessInError").":</b> ".($db->lasterror() ? dol_escape_htmltag($db->lasterror()) : $langs->trans("ErrorNoRequestInError"))."<br>\n";
3734 3734
                 $out .= "<br>\n";
3735 3735
             } else {                            // Mode CLI
3736 3736
 // No dol_escape_htmltag for output, we are in CLI mode
3737
-                $out .= '> ' . $langs->transnoentities("DatabaseTypeManager") . ":\n" . $db->type . "\n";
3738
-                $out .= '> ' . $langs->transnoentities("RequestLastAccessInError") . ":\n" . ($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3739
-                $out .= '> ' . $langs->transnoentities("ReturnCodeLastAccessInError") . ":\n" . ($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3740
-                $out .= '> ' . $langs->transnoentities("InformationLastAccessInError") . ":\n" . ($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError")) . "\n";
3737
+                $out .= '> '.$langs->transnoentities("DatabaseTypeManager").":\n".$db->type."\n";
3738
+                $out .= '> '.$langs->transnoentities("RequestLastAccessInError").":\n".($db->lastqueryerror() ? $db->lastqueryerror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3739
+                $out .= '> '.$langs->transnoentities("ReturnCodeLastAccessInError").":\n".($db->lasterrno() ? $db->lasterrno() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3740
+                $out .= '> '.$langs->transnoentities("InformationLastAccessInError").":\n".($db->lasterror() ? $db->lasterror() : $langs->transnoentities("ErrorNoRequestInError"))."\n";
3741 3741
             }
3742
-            $syslog .= ", sql=" . $db->lastquery();
3743
-            $syslog .= ", db_error=" . $db->lasterror();
3742
+            $syslog .= ", sql=".$db->lastquery();
3743
+            $syslog .= ", db_error=".$db->lasterror();
3744 3744
         }
3745 3745
 
3746 3746
         if ($error || $errors) {
@@ -3760,31 +3760,31 @@  discard block
 block discarded – undo
3760 3760
                 if (empty($msg))
3761 3761
                     continue;
3762 3762
                 if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3763
-                    $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
3763
+                    $out .= "<b>".$langs->trans("Message").":</b> ".dol_escape_htmltag($msg)."<br>\n";
3764 3764
                 } else {                        // Mode CLI
3765
-                    $out .= '> ' . $langs->transnoentities("Message") . ":\n" . $msg . "\n";
3765
+                    $out .= '> '.$langs->transnoentities("Message").":\n".$msg."\n";
3766 3766
                 }
3767
-                $syslog .= ", msg=" . $msg;
3767
+                $syslog .= ", msg=".$msg;
3768 3768
             }
3769 3769
         }
3770 3770
         if (empty($dolibarr_main_prod) && $_SERVER['DOCUMENT_ROOT'] && function_exists('xdebug_print_function_stack') && function_exists('xdebug_call_file')) {
3771 3771
             xdebug_print_function_stack();
3772
-            $out .= '<b>XDebug informations:</b>' . "<br>\n";
3773
-            $out .= 'File: ' . xdebug_call_file() . "<br>\n";
3774
-            $out .= 'Line: ' . xdebug_call_line() . "<br>\n";
3775
-            $out .= 'Function: ' . xdebug_call_function() . "<br>\n";
3772
+            $out .= '<b>XDebug informations:</b>'."<br>\n";
3773
+            $out .= 'File: '.xdebug_call_file()."<br>\n";
3774
+            $out .= 'Line: '.xdebug_call_line()."<br>\n";
3775
+            $out .= 'Function: '.xdebug_call_function()."<br>\n";
3776 3776
             $out .= "<br>\n";
3777 3777
         }
3778 3778
 
3779 3779
         if (empty($dolibarr_main_prod))
3780 3780
             print $out;
3781 3781
         else {
3782
-            print $langs->trans("DolibarrHasDetectedError") . '. ';
3782
+            print $langs->trans("DolibarrHasDetectedError").'. ';
3783 3783
             print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
3784 3784
             define("MAIN_CORE_ERROR", 1);
3785 3785
         }
3786 3786
 //else print 'Sorry, an error occured but the parameter $dolibarr_main_prod is defined in conf file so no message is reported to your browser. Please read the log file for error message.';
3787
-        dol_syslog("Error " . $syslog, LOG_ERR);
3787
+        dol_syslog("Error ".$syslog, LOG_ERR);
3788 3788
     }
3789 3789
 
3790 3790
     /**
@@ -3807,13 +3807,13 @@  discard block
 block discarded – undo
3807 3807
         $langs->load("errors");
3808 3808
         $now = dol_now();
3809 3809
 
3810
-        print '<br><div class="center login_main_message"><div class="' . $morecss . '">';
3811
-        print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
3810
+        print '<br><div class="center login_main_message"><div class="'.$morecss.'">';
3811
+        print $langs->trans("ErrorContactEMail", $email, $prefixcode.dol_print_date($now, '%Y%m%d'));
3812 3812
         if ($errormessage)
3813
-            print '<br><br>' . $errormessage;
3813
+            print '<br><br>'.$errormessage;
3814 3814
         if (is_array($errormessages) && count($errormessages)) {
3815 3815
             foreach ($errormessages as $mesgtoshow) {
3816
-                print '<br><br>' . $mesgtoshow;
3816
+                print '<br><br>'.$mesgtoshow;
3817 3817
             }
3818 3818
         }
3819 3819
         print '</div></div>';
@@ -3871,16 +3871,16 @@  discard block
 block discarded – undo
3871 3871
         }
3872 3872
 
3873 3873
         $tmpsortfield = explode(',', $sortfield);
3874
-        $sortfield1 = trim($tmpsortfield[0]);    // If $sortfield is 'd.datep,d.id', it becomes 'd.datep'
3874
+        $sortfield1 = trim($tmpsortfield[0]); // If $sortfield is 'd.datep,d.id', it becomes 'd.datep'
3875 3875
         $tmpfield = explode(',', $field);
3876
-        $field1 = trim($tmpfield[0]);            // If $field is 'd.datep,d.id', it becomes 'd.datep'
3876
+        $field1 = trim($tmpfield[0]); // If $field is 'd.datep,d.id', it becomes 'd.datep'
3877 3877
 //var_dump('field='.$field.' field1='.$field1.' sortfield='.$sortfield.' sortfield1='.$sortfield1);
3878 3878
 // If field is used as sort criteria we use a specific css class liste_titre_sel
3879 3879
 // Example if (sortfield,field)=("nom","xxx.nom") or (sortfield,field)=("nom","nom")
3880 3880
         if ($field1 && ($sortfield1 == $field1 || $sortfield1 == preg_replace("/^[^\.]+\./", "", $field1))) {
3881
-            $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre_sel" ' . $moreattrib . '>';
3881
+            $out .= '<'.$tag.' class="'.$prefix.'liste_titre_sel" '.$moreattrib.'>';
3882 3882
         } else {
3883
-            $out .= '<' . $tag . ' class="' . $prefix . 'liste_titre" ' . $moreattrib . '>';
3883
+            $out .= '<'.$tag.' class="'.$prefix.'liste_titre" '.$moreattrib.'>';
3884 3884
         }
3885 3885
 
3886 3886
         if (empty($thead) && $field && empty($disablesortlink)) {    // If this is a sort field
@@ -3888,7 +3888,7 @@  discard block
 block discarded – undo
3888 3888
             $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
3889 3889
             $options = preg_replace('/&+/i', '&', $options);
3890 3890
             if (!preg_match('/^&/', $options)) {
3891
-                $options = '&' . $options;
3891
+                $options = '&'.$options;
3892 3892
             }
3893 3893
 
3894 3894
             $sortordertouseinlink = '';
@@ -3906,7 +3906,7 @@  discard block
 block discarded – undo
3906 3906
                 }
3907 3907
             }
3908 3908
             $sortordertouseinlink = preg_replace('/,$/', '', $sortordertouseinlink);
3909
-            $out .= '<a class="reposition" href="' . $file . '?sortfield=' . $field . '&sortorder=' . $sortordertouseinlink . '&begin=' . $begin . $options . '">';
3909
+            $out .= '<a class="reposition" href="'.$file.'?sortfield='.$field.'&sortorder='.$sortordertouseinlink.'&begin='.$begin.$options.'">';
3910 3910
         }
3911 3911
 
3912 3912
         if ($tooltip) {
@@ -3924,7 +3924,7 @@  discard block
 block discarded – undo
3924 3924
             $options = preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i', '', $options);
3925 3925
             $options = preg_replace('/&+/i', '&', $options);
3926 3926
             if (!preg_match('/^&/', $options)) {
3927
-                $options = '&' . $options;
3927
+                $options = '&'.$options;
3928 3928
             }
3929 3929
 
3930 3930
             if (!$sortorder || $field1 != $sortfield1) {
@@ -3934,19 +3934,19 @@  discard block
 block discarded – undo
3934 3934
                 if (preg_match('/^DESC/', $sortorder)) {
3935 3935
                     //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>';
3936 3936
                     //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>';
3937
-                    $sortimg .= '<span class="nowrap">' . img_up("Z-A", 0) . '</span>';
3937
+                    $sortimg .= '<span class="nowrap">'.img_up("Z-A", 0).'</span>';
3938 3938
                 }
3939 3939
                 if (preg_match('/^ASC/', $sortorder)) {
3940 3940
                     //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>';
3941 3941
                     //$out.= '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>';
3942
-                    $sortimg .= '<span class="nowrap">' . img_down("A-Z", 0) . '</span>';
3942
+                    $sortimg .= '<span class="nowrap">'.img_down("A-Z", 0).'</span>';
3943 3943
                 }
3944 3944
             }
3945 3945
         }
3946 3946
 
3947 3947
         $out .= $sortimg;
3948 3948
 
3949
-        $out .= '</' . $tag . '>';
3949
+        $out .= '</'.$tag.'>';
3950 3950
 
3951 3951
         return $out;
3952 3952
     }
@@ -3961,9 +3961,9 @@  discard block
 block discarded – undo
3961 3961
      */
3962 3962
     static function print_titre($title)
3963 3963
     {
3964
-        dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
3964
+        dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
3965 3965
 
3966
-        print '<div class="titre">' . $title . '</div>';
3966
+        print '<div class="titre">'.$title.'</div>';
3967 3967
     }
3968 3968
 
3969 3969
     /**
@@ -4006,20 +4006,20 @@  discard block
 block discarded – undo
4006 4006
         }
4007 4007
 
4008 4008
         $return .= "\n";
4009
-        $return .= '<table ' . ($id ? 'id="' . $id . '" ' : '') . 'summary="" class="centpercent notopnoleftnoright' . ($morecssontable ? ' ' . $morecssontable : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list
4009
+        $return .= '<table '.($id ? 'id="'.$id.'" ' : '').'summary="" class="centpercent notopnoleftnoright'.($morecssontable ? ' '.$morecssontable : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into print_barre_list
4010 4010
         if ($picto) {
4011
-            $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">' . img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath) . '</td>';
4011
+            $return .= '<td class="nobordernopadding widthpictotitle opacityhigh" valign="middle">'.img_picto('', $picto, 'class="valignmiddle widthpictotitle pictotitle"', $pictoisfullpath).'</td>';
4012 4012
         }
4013 4013
         $return .= '<td class="nobordernopadding valignmiddle">';
4014
-        $return .= '<div class="titre inline-block">' . $titre . '</div>';
4014
+        $return .= '<div class="titre inline-block">'.$titre.'</div>';
4015 4015
         $return .= '</td>';
4016 4016
         if (dol_strlen($morehtmlcenter)) {
4017
-            $return .= '<td class="nobordernopadding" align="center" valign="middle">' . $morehtmlcenter . '</td>';
4017
+            $return .= '<td class="nobordernopadding" align="center" valign="middle">'.$morehtmlcenter.'</td>';
4018 4018
         }
4019 4019
         if (dol_strlen($morehtmlright)) {
4020
-            $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">' . $morehtmlright . '</td>';
4020
+            $return .= '<td class="nobordernopadding titre_right wordbreak" align="right" valign="middle">'.$morehtmlright.'</td>';
4021 4021
         }
4022
-        $return .= '</tr></table>' . "\n";
4022
+        $return .= '</tr></table>'."\n";
4023 4023
 
4024 4024
         return $return;
4025 4025
     }
@@ -4067,29 +4067,29 @@  discard block
 block discarded – undo
4067 4067
 //print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage;
4068 4068
 
4069 4069
         print "\n";
4070
-        print "<!-- Begin title '" . $titre . "' -->\n";
4071
-        print '<table border="0" class="centpercent notopnoleftnoright' . ($morecss ? ' ' . $morecss : '') . '" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire
4070
+        print "<!-- Begin title '".$titre."' -->\n";
4071
+        print '<table border="0" class="centpercent notopnoleftnoright'.($morecss ? ' '.$morecss : '').'" style="margin-bottom: 6px;"><tr>'; // maring bottom must be same than into load_fiche_tire
4072 4072
 // Left
4073 4073
 //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
4074 4074
         print '<td class="nobordernopadding valignmiddle">';
4075 4075
         if ($picto && $titre)
4076 4076
             print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4077
-        print '<div class="titre inline-block">' . $titre;
4077
+        print '<div class="titre inline-block">'.$titre;
4078 4078
         if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '')
4079
-            print ' (' . $totalnboflines . ')';
4079
+            print ' ('.$totalnboflines.')';
4080 4080
         print '</div></td>';
4081 4081
 
4082 4082
 // Center
4083 4083
         if ($morehtmlcenter) {
4084
-            print '<td class="nobordernopadding center valignmiddle">' . $morehtmlcenter . '</td>';
4084
+            print '<td class="nobordernopadding center valignmiddle">'.$morehtmlcenter.'</td>';
4085 4085
         }
4086 4086
 
4087 4087
 // Right
4088 4088
         print '<td class="nobordernopadding valignmiddle" align="right">';
4089 4089
         if ($sortfield)
4090
-            $options .= "&sortfield=" . urlencode($sortfield);
4090
+            $options .= "&sortfield=".urlencode($sortfield);
4091 4091
         if ($sortorder)
4092
-            $options .= "&sortorder=" . urlencode($sortorder);
4092
+            $options .= "&sortorder=".urlencode($sortorder);
4093 4093
 // Show navigation bar
4094 4094
         $pagelist = '';
4095 4095
         if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
@@ -4107,40 +4107,40 @@  discard block
 block discarded – undo
4107 4107
                 }
4108 4108
 
4109 4109
                 if ($cpt >= 1) {
4110
-                    $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>';
4110
+                    $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=0'.$options.'">1</a></li>';
4111 4111
                     if ($cpt > 2)
4112
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4112
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>';
4113 4113
                     else if ($cpt == 2)
4114
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4114
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page=1'.$options.'">2</a></li>';
4115 4115
                 }
4116 4116
 
4117 4117
                 do {
4118 4118
                     if ($cpt == $page) {
4119
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . '</span></li>';
4119
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1).'</span></li>';
4120 4120
                     } else {
4121
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . $cpt . $options . '">' . ($cpt + 1) . '</a></li>';
4121
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.$cpt.$options.'">'.($cpt + 1).'</a></li>';
4122 4122
                     }
4123 4123
                     $cpt++;
4124 4124
                 } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage);
4125 4125
 
4126 4126
                 if ($cpt < $nbpages) {
4127 4127
                     if ($cpt < $nbpages - 2)
4128
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4128
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '').'>...</span></li>';
4129 4129
                     else if ($cpt == $nbpages - 2)
4130
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4131
-                    $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>';
4130
+                        $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 2).$options.'">'.($nbpages - 1).'</a></li>';
4131
+                    $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><a href="'.$file.'?page='.($nbpages - 1).$options.'">'.$nbpages.'</a></li>';
4132 4132
                 }
4133 4133
             }
4134 4134
             else {
4135
-                $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>";
4135
+                $pagelist .= '<li'.((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '').'><span '.((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '').'>'.($page + 1)."</li>";
4136 4136
             }
4137 4137
         }
4138 4138
 
4139
-        print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit);  // output the div and ul for previous/last completed with page numbers into $pagelist
4139
+        print_fleche_navigation($page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit); // output the div and ul for previous/last completed with page numbers into $pagelist
4140 4140
 
4141 4141
         print '</td>';
4142 4142
 
4143
-        print '</tr></table>' . "\n";
4143
+        print '</tr></table>'."\n";
4144 4144
         print "<!-- End title -->\n\n";
4145 4145
     }
4146 4146
 
@@ -4171,12 +4171,12 @@  discard block
 block discarded – undo
4171 4171
                 $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES;
4172 4172
 
4173 4173
             print '<li class="pagination">';
4174
-            print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
4174
+            print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")).'">';
4175 4175
             $tmpchoice = explode(',', $pagesizechoices);
4176
-            $tmpkey = $limit . ':' . $limit;
4176
+            $tmpkey = $limit.':'.$limit;
4177 4177
             if (!in_array($tmpkey, $tmpchoice))
4178 4178
                 $tmpchoice[] = $tmpkey;
4179
-            $tmpkey = Globals::$conf->liste_limit . ':' . Globals::$conf->liste_limit;
4179
+            $tmpkey = Globals::$conf->liste_limit.':'.Globals::$conf->liste_limit;
4180 4180
             if (!in_array($tmpkey, $tmpchoice))
4181 4181
                 $tmpchoice[] = $tmpkey;
4182 4182
             asort($tmpchoice, SORT_NUMERIC);
@@ -4191,7 +4191,7 @@  discard block
 block discarded – undo
4191 4191
                         $selected = ' selected="selected"';
4192 4192
                         $found = true;
4193 4193
                     }
4194
-                    print '<option name="' . $key . '"' . $selected . '>' . dol_escape_htmltag($val) . '</option>' . "\n";
4194
+                    print '<option name="'.$key.'"'.$selected.'>'.dol_escape_htmltag($val).'</option>'."\n";
4195 4195
                 }
4196 4196
             }
4197 4197
             print '</select>';
@@ -4210,20 +4210,20 @@  discard block
 block discarded – undo
4210 4210
             print '</li>';
4211 4211
         }
4212 4212
         if ($page > 0) {
4213
-            print '<li class="pagination"><a class="paginationprevious" href="' . $file . '?page=' . ($page - 1) . $options . '"><i class="fa fa-chevron-left" title="' . dol_escape_htmltag($langs->trans("Previous")) . '"></i></a></li>';
4213
+            print '<li class="pagination"><a class="paginationprevious" href="'.$file.'?page='.($page - 1).$options.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
4214 4214
         }
4215 4215
         if ($betweenarrows) {
4216 4216
             print $betweenarrows;
4217 4217
         }
4218 4218
         if ($nextpage > 0) {
4219
-            print '<li class="pagination"><a class="paginationnext" href="' . $file . '?page=' . ($page + 1) . $options . '"><i class="fa fa-chevron-right" title="' . dol_escape_htmltag($langs->trans("Next")) . '"></i></a></li>';
4219
+            print '<li class="pagination"><a class="paginationnext" href="'.$file.'?page='.($page + 1).$options.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
4220 4220
         }
4221 4221
         if ($afterarrows) {
4222 4222
             print '<li class="paginationafterarrows">';
4223 4223
             print $afterarrows;
4224 4224
             print '</li>';
4225 4225
         }
4226
-        print '</ul></div>' . "\n";
4226
+        print '</ul></div>'."\n";
4227 4227
     }
4228 4228
 
4229 4229
     /**
@@ -4245,8 +4245,8 @@  discard block
 block discarded – undo
4245 4245
             $addpercent = true;
4246 4246
         }
4247 4247
         if (preg_match('/\((.*)\)/', $rate, $reg)) {
4248
-            $morelabel = ' (' . $reg[1] . ')';
4249
-            $rate = preg_replace('/\s*' . preg_quote($morelabel, '/') . '/', '', $rate);
4248
+            $morelabel = ' ('.$reg[1].')';
4249
+            $rate = preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate);
4250 4250
         }
4251 4251
         if (preg_match('/\*/', $rate)) {
4252 4252
             $rate = str_replace('*', '', $rate);
@@ -4255,10 +4255,10 @@  discard block
 block discarded – undo
4255 4255
 
4256 4256
 // If rate is '9/9/9' we don't change it.  If rate is '9.000' we apply price()
4257 4257
         if (!preg_match('/\//', $rate))
4258
-            $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4258
+            $ret = price($rate, 0, '', 0, 0).($addpercent ? '%' : '');
4259 4259
         else {
4260 4260
 // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
4261
-            $ret = $rate . ($addpercent ? '%' : '');
4261
+            $ret = $rate.($addpercent ? '%' : '');
4262 4262
         }
4263 4263
         if (($info_bits & 1) && $usestarfornpr >= 0)
4264 4264
             $ret .= ' *';
@@ -4351,10 +4351,10 @@  discard block
 block discarded – undo
4351 4351
                 $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4352 4352
             else {
4353 4353
                 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4354
-                $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
4354
+                $cursymbolafter .= ($tmpcur == $currency_code ? ' '.$tmpcur : $tmpcur);
4355 4355
             }
4356 4356
         }
4357
-        $output = $cursymbolbefore . $output . $end . ($cursymbolafter ? ' ' : '') . $cursymbolafter;
4357
+        $output = $cursymbolbefore.$output.$end.($cursymbolafter ? ' ' : '').$cursymbolafter;
4358 4358
 
4359 4359
         return $output;
4360 4360
     }
@@ -4407,7 +4407,7 @@  discard block
 block discarded – undo
4407 4407
 // Now make replace (the main goal of function)
4408 4408
             if ($thousand != ',' && $thousand != '.')
4409 4409
                 $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4410
-            $amount = str_replace(' ', '', $amount);  // To avoid spaces
4410
+            $amount = str_replace(' ', '', $amount); // To avoid spaces
4411 4411
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4412 4412
             $amount = str_replace($dec, '.', $amount);
4413 4413
         }
@@ -4436,14 +4436,14 @@  discard block
 block discarded – undo
4436 4436
                 $temps = sprintf("%0.10F", $amount - intval($amount)); // temps=0.0000000000 or 0.0000200000 or 9999.1000000000
4437 4437
                 $temps = preg_replace('/([\.1-9])0+$/', '\\1', $temps); // temps=0. or 0.00002 or 9999.1
4438 4438
                 $nbofdec = max(0, dol_strlen($temps) - 2); // -2 to remove "0."
4439
-                $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand);  // Convert amount to format with dolibarr dec and thousand
4439
+                $amount = number_format($amount, min($nbofdec, $nbofdectoround), $dec, $thousand); // Convert amount to format with dolibarr dec and thousand
4440 4440
             }
4441 4441
 //print "TT".$amount.'<br>';
4442 4442
 // Always make replace because each math static function (like round) replace
4443 4443
 // with local values and we want a number that has a SQL string format x.y
4444 4444
             if ($thousand != ',' && $thousand != '.')
4445 4445
                 $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4446
-            $amount = str_replace(' ', '', $amount);  // To avoid spaces
4446
+            $amount = str_replace(' ', '', $amount); // To avoid spaces
4447 4447
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4448 4448
             $amount = str_replace($dec, '.', $amount);
4449 4449
         }
@@ -4464,7 +4464,7 @@  discard block
 block discarded – undo
4464 4464
      */
4465 4465
     static function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round = -1, $forceunitoutput = 'no')
4466 4466
     {
4467
-        require_once DOL_BASE_PATH . '/core/lib/product.lib.php';
4467
+        require_once DOL_BASE_PATH.'/core/lib/product.lib.php';
4468 4468
 
4469 4469
         if (($forceunitoutput == 'no' && $dimension < 1 / 10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6)) {
4470 4470
             $dimension = $dimension * 1000000;
@@ -4480,7 +4480,7 @@  discard block
 block discarded – undo
4480 4480
             $unit = $unit + 3;
4481 4481
         }
4482 4482
 
4483
-        $ret = price($dimension, 0, $outputlangs, 0, 0, $round) . ' ' . measuring_units_string($unit, $type);
4483
+        $ret = price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
4484 4484
 
4485 4485
         return $ret;
4486 4486
     }
@@ -4504,7 +4504,7 @@  discard block
 block discarded – undo
4504 4504
         if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4505 4505
             $thirdparty_seller = $mysoc;
4506 4506
 
4507
-        dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . "  thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj);
4507
+        dol_syslog("get_localtax tva=".$vatrate." local=".$local." thirdparty_buyer id=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '')."/country_code=".(is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '')." thirdparty_seller id=".$thirdparty_seller->id."/country_code=".$thirdparty_seller->country_code." thirdparty_seller localtax1_assuj=".$thirdparty_seller->localtax1_assuj."  thirdparty_seller localtax2_assuj=".$thirdparty_seller->localtax2_assuj);
4508 4508
 
4509 4509
         $vatratecleaned = $vatrate;
4510 4510
         if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
@@ -4535,7 +4535,7 @@  discard block
 block discarded – undo
4535 4535
             if ($local == 2) {
4536 4536
 //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0;
4537 4537
                 if (!$mysoc->localtax2_assuj)
4538
-                    return 0;  // If main vat is 0, IRPF may be different than 0.
4538
+                    return 0; // If main vat is 0, IRPF may be different than 0.
4539 4539
                 if ($thirdparty_seller->id == $mysoc->id) {
4540 4540
                     if (!$thirdparty_buyer->localtax2_assuj)
4541 4541
                         return 0;
@@ -4589,13 +4589,13 @@  discard block
 block discarded – undo
4589 4589
 
4590 4590
 // By default, search value of local tax on line of common tax
4591 4591
         $sql = "SELECT t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
4592
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4593
-        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'";
4594
-        $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4592
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4593
+        $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$thirdparty_seller->country_code."'";
4594
+        $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4595 4595
         if ($vatratecode)
4596
-            $sql .= " AND t.code ='" . $vatratecode . "'";  // If we have the code, we use it in priority
4596
+            $sql .= " AND t.code ='".$vatratecode."'"; // If we have the code, we use it in priority
4597 4597
         else
4598
-            $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4598
+            $sql .= " AND t.recuperableonly ='".$vatnpr."'";
4599 4599
         dol_syslog("get_localtax", LOG_DEBUG);
4600 4600
         $resql = $db->query($sql);
4601 4601
 
@@ -4641,10 +4641,10 @@  discard block
 block discarded – undo
4641 4641
     {
4642 4642
        // global $db, $mysoc;
4643 4643
         $sql = "SELECT t.localtax1, t.localtax2 ";
4644
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=t.fk_pays";
4645
-        $sql .= " WHERE c.code = '" . $mysoc->country_code . "' AND t.active = 1 AND t.taux=(";
4646
-        $sql .= "  SELECT max(tt.taux) FROM " . MAIN_DB_PREFIX . "c_tva as tt inner join " . MAIN_DB_PREFIX . "c_country as c ON c.rowid=tt.fk_pays";
4647
-        $sql .= "  WHERE c.code = '" . $mysoc->country_code . "' AND tt.active = 1";
4644
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays";
4645
+        $sql .= " WHERE c.code = '".$mysoc->country_code."' AND t.active = 1 AND t.taux=(";
4646
+        $sql .= "  SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays";
4647
+        $sql .= "  WHERE c.code = '".$mysoc->country_code."' AND tt.active = 1";
4648 4648
         $sql .= "  )";
4649 4649
 
4650 4650
         $resql = $db->query($sql);
@@ -4674,13 +4674,13 @@  discard block
 block discarded – undo
4674 4674
     {
4675 4675
        // global $db, $mysoc;
4676 4676
 
4677
-        dol_syslog("getTaxesFromId vat id or rate = " . $vatrate);
4677
+        dol_syslog("getTaxesFromId vat id or rate = ".$vatrate);
4678 4678
 
4679 4679
 // Search local taxes
4680 4680
         $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
4681
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4681
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
4682 4682
         if ($firstparamisid)
4683
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4683
+            $sql .= " WHERE t.rowid = ".(int) $vatrate;
4684 4684
         else {
4685 4685
             $vatratecleaned = $vatrate;
4686 4686
             $vatratecode = '';
@@ -4689,13 +4689,13 @@  discard block
 block discarded – undo
4689 4689
                 $vatratecode = $reg[2];
4690 4690
             }
4691 4691
 
4692
-            $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4692
+            $sql .= ", ".MAIN_DB_PREFIX."c_country as c";
4693 4693
             /* if ($mysoc->country_code == 'ES') $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'";    // vat in spain use the buyer country ??
4694 4694
               else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */
4695
-            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4696
-            $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4695
+            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
4696
+            $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4697 4697
             if ($vatratecode)
4698
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4698
+                $sql .= " AND t.code = '".$vatratecode."'";
4699 4699
         }
4700 4700
 
4701 4701
         $resql = $db->query($sql);
@@ -4731,13 +4731,13 @@  discard block
 block discarded – undo
4731 4731
     {
4732 4732
        // global $db, $mysoc;
4733 4733
 
4734
-        dol_syslog("getLocalTaxesFromRate vatrate=" . $vatrate . " local=" . $local);
4734
+        dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local);
4735 4735
 
4736 4736
 // Search local taxes
4737 4737
         $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
4738
-        $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4738
+        $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
4739 4739
         if ($firstparamisid)
4740
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4740
+            $sql .= " WHERE t.rowid = ".(int) $vatrate;
4741 4741
         else {
4742 4742
             $vatratecleaned = $vatrate;
4743 4743
             $vatratecode = '';
@@ -4746,14 +4746,14 @@  discard block
 block discarded – undo
4746 4746
                 $vatratecode = $reg[2];
4747 4747
             }
4748 4748
 
4749
-            $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4749
+            $sql .= ", ".MAIN_DB_PREFIX."c_country as c";
4750 4750
             if ($mysoc->country_code == 'ES')
4751
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";    // local tax in spain use the buyer country ??
4751
+                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$buyer->country_code."'"; // local tax in spain use the buyer country ??
4752 4752
             else
4753
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4754
-            $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4753
+                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'";
4754
+            $sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
4755 4755
             if ($vatratecode)
4756
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4756
+                $sql .= " AND t.code = '".$vatratecode."'";
4757 4757
         }
4758 4758
 
4759 4759
         $resql = $db->query($sql);
@@ -4785,7 +4785,7 @@  discard block
 block discarded – undo
4785 4785
     {
4786 4786
        // global $db, Globals::$conf, $mysoc;
4787 4787
 
4788
-        require_once DOL_BASE_PATH . '/product/class/product.class.php';
4788
+        require_once DOL_BASE_PATH.'/product/class/product.class.php';
4789 4789
 
4790 4790
         $ret = 0;
4791 4791
         $found = 0;
@@ -4800,12 +4800,12 @@  discard block
 block discarded – undo
4800 4800
                     $product->get_buyprice($idprodfournprice, 0, 0, 0);
4801 4801
                     $ret = $product->vatrate_supplier;
4802 4802
                     if ($product->default_vat_code)
4803
-                        $ret .= ' (' . $product->default_vat_code . ')';
4803
+                        $ret .= ' ('.$product->default_vat_code.')';
4804 4804
                 }
4805 4805
                 else {
4806
-                    $ret = $product->tva_tx;    // Default vat of product we defined
4806
+                    $ret = $product->tva_tx; // Default vat of product we defined
4807 4807
                     if ($product->default_vat_code)
4808
-                        $ret .= ' (' . $product->default_vat_code . ')';
4808
+                        $ret .= ' ('.$product->default_vat_code.')';
4809 4809
                 }
4810 4810
                 $found = 1;
4811 4811
             }
@@ -4819,8 +4819,8 @@  discard block
 block discarded – undo
4819 4819
             if (empty(Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS)) {
4820 4820
 // If vat of product for the country not found or not defined, we return the first higher vat of country.
4821 4821
                 $sql = "SELECT t.taux as vat_rate, t.code as default_vat_code";
4822
-                $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4823
-                $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'";
4822
+                $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4823
+                $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'";
4824 4824
                 $sql .= " ORDER BY t.taux DESC, t.code ASC, t.recuperableonly ASC";
4825 4825
                 $sql .= $db->plimit(1);
4826 4826
 
@@ -4830,16 +4830,16 @@  discard block
 block discarded – undo
4830 4830
                     if ($obj) {
4831 4831
                         $ret = $obj->vat_rate;
4832 4832
                         if ($obj->default_vat_code)
4833
-                            $ret .= ' (' . $obj->default_vat_code . ')';
4833
+                            $ret .= ' ('.$obj->default_vat_code.')';
4834 4834
                     }
4835 4835
                     $db->free($sql);
4836 4836
                 } else
4837 4837
                     dol_print_error($db);
4838 4838
             } else
4839
-                $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;    // Forced value if autodetect fails
4839
+                $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails
4840 4840
         }
4841 4841
 
4842
-        dol_syslog("get_product_vat_for_country: ret=" . $ret);
4842
+        dol_syslog("get_product_vat_for_country: ret=".$ret);
4843 4843
         return $ret;
4844 4844
     }
4845 4845
 
@@ -4857,7 +4857,7 @@  discard block
 block discarded – undo
4857 4857
        // global $db, $mysoc;
4858 4858
 
4859 4859
         if (!class_exists('Product')) {
4860
-            require_once DOL_BASE_PATH . 'product/class/product.class.php';
4860
+            require_once DOL_BASE_PATH.'product/class/product.class.php';
4861 4861
         }
4862 4862
 
4863 4863
         $ret = 0;
@@ -4882,8 +4882,8 @@  discard block
 block discarded – undo
4882 4882
         if (!$found) {
4883 4883
 // If vat of product for the country not found or not defined, we return higher vat of country.
4884 4884
             $sql = "SELECT taux as vat_rate, localtax1, localtax2";
4885
-            $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4886
-            $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='" . $thirdparty_seller->country_code . "'";
4885
+            $sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
4886
+            $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$thirdparty_seller->country_code."'";
4887 4887
             $sql .= " ORDER BY t.taux DESC, t.recuperableonly ASC";
4888 4888
             $sql .= $db->plimit(1);
4889 4889
 
@@ -4900,7 +4900,7 @@  discard block
 block discarded – undo
4900 4900
                 dol_print_error($db);
4901 4901
         }
4902 4902
 
4903
-        dol_syslog("get_product_localtax_for_country: ret=" . $ret);
4903
+        dol_syslog("get_product_localtax_for_country: ret=".$ret);
4904 4904
         return $ret;
4905 4905
     }
4906 4906
 
@@ -4924,7 +4924,7 @@  discard block
 block discarded – undo
4924 4924
     {
4925 4925
        // global Globals::$conf;
4926 4926
 
4927
-        require_once DOL_BASE_PATH . '/core/lib/company.lib.php';
4927
+        require_once DOL_BASE_PATH.'/core/lib/company.lib.php';
4928 4928
 
4929 4929
 // Note: possible values for tva_assuj are 0/1 or franchise/reel
4930 4930
         $seller_use_vat = ((is_numeric($thirdparty_seller->tva_assuj) && !$thirdparty_seller->tva_assuj) || (!is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj == 'franchise')) ? 0 : 1;
@@ -4935,7 +4935,7 @@  discard block
 block discarded – undo
4935 4935
         $buyer_country_code = $thirdparty_buyer->country_code;
4936 4936
         $buyer_in_cee = isInEEC($thirdparty_buyer);
4937 4937
 
4938
-        dol_syslog("get_default_tva: seller use vat=" . $seller_use_vat . ", seller country=" . $seller_country_code . ", seller in cee=" . $seller_in_cee . ", buyer vat number=" . $thirdparty_buyer->tva_intra . " buyer country=" . $buyer_country_code . ", buyer in cee=" . $buyer_in_cee . ", idprod=" . $idprod . ", idprodfournprice=" . $idprodfournprice . ", SERVICE_ARE_ECOMMERCE_200238EC=" . (!empty(Globals::$conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? Globals::$conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
4938
+        dol_syslog("get_default_tva: seller use vat=".$seller_use_vat.", seller country=".$seller_country_code.", seller in cee=".$seller_in_cee.", buyer vat number=".$thirdparty_buyer->tva_intra." buyer country=".$buyer_country_code.", buyer in cee=".$buyer_in_cee.", idprod=".$idprod.", idprodfournprice=".$idprodfournprice.", SERVICE_ARE_ECOMMERCE_200238EC=".(!empty(Globals::$conf->global->SERVICES_ARE_ECOMMERCE_200238EC) ? Globals::$conf->global->SERVICES_ARE_ECOMMERCE_200238EC : ''));
4939 4939
 
4940 4940
 // If services are eServices according to EU Council Directive 2002/38/EC (http://ec.europa.eu/taxation_customs/taxation/vat/traders/e-commerce/article_1610_en.htm)
4941 4941
 // we use the buyer VAT.
@@ -5001,14 +5001,14 @@  discard block
 block discarded – undo
5001 5001
 
5002 5002
         if ($idprodfournprice > 0) {
5003 5003
             if (!class_exists('ProductFournisseur'))
5004
-                require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5004
+                require_once DOL_BASE_PATH.'/fourn/class/fournisseur.product.class.php';
5005 5005
             $prodprice = new ProductFournisseur($db);
5006 5006
             $prodprice->fetch_product_fournisseur_price($idprodfournprice);
5007 5007
             return $prodprice->fourn_tva_npr;
5008 5008
         }
5009 5009
         elseif ($idprod > 0) {
5010 5010
             if (!class_exists('Product'))
5011
-                require_once DOL_BASE_PATH . 'product/class/product.class.php';
5011
+                require_once DOL_BASE_PATH.'product/class/product.class.php';
5012 5012
             $prod = new Product($db);
5013 5013
             $prod->fetch($idprod);
5014 5014
             return $prod->tva_npr;
@@ -5087,7 +5087,7 @@  discard block
 block discarded – undo
5087 5087
             if ($case == 2)
5088 5088
                 $result = '<input type="checkbox" value="1" checked disabled>';
5089 5089
             if ($case == 3)
5090
-                $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5090
+                $result = '<input type="checkbox" value="1" checked disabled> '.$result;
5091 5091
 
5092 5092
             $classname = 'ok';
5093 5093
         }
@@ -5098,7 +5098,7 @@  discard block
 block discarded – undo
5098 5098
             if ($case == 2)
5099 5099
                 $result = '<input type="checkbox" value="0" disabled>';
5100 5100
             if ($case == 3)
5101
-                $result = '<input type="checkbox" value="0" disabled> ' . $result;
5101
+                $result = '<input type="checkbox" value="0" disabled> '.$result;
5102 5102
 
5103 5103
             if ($color == 2)
5104 5104
                 $classname = 'ok';
@@ -5106,7 +5106,7 @@  discard block
 block discarded – undo
5106 5106
                 $classname = 'error';
5107 5107
         }
5108 5108
         if ($color)
5109
-            return '<font class="' . $classname . '">' . $result . '</font>';
5109
+            return '<font class="'.$classname.'">'.$result.'</font>';
5110 5110
         return $result;
5111 5111
     }
5112 5112
 
@@ -5140,13 +5140,13 @@  discard block
 block discarded – undo
5140 5140
                 $num = preg_replace('/([^0-9])/i', '', $num);
5141 5141
             else
5142 5142
                 $num = preg_replace('/^.*\-/i', '', $num);
5143
-            $num = substr("000" . $num, -$level);
5143
+            $num = substr("000".$num, -$level);
5144 5144
             if ($level == 1)
5145 5145
                 $path = substr($num, 0, 1);
5146 5146
             if ($level == 2)
5147
-                $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5147
+                $path = substr($num, 1, 1).'/'.substr($num, 0, 1);
5148 5148
             if ($level == 3)
5149
-                $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5149
+                $path = substr($num, 2, 1).'/'.substr($num, 1, 1).'/'.substr($num, 0, 1);
5150 5150
         }
5151 5151
         else {
5152 5152
 // TODO
@@ -5177,7 +5177,7 @@  discard block
 block discarded – undo
5177 5177
     {
5178 5178
        // global Globals::$conf;
5179 5179
 
5180
-        dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5180
+        dol_syslog("functions.lib::dol_mkdir: dir=".$dir, LOG_INFO);
5181 5181
 
5182 5182
         $dir_osencoded = dol_osencode($dir);
5183 5183
         if (@is_dir($dir_osencoded))
@@ -5189,15 +5189,15 @@  discard block
 block discarded – undo
5189 5189
         $ccdir = '';
5190 5190
         if (!empty($dataroot)) {
5191 5191
 // Remove data root from loop
5192
-            $dir = str_replace($dataroot . '/', '', $dir);
5193
-            $ccdir = $dataroot . '/';
5192
+            $dir = str_replace($dataroot.'/', '', $dir);
5193
+            $ccdir = $dataroot.'/';
5194 5194
         }
5195 5195
 
5196 5196
         $cdir = explode("/", $dir);
5197 5197
         $num = count($cdir);
5198 5198
         for ($i = 0; $i < $num; $i++) {
5199 5199
             if ($i > 0)
5200
-                $ccdir .= '/' . $cdir[$i];
5200
+                $ccdir .= '/'.$cdir[$i];
5201 5201
             else
5202 5202
                 $ccdir .= $cdir[$i];
5203 5203
             if (preg_match("/^.:$/", $ccdir, $regs))
@@ -5241,20 +5241,20 @@  discard block
 block discarded – undo
5241 5241
             if ($ccdir) {
5242 5242
                 $ccdir_osencoded = dol_osencode($ccdir);
5243 5243
                 if (!@is_dir($ccdir_osencoded)) {
5244
-                    dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
5244
+                    dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' does not exists or is outside open_basedir PHP setting.", LOG_DEBUG);
5245 5245
 
5246 5246
                     umask(0);
5247 5247
                     $dirmaskdec = octdec($newmask);
5248 5248
                     if (empty($newmask)) {
5249 5249
                         $dirmaskdec = empty(Globals::$conf->global->MAIN_UMASK) ? octdec('0755') : octdec(Globals::$conf->global->MAIN_UMASK);
5250 5250
                     }
5251
-                    $dirmaskdec |= octdec('0111');  // Set x bit required for directories
5251
+                    $dirmaskdec |= octdec('0111'); // Set x bit required for directories
5252 5252
                     if (!@mkdir($ccdir_osencoded, $dirmaskdec)) {
5253 5253
                         // Si le is_dir a renvoye une fausse info, alors on passe ici.
5254
-                        dol_syslog("functions.lib::dol_mkdir: Fails to create directory '" . $ccdir . "' or directory already exists.", LOG_WARNING);
5254
+                        dol_syslog("functions.lib::dol_mkdir: Fails to create directory '".$ccdir."' or directory already exists.", LOG_WARNING);
5255 5255
                         $nberr++;
5256 5256
                     } else {
5257
-                        dol_syslog("functions.lib::dol_mkdir: Directory '" . $ccdir . "' created", LOG_DEBUG);
5257
+                        dol_syslog("functions.lib::dol_mkdir: Directory '".$ccdir."' created", LOG_DEBUG);
5258 5258
                         $nberr = 0; // On remet a zero car si on arrive ici, cela veut dire que les echecs precedents peuvent etre ignore
5259 5259
                         $nbcreated++;
5260 5260
                     }
@@ -5302,9 +5302,9 @@  discard block
 block discarded – undo
5302 5302
         } else {
5303 5303
             $pattern = "/<[^<>]+>/";
5304 5304
 // Exemple of $temp: <a href="/myurl" title="<u>A title</u>">0000-021</a>
5305
-            $temp = preg_replace($pattern, "", $temp);    // pass 1
5305
+            $temp = preg_replace($pattern, "", $temp); // pass 1
5306 5306
 // $temp after pass 1: <a href="/myurl" title="A title">0000-021
5307
-            $temp = preg_replace($pattern, "", $temp);    // pass 2
5307
+            $temp = preg_replace($pattern, "", $temp); // pass 2
5308 5308
 // $temp after pass 2: 0000-021
5309 5309
         }
5310 5310
 
@@ -5360,8 +5360,8 @@  discard block
 block discarded – undo
5360 5360
     {
5361 5361
         $temp = $stringtoclean;
5362 5362
         foreach ($disallowed_tags as $tagtoremove) {
5363
-            $temp = preg_replace('/<\/?' . $tagtoremove . '>/', '', $temp);
5364
-            $temp = preg_replace('/<\/?' . $tagtoremove . '\s+[^>]*>/', '', $temp);
5363
+            $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp);
5364
+            $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp);
5365 5365
         }
5366 5366
         return $temp;
5367 5367
     }
@@ -5378,12 +5378,12 @@  discard block
 block discarded – undo
5378 5378
     {
5379 5379
         if ($nboflines == 1) {
5380 5380
             if (dol_textishtml($text)) {
5381
-                $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text);  // The s pattern modifier means the . can match newline characters
5381
+                $firstline = preg_replace('/<br[^>]*>.*$/s', '', $text); // The s pattern modifier means the . can match newline characters
5382 5382
                 $firstline = preg_replace('/<div[^>]*>.*$/s', '', $firstline); // The s pattern modifier means the . can match newline characters
5383 5383
             } else {
5384 5384
                 $firstline = preg_replace('/[\n\r].*/', '', $text);
5385 5385
             }
5386
-            return $firstline . ((strlen($firstline) != strlen($text)) ? '...' : '');
5386
+            return $firstline.((strlen($firstline) != strlen($text)) ? '...' : '');
5387 5387
         } else {
5388 5388
             $ishtml = 0;
5389 5389
             if (dol_textishtml($text)) {
@@ -5399,7 +5399,7 @@  discard block
 block discarded – undo
5399 5399
                 $pattern = '/(<br[^>]*>)/Uu';
5400 5400
             } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5401 5401
             else
5402
-                $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5402
+                $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
5403 5403
             $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5404 5404
 
5405 5405
             $firstline = '';
@@ -5413,7 +5413,7 @@  discard block
 block discarded – undo
5413 5413
                 $i++;
5414 5414
             }
5415 5415
             unset($a);
5416
-            return $firstline . (($i < $nba) ? '...' : '');
5416
+            return $firstline.(($i < $nba) ? '...' : '');
5417 5417
         }
5418 5418
     }
5419 5419
 
@@ -5484,9 +5484,9 @@  discard block
 block discarded – undo
5484 5484
     static function dol_htmlentitiesbr_decode($stringtodecode, $pagecodeto = 'UTF-8')
5485 5485
     {
5486 5486
         $ret = dol_html_entity_decode($stringtodecode, ENT_COMPAT, $pagecodeto);
5487
-        $ret = preg_replace('/' . "\r\n" . '<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
5488
-        $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\r\n" . '/i', "\r\n", $ret);
5489
-        $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>' . "\n" . '/i', "\n", $ret);
5487
+        $ret = preg_replace('/'."\r\n".'<br(\s[\sa-zA-Z_="]*)?\/?>/i', "<br>", $ret);
5488
+        $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\r\n".'/i', "\r\n", $ret);
5489
+        $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>'."\n".'/i', "\n", $ret);
5490 5490
         $ret = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', "\n", $ret);
5491 5491
         return $ret;
5492 5492
     }
@@ -5499,7 +5499,7 @@  discard block
 block discarded – undo
5499 5499
      */
5500 5500
     static function dol_htmlcleanlastbr($stringtodecode)
5501 5501
     {
5502
-        $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|' . "\n" . '|' . "\r" . ')+$/i', "", $stringtodecode);
5502
+        $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|'."\n".'|'."\r".')+$/i', "", $stringtodecode);
5503 5503
         return $ret;
5504 5504
     }
5505 5505
 
@@ -5596,7 +5596,7 @@  discard block
 block discarded – undo
5596 5596
             $pattern = '/(<br[^>]*>)/Uu';
5597 5597
         } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5598 5598
         else
5599
-            $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5599
+            $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
5600 5600
         $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5601 5601
 
5602 5602
         $nblines = (int) floor((count($a) + 1) / 2);
@@ -5627,7 +5627,7 @@  discard block
 block discarded – undo
5627 5627
      */
5628 5628
     static function dol_microtime_float()
5629 5629
     {
5630
-        dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
5630
+        dol_syslog(__FUNCTION__." is deprecated", LOG_WARNING);
5631 5631
 
5632 5632
         return microtime(true);
5633 5633
     }
@@ -5673,9 +5673,9 @@  discard block
 block discarded – undo
5673 5673
             elseif (preg_match('/<h[0-9]>/i', $msg))
5674 5674
                 return true;
5675 5675
             elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
5676
-                return true;    // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5676
+                return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5677 5677
             elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
5678
-                return true;    // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5678
+                return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5679 5679
 
5680 5680
             return false;
5681 5681
         }
@@ -5900,7 +5900,7 @@  discard block
 block discarded – undo
5900 5900
                     if ($object->fetch_optionals() > 0) {
5901 5901
                         if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) {
5902 5902
                             foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) {
5903
-                                $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key];
5903
+                                $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key];
5904 5904
                             }
5905 5905
                         }
5906 5906
                     }
@@ -5912,7 +5912,7 @@  discard block
 block discarded – undo
5912 5912
                     $paymenturl = '';
5913 5913
                 } else {
5914 5914
                     // Set the online payment url link into __ONLINE_PAYMENT_URL__ key
5915
-                    require_once DOL_BASE_PATH . '/core/lib/payments.lib.php';
5915
+                    require_once DOL_BASE_PATH.'/core/lib/payments.lib.php';
5916 5916
                     $outputlangs->loadLangs(array('paypal', 'other'));
5917 5917
                     $typeforonlinepayment = 'free';
5918 5918
                     if (is_object($object) && $object->element == 'commande')
@@ -5973,7 +5973,7 @@  discard block
 block discarded – undo
5973 5973
 
5974 5974
 //var_dump($substitutionarray['__AMOUNT_FORMATED__']);
5975 5975
         if (empty($exclude) || !in_array('date', $exclude)) {
5976
-            include_once DOL_BASE_PATH . '/core/lib/date.lib.php';
5976
+            include_once DOL_BASE_PATH.'/core/lib/date.lib.php';
5977 5977
 
5978 5978
             $tmp = dol_getdate(dol_now(), true);
5979 5979
             $tmp2 = dol_get_prev_day($tmp['mday'], $tmp['mon'], $tmp['year']);
@@ -5983,13 +5983,13 @@  discard block
 block discarded – undo
5983 5983
 
5984 5984
             $substitutionarray = array_merge($substitutionarray, array(
5985 5985
                 '__DAY__' => (string) $tmp['mday'],
5986
-                '__DAY_TEXT__' => $outputlangs->trans('Day' . $tmp['wday']), // Monday
5987
-                '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'] . 'Min'), // Mon
5988
-                '__DAY_TEXT_MIN__' => $outputlangs->trans('Short' . $tmp['weekday']), // M
5986
+                '__DAY_TEXT__' => $outputlangs->trans('Day'.$tmp['wday']), // Monday
5987
+                '__DAY_TEXT_SHORT__' => $outputlangs->trans($tmp['weekday'].'Min'), // Mon
5988
+                '__DAY_TEXT_MIN__' => $outputlangs->trans('Short'.$tmp['weekday']), // M
5989 5989
                 '__MONTH__' => (string) $tmp['mon'],
5990
-                '__MONTH_TEXT__' => $outputlangs->trans('Month' . sprintf("%02d", $tmp['mon'])),
5991
-                '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort' . sprintf("%02d", $tmp['mon'])),
5992
-                '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort' . sprintf("%02d", $tmp['mon'])),
5990
+                '__MONTH_TEXT__' => $outputlangs->trans('Month'.sprintf("%02d", $tmp['mon'])),
5991
+                '__MONTH_TEXT_SHORT__' => $outputlangs->trans('MonthShort'.sprintf("%02d", $tmp['mon'])),
5992
+                '__MONTH_TEXT_MIN__' => $outputlangs->trans('MonthVeryShort'.sprintf("%02d", $tmp['mon'])),
5993 5993
                 '__YEAR__' => (string) $tmp['year'],
5994 5994
                 '__PREVIOUS_DAY__' => (string) $tmp2['day'],
5995 5995
                 '__PREVIOUS_MONTH__' => (string) $tmp3['month'],
@@ -6048,7 +6048,7 @@  discard block
 block discarded – undo
6048 6048
                 if (!empty($tmp[1]))
6049 6049
                     $outputlangs->load($tmp[1]);
6050 6050
 
6051
-                $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6051
+                $text = preg_replace('/__\('.preg_quote($reg[1], '/').'\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6052 6052
             }
6053 6053
         }
6054 6054
 
@@ -6064,13 +6064,13 @@  discard block
 block discarded – undo
6064 6064
                 $newval = '*****forbidden*****';
6065 6065
             else
6066 6066
                 $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound;
6067
-            $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6067
+            $text = preg_replace('/__\['.preg_quote($keyfound, '/').'\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6068 6068
         }
6069 6069
 
6070 6070
 // Make substitition for array $substitutionarray
6071 6071
         foreach ($substitutionarray as $key => $value) {
6072 6072
             if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6073
-                $value = '';  // Protection
6073
+                $value = ''; // Protection
6074 6074
             if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6075 6075
                 $value = ''; // Protection
6076 6076
 
@@ -6096,7 +6096,7 @@  discard block
 block discarded – undo
6096 6096
     {
6097 6097
        // global Globals::$conf, $user;
6098 6098
 
6099
-        require_once DOL_BASE_PATH . '/core/lib/files.lib.php';
6099
+        require_once DOL_BASE_PATH.'/core/lib/files.lib.php';
6100 6100
 
6101 6101
 // Add a substitution key for each extrafields, using key __EXTRA_XXX__
6102 6102
 // TODO Remove this. Already available into the getCommonSubstitutionArray used to build the substitution array.
@@ -6126,11 +6126,11 @@  discard block
 block discarded – undo
6126 6126
                 if (preg_match('/functions_(.*)\.lib\.php/i', $substitfile['name'], $reg)) {
6127 6127
                     $module = $reg[1];
6128 6128
 
6129
-                    dol_syslog("Library " . $substitfile['name'] . " found into " . $dir);
6129
+                    dol_syslog("Library ".$substitfile['name']." found into ".$dir);
6130 6130
                     // Include the user's functions file
6131
-                    require_once $dir . $substitfile['name'];
6131
+                    require_once $dir.$substitfile['name'];
6132 6132
                     // Call the user's function, and only if it is defined
6133
-                    $function_name = $module . "_" . $callfunc;
6133
+                    $function_name = $module."_".$callfunc;
6134 6134
                     if (function_exists($function_name))
6135 6135
                         $function_name($substitutionarray, $outputlangs, $object, $parameters);
6136 6136
                 }
@@ -6172,13 +6172,13 @@  discard block
 block discarded – undo
6172 6172
             $outputlangs = $langs;
6173 6173
 
6174 6174
         if ($date_start && $date_end) {
6175
-            $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6175
+            $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6176 6176
         }
6177 6177
         if ($date_start && !$date_end) {
6178
-            $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6178
+            $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateFrom', dol_print_date($date_start, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6179 6179
         }
6180 6180
         if (!$date_start && $date_end) {
6181
-            $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
6181
+            $out .= ($withparenthesis ? ' (' : '').$outputlangs->transnoentitiesnoconv('DateUntil', dol_print_date($date_end, $format, false, $outputlangs)).($withparenthesis ? ')' : '');
6182 6182
         }
6183 6183
 
6184 6184
         return $out;
@@ -6258,7 +6258,7 @@  discard block
 block discarded – undo
6258 6258
             dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
6259 6259
         } else {
6260 6260
             if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
6261
-                dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6261
+                dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages');
6262 6262
             if (empty($mesgs))
6263 6263
                 setEventMessage($mesg, $style);
6264 6264
             else {
@@ -6327,7 +6327,7 @@  discard block
 block discarded – undo
6327 6327
 
6328 6328
 // If inline message with no format, we add it.
6329 6329
         if ((empty(Globals::$conf->use_javascript_ajax) || !empty(Globals::$conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) || $keepembedded) && !preg_match('/<div class=".*">/i', $out)) {
6330
-            $divstart = '<div class="' . $style . ' clearboth">';
6330
+            $divstart = '<div class="'.$style.' clearboth">';
6331 6331
             $divend = '</div>';
6332 6332
         }
6333 6333
 
@@ -6354,14 +6354,14 @@  discard block
 block discarded – undo
6354 6354
             if (!empty(Globals::$conf->use_javascript_ajax) && empty(Globals::$conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && empty($keepembedded)) {
6355 6355
                 $return = '<script type="text/javascript">
6356 6356
 					$(document).ready(function() {
6357
-						var block = ' . (!empty(Globals::$conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false") . '
6357
+						var block = ' . (!empty(Globals::$conf->global->MAIN_USE_JQUERY_BLOCKUI) ? "true" : "false").'
6358 6358
 						if (block) {
6359
-							$.dolEventValid("","' . dol_escape_js($out) . '");
6359
+							$.dolEventValid("","' . dol_escape_js($out).'");
6360 6360
 						} else {
6361 6361
 							/* jnotify(message, preset of message type, keepmessage) */
6362
-							$.jnotify("' . dol_escape_js($out) . '",
6363
-							"' . ($style == "ok" ? 3000 : $style) . '",
6364
-							' . ($style == "ok" ? "false" : "true") . ',
6362
+							$.jnotify("' . dol_escape_js($out).'",
6363
+							"' . ($style == "ok" ? 3000 : $style).'",
6364
+							' . ($style == "ok" ? "false" : "true").',
6365 6365
 							{ remove: static function (){} } );
6366 6366
 						}
6367 6367
 					});
@@ -6556,11 +6556,11 @@  discard block
 block discarded – undo
6556 6556
     {
6557 6557
        // global Globals::$conf;
6558 6558
 
6559
-        $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6559
+        $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0
6560 6560
         if (empty($tmp) && !empty($_SERVER["WINDIR"]))
6561 6561
             $tmp = 'iso-8859-1'; // By default for windows
6562 6562
         if (empty($tmp))
6563
-            $tmp = 'utf-8';          // By default for other
6563
+            $tmp = 'utf-8'; // By default for other
6564 6564
         if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING))
6565 6565
             $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING;
6566 6566
 
@@ -6591,16 +6591,16 @@  discard block
 block discarded – undo
6591 6591
 
6592 6592
 // Check in cache
6593 6593
         if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
6594
-            return $cache_codes[$tablename][$key][$fieldid];   // Found in cache
6594
+            return $cache_codes[$tablename][$key][$fieldid]; // Found in cache
6595 6595
         }
6596 6596
 
6597 6597
         dol_syslog('dol_getIdFromCode (value not found into cache)', LOG_DEBUG);
6598 6598
 
6599
-        $sql = "SELECT " . $fieldid . " as valuetoget";
6600
-        $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
6601
-        $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'";
6599
+        $sql = "SELECT ".$fieldid." as valuetoget";
6600
+        $sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
6601
+        $sql .= " WHERE ".$fieldkey." = '".$db->escape($key)."'";
6602 6602
         if (!empty($entityfilter))
6603
-            $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6603
+            $sql .= " AND entity IN (".getEntity($tablename).")";
6604 6604
 
6605 6605
         $resql = $db->query($sql);
6606 6606
         if ($resql) {
@@ -6631,8 +6631,8 @@  discard block
 block discarded – undo
6631 6631
 //print $strRights."<br>\n";
6632 6632
         $rights = true;
6633 6633
         if ($strRights != '') {
6634
-            $str = 'if(!(' . $strRights . ')) { $rights = false; }';
6635
-            self::dol_eval($str);  // The dol_eval must contains all the// global $xxx used into a condition
6634
+            $str = 'if(!('.$strRights.')) { $rights = false; }';
6635
+            self::dol_eval($str); // The dol_eval must contains all the// global $xxx used into a condition
6636 6636
         }
6637 6637
         return $rights;
6638 6638
     }
@@ -6659,9 +6659,9 @@  discard block
 block discarded – undo
6659 6659
 //print $s."<br>\n";
6660 6660
         if ($returnvalue) {
6661 6661
             if ($hideerrors)
6662
-                return @eval('return ' . $s . ';');
6662
+                return @eval('return '.$s.';');
6663 6663
             else
6664
-                return eval('return ' . $s . ';');
6664
+                return eval('return '.$s.';');
6665 6665
         }
6666 6666
         else {
6667 6667
             if ($hideerrors)
@@ -6715,7 +6715,7 @@  discard block
 block discarded – undo
6715 6715
             $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
6716 6716
         }
6717 6717
 
6718
-        return img_picto_common($codelang, 'flags/' . strtolower($flagImage) . '.png', $moreatt);
6718
+        return img_picto_common($codelang, 'flags/'.strtolower($flagImage).'.png', $moreatt);
6719 6719
     }
6720 6720
 
6721 6721
     /**
@@ -6913,16 +6913,16 @@  discard block
 block discarded – undo
6913 6913
             'zu-ZA',
6914 6914
         );
6915 6915
 
6916
-        $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode);
6916
+        $buildprimarykeytotest = strtolower($countrycode).'-'.strtoupper($countrycode);
6917 6917
         if (in_array($buildprimarykeytotest, $locales))
6918
-            return strtolower($countrycode) . '_' . strtoupper($countrycode);
6918
+            return strtolower($countrycode).'_'.strtoupper($countrycode);
6919 6919
 
6920 6920
         foreach ($locales as $locale) {
6921 6921
             $locale_language = locale_get_primary_language($locale);
6922 6922
             $locale_region = locale_get_region($locale);
6923 6923
             if (strtoupper($countrycode) == $locale_region) {
6924 6924
 //var_dump($locale.'-'.$locale_language.'-'.$locale_region);
6925
-                return strtolower($locale_language) . '_' . strtoupper($locale_region);
6925
+                return strtolower($locale_language).'_'.strtoupper($locale_region);
6926 6926
             }
6927 6927
         }
6928 6928
 
@@ -6983,7 +6983,7 @@  discard block
 block discarded – undo
6983 6983
                                 $label = $langs->trans($values[2]);
6984 6984
 
6985 6985
                             //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
6986
-                            $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
6986
+                            $head[$h][0] = BASE_URI.preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
6987 6987
                             $head[$h][1] = $label;
6988 6988
                             $head[$h][2] = str_replace('+', '', $values[1]);
6989 6989
                             $h++;
@@ -7054,43 +7054,43 @@  discard block
 block discarded – undo
7054 7054
         // global $micro_start_time;
7055 7055
 
7056 7056
         if ($zone == 'private')
7057
-            print "\n" . '<!-- Common footer for private page -->' . "\n";
7057
+            print "\n".'<!-- Common footer for private page -->'."\n";
7058 7058
         else
7059
-            print "\n" . '<!-- Common footer for public page -->' . "\n";
7059
+            print "\n".'<!-- Common footer for public page -->'."\n";
7060 7060
 
7061 7061
 // A div to store page_y POST parameter so we can read it using javascript
7062 7062
         print "\n<!-- A div to store page_y POST paramater -->\n";
7063
-        print '<div id="page_y" style="display: none;">' . $_POST['page_y'] . '</div>' . "\n";
7063
+        print '<div id="page_y" style="display: none;">'.$_POST['page_y'].'</div>'."\n";
7064 7064
 
7065 7065
         $parameters = array();
7066
-        $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
7066
+        $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks
7067 7067
         if (empty($reshook)) {
7068 7068
             if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER))
7069
-                print Globals::$conf->global->MAIN_HTML_FOOTER . "\n";
7069
+                print Globals::$conf->global->MAIN_HTML_FOOTER."\n";
7070 7070
 
7071 7071
             print "\n";
7072 7072
             if (!empty(Globals::$conf->use_javascript_ajax)) {
7073
-                print '<script type="text/javascript" language="javascript">' . "\n";
7074
-                print 'jQuery(document).ready(function() {' . "\n";
7073
+                print '<script type="text/javascript" language="javascript">'."\n";
7074
+                print 'jQuery(document).ready(function() {'."\n";
7075 7075
 
7076 7076
                 if ($zone == 'private' && empty(Globals::$conf->dol_use_jmobile)) {
7077 7077
                     print "\n";
7078
-                    print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */' . "\n";
7078
+                    print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n";
7079 7079
                     print 'jQuery(".menuhider").click(function() {';
7080
-                    print '  console.log("We click on .menuhider");' . "\n";
7080
+                    print '  console.log("We click on .menuhider");'."\n";
7081 7081
                     //print "  $('.side-nav').animate({width:'toggle'},200);\n";     // OK with eldy theme but not with md
7082 7082
                     print "  $('.side-nav').toggle()\n";
7083 7083
                     print "  $('.login_block').toggle()\n";
7084
-                    print '});' . "\n";
7084
+                    print '});'."\n";
7085 7085
                 }
7086 7086
 
7087 7087
 // Management of focus and mandatory for fields
7088 7088
                 if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"])))) {
7089
-                    print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n";
7089
+                    print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n";
7090 7090
                     $relativepathstring = $_SERVER["PHP_SELF"];
7091 7091
                     // Clean $relativepathstring
7092 7092
                     if (constant('DOL_BASE_URI'))
7093
-                        $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
7093
+                        $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_BASE_URI'), '/').'/', '', $relativepathstring);
7094 7094
                     $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
7095 7095
                     $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
7096 7096
                     $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
@@ -7113,9 +7113,9 @@  discard block
 block discarded – undo
7113 7113
                             if ($qualified) {
7114 7114
                                 foreach ($defval as $paramkey => $paramval) {
7115 7115
                                     // Set focus on field
7116
-                                    print 'jQuery("input[name=\'' . $paramkey . '\']").focus();' . "\n";
7117
-                                    print 'jQuery("textarea[name=\'' . $paramkey . '\']").focus();' . "\n";
7118
-                                    print 'jQuery("select[name=\'' . $paramkey . '\']").focus();' . "\n";  // Not really usefull, but we keep it in case of.
7116
+                                    print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n";
7117
+                                    print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n";
7118
+                                    print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really usefull, but we keep it in case of.
7119 7119
                                 }
7120 7120
                             }
7121 7121
                         }
@@ -7139,16 +7139,16 @@  discard block
 block discarded – undo
7139 7139
                             if ($qualified) {
7140 7140
                                 foreach ($defval as $paramkey => $paramval) {
7141 7141
                                     // Add property 'required' on input
7142
-                                    print 'jQuery("input[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
7143
-                                    print 'jQuery("textarea[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";
7144
-                                    print 'jQuery("select[name=\'' . $paramkey . '\']").prop(\'required\',true);' . "\n";  // required on a select works only if key is "", this does not happen in Dolibarr
7142
+                                    print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
7143
+                                    print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
7144
+                                    print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
7145 7145
                                 }
7146 7146
                             }
7147 7147
                         }
7148 7148
                     }
7149 7149
                 }
7150 7150
 
7151
-                print '});' . "\n";
7151
+                print '});'."\n";
7152 7152
 
7153 7153
 // Google Analytics
7154 7154
 // TODO Add a hook here
@@ -7156,15 +7156,15 @@  discard block
 block discarded – undo
7156 7156
                     if ((Globals::$conf->dol_use_jmobile != 4)) {
7157 7157
                         print "\n";
7158 7158
                         print "/* JS CODE TO ENABLE for google analtics tag */\n";
7159
-                        print '  var _gaq = _gaq || [];' . "\n";
7160
-                        print '  _gaq.push([\'_setAccount\', \'' . Globals::$conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
7161
-                        print '  _gaq.push([\'_trackPageview\']);' . "\n";
7162
-                        print '' . "\n";
7163
-                        print '  (function() {' . "\n";
7164
-                        print '    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
7165
-                        print '    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
7166
-                        print '    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
7167
-                        print '  })();' . "\n";
7159
+                        print '  var _gaq = _gaq || [];'."\n";
7160
+                        print '  _gaq.push([\'_setAccount\', \''.Globals::$conf->global->MAIN_GOOGLE_AN_ID.'\']);'."\n";
7161
+                        print '  _gaq.push([\'_trackPageview\']);'."\n";
7162
+                        print ''."\n";
7163
+                        print '  (function() {'."\n";
7164
+                        print '    var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;'."\n";
7165
+                        print '    ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';'."\n";
7166
+                        print '    var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);'."\n";
7167
+                        print '  })();'."\n";
7168 7168
                     }
7169 7169
                 }
7170 7170
 
@@ -7174,27 +7174,27 @@  discard block
 block discarded – undo
7174 7174
                     print "/* JS CODE TO ENABLE to add memory info */\n";
7175 7175
                     print 'window.console && console.log("';
7176 7176
                     if (!empty(Globals::$conf->global->MEMCACHED_SERVER))
7177
-                        print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - ';
7178
-                    print 'MAIN_OPTIMIZE_SPEED=' . (isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7177
+                        print 'MEMCACHED_SERVER='.Globals::$conf->global->MEMCACHED_SERVER.' - ';
7178
+                    print 'MAIN_OPTIMIZE_SPEED='.(isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7179 7179
                     if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in// global variable.
7180 7180
                         $micro_end_time = microtime(true);
7181
-                        print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
7181
+                        print ' - Build time: '.ceil(1000 * ($micro_end_time - $micro_start_time)).' ms';
7182 7182
                     }
7183 7183
                     if (function_exists("memory_get_usage")) {
7184
-                        print ' - Mem: ' . memory_get_usage();
7184
+                        print ' - Mem: '.memory_get_usage();
7185 7185
                     }
7186 7186
                     if (function_exists("xdebug_memory_usage")) {
7187
-                        print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
7188
-                        print ' - XDebug mem: ' . xdebug_memory_usage();
7189
-                        print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
7187
+                        print ' - XDebug time: '.ceil(1000 * xdebug_time_index()).' ms';
7188
+                        print ' - XDebug mem: '.xdebug_memory_usage();
7189
+                        print ' - XDebug mem peak: '.xdebug_peak_memory_usage();
7190 7190
                     }
7191 7191
                     if (function_exists("zend_loader_file_encoded")) {
7192
-                        print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
7192
+                        print ' - Zend encoded file: '.(zend_loader_file_encoded() ? 'yes' : 'no');
7193 7193
                     }
7194
-                    print '");' . "\n";
7194
+                    print '");'."\n";
7195 7195
                 }
7196 7196
 
7197
-                print "\n" . '</script>' . "\n";
7197
+                print "\n".'</script>'."\n";
7198 7198
             }
7199 7199
 
7200 7200
 // Add Xdebug coverage of code
@@ -7208,7 +7208,7 @@  discard block
 block discarded – undo
7208 7208
                 print "<!-- Start of log output\n";
7209 7209
 //print '<div class="hidden">'."\n";
7210 7210
                 foreach (Globals::$conf->logbuffer as $logline) {
7211
-                    print $logline . "<br>\n";
7211
+                    print $logline."<br>\n";
7212 7212
                 }
7213 7213
 //print '</div>'."\n";
7214 7214
                 print "End of log output -->\n";
@@ -7251,8 +7251,8 @@  discard block
 block discarded – undo
7251 7251
      */
7252 7252
     static function dol_set_focus($selector)
7253 7253
     {
7254
-        print "\n" . '<!-- Set focus onto a specific field -->' . "\n";
7255
-        print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("' . dol_escape_js($selector) . '").focus(); });</script>' . "\n";
7254
+        print "\n".'<!-- Set focus onto a specific field -->'."\n";
7255
+        print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() { jQuery("'.dol_escape_js($selector).'").focus(); });</script>'."\n";
7256 7256
     }
7257 7257
 
7258 7258
     /**
@@ -7297,7 +7297,7 @@  discard block
 block discarded – undo
7297 7297
             $value = preg_replace('/\*/', '%', $value); // Replace * with %
7298 7298
         }
7299 7299
         if ($mode == 1) {
7300
-            $value = preg_replace('/([<>=]+)\s+([0-9' . preg_quote($langs->trans("DecimalSeparator"), '/') . '\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
7300
+            $value = preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
7301 7301
         }
7302 7302
 
7303 7303
         $value = preg_replace('/\s*\|\s*/', '|', $value);
@@ -7326,14 +7326,14 @@  discard block
 block discarded – undo
7326 7326
                     if ($newcrit != '') {
7327 7327
                         $numnewcrit = price2num($newcrit);
7328 7328
                         if (is_numeric($numnewcrit)) {
7329
-                            $newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' ' . $operator . ' ' . $numnewcrit;
7329
+                            $newres .= ($i2 > 0 ? ' OR ' : '').$field.' '.$operator.' '.$numnewcrit;
7330 7330
                         } else {
7331
-                            $newres .= ($i2 > 0 ? ' OR ' : '') . '1 = 2'; // force false
7331
+                            $newres .= ($i2 > 0 ? ' OR ' : '').'1 = 2'; // force false
7332 7332
                         }
7333 7333
                         $i2++; // a criteria was added to string
7334 7334
                     }
7335 7335
                 } else if ($mode == 2) {
7336
-                    $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $db->escape(trim($crit)) . ")";
7336
+                    $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$db->escape(trim($crit)).")";
7337 7337
                     $i2++; // a criteria was added to string
7338 7338
                 } else if ($mode == 3) {
7339 7339
                     $tmparray = explode(',', trim($crit));
@@ -7342,10 +7342,10 @@  discard block
 block discarded – undo
7342 7342
                         foreach ($tmparray as $val) {
7343 7343
                             if ($val) {
7344 7344
                                 $listofcodes .= ($listofcodes ? ',' : '');
7345
-                                $listofcodes .= "'" . $db->escape(trim($val)) . "'";
7345
+                                $listofcodes .= "'".$db->escape(trim($val))."'";
7346 7346
                             }
7347 7347
                         }
7348
-                        $newres .= ($i2 > 0 ? ' OR ' : '') . $field . " IN (" . $listofcodes . ")";
7348
+                        $newres .= ($i2 > 0 ? ' OR ' : '').$field." IN (".$listofcodes.")";
7349 7349
                         $i2++; // a criteria was added to string
7350 7350
                     }
7351 7351
                 } else if ($mode == 4) {
@@ -7354,10 +7354,10 @@  discard block
 block discarded – undo
7354 7354
                         $listofcodes = '';
7355 7355
                         foreach ($tmparray as $val) {
7356 7356
                             if ($val) {
7357
-                                $newres .= ($i2 > 0 ? ' OR (' : '(') . $field . ' LIKE \'' . $db->escape(trim($val)) . ',%\'';
7358
-                                $newres .= ' OR ' . $field . ' = \'' . $db->escape(trim($val)) . '\'';
7359
-                                $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . '\'';
7360
-                                $newres .= ' OR ' . $field . ' LIKE \'%,' . $db->escape(trim($val)) . ',%\'';
7357
+                                $newres .= ($i2 > 0 ? ' OR (' : '(').$field.' LIKE \''.$db->escape(trim($val)).',%\'';
7358
+                                $newres .= ' OR '.$field.' = \''.$db->escape(trim($val)).'\'';
7359
+                                $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).'\'';
7360
+                                $newres .= ' OR '.$field.' LIKE \'%,'.$db->escape(trim($val)).',%\'';
7361 7361
                                 $newres .= ')';
7362 7362
                                 $i2++;
7363 7363
                             }
@@ -7374,9 +7374,9 @@  discard block
 block discarded – undo
7374 7374
                         $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
7375 7375
 
7376 7376
                         if (preg_match('/\.(id|rowid)$/', $field)) { // Special case for rowid that is sometimes a ref so used as a search field
7377
-                            $newres .= $field . " = " . (is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0');
7377
+                            $newres .= $field." = ".(is_numeric(trim($tmpcrit)) ? trim($tmpcrit) : '0');
7378 7378
                         } else {
7379
-                            $newres .= $field . " LIKE '";
7379
+                            $newres .= $field." LIKE '";
7380 7380
 
7381 7381
                             $tmpcrit = trim($tmpcrit);
7382 7382
                             $tmpcrit2 = $tmpcrit;
@@ -7395,7 +7395,7 @@  discard block
 block discarded – undo
7395 7395
                             $newres .= $tmpafter;
7396 7396
                             $newres .= "'";
7397 7397
                             if ($tmpcrit2 == '') {
7398
-                                $newres .= ' OR ' . $field . " IS NULL";
7398
+                                $newres .= ' OR '.$field." IS NULL";
7399 7399
                             }
7400 7400
                         }
7401 7401
 
@@ -7406,10 +7406,10 @@  discard block
 block discarded – undo
7406 7406
                 $i++;
7407 7407
             }
7408 7408
             if ($newres)
7409
-                $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7409
+                $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : '');
7410 7410
             $j++;
7411 7411
         }
7412
-        $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
7412
+        $res = ($nofirstand ? "" : " AND ")."(".$res.")";
7413 7413
 //print 'xx'.$res.'yy';
7414 7414
         return $res;
7415 7415
     }
@@ -7428,8 +7428,8 @@  discard block
 block discarded – undo
7428 7428
         $url = $object->getLastMainDocLink($object->element);
7429 7429
 
7430 7430
         if ($url) {
7431
-            $out .= img_picto('', 'object_globe.png') . ' ' . $langs->trans("DirectDownloadLink") . '<br>';
7432
-            $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="' . $url . '">';
7431
+            $out .= img_picto('', 'object_globe.png').' '.$langs->trans("DirectDownloadLink").'<br>';
7432
+            $out .= '<input type="text" id="directdownloadlink" class="quatrevingtpercent" value="'.$url.'">';
7433 7433
             $out .= ajax_autoselect("directdownloadlink", 0);
7434 7434
         }
7435 7435
         return $out;
@@ -7470,7 +7470,7 @@  discard block
 block discarded – undo
7470 7470
         if ($extName)
7471 7471
             $subdir = 'thumbs/';
7472 7472
 
7473
-        return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb
7473
+        return ($dirName ? $dirName.'/' : '').$subdir.$fileName.$extName.$extImgTarget; // New filename for thumb
7474 7474
     }
7475 7475
 
7476 7476
     /**
@@ -7496,14 +7496,14 @@  discard block
 block discarded – undo
7496 7496
 
7497 7497
         if ($alldata == 1) {
7498 7498
             if ($num_mime !== false)
7499
-                return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7499
+                return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime' => dol_mimetype($relativepath),);
7500 7500
             else
7501 7501
                 return array();
7502 7502
         }
7503 7503
 
7504 7504
 // old behavior
7505 7505
         if ($num_mime !== false)
7506
-            return 'javascript:document_preview(\'' . dol_escape_js(DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7506
+            return 'javascript:document_preview(\''.dol_escape_js(DOL_BASE_URI.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')';
7507 7507
         else
7508 7508
             return '';
7509 7509
     }
@@ -7520,11 +7520,11 @@  discard block
 block discarded – undo
7520 7520
        // global $langs;
7521 7521
         $out = '<script type="text/javascript">
7522 7522
                jQuery(document).ready(static function () {
7523
-				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
7523
+				    jQuery("#' . $htmlname.'").click(function() { jQuery(this).select(); } );
7524 7524
 				});
7525 7525
 		    </script>';
7526 7526
         if ($addlink)
7527
-            $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7527
+            $out .= ' <a href="'.$addlink.'" target="_blank">'.$langs->trans("Link").'</a>';
7528 7528
         return $out;
7529 7529
     }
7530 7530
 
@@ -7905,9 +7905,9 @@  discard block
 block discarded – undo
7905 7905
 
7906 7906
         if (!isset($dictvalues[$tablename])) {
7907 7907
             $dictvalues[$tablename] = array();
7908
-            $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1';
7908
+            $sql = 'SELECT * FROM '.$tablename.' WHERE 1';
7909 7909
             if ($checkentity)
7910
-                $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
7910
+                $sql .= ' AND entity IN (0,'.getEntity($tablename).')';
7911 7911
 
7912 7912
             $resql = $db->query($sql);
7913 7913
             if ($resql) {
@@ -7945,14 +7945,14 @@  discard block
 block discarded – undo
7945 7945
                 $g = $tmp[1];
7946 7946
                 $b = $tmp[2];
7947 7947
             } else {
7948
-                $hexr = $stringcolor[0] . $stringcolor[1];
7949
-                $hexg = $stringcolor[2] . $stringcolor[3];
7950
-                $hexb = $stringcolor[4] . $stringcolor[5];
7948
+                $hexr = $stringcolor[0].$stringcolor[1];
7949
+                $hexg = $stringcolor[2].$stringcolor[3];
7950
+                $hexb = $stringcolor[4].$stringcolor[5];
7951 7951
                 $r = hexdec($hexr);
7952 7952
                 $g = hexdec($hexg);
7953 7953
                 $b = hexdec($hexb);
7954 7954
             }
7955
-            $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;    // HSL algorithm
7955
+            $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm
7956 7956
             if ($bright > 0.6)
7957 7957
                 $res = 1;
7958 7958
         }
@@ -7987,11 +7987,11 @@  discard block
 block discarded – undo
7987 7987
                 return 0; // Entry is for menus all excluded to external users
7988 7988
         }
7989 7989
         if (!$menuentry['perms'] && $type_user)
7990
-            return 0;            // No permissions and user is external
7990
+            return 0; // No permissions and user is external
7991 7991
         if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
7992 7992
             return 0; // No permissions and option to hide when not allowed, even for internal user, is on
7993 7993
         if (!$menuentry['perms'])
7994
-            return 2;               // No permissions and user is external
7994
+            return 2; // No permissions and user is external
7995 7995
         return 1;
7996 7996
     }
7997 7997
 
Please login to merge, or discard this patch.
Braces   +1453 added lines, -1047 removed lines patch added patch discarded remove patch
@@ -75,8 +75,9 @@  discard block
 block discarded – undo
75 75
           if ($found) return $result;
76 76
           } */
77 77
 
78
-        if (isset($class::$member))
79
-            return $class::$member;
78
+        if (isset($class::$member)) {
79
+                    return $class::$member;
80
+        }
80 81
         dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.');
81 82
         return null;
82 83
     }
@@ -127,8 +128,9 @@  discard block
 block discarded – undo
127 128
         } else {
128 129
             $out = '';
129 130
             $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values');
130
-            if (in_array($element, $addzero))
131
-                $out .= '0,';
131
+            if (in_array($element, $addzero)) {
132
+                            $out .= '0,';
133
+            }
132 134
             $out .= Globals::$conf->entity;
133 135
             return $out;
134 136
         }
@@ -307,32 +309,35 @@  discard block
 block discarded – undo
307 309
     {
308 310
        // global $mysoc, $user, Globals::$conf;
309 311
 
310
-        if (empty($paramname))
311
-            return 'BadFirstParameterForDolUtils::GETPOST';
312
+        if (empty($paramname)) {
313
+                    return 'BadFirstParameterForDolUtils::GETPOST';
314
+        }
312 315
         if (empty($check)) {
313 316
             dol_syslog("Deprecated use of DolUtils::GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING);
314 317
         // Enable this line to know who call the DolUtils::GETPOST with '' $check parameter.
315 318
         //var_dump(debug_backtrace()[0]);
316 319
         }
317 320
 
318
-        if (empty($method))
319
-            $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
320
-        elseif ($method == 1)
321
-            $out = isset($_GET[$paramname]) ? $_GET[$paramname] : '';
322
-        elseif ($method == 2)
323
-            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : '';
324
-        elseif ($method == 3)
325
-            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : '');
326
-        elseif ($method == 4)
327
-            $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : ''));
328
-        else
329
-            return 'BadThirdParameterForDolUtils::GETPOST';
321
+        if (empty($method)) {
322
+                    $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : '');
323
+        } elseif ($method == 1) {
324
+                    $out = isset($_GET[$paramname]) ? $_GET[$paramname] : '';
325
+        } elseif ($method == 2) {
326
+                    $out = isset($_POST[$paramname]) ? $_POST[$paramname] : '';
327
+        } elseif ($method == 3) {
328
+                    $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : '');
329
+        } elseif ($method == 4) {
330
+                    $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : ''));
331
+        } else {
332
+                    return 'BadThirdParameterForDolUtils::GETPOST';
333
+        }
330 334
 
331 335
         if (empty($method) || $method == 3 || $method == 4) {
332 336
             $relativepathstring = $_SERVER["PHP_SELF"];
333 337
             // Clean $relativepathstring
334
-            if (constant('DOL_BASE_URI'))
335
-                $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
338
+            if (constant('DOL_BASE_URI')) {
339
+                            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
340
+            }
336 341
             $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
337 342
             $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
338 343
             //var_dump($relativepathstring);
@@ -381,14 +386,17 @@  discard block
 block discarded – undo
381 386
                                         $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
382 387
                                         $foundintru = 0;
383 388
                                         foreach ($tmpqueryarraytohave as $tmpquerytohave) {
384
-                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
385
-                                                $foundintru = 1;
389
+                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
390
+                                                                                            $foundintru = 1;
391
+                                            }
386 392
                                         }
387
-                                        if (!$foundintru)
388
-                                            $qualified = 1;
393
+                                        if (!$foundintru) {
394
+                                                                                    $qualified = 1;
395
+                                        }
389 396
                                         //var_dump($defkey.'-'.$qualified);
390
-                                    } else
391
-                                        $qualified = 1;
397
+                                    } else {
398
+                                                                            $qualified = 1;
399
+                                    }
392 400
 
393 401
                                     if ($qualified) {
394 402
                                         //var_dump($user->default_values[$relativepathstring][$defkey]['createform']);
@@ -415,20 +423,24 @@  discard block
 block discarded – undo
415 423
                                             $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
416 424
                                             $foundintru = 0;
417 425
                                             foreach ($tmpqueryarraytohave as $tmpquerytohave) {
418
-                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
419
-                                                    $foundintru = 1;
426
+                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
427
+                                                                                                    $foundintru = 1;
428
+                                                }
420 429
                                             }
421
-                                            if (!$foundintru)
422
-                                                $qualified = 1;
430
+                                            if (!$foundintru) {
431
+                                                                                            $qualified = 1;
432
+                                            }
423 433
                                             //var_dump($defkey.'-'.$qualified);
424
-                                        } else
425
-                                            $qualified = 1;
434
+                                        } else {
435
+                                                                                    $qualified = 1;
436
+                                        }
426 437
 
427 438
                                         if ($qualified) {
428 439
                                             $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
429 440
                                             foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
430
-                                                if ($out)
431
-                                                    $out .= ', ';
441
+                                                if ($out) {
442
+                                                                                                    $out .= ', ';
443
+                                                }
432 444
                                                 if ($paramname == 'sortfield') {
433 445
                                                     $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace);
434 446
                                                 }
@@ -448,14 +460,17 @@  discard block
 block discarded – undo
448 460
                                         $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
449 461
                                         $foundintru = 0;
450 462
                                         foreach ($tmpqueryarraytohave as $tmpquerytohave) {
451
-                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
452
-                                                $foundintru = 1;
463
+                                            if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
464
+                                                                                            $foundintru = 1;
465
+                                            }
453 466
                                         }
454
-                                        if (!$foundintru)
455
-                                            $qualified = 1;
467
+                                        if (!$foundintru) {
468
+                                                                                    $qualified = 1;
469
+                                        }
456 470
                                         //var_dump($defkey.'-'.$qualified);
457
-                                    } else
458
-                                        $qualified = 1;
471
+                                    } else {
472
+                                                                            $qualified = 1;
473
+                                    }
459 474
 
460 475
                                     if ($qualified) {
461 476
                                         if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
@@ -527,8 +542,10 @@  discard block
 block discarded – undo
527 542
                     $newout = $user->fk_user;
528 543
                 } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') {
529 544
                     $newout = Globals::$conf->entity;
530
-                } else
531
-                    $newout = '';     // Key not found, we replace with empty string
545
+                } else {
546
+                                    $newout = '';
547
+                }
548
+                // Key not found, we replace with empty string
532 549
 
533 550
 
534 551
 
@@ -577,18 +594,20 @@  discard block
 block discarded – undo
577 594
                 }
578 595
                 break;
579 596
             case 'intcomma':
580
-                if (preg_match('/[^0-9,-]+/i', $out))
581
-                    $out = '';
597
+                if (preg_match('/[^0-9,-]+/i', $out)) {
598
+                                    $out = '';
599
+                }
582 600
                 break;
583 601
             case 'alpha':
584 602
                 if (!is_array($out)) {
585 603
                     $out = trim($out);
586 604
                     // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
587 605
                     // '../' is dangerous because it allows dir transversals
588
-                    if (preg_match('/"/', $out))
589
-                        $out = '';
590
-                    else if (preg_match('/\.\.\//', $out))
591
-                        $out = '';
606
+                    if (preg_match('/"/', $out)) {
607
+                                            $out = '';
608
+                    } else if (preg_match('/\.\.\//', $out)) {
609
+                                            $out = '';
610
+                    }
592 611
                 }
593 612
                 break;
594 613
             case 'san_alpha':
@@ -597,27 +616,31 @@  discard block
 block discarded – undo
597 616
             case 'aZ':
598 617
                 if (!is_array($out)) {
599 618
                     $out = trim($out);
600
-                    if (preg_match('/[^a-z]+/i', $out))
601
-                        $out = '';
619
+                    if (preg_match('/[^a-z]+/i', $out)) {
620
+                                            $out = '';
621
+                    }
602 622
                 }
603 623
                 break;
604 624
             case 'aZ09':
605 625
                 if (!is_array($out)) {
606 626
                     $out = trim($out);
607
-                    if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
608
-                        $out = '';
627
+                    if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) {
628
+                                            $out = '';
629
+                    }
609 630
                 }
610 631
                 break;
611 632
             case 'aZ09comma':  // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh
612 633
                 if (!is_array($out)) {
613 634
                     $out = trim($out);
614
-                    if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
615
-                        $out = '';
635
+                    if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) {
636
+                                            $out = '';
637
+                    }
616 638
                 }
617 639
                 break;
618 640
             case 'array':
619
-                if (!is_array($out) || empty($out))
620
-                    $out = array();
641
+                if (!is_array($out) || empty($out)) {
642
+                                    $out = array();
643
+                }
621 644
                 break;
622 645
             case 'nohtml':  // Recommended for most scalar parameters
623 646
                 $out = dol_string_nohtmltag($out, 0);
@@ -627,16 +650,18 @@  discard block
 block discarded – undo
627 650
                     $out = trim($out);
628 651
                     // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
629 652
                     // '../' is dangerous because it allows dir transversals
630
-                    if (preg_match('/"/', $out))
631
-                        $out = '';
632
-                    else if (preg_match('/\.\.\//', $out))
633
-                        $out = '';
653
+                    if (preg_match('/"/', $out)) {
654
+                                            $out = '';
655
+                    } else if (preg_match('/\.\.\//', $out)) {
656
+                                            $out = '';
657
+                    }
634 658
                     $out = dol_string_nohtmltag($out);
635 659
                 }
636 660
                 break;
637 661
             case 'custom':
638
-                if (empty($filter))
639
-                    return 'BadFourthParameterForDolUtils::GETPOST';
662
+                if (empty($filter)) {
663
+                                    return 'BadFourthParameterForDolUtils::GETPOST';
664
+                }
640 665
                 $out = filter_var($out, $filter, $options);
641 666
                 break;
642 667
         }
@@ -754,11 +779,11 @@  discard block
 block discarded – undo
754 779
                 }
755 780
             }
756 781
             if ($returnemptyifnotfound) {        // Not found into alternate dir
757
-                if ($returnemptyifnotfound == 1 || !file_exists($res))
758
-                    return '';
782
+                if ($returnemptyifnotfound == 1 || !file_exists($res)) {
783
+                                    return '';
784
+                }
759 785
             }
760
-        }
761
-        else {    // For an url path
786
+        } else {    // For an url path
762 787
 // We try to get local path of file on filesystem from url
763 788
 // Note that trying to know if a file on disk exist by forging path on disk from url
764 789
 // works only for some web server and some setup. This is bugged when
@@ -853,12 +878,14 @@  discard block
 block discarded – undo
853 878
     static function dol_size($size, $type = '')
854 879
     {
855 880
         //global Globals::$conf;
856
-        if (empty(Globals::$conf->dol_optimize_smallscreen))
857
-            return $size;
858
-        if ($type == 'width' && $size > 250)
859
-            return 250;
860
-        else
861
-            return 10;
881
+        if (empty(Globals::$conf->dol_optimize_smallscreen)) {
882
+                    return $size;
883
+        }
884
+        if ($type == 'width' && $size > 250) {
885
+                    return 250;
886
+        } else {
887
+                    return 10;
888
+        }
862 889
     }
863 890
 
864 891
     /**
@@ -958,9 +985,10 @@  discard block
 block discarded – undo
958 985
     {
959 986
         $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
960 987
         $forbidden_chars_to_remove = array();
961
-        if (is_array($badcharstoreplace))
962
-            $forbidden_chars_to_replace = $badcharstoreplace;
963
-//$forbidden_chars_to_remove=array("(",")");
988
+        if (is_array($badcharstoreplace)) {
989
+                    $forbidden_chars_to_replace = $badcharstoreplace;
990
+        }
991
+        //$forbidden_chars_to_remove=array("(",")");
964 992
 
965 993
         return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str));
966 994
     }
@@ -996,9 +1024,9 @@  discard block
 block discarded – undo
996 1024
         if (empty($mode)) {
997 1025
             $substitjs["'"] = "\\'";
998 1026
             $substitjs['"'] = "\\'";
999
-        } else if ($mode == 1)
1000
-            $substitjs["'"] = "\\'";
1001
-        else if ($mode == 2) {
1027
+        } else if ($mode == 1) {
1028
+                    $substitjs["'"] = "\\'";
1029
+        } else if ($mode == 2) {
1002 1030
             $substitjs['"'] = '\\"';
1003 1031
         } else if ($mode == 3) {
1004 1032
             $substitjs["'"] = "\\'";
@@ -1020,10 +1048,12 @@  discard block
 block discarded – undo
1020 1048
     {
1021 1049
 // escape quotes and backslashes, newlines, etc.
1022 1050
         $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8');  // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1023
-        if (!$keepb)
1024
-            $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1025
-        if (!$keepn)
1026
-            $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1051
+        if (!$keepb) {
1052
+                    $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1053
+        }
1054
+        if (!$keepn) {
1055
+                    $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1056
+        }
1027 1057
         return htmlentities($tmp, ENT_COMPAT, 'UTF-8');      // TODO Use htmlspecialchars instead, that make only required change for html tags
1028 1058
     }
1029 1059
 
@@ -1073,8 +1103,9 @@  discard block
 block discarded – undo
1073 1103
     {
1074 1104
        // global Globals::$conf, $user;
1075 1105
 // If syslog module enabled
1076
-        if (empty(Globals::$conf->syslog->enabled))
1077
-            return;
1106
+        if (empty(Globals::$conf->syslog->enabled)) {
1107
+                    return;
1108
+        }
1078 1109
 
1079 1110
         if ($ident < 0) {
1080 1111
             foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
@@ -1088,8 +1119,9 @@  discard block
 block discarded – undo
1088 1119
             if (!in_array($level, $logLevels, true)) {
1089 1120
                 throw new Exception('Incorrect log level');
1090 1121
             }
1091
-            if ($level > Globals::$conf->global->SYSLOG_LEVEL)
1092
-                return;
1122
+            if ($level > Globals::$conf->global->SYSLOG_LEVEL) {
1123
+                            return;
1124
+            }
1093 1125
 
1094 1126
             $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
1095 1127
 // If adding log inside HTML page is required
@@ -1114,24 +1146,30 @@  discard block
 block discarded – undo
1114 1146
             );
1115 1147
 
1116 1148
 // This is when server run behind a reverse proxy
1117
-            if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
1118
-                $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1119
-// This is when server run normally on a server
1120
-            else if (!empty($_SERVER["REMOTE_ADDR"]))
1121
-                $data['ip'] = $_SERVER['REMOTE_ADDR'];
1122
-// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
1123
-            else if (!empty($_SERVER['SERVER_ADDR']))
1124
-                $data['ip'] = $_SERVER['SERVER_ADDR'];
1125
-// This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
1126
-            else if (!empty($_SERVER['COMPUTERNAME']))
1127
-                $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1128
-// This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
1129
-            else if (!empty($_SERVER['LOGNAME']))
1130
-                $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1131
-// Loop on each log handler and send output
1149
+            if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
1150
+                            $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1151
+            }
1152
+            // This is when server run normally on a server
1153
+            else if (!empty($_SERVER["REMOTE_ADDR"])) {
1154
+                            $data['ip'] = $_SERVER['REMOTE_ADDR'];
1155
+            }
1156
+            // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
1157
+            else if (!empty($_SERVER['SERVER_ADDR'])) {
1158
+                            $data['ip'] = $_SERVER['SERVER_ADDR'];
1159
+            }
1160
+            // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it).
1161
+            else if (!empty($_SERVER['COMPUTERNAME'])) {
1162
+                            $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1163
+            }
1164
+            // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it).
1165
+            else if (!empty($_SERVER['LOGNAME'])) {
1166
+                            $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1167
+            }
1168
+            // Loop on each log handler and send output
1132 1169
             foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
1133
-                if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
1134
-                    continue;
1170
+                if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1171
+                                    continue;
1172
+                }
1135 1173
                 $loghandlerinstance->export($data, $suffixinfilename);
1136 1174
             }
1137 1175
             unset($data);
@@ -1187,13 +1225,15 @@  discard block
 block discarded – undo
1187 1225
 
1188 1226
 // Show title
1189 1227
         $showtitle = 1;
1190
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
1191
-            $showtitle = 0;
1228
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1229
+                    $showtitle = 0;
1230
+        }
1192 1231
         if (!empty($title) && $showtitle) {
1193 1232
             $limittitle = 30;
1194 1233
             $out .= '<a class="tabTitle">';
1195
-            if ($picto)
1196
-                $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1234
+            if ($picto) {
1235
+                            $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1236
+            }
1197 1237
             $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>';
1198 1238
             $out .= '</a>';
1199 1239
         }
@@ -1202,12 +1242,14 @@  discard block
 block discarded – undo
1202 1242
         $maxkey = -1;
1203 1243
         if (is_array($links) && !empty($links)) {
1204 1244
             $keys = array_keys($links);
1205
-            if (count($keys))
1206
-                $maxkey = max($keys);
1245
+            if (count($keys)) {
1246
+                            $maxkey = max($keys);
1247
+            }
1207 1248
         }
1208 1249
 
1209
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
1210
-            Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2;
1250
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1251
+                    Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2;
1252
+        }
1211 1253
 
1212 1254
 // Show tabs
1213 1255
         $bactive = false;
@@ -1220,8 +1262,9 @@  discard block
 block discarded – undo
1220 1262
         for ($i = 0; $i <= $maxkey; $i++) {
1221 1263
             if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1222 1264
 // If active tab is already present
1223
-                if ($i >= $limittoshow)
1224
-                    $limittoshow--;
1265
+                if ($i >= $limittoshow) {
1266
+                                    $limittoshow--;
1267
+                }
1225 1268
             }
1226 1269
         }
1227 1270
 
@@ -1262,12 +1305,12 @@  discard block
 block discarded – undo
1262 1305
                 }
1263 1306
                 $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">';
1264 1307
                 if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1265
-                    if (!empty($links[$i][0]))
1266
-                        $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1267
-                    else
1268
-                        $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1269
-                }
1270
-                else if (!empty($links[$i][1])) {
1308
+                    if (!empty($links[$i][0])) {
1309
+                                            $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1310
+                    } else {
1311
+                                            $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1312
+                    }
1313
+                } else if (!empty($links[$i][1])) {
1271 1314
                     $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1272 1315
                     $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts.
1273 1316
                     $outmore .= '</a>' . "\n";
@@ -1278,8 +1321,9 @@  discard block
 block discarded – undo
1278 1321
             }
1279 1322
             $displaytab = $i;
1280 1323
         }
1281
-        if ($popuptab)
1282
-            $outmore .= '</div>';
1324
+        if ($popuptab) {
1325
+                    $outmore .= '</div>';
1326
+        }
1283 1327
 
1284 1328
         if ($displaytab > $limittoshow) {
1285 1329
             $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
@@ -1302,8 +1346,9 @@  discard block
 block discarded – undo
1302 1346
 
1303 1347
         $out .= "</div>\n";
1304 1348
 
1305
-        if (!$notab || $notab == -1)
1306
-            $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1349
+        if (!$notab || $notab == -1) {
1350
+                    $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1351
+        }
1307 1352
 
1308 1353
         $parameters = array('tabname' => $active, 'out' => $out);
1309 1354
         $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
@@ -1333,10 +1378,11 @@  discard block
 block discarded – undo
1333 1378
      */
1334 1379
     static function dol_get_fiche_end($notab = 0)
1335 1380
     {
1336
-        if (!$notab || $notab == -1)
1337
-            return "\n</div>\n";
1338
-        else
1339
-            return '';
1381
+        if (!$notab || $notab == -1) {
1382
+                    return "\n</div>\n";
1383
+        } else {
1384
+                    return '';
1385
+        }
1340 1386
     }
1341 1387
 
1342 1388
     /**
@@ -1368,40 +1414,55 @@  discard block
 block discarded – undo
1368 1414
         $showimage = 1;
1369 1415
         $entity = (empty($object->entity) ? Globals::$conf->entity : $object->entity);
1370 1416
         $showbarcode = empty(Globals::$conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0);
1371
-        if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance))
1372
-            $showbarcode = 0;
1417
+        if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1418
+                    $showbarcode = 0;
1419
+        }
1373 1420
         $modulepart = 'unknown';
1374 1421
 
1375
-        if ($object->element == 'societe')
1376
-            $modulepart = 'societe';
1377
-        if ($object->element == 'contact')
1378
-            $modulepart = 'contact';
1379
-        if ($object->element == 'member')
1380
-            $modulepart = 'memberphoto';
1381
-        if ($object->element == 'user')
1382
-            $modulepart = 'userphoto';
1383
-        if ($object->element == 'product')
1384
-            $modulepart = 'product';
1422
+        if ($object->element == 'societe') {
1423
+                    $modulepart = 'societe';
1424
+        }
1425
+        if ($object->element == 'contact') {
1426
+                    $modulepart = 'contact';
1427
+        }
1428
+        if ($object->element == 'member') {
1429
+                    $modulepart = 'memberphoto';
1430
+        }
1431
+        if ($object->element == 'user') {
1432
+                    $modulepart = 'userphoto';
1433
+        }
1434
+        if ($object->element == 'product') {
1435
+                    $modulepart = 'product';
1436
+        }
1385 1437
 
1386 1438
         if (class_exists("Imagick")) {
1387
-            if ($object->element == 'propal')
1388
-                $modulepart = 'propal';
1389
-            if ($object->element == 'commande')
1390
-                $modulepart = 'commande';
1391
-            if ($object->element == 'facture')
1392
-                $modulepart = 'facture';
1393
-            if ($object->element == 'fichinter')
1394
-                $modulepart = 'ficheinter';
1395
-            if ($object->element == 'contrat')
1396
-                $modulepart = 'contract';
1397
-            if ($object->element == 'supplier_proposal')
1398
-                $modulepart = 'supplier_proposal';
1399
-            if ($object->element == 'order_supplier')
1400
-                $modulepart = 'supplier_order';
1401
-            if ($object->element == 'invoice_supplier')
1402
-                $modulepart = 'supplier_invoice';
1403
-            if ($object->element == 'expensereport')
1404
-                $modulepart = 'expensereport';
1439
+            if ($object->element == 'propal') {
1440
+                            $modulepart = 'propal';
1441
+            }
1442
+            if ($object->element == 'commande') {
1443
+                            $modulepart = 'commande';
1444
+            }
1445
+            if ($object->element == 'facture') {
1446
+                            $modulepart = 'facture';
1447
+            }
1448
+            if ($object->element == 'fichinter') {
1449
+                            $modulepart = 'ficheinter';
1450
+            }
1451
+            if ($object->element == 'contrat') {
1452
+                            $modulepart = 'contract';
1453
+            }
1454
+            if ($object->element == 'supplier_proposal') {
1455
+                            $modulepart = 'supplier_proposal';
1456
+            }
1457
+            if ($object->element == 'order_supplier') {
1458
+                            $modulepart = 'supplier_order';
1459
+            }
1460
+            if ($object->element == 'invoice_supplier') {
1461
+                            $modulepart = 'supplier_invoice';
1462
+            }
1463
+            if ($object->element == 'expensereport') {
1464
+                            $modulepart = 'expensereport';
1465
+            }
1405 1466
         }
1406 1467
 
1407 1468
         if ($object->element == 'product') {
@@ -1409,11 +1470,12 @@  discard block
 block discarded – undo
1409 1470
             $cssclass = 'photoref';
1410 1471
             $showimage = $object->is_photo_available(Globals::$conf->product->multidir_output[$entity]);
1411 1472
             $maxvisiblephotos = (isset(Globals::$conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? Globals::$conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5);
1412
-            if (Globals::$conf->browser->layout == 'phone')
1413
-                $maxvisiblephotos = 1;
1414
-            if ($showimage)
1415
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1416
-            else {
1473
+            if (Globals::$conf->browser->layout == 'phone') {
1474
+                            $maxvisiblephotos = 1;
1475
+            }
1476
+            if ($showimage) {
1477
+                            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', Globals::$conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1478
+            } else {
1417 1479
                 if (!empty(Globals::$conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
1418 1480
                     $nophoto = '';
1419 1481
                     $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>';
@@ -1429,11 +1491,12 @@  discard block
 block discarded – undo
1429 1491
             $cssclass = 'photoref';
1430 1492
             $showimage = $object->is_photo_available(Globals::$conf->ticket->multidir_output[$entity] . '/' . $object->track_id);
1431 1493
             $maxvisiblephotos = (isset(Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? Globals::$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2);
1432
-            if (Globals::$conf->browser->layout == 'phone')
1433
-                $maxvisiblephotos = 1;
1434
-            if ($showimage)
1435
-                $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1436
-            else {
1494
+            if (Globals::$conf->browser->layout == 'phone') {
1495
+                            $maxvisiblephotos = 1;
1496
+            }
1497
+            if ($showimage) {
1498
+                            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', Globals::$conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>';
1499
+            } else {
1437 1500
                 if (!empty(Globals::$conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
1438 1501
                     $nophoto = '';
1439 1502
                     $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>';
@@ -1458,8 +1521,10 @@  discard block
 block discarded – undo
1458 1521
                         } else {
1459 1522
                             $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1460 1523
                         }
1461
-                        if (empty($subdir))
1462
-                            $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
1524
+                        if (empty($subdir)) {
1525
+                                                    $subdir = 'errorgettingsubdirofobject';
1526
+                        }
1527
+                        // Protection to avoid to return empty path
1463 1528
 
1464 1529
                         $filepath = $dir_output . $subdir . "/";
1465 1530
 
@@ -1480,14 +1545,16 @@  discard block
 block discarded – undo
1480 1545
                                 if (empty(Globals::$conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
1481 1546
                                     include_once DOL_BASE_PATH . '/core/lib/files.lib.php';
1482 1547
                                     $ret = dol_convert_file($file, 'png', $fileimage);
1483
-                                    if ($ret < 0)
1484
-                                        $error++;
1548
+                                    if ($ret < 0) {
1549
+                                                                            $error++;
1550
+                                    }
1485 1551
                                 }
1486 1552
                             }
1487 1553
 
1488 1554
                             $heightforphotref = 70;
1489
-                            if (!empty(Globals::$conf->dol_optimize_smallscreen))
1490
-                                $heightforphotref = 60;
1555
+                            if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1556
+                                                            $heightforphotref = 60;
1557
+                            }
1491 1558
                             // Si fichier png PDF d'1 page trouve
1492 1559
                             if (file_exists($fileimage)) {
1493 1560
                                 $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
@@ -1523,8 +1590,10 @@  discard block
 block discarded – undo
1523 1590
                         $width = 14;
1524 1591
                         $cssclass = 'photorefcenter';
1525 1592
                         $picto = $object->picto;
1526
-                        if ($object->element == 'project' && !$object->public)
1527
-                            $picto = 'project'; // instead of projectpub
1593
+                        if ($object->element == 'project' && !$object->public) {
1594
+                                                    $picto = 'project';
1595
+                        }
1596
+                        // instead of projectpub
1528 1597
                         $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
1529 1598
                     }
1530 1599
                     $morehtmlleft .= '<!-- No photo to show -->';
@@ -1535,8 +1604,9 @@  discard block
 block discarded – undo
1535 1604
             }
1536 1605
         }
1537 1606
 
1538
-        if ($showbarcode)
1539
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1607
+        if ($showbarcode) {
1608
+                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1609
+        }
1540 1610
 
1541 1611
         if ($object->element == 'societe') {
1542 1612
             if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->societe->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
@@ -1560,35 +1630,37 @@  discard block
 block discarded – undo
1560 1630
             }
1561 1631
         } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
1562 1632
             $tmptxt = $object->getLibStatut(6, $object->totalpaye);
1563
-            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone')
1564
-                $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1633
+            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') {
1634
+                            $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1635
+            }
1565 1636
             $morehtmlstatus .= $tmptxt;
1566
-        }
1567
-        elseif ($object->element == 'contrat' || $object->element == 'contract') {
1568
-            if ($object->statut == 0)
1569
-                $morehtmlstatus .= $object->getLibStatut(5);
1570
-            else
1571
-                $morehtmlstatus .= $object->getLibStatut(4);
1572
-        }
1573
-        elseif ($object->element == 'facturerec') {
1574
-            if ($object->frequency == 0)
1575
-                $morehtmlstatus .= $object->getLibStatut(2);
1576
-            else
1577
-                $morehtmlstatus .= $object->getLibStatut(5);
1578
-        }
1579
-        elseif ($object->element == 'project_task') {
1637
+        } elseif ($object->element == 'contrat' || $object->element == 'contract') {
1638
+            if ($object->statut == 0) {
1639
+                            $morehtmlstatus .= $object->getLibStatut(5);
1640
+            } else {
1641
+                            $morehtmlstatus .= $object->getLibStatut(4);
1642
+            }
1643
+        } elseif ($object->element == 'facturerec') {
1644
+            if ($object->frequency == 0) {
1645
+                            $morehtmlstatus .= $object->getLibStatut(2);
1646
+            } else {
1647
+                            $morehtmlstatus .= $object->getLibStatut(5);
1648
+            }
1649
+        } elseif ($object->element == 'project_task') {
1580 1650
             $object->fk_statut = 1;
1581
-            if ($object->progress > 0)
1582
-                $object->fk_statut = 2;
1583
-            if ($object->progress >= 100)
1584
-                $object->fk_statut = 3;
1651
+            if ($object->progress > 0) {
1652
+                            $object->fk_statut = 2;
1653
+            }
1654
+            if ($object->progress >= 100) {
1655
+                            $object->fk_statut = 3;
1656
+            }
1585 1657
             $tmptxt = $object->getLibStatut(5);
1586 1658
             $morehtmlstatus .= $tmptxt;  // No status on task
1587
-        }
1588
-        else { // Generic case
1659
+        } else { // Generic case
1589 1660
             $tmptxt = $object->getLibStatut(6);
1590
-            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone')
1591
-                $tmptxt = $object->getLibStatut(5);
1661
+            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') {
1662
+                            $tmptxt = $object->getLibStatut(5);
1663
+            }
1592 1664
             $morehtmlstatus .= $tmptxt;
1593 1665
         }
1594 1666
 
@@ -1602,13 +1674,15 @@  discard block
 block discarded – undo
1602 1674
         }
1603 1675
 
1604 1676
 // Add alias for thirdparty
1605
-        if (!empty($object->name_alias))
1606
-            $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1677
+        if (!empty($object->name_alias)) {
1678
+                    $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1679
+        }
1607 1680
 
1608 1681
 // Add label
1609 1682
         if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
1610
-            if (!empty($object->label))
1611
-                $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1683
+            if (!empty($object->label)) {
1684
+                            $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1685
+            }
1612 1686
         }
1613 1687
 
1614 1688
         if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
@@ -1641,15 +1715,19 @@  discard block
 block discarded – undo
1641 1715
     {
1642 1716
        // global Globals::$conf, $langs;
1643 1717
         $ret = '';
1644
-        if ($fieldrequired)
1645
-            $ret .= '<span class="fieldrequired">';
1646
-        if ((Globals::$conf->dol_use_jmobile != 4))
1647
-            $ret .= '<label for="' . $fieldkey . '">';
1718
+        if ($fieldrequired) {
1719
+                    $ret .= '<span class="fieldrequired">';
1720
+        }
1721
+        if ((Globals::$conf->dol_use_jmobile != 4)) {
1722
+                    $ret .= '<label for="' . $fieldkey . '">';
1723
+        }
1648 1724
         $ret .= $langs->trans($langkey);
1649
-        if ((Globals::$conf->dol_use_jmobile != 4))
1650
-            $ret .= '</label>';
1651
-        if ($fieldrequired)
1652
-            $ret .= '</span>';
1725
+        if ((Globals::$conf->dol_use_jmobile != 4)) {
1726
+                    $ret .= '</label>';
1727
+        }
1728
+        if ($fieldrequired) {
1729
+                    $ret .= '</span>';
1730
+        }
1653 1731
         return $ret;
1654 1732
     }
1655 1733
 
@@ -1664,8 +1742,9 @@  discard block
 block discarded – undo
1664 1742
     {
1665 1743
        // global $bc;
1666 1744
         $ret = ' ' . $bc[$var];
1667
-        if ($moreclass)
1668
-            $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1745
+        if ($moreclass) {
1746
+                    $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1747
+        }
1669 1748
         return $ret;
1670 1749
     }
1671 1750
 
@@ -1696,18 +1775,18 @@  discard block
 block discarded – undo
1696 1775
             if ($object->state) {
1697 1776
                 $ret .= ($ret ? ", " : '') . $object->state;
1698 1777
             }
1699
-            if ($object->zip)
1700
-                $ret .= ($ret ? ", " : '') . $object->zip;
1701
-        }
1702
-        else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1778
+            if ($object->zip) {
1779
+                            $ret .= ($ret ? ", " : '') . $object->zip;
1780
+            }
1781
+        } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1703 1782
             $ret .= ($ret ? $sep : '' ) . $object->town;
1704 1783
             if ($object->state) {
1705 1784
                 $ret .= ($ret ? ", " : '') . $object->state;
1706 1785
             }
1707
-            if ($object->zip)
1708
-                $ret .= ($ret ? $sep : '' ) . $object->zip;
1709
-        }
1710
-        else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1786
+            if ($object->zip) {
1787
+                            $ret .= ($ret ? $sep : '' ) . $object->zip;
1788
+            }
1789
+        } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1711 1790
             $ret .= ($ret ? $sep : '' ) . $object->zip;
1712 1791
             $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1713 1792
             if ($object->state) {
@@ -1724,8 +1803,9 @@  discard block
 block discarded – undo
1724 1803
                 $ret .= ($ret ? ", " : '') . $object->state;
1725 1804
             }
1726 1805
         }
1727
-        if (!is_object($outputlangs))
1728
-            $outputlangs = $langs;
1806
+        if (!is_object($outputlangs)) {
1807
+                    $outputlangs = $langs;
1808
+        }
1729 1809
         if ($withcountry) {
1730 1810
             $langs->load("dict");
1731 1811
             $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
@@ -1746,8 +1826,9 @@  discard block
 block discarded – undo
1746 1826
     {
1747 1827
         if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
1748 1828
             return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
1749
-        } else
1750
-            return 'Error date into a not supported range';
1829
+        } else {
1830
+                    return 'Error date into a not supported range';
1831
+        }
1751 1832
     }
1752 1833
 
1753 1834
     /**
@@ -1793,10 +1874,12 @@  discard block
 block discarded – undo
1793 1874
                 }
1794 1875
             }
1795 1876
         }
1796
-        if (!is_object($outputlangs))
1797
-            $outputlangs = $langs;
1798
-        if (!$format)
1799
-            $format = 'daytextshort';
1877
+        if (!is_object($outputlangs)) {
1878
+                    $outputlangs = $langs;
1879
+        }
1880
+        if (!$format) {
1881
+                    $format = 'daytextshort';
1882
+        }
1800 1883
         $reduceformat = (!empty(Globals::$conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
1801 1884
         $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
1802 1885
         if ($formatwithoutreduce != $format) {
@@ -1805,40 +1888,46 @@  discard block
 block discarded – undo
1805 1888
         }  // so format 'dayreduceformat' is processed like day
1806 1889
 // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
1807 1890
 // TODO Add format daysmallyear and dayhoursmallyear
1808
-        if ($format == 'day')
1809
-            $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
1810
-        else if ($format == 'hour')
1811
-            $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
1812
-        else if ($format == 'hourduration')
1813
-            $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
1814
-        else if ($format == 'daytext')
1815
-            $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
1816
-        else if ($format == 'daytextshort')
1817
-// Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1818
-            $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
1819
-        else if ($format == 'dayhour')
1820
-            $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short);
1821
-        else if ($format == 'dayhoursec')
1822
-            $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
1823
-        else if ($format == 'dayhourtext')
1824
-            $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
1825
-        else if ($format == 'dayhourtextshort')
1826
-            $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
1827
-// Format not sensitive to language
1828
-        else if ($format == 'dayhourlog')
1829
-            $format = '%Y%m%d%H%M%S';
1830
-        else if ($format == 'dayhourldap')
1831
-            $format = '%Y%m%d%H%M%SZ';
1832
-        else if ($format == 'dayhourxcard')
1833
-            $format = '%Y%m%dT%H%M%SZ';
1834
-        else if ($format == 'dayxcard')
1835
-            $format = '%Y%m%d';
1836
-        else if ($format == 'dayrfc')
1837
-            $format = '%Y-%m-%d';             // DATE_RFC3339
1838
-        else if ($format == 'dayhourrfc')
1839
-            $format = '%Y-%m-%dT%H:%M:%SZ';   // DATETIME RFC3339
1840
-        else if ($format == 'standard')
1841
-            $format = '%Y-%m-%d %H:%M:%S';
1891
+        if ($format == 'day') {
1892
+                    $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
1893
+        } else if ($format == 'hour') {
1894
+                    $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
1895
+        } else if ($format == 'hourduration') {
1896
+                    $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
1897
+        } else if ($format == 'daytext') {
1898
+                    $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
1899
+        } else if ($format == 'daytextshort') {
1900
+            // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1901
+            $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
1902
+        } else if ($format == 'dayhour') {
1903
+                    $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short);
1904
+        } else if ($format == 'dayhoursec') {
1905
+                    $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
1906
+        } else if ($format == 'dayhourtext') {
1907
+                    $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
1908
+        } else if ($format == 'dayhourtextshort') {
1909
+                    $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
1910
+        }
1911
+        // Format not sensitive to language
1912
+        else if ($format == 'dayhourlog') {
1913
+                    $format = '%Y%m%d%H%M%S';
1914
+        } else if ($format == 'dayhourldap') {
1915
+                    $format = '%Y%m%d%H%M%SZ';
1916
+        } else if ($format == 'dayhourxcard') {
1917
+                    $format = '%Y%m%dT%H%M%SZ';
1918
+        } else if ($format == 'dayxcard') {
1919
+                    $format = '%Y%m%d';
1920
+        } else if ($format == 'dayrfc') {
1921
+                    $format = '%Y-%m-%d';
1922
+        }
1923
+        // DATE_RFC3339
1924
+        else if ($format == 'dayhourrfc') {
1925
+                    $format = '%Y-%m-%dT%H:%M:%SZ';
1926
+        }
1927
+        // DATETIME RFC3339
1928
+        else if ($format == 'standard') {
1929
+                    $format = '%Y-%m-%d %H:%M:%S';
1930
+        }
1842 1931
 
1843 1932
         if ($reduceformat) {
1844 1933
             $format = str_replace('%Y', '%y', $format);
@@ -1846,8 +1935,10 @@  discard block
 block discarded – undo
1846 1935
         }
1847 1936
 
1848 1937
 // If date undefined or "", we return ""
1849
-        if (dol_strlen($time) == 0)
1850
-            return '';  // $time=0 allowed (it means 01/01/1970 00:00:00)
1938
+        if (dol_strlen($time) == 0) {
1939
+                    return '';
1940
+        }
1941
+        // $time=0 allowed (it means 01/01/1970 00:00:00)
1851 1942
 
1852 1943
 
1853 1944
 
@@ -1915,8 +2006,9 @@  discard block
 block discarded – undo
1915 2006
                 $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1916 2007
 
1917 2008
                 $ret = adodb_strftime($format, $timetouse, $to_gmt);
1918
-            } else
1919
-                $ret = 'Bad value ' . $time . ' for date';
2009
+            } else {
2010
+                            $ret = 'Bad value ' . $time . ' for date';
2011
+            }
1920 2012
         }
1921 2013
 
1922 2014
         if (preg_match('/__b__/i', $format)) {
@@ -1987,10 +2079,14 @@  discard block
 block discarded – undo
1987 2079
        // global Globals::$conf;
1988 2080
 
1989 2081
         $usealternatemethod = false;
1990
-        if ($timestamp <= 0)
1991
-            $usealternatemethod = true;    // <= 1970
1992
-        if ($timestamp >= 2145913200)
1993
-            $usealternatemethod = true;  // >= 2038
2082
+        if ($timestamp <= 0) {
2083
+                    $usealternatemethod = true;
2084
+        }
2085
+        // <= 1970
2086
+        if ($timestamp >= 2145913200) {
2087
+                    $usealternatemethod = true;
2088
+        }
2089
+        // >= 2038
1994 2090
 
1995 2091
         if ($usealternatemethod) {
1996 2092
             $arrayinfo = adodb_getdate($timestamp, $fast);
@@ -2025,27 +2121,36 @@  discard block
 block discarded – undo
2025 2121
        // global Globals::$conf;
2026 2122
 //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
2027 2123
 // Clean parameters
2028
-        if ($hour == -1 || empty($hour))
2029
-            $hour = 0;
2030
-        if ($minute == -1 || empty($minute))
2031
-            $minute = 0;
2032
-        if ($second == -1 || empty($second))
2033
-            $second = 0;
2124
+        if ($hour == -1 || empty($hour)) {
2125
+                    $hour = 0;
2126
+        }
2127
+        if ($minute == -1 || empty($minute)) {
2128
+                    $minute = 0;
2129
+        }
2130
+        if ($second == -1 || empty($second)) {
2131
+                    $second = 0;
2132
+        }
2034 2133
 
2035 2134
 // Check parameters
2036 2135
         if ($check) {
2037
-            if (!$month || !$day)
2038
-                return '';
2039
-            if ($day > 31)
2040
-                return '';
2041
-            if ($month > 12)
2042
-                return '';
2043
-            if ($hour < 0 || $hour > 24)
2044
-                return '';
2045
-            if ($minute < 0 || $minute > 60)
2046
-                return '';
2047
-            if ($second < 0 || $second > 60)
2048
-                return '';
2136
+            if (!$month || !$day) {
2137
+                            return '';
2138
+            }
2139
+            if ($day > 31) {
2140
+                            return '';
2141
+            }
2142
+            if ($month > 12) {
2143
+                            return '';
2144
+            }
2145
+            if ($hour < 0 || $hour > 24) {
2146
+                            return '';
2147
+            }
2148
+            if ($minute < 0 || $minute > 60) {
2149
+                            return '';
2150
+            }
2151
+            if ($second < 0 || $second > 60) {
2152
+                            return '';
2153
+            }
2049 2154
         }
2050 2155
 
2051 2156
         if (method_exists('DateTime', 'getTimestamp')) {
@@ -2102,8 +2207,10 @@  discard block
 block discarded – undo
2102 2207
 
2103 2208
 // Note that gmmktime and mktime return same value (GMT) when used without parameters
2104 2209
 //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() static function instead
2105
-        if ($mode == 'gmt')
2106
-            $ret = time(); // Time for now at greenwich.
2210
+        if ($mode == 'gmt') {
2211
+                    $ret = time();
2212
+        }
2213
+        // Time for now at greenwich.
2107 2214
         else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
2108 2215
             require_once DOL_BASE_PATH . '/core/lib/date.lib.php';
2109 2216
             $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
@@ -2137,8 +2244,9 @@  discard block
 block discarded – undo
2137 2244
        // global Globals::$conf, $langs;
2138 2245
         $level = 1024;
2139 2246
 
2140
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
2141
-            $shortunit = 1;
2247
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
2248
+                    $shortunit = 1;
2249
+        }
2142 2250
 
2143 2251
 // Set value text
2144 2252
         if (empty($shortvalue) || $size < ($level * 10)) {
@@ -2173,19 +2281,23 @@  discard block
 block discarded – undo
2173 2281
     {
2174 2282
        // global $langs;
2175 2283
 
2176
-        if (empty($url))
2177
-            return '';
2284
+        if (empty($url)) {
2285
+                    return '';
2286
+        }
2178 2287
 
2179 2288
         $link = '<a href="';
2180
-        if (!preg_match('/^http/i', $url))
2181
-            $link .= 'http://';
2289
+        if (!preg_match('/^http/i', $url)) {
2290
+                    $link .= 'http://';
2291
+        }
2182 2292
         $link .= $url;
2183 2293
         $link .= '"';
2184
-        if ($target)
2185
-            $link .= ' target="' . $target . '"';
2294
+        if ($target) {
2295
+                    $link .= ' target="' . $target . '"';
2296
+        }
2186 2297
         $link .= '>';
2187
-        if (!preg_match('/^http/i', $url))
2188
-            $link .= 'http://';
2298
+        if (!preg_match('/^http/i', $url)) {
2299
+                    $link .= 'http://';
2300
+        }
2189 2301
         $link .= dol_trunc($url, $max);
2190 2302
         $link .= '</a>';
2191 2303
         return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
@@ -2209,13 +2321,15 @@  discard block
 block discarded – undo
2209 2321
 
2210 2322
         $newemail = $email;
2211 2323
 
2212
-        if (empty($email))
2213
-            return '&nbsp;';
2324
+        if (empty($email)) {
2325
+                    return '&nbsp;';
2326
+        }
2214 2327
 
2215 2328
         if (!empty($addlink)) {
2216 2329
             $newemail = '<a style="text-overflow: ellipsis;" href="';
2217
-            if (!preg_match('/^mailto:/i', $email))
2218
-                $newemail .= 'mailto:';
2330
+            if (!preg_match('/^mailto:/i', $email)) {
2331
+                            $newemail .= 'mailto:';
2332
+            }
2219 2333
             $newemail .= $email;
2220 2334
             $newemail .= '">';
2221 2335
             $newemail .= dol_trunc($email, $max);
@@ -2228,13 +2342,14 @@  discard block
 block discarded – undo
2228 2342
             if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2229 2343
                 $type = 'AC_EMAIL';
2230 2344
                 $link = '';
2231
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL))
2232
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2233
-                if ($link)
2234
-                    $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2345
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) {
2346
+                                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2347
+                }
2348
+                if ($link) {
2349
+                                    $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2350
+                }
2235 2351
             }
2236
-        }
2237
-        else {
2352
+        } else {
2238 2353
             if ($showinvalid && !isValidEmail($email)) {
2239 2354
                 $langs->load("errors");
2240 2355
                 $newemail .= img_warning($langs->trans("ErrorBadEMail", $email));
@@ -2266,8 +2381,9 @@  discard block
 block discarded – undo
2266 2381
 
2267 2382
         $newskype = $value;
2268 2383
 
2269
-        if (empty($value))
2270
-            return '&nbsp;';
2384
+        if (empty($value)) {
2385
+                    return '&nbsp;';
2386
+        }
2271 2387
 
2272 2388
         if (!empty($type)) {
2273 2389
             $newskype = '<div class="divsocialnetwork inline-block valignmiddle">';
@@ -2288,13 +2404,13 @@  discard block
 block discarded – undo
2288 2404
             if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
2289 2405
                 $addlink = 'AC_SKYPE';
2290 2406
                 $link = '';
2291
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE))
2292
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2407
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) {
2408
+                                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $addlink . '&amp;contactid=' . $cid . '&amp;socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2409
+                }
2293 2410
                 $newskype .= ($link ? ' ' . $link : '');
2294 2411
             }
2295 2412
             $newskype .= '</div>';
2296
-        }
2297
-        else {
2413
+        } else {
2298 2414
             $langs->load("errors");
2299 2415
             $newskype .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value));
2300 2416
         }
@@ -2323,12 +2439,14 @@  discard block
 block discarded – undo
2323 2439
         if (empty($phone)) {
2324 2440
             return '';
2325 2441
         }
2326
-        if (empty($countrycode))
2327
-            $countrycode = $mysoc->country_code;
2442
+        if (empty($countrycode)) {
2443
+                    $countrycode = $mysoc->country_code;
2444
+        }
2328 2445
 
2329 2446
 // Short format for small screens
2330
-        if (Globals::$conf->dol_optimize_smallscreen)
2331
-            $separ = '';
2447
+        if (Globals::$conf->dol_optimize_smallscreen) {
2448
+                    $separ = '';
2449
+        }
2332 2450
 
2333 2451
         $newphone = $phone;
2334 2452
         if (strtoupper($countrycode) == "FR") {
@@ -2494,15 +2612,18 @@  discard block
 block discarded – undo
2494 2612
                 $newphone = '<a href="tel:' . $phone . '"';
2495 2613
                 $newphone .= '>' . $phone . '</a>';
2496 2614
             } else if (!empty(Globals::$conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
2497
-                if (empty($user->clicktodial_loaded))
2498
-                    $user->fetch_clicktodial();
2615
+                if (empty($user->clicktodial_loaded)) {
2616
+                                    $user->fetch_clicktodial();
2617
+                }
2499 2618
 
2500 2619
 // Define urlmask
2501 2620
                 $urlmask = 'ErrorClickToDialModuleNotConfigured';
2502
-                if (!empty(Globals::$conf->global->CLICKTODIAL_URL))
2503
-                    $urlmask = Globals::$conf->global->CLICKTODIAL_URL;
2504
-                if (!empty($user->clicktodial_url))
2505
-                    $urlmask = $user->clicktodial_url;
2621
+                if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) {
2622
+                                    $urlmask = Globals::$conf->global->CLICKTODIAL_URL;
2623
+                }
2624
+                if (!empty($user->clicktodial_url)) {
2625
+                                    $urlmask = $user->clicktodial_url;
2626
+                }
2506 2627
 
2507 2628
                 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : '');
2508 2629
                 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : '');
@@ -2517,8 +2638,9 @@  discard block
 block discarded – undo
2517 2638
                 $url = make_substitutions($url, $substitarray);
2518 2639
                 $newphonesav = $newphone;
2519 2640
                 $newphone = '<a href="' . $url . '"';
2520
-                if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET))
2521
-                    $newphone .= ' target="_blank"';
2641
+                if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) {
2642
+                                    $newphone .= ' target="_blank"';
2643
+                }
2522 2644
                 $newphone .= '>' . $newphonesav . '</a>';
2523 2645
             }
2524 2646
 
@@ -2526,12 +2648,15 @@  discard block
 block discarded – undo
2526 2648
             if (!empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2527 2649
                 $type = 'AC_TEL';
2528 2650
                 $link = '';
2529
-                if ($addlink == 'AC_FAX')
2530
-                    $type = 'AC_FAX';
2531
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE))
2532
-                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2533
-                if ($link)
2534
-                    $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2651
+                if ($addlink == 'AC_FAX') {
2652
+                                    $type = 'AC_FAX';
2653
+                }
2654
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) {
2655
+                                    $link = '<a href="' . DOL_BASE_URI . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . $type . ($cid ? '&amp;contactid=' . $cid : '') . ($socid ? '&amp;socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
2656
+                }
2657
+                if ($link) {
2658
+                                    $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2659
+                }
2535 2660
             }
2536 2661
         }
2537 2662
 
@@ -2558,15 +2683,17 @@  discard block
 block discarded – undo
2558 2683
                     $picto = '';
2559 2684
                 }
2560 2685
             }
2561
-            if ($adddivfloat)
2562
-                $rep .= '<div class="nospan float" style="margin-right: 10px">';
2563
-            else
2564
-                $rep .= '<span style="margin-right: 10px;">';
2686
+            if ($adddivfloat) {
2687
+                            $rep .= '<div class="nospan float" style="margin-right: 10px">';
2688
+            } else {
2689
+                            $rep .= '<span style="margin-right: 10px;">';
2690
+            }
2565 2691
             $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone;
2566
-            if ($adddivfloat)
2567
-                $rep .= '</div>';
2568
-            else
2569
-                $rep .= '</span>';
2692
+            if ($adddivfloat) {
2693
+                            $rep .= '</div>';
2694
+            } else {
2695
+                            $rep .= '</span>';
2696
+            }
2570 2697
         }
2571 2698
 
2572 2699
         return $rep;
@@ -2596,8 +2723,9 @@  discard block
 block discarded – undo
2596 2723
             if ($countrycode) { // If success, countrycode is us, fr, ...
2597 2724
                 if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
2598 2725
                     $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
2599
-                } else
2600
-                    $ret .= ' (' . $countrycode . ')';
2726
+                } else {
2727
+                                    $ret .= ' (' . $countrycode . ')';
2728
+                }
2601 2729
             }
2602 2730
         }
2603 2731
 
@@ -2694,26 +2822,33 @@  discard block
 block discarded – undo
2694 2822
                 $out .= $hookmanager->resPrint;
2695 2823
             }
2696 2824
             if (empty($reshook)) {
2697
-                if (empty($charfornl))
2698
-                    $out .= nl2br($address);
2699
-                else
2700
-                    $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2825
+                if (empty($charfornl)) {
2826
+                                    $out .= nl2br($address);
2827
+                } else {
2828
+                                    $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2829
+                }
2701 2830
 
2702 2831
                 $showgmap = $showomap = 0;
2703 2832
 
2704 2833
 // TODO Add a hook here
2705
-                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS))
2706
-                    $showgmap = 1;
2707
-                if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS))
2708
-                    $showgmap = 1;
2709
-                if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS))
2710
-                    $showgmap = 1;
2711
-                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS))
2712
-                    $showomap = 1;
2713
-                if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS))
2714
-                    $showomap = 1;
2715
-                if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS))
2716
-                    $showomap = 1;
2834
+                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) {
2835
+                                    $showgmap = 1;
2836
+                }
2837
+                if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
2838
+                                    $showgmap = 1;
2839
+                }
2840
+                if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
2841
+                                    $showgmap = 1;
2842
+                }
2843
+                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
2844
+                                    $showomap = 1;
2845
+                }
2846
+                if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
2847
+                                    $showomap = 1;
2848
+                }
2849
+                if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
2850
+                                    $showomap = 1;
2851
+                }
2717 2852
 
2718 2853
                 if ($showgmap) {
2719 2854
                     $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
@@ -2725,10 +2860,11 @@  discard block
 block discarded – undo
2725 2860
                 }
2726 2861
             }
2727 2862
         }
2728
-        if ($noprint)
2729
-            return $out;
2730
-        else
2731
-            print $out;
2863
+        if ($noprint) {
2864
+                    return $out;
2865
+        } else {
2866
+                    print $out;
2867
+        }
2732 2868
     }
2733 2869
 
2734 2870
     /**
@@ -2740,10 +2876,12 @@  discard block
 block discarded – undo
2740 2876
      */
2741 2877
     static function isValidEmail($address, $acceptsupervisorkey = 0)
2742 2878
     {
2743
-        if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__')
2744
-            return true;
2745
-        if (filter_var($address, FILTER_VALIDATE_EMAIL))
2746
-            return true;
2879
+        if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') {
2880
+                    return true;
2881
+        }
2882
+        if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
2883
+                    return true;
2884
+        }
2747 2885
 
2748 2886
         return false;
2749 2887
     }
@@ -2765,10 +2903,12 @@  discard block
 block discarded – undo
2765 2903
                 $mxhosts = array();
2766 2904
                 $weight = array();
2767 2905
                 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
2768
-                if (count($mxhosts) > 1)
2769
-                    return 1;
2770
-                if (count($mxhosts) == 1 && !empty($mxhosts[0]))
2771
-                    return 1;
2906
+                if (count($mxhosts) > 1) {
2907
+                                    return 1;
2908
+                }
2909
+                if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
2910
+                                    return 1;
2911
+                }
2772 2912
 
2773 2913
                 return 0;
2774 2914
             }
@@ -2797,10 +2937,11 @@  discard block
 block discarded – undo
2797 2937
      */
2798 2938
     static function dol_strlen($string, $stringencoding = 'UTF-8')
2799 2939
     {
2800
-        if (function_exists('mb_strlen'))
2801
-            return mb_strlen($string, $stringencoding);
2802
-        else
2803
-            return strlen($string);
2940
+        if (function_exists('mb_strlen')) {
2941
+                    return mb_strlen($string, $stringencoding);
2942
+        } else {
2943
+                    return strlen($string);
2944
+        }
2804 2945
     }
2805 2946
 
2806 2947
     /**
@@ -2817,8 +2958,9 @@  discard block
 block discarded – undo
2817 2958
     {
2818 2959
        // global $langs;
2819 2960
 
2820
-        if (empty($stringencoding))
2821
-            $stringencoding = $langs->charset_output;
2961
+        if (empty($stringencoding)) {
2962
+                    $stringencoding = $langs->charset_output;
2963
+        }
2822 2964
 
2823 2965
         $ret = '';
2824 2966
         if (empty($trunconbytes)) {
@@ -2854,48 +2996,55 @@  discard block
 block discarded – undo
2854 2996
     {
2855 2997
        // global Globals::$conf;
2856 2998
 
2857
-        if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC))
2858
-            return $string;
2999
+        if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) {
3000
+                    return $string;
3001
+        }
2859 3002
 
2860
-        if (empty($stringencoding))
2861
-            $stringencoding = 'UTF-8';
2862
-// reduce for small screen
2863
-        if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1)
2864
-            $size = round($size / 3);
3003
+        if (empty($stringencoding)) {
3004
+                    $stringencoding = 'UTF-8';
3005
+        }
3006
+        // reduce for small screen
3007
+        if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) {
3008
+                    $size = round($size / 3);
3009
+        }
2865 3010
 
2866 3011
 // We go always here
2867 3012
         if ($trunc == 'right') {
2868 3013
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2869
-            if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2870
-                return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
2871
-            else
2872
-//return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
2873
-                return $string;
2874
-        }
2875
-        elseif ($trunc == 'middle') {
3014
+            if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3015
+                // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3016
+                return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
3017
+            } else {
3018
+                //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string;
3019
+                return $string;
3020
+            }
3021
+        } elseif ($trunc == 'middle') {
2876 3022
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2877 3023
             if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) {
2878 3024
                 $size1 = round($size / 2);
2879 3025
                 $size2 = round($size / 2);
2880 3026
                 return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2881
-            } else
2882
-                return $string;
2883
-        }
2884
-        elseif ($trunc == 'left') {
3027
+            } else {
3028
+                            return $string;
3029
+            }
3030
+        } elseif ($trunc == 'left') {
2885 3031
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2886
-            if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3)))    // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
2887
-                return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2888
-            else
2889
-                return $string;
2890
-        }
2891
-        elseif ($trunc == 'wrap') {
3032
+            if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3033
+                // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3034
+                return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3035
+            } else {
3036
+                            return $string;
3037
+            }
3038
+        } elseif ($trunc == 'wrap') {
2892 3039
             $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2893
-            if (dol_strlen($newstring, $stringencoding) > ($size + 1))
2894
-                return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2895
-            else
2896
-                return $string;
2897
-        } else
2898
-            return 'BadParam3CallingDolTrunc';
3040
+            if (dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3041
+                            return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
3042
+            } else {
3043
+                            return $string;
3044
+            }
3045
+        } else {
3046
+                    return 'BadParam3CallingDolTrunc';
3047
+        }
2899 3048
     }
2900 3049
 
2901 3050
     /**
@@ -3105,8 +3254,9 @@  discard block
 block discarded – undo
3105 3254
     {
3106 3255
        // global Globals::$conf;
3107 3256
 
3108
-        if (!preg_match('/(\.png|\.gif)$/i', $picto))
3109
-            $picto .= '.png';
3257
+        if (!preg_match('/(\.png|\.gif)$/i', $picto)) {
3258
+                    $picto .= '.png';
3259
+        }
3110 3260
 
3111 3261
 //$path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
3112 3262
         $path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
@@ -3128,20 +3278,22 @@  discard block
 block discarded – undo
3128 3278
     {
3129 3279
        // global Globals::$conf;
3130 3280
 
3131
-        if (!preg_match('/(\.png|\.gif)$/i', $picto))
3132
-            $picto .= '.png';
3281
+        if (!preg_match('/(\.png|\.gif)$/i', $picto)) {
3282
+                    $picto .= '.png';
3283
+        }
3133 3284
 
3134
-        if ($pictoisfullpath)
3135
-            $path = $picto;
3136
-        else {
3285
+        if ($pictoisfullpath) {
3286
+                    $path = $picto;
3287
+        } else {
3137 3288
 //$path = DOL_BASE_URI . '/theme/common/' . $picto;
3138 3289
             $path = DOL_BASE_URI . '/theme/common/' . $picto;
3139 3290
 
3140 3291
             if (!empty(Globals::$conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) {
3141 3292
                 $themepath = DOL_BASE_PATH . 'theme/' . Globals::$conf->theme . '/img/' . $picto;
3142 3293
 
3143
-                if (file_exists($themepath))
3144
-                    $path = $themepath;
3294
+                if (file_exists($themepath)) {
3295
+                                    $path = $themepath;
3296
+                }
3145 3297
             }
3146 3298
         }
3147 3299
 
@@ -3180,8 +3332,9 @@  discard block
 block discarded – undo
3180 3332
                 $numaction = 0;
3181 3333
             }
3182 3334
         }
3183
-        if (!is_numeric($numaction))
3184
-            $numaction = 0;
3335
+        if (!is_numeric($numaction)) {
3336
+                    $numaction = 0;
3337
+        }
3185 3338
 
3186 3339
         return img_picto($titlealt, 'stcomm' . $numaction . '.png');
3187 3340
     }
@@ -3197,8 +3350,9 @@  discard block
 block discarded – undo
3197 3350
     {
3198 3351
        // global Globals::$conf, $langs;
3199 3352
 
3200
-        if ($titlealt == 'default')
3201
-            $titlealt = $langs->trans('Show');
3353
+        if ($titlealt == 'default') {
3354
+                    $titlealt = $langs->trans('Show');
3355
+        }
3202 3356
 
3203 3357
         return img_picto($titlealt, 'pdf' . $size . '.png');
3204 3358
     }
@@ -3214,8 +3368,9 @@  discard block
 block discarded – undo
3214 3368
     {
3215 3369
        // global Globals::$conf, $langs;
3216 3370
 
3217
-        if ($titlealt == 'default')
3218
-            $titlealt = $langs->trans('Add');
3371
+        if ($titlealt == 'default') {
3372
+                    $titlealt = $langs->trans('Add');
3373
+        }
3219 3374
 
3220 3375
         return img_picto($titlealt, 'edit_add.png', $other);
3221 3376
     }
@@ -3231,8 +3386,9 @@  discard block
 block discarded – undo
3231 3386
     {
3232 3387
        // global Globals::$conf, $langs;
3233 3388
 
3234
-        if ($titlealt == 'default')
3235
-            $titlealt = $langs->trans('Remove');
3389
+        if ($titlealt == 'default') {
3390
+                    $titlealt = $langs->trans('Remove');
3391
+        }
3236 3392
 
3237 3393
         return img_picto($titlealt, 'edit_remove.png', $other);
3238 3394
     }
@@ -3249,8 +3405,9 @@  discard block
 block discarded – undo
3249 3405
     {
3250 3406
        // global Globals::$conf, $langs;
3251 3407
 
3252
-        if ($titlealt == 'default')
3253
-            $titlealt = $langs->trans('Modify');
3408
+        if ($titlealt == 'default') {
3409
+                    $titlealt = $langs->trans('Modify');
3410
+        }
3254 3411
 
3255 3412
         return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : ''));
3256 3413
     }
@@ -3267,8 +3424,9 @@  discard block
 block discarded – undo
3267 3424
     {
3268 3425
        // global Globals::$conf, $langs;
3269 3426
 
3270
-        if ($titlealt == 'default')
3271
-            $titlealt = $langs->trans('View');
3427
+        if ($titlealt == 'default') {
3428
+                    $titlealt = $langs->trans('View');
3429
+        }
3272 3430
 
3273 3431
         $moreatt = ($float ? 'style="float: right" ' : '') . $other;
3274 3432
 
@@ -3286,8 +3444,9 @@  discard block
 block discarded – undo
3286 3444
     {
3287 3445
        // global Globals::$conf, $langs;
3288 3446
 
3289
-        if ($titlealt == 'default')
3290
-            $titlealt = $langs->trans('Delete');
3447
+        if ($titlealt == 'default') {
3448
+                    $titlealt = $langs->trans('Delete');
3449
+        }
3291 3450
 
3292 3451
         return img_picto($titlealt, 'delete.png', $other);
3293 3452
 //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>';
@@ -3303,8 +3462,9 @@  discard block
 block discarded – undo
3303 3462
     static function img_printer($titlealt = "default", $other = '')
3304 3463
     {
3305 3464
        // global Globals::$conf, $langs;
3306
-        if ($titlealt == "default")
3307
-            $titlealt = $langs->trans("Print");
3465
+        if ($titlealt == "default") {
3466
+                    $titlealt = $langs->trans("Print");
3467
+        }
3308 3468
         return img_picto($titlealt, 'printer.png', $other);
3309 3469
     }
3310 3470
 
@@ -3319,8 +3479,9 @@  discard block
 block discarded – undo
3319 3479
     {
3320 3480
        // global Globals::$conf, $langs;
3321 3481
 
3322
-        if ($titlealt == 'default')
3323
-            $titlealt = $langs->trans('Split');
3482
+        if ($titlealt == 'default') {
3483
+                    $titlealt = $langs->trans('Split');
3484
+        }
3324 3485
 
3325 3486
         return img_picto($titlealt, 'split.png', $other);
3326 3487
     }
@@ -3337,10 +3498,11 @@  discard block
 block discarded – undo
3337 3498
        // global Globals::$conf, $langs;
3338 3499
 
3339 3500
         if ($usealttitle) {
3340
-            if (is_string($usealttitle))
3341
-                $usealttitle = dol_escape_htmltag($usealttitle);
3342
-            else
3343
-                $usealttitle = $langs->trans('Info');
3501
+            if (is_string($usealttitle)) {
3502
+                            $usealttitle = dol_escape_htmltag($usealttitle);
3503
+            } else {
3504
+                            $usealttitle = $langs->trans('Info');
3505
+            }
3344 3506
         }
3345 3507
 
3346 3508
         return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"');
@@ -3356,8 +3518,9 @@  discard block
 block discarded – undo
3356 3518
     {
3357 3519
        // global Globals::$conf, $langs;
3358 3520
 
3359
-        if ($titlealt == 'default')
3360
-            $titlealt = $langs->trans('Informations');
3521
+        if ($titlealt == 'default') {
3522
+                    $titlealt = $langs->trans('Informations');
3523
+        }
3361 3524
 
3362 3525
         return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"');
3363 3526
     }
@@ -3373,8 +3536,9 @@  discard block
 block discarded – undo
3373 3536
     {
3374 3537
        // global Globals::$conf, $langs;
3375 3538
 
3376
-        if ($titlealt == 'default')
3377
-            $titlealt = $langs->trans('Warning');
3539
+        if ($titlealt == 'default') {
3540
+                    $titlealt = $langs->trans('Warning');
3541
+        }
3378 3542
 
3379 3543
 //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>';
3380 3544
         return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : ''));
@@ -3390,8 +3554,9 @@  discard block
 block discarded – undo
3390 3554
     {
3391 3555
        // global Globals::$conf, $langs;
3392 3556
 
3393
-        if ($titlealt == 'default')
3394
-            $titlealt = $langs->trans('Error');
3557
+        if ($titlealt == 'default') {
3558
+                    $titlealt = $langs->trans('Error');
3559
+        }
3395 3560
 
3396 3561
         return img_picto($titlealt, 'error.png', 'class="valigntextbottom"');
3397 3562
     }
@@ -3407,8 +3572,9 @@  discard block
 block discarded – undo
3407 3572
     {
3408 3573
        // global Globals::$conf, $langs;
3409 3574
 
3410
-        if ($titlealt == 'default')
3411
-            $titlealt = $langs->trans('Next');
3575
+        if ($titlealt == 'default') {
3576
+                    $titlealt = $langs->trans('Next');
3577
+        }
3412 3578
 
3413 3579
 //return img_picto($titlealt, 'next.png', $moreatt);
3414 3580
         return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
@@ -3425,8 +3591,9 @@  discard block
 block discarded – undo
3425 3591
     {
3426 3592
        // global Globals::$conf, $langs;
3427 3593
 
3428
-        if ($titlealt == 'default')
3429
-            $titlealt = $langs->trans('Previous');
3594
+        if ($titlealt == 'default') {
3595
+                    $titlealt = $langs->trans('Previous');
3596
+        }
3430 3597
 
3431 3598
 //return img_picto($titlealt, 'previous.png', $moreatt);
3432 3599
         return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>';
@@ -3444,8 +3611,9 @@  discard block
 block discarded – undo
3444 3611
     {
3445 3612
        // global Globals::$conf, $langs;
3446 3613
 
3447
-        if ($titlealt == 'default')
3448
-            $titlealt = $langs->trans('Down');
3614
+        if ($titlealt == 'default') {
3615
+                    $titlealt = $langs->trans('Down');
3616
+        }
3449 3617
 
3450 3618
         return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"');
3451 3619
     }
@@ -3462,8 +3630,9 @@  discard block
 block discarded – undo
3462 3630
     {
3463 3631
        // global Globals::$conf, $langs;
3464 3632
 
3465
-        if ($titlealt == 'default')
3466
-            $titlealt = $langs->trans('Up');
3633
+        if ($titlealt == 'default') {
3634
+                    $titlealt = $langs->trans('Up');
3635
+        }
3467 3636
 
3468 3637
         return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"');
3469 3638
     }
@@ -3480,8 +3649,9 @@  discard block
 block discarded – undo
3480 3649
     {
3481 3650
        // global Globals::$conf, $langs;
3482 3651
 
3483
-        if ($titlealt == 'default')
3484
-            $titlealt = $langs->trans('Left');
3652
+        if ($titlealt == 'default') {
3653
+                    $titlealt = $langs->trans('Left');
3654
+        }
3485 3655
 
3486 3656
         return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt);
3487 3657
     }
@@ -3498,8 +3668,9 @@  discard block
 block discarded – undo
3498 3668
     {
3499 3669
        // global Globals::$conf, $langs;
3500 3670
 
3501
-        if ($titlealt == 'default')
3502
-            $titlealt = $langs->trans('Right');
3671
+        if ($titlealt == 'default') {
3672
+                    $titlealt = $langs->trans('Right');
3673
+        }
3503 3674
 
3504 3675
         return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt);
3505 3676
     }
@@ -3515,11 +3686,13 @@  discard block
 block discarded – undo
3515 3686
     {
3516 3687
        // global Globals::$conf, $langs;
3517 3688
 
3518
-        if ($titlealt == 'default')
3519
-            $titlealt = $langs->trans('Active');
3689
+        if ($titlealt == 'default') {
3690
+                    $titlealt = $langs->trans('Active');
3691
+        }
3520 3692
 
3521
-        if ($allow == 1)
3522
-            return img_picto($titlealt, 'tick.png');
3693
+        if ($allow == 1) {
3694
+                    return img_picto($titlealt, 'tick.png');
3695
+        }
3523 3696
 
3524 3697
         return '-';
3525 3698
     }
@@ -3567,8 +3740,9 @@  discard block
 block discarded – undo
3567 3740
         $mimeimg = dol_mimetype($file, '', 2);
3568 3741
         $mimefa = dol_mimetype($file, '', 4);
3569 3742
 
3570
-        if (empty($titlealt))
3571
-            $titlealt = 'Mime type: ' . $mimetype;
3743
+        if (empty($titlealt)) {
3744
+                    $titlealt = 'Mime type: ' . $mimetype;
3745
+        }
3572 3746
 
3573 3747
 //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
3574 3748
         return '<i class="fa fa-' . $mimefa . ' paddingright"></i>';
@@ -3590,13 +3764,15 @@  discard block
 block discarded – undo
3590 3764
 
3591 3765
        // global Globals::$conf, $langs;
3592 3766
 
3593
-        if ($titlealt == 'default')
3594
-            $titlealt = $langs->trans('Call');
3767
+        if ($titlealt == 'default') {
3768
+                    $titlealt = $langs->trans('Call');
3769
+        }
3595 3770
 
3596
-        if ($option == 1)
3597
-            $img = 'call';
3598
-        else
3599
-            $img = 'call_out';
3771
+        if ($option == 1) {
3772
+                    $img = 'call';
3773
+        } else {
3774
+                    $img = 'call_out';
3775
+        }
3600 3776
 
3601 3777
         return img_picto($titlealt, $img);
3602 3778
     }
@@ -3612,8 +3788,9 @@  discard block
 block discarded – undo
3612 3788
     {
3613 3789
        // global Globals::$conf, $langs;
3614 3790
 
3615
-        if ($titlealt == 'default')
3616
-            $titlealt = $langs->trans('Search');
3791
+        if ($titlealt == 'default') {
3792
+                    $titlealt = $langs->trans('Search');
3793
+        }
3617 3794
 
3618 3795
         $img = img_picto($titlealt, 'search.png', $other, false, 1);
3619 3796
 
@@ -3634,8 +3811,9 @@  discard block
 block discarded – undo
3634 3811
     {
3635 3812
        // global Globals::$conf, $langs;
3636 3813
 
3637
-        if ($titlealt == 'default')
3638
-            $titlealt = $langs->trans('Search');
3814
+        if ($titlealt == 'default') {
3815
+                    $titlealt = $langs->trans('Search');
3816
+        }
3639 3817
 
3640 3818
         $img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
3641 3819
 
@@ -3697,14 +3875,16 @@  discard block
 block discarded – undo
3697 3875
 
3698 3876
         if ($_SERVER['DOCUMENT_ROOT']) {    // Mode web
3699 3877
             $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n";
3700
-            if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL))
3701
-                $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3878
+            if (!empty(Globals::$conf->global->MAIN_FEATURES_LEVEL)) {
3879
+                            $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n";
3880
+            }
3702 3881
             $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n";
3703 3882
 
3704 3883
             $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n";
3705 3884
             $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n";
3706
-            if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL))
3707
-                $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3885
+            if (isset(Globals::$conf->global->MAIN_FEATURES_LEVEL)) {
3886
+                            $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . Globals::$conf->global->MAIN_FEATURES_LEVEL . "<br>\n";
3887
+            }
3708 3888
             if (function_exists("phpversion")) {
3709 3889
                 $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n";
3710 3890
             }
@@ -3747,18 +3927,20 @@  discard block
 block discarded – undo
3747 3927
             $langs->load("errors");
3748 3928
 
3749 3929
 // Merge all into $errors array
3750
-            if (is_array($error) && is_array($errors))
3751
-                $errors = array_merge($error, $errors);
3752
-            elseif (is_array($error))
3753
-                $errors = $error;
3754
-            elseif (is_array($errors))
3755
-                $errors = array_merge(array($error), $errors);
3756
-            else
3757
-                $errors = array_merge(array($error));
3930
+            if (is_array($error) && is_array($errors)) {
3931
+                            $errors = array_merge($error, $errors);
3932
+            } elseif (is_array($error)) {
3933
+                            $errors = $error;
3934
+            } elseif (is_array($errors)) {
3935
+                            $errors = array_merge(array($error), $errors);
3936
+            } else {
3937
+                            $errors = array_merge(array($error));
3938
+            }
3758 3939
 
3759 3940
             foreach ($errors as $msg) {
3760
-                if (empty($msg))
3761
-                    continue;
3941
+                if (empty($msg)) {
3942
+                                    continue;
3943
+                }
3762 3944
                 if ($_SERVER['DOCUMENT_ROOT']) {  // Mode web
3763 3945
                     $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n";
3764 3946
                 } else {                        // Mode CLI
@@ -3776,9 +3958,9 @@  discard block
 block discarded – undo
3776 3958
             $out .= "<br>\n";
3777 3959
         }
3778 3960
 
3779
-        if (empty($dolibarr_main_prod))
3780
-            print $out;
3781
-        else {
3961
+        if (empty($dolibarr_main_prod)) {
3962
+                    print $out;
3963
+        } else {
3782 3964
             print $langs->trans("DolibarrHasDetectedError") . '. ';
3783 3965
             print $langs->trans("YouCanSetOptionDolibarrMainProdToZero");
3784 3966
             define("MAIN_CORE_ERROR", 1);
@@ -3801,16 +3983,18 @@  discard block
 block discarded – undo
3801 3983
     {
3802 3984
        // global $langs, Globals::$conf;
3803 3985
 
3804
-        if (empty($email))
3805
-            $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL;
3986
+        if (empty($email)) {
3987
+                    $email = Globals::$conf->global->MAIN_INFO_SOCIETE_MAIL;
3988
+        }
3806 3989
 
3807 3990
         $langs->load("errors");
3808 3991
         $now = dol_now();
3809 3992
 
3810 3993
         print '<br><div class="center login_main_message"><div class="' . $morecss . '">';
3811 3994
         print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d'));
3812
-        if ($errormessage)
3813
-            print '<br><br>' . $errormessage;
3995
+        if ($errormessage) {
3996
+                    print '<br><br>' . $errormessage;
3997
+        }
3814 3998
         if (is_array($errormessages) && count($errormessages)) {
3815 3999
             foreach ($errormessages as $mesgtoshow) {
3816 4000
                 print '<br><br>' . $mesgtoshow;
@@ -4053,12 +4237,15 @@  discard block
 block discarded – undo
4053 4237
         $savtotalnboflines = $totalnboflines;
4054 4238
         $totalnboflines = abs($totalnboflines);
4055 4239
 
4056
-        if ($picto == 'setup')
4057
-            $picto = 'title_setup.png';
4058
-        if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png')
4059
-            $picto = 'title.gif';
4060
-        if ($limit < 0)
4061
-            $limit = Globals::$conf->liste_limit;
4240
+        if ($picto == 'setup') {
4241
+                    $picto = 'title_setup.png';
4242
+        }
4243
+        if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') {
4244
+                    $picto = 'title.gif';
4245
+        }
4246
+        if ($limit < 0) {
4247
+                    $limit = Globals::$conf->liste_limit;
4248
+        }
4062 4249
         if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
4063 4250
             $nextpage = 1;
4064 4251
         } else {
@@ -4072,11 +4259,13 @@  discard block
 block discarded – undo
4072 4259
 // Left
4073 4260
 //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
4074 4261
         print '<td class="nobordernopadding valignmiddle">';
4075
-        if ($picto && $titre)
4076
-            print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4262
+        if ($picto && $titre) {
4263
+                    print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4264
+        }
4077 4265
         print '<div class="titre inline-block">' . $titre;
4078
-        if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '')
4079
-            print ' (' . $totalnboflines . ')';
4266
+        if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') {
4267
+                    print ' (' . $totalnboflines . ')';
4268
+        }
4080 4269
         print '</div></td>';
4081 4270
 
4082 4271
 // Center
@@ -4086,21 +4275,24 @@  discard block
 block discarded – undo
4086 4275
 
4087 4276
 // Right
4088 4277
         print '<td class="nobordernopadding valignmiddle" align="right">';
4089
-        if ($sortfield)
4090
-            $options .= "&sortfield=" . urlencode($sortfield);
4091
-        if ($sortorder)
4092
-            $options .= "&sortorder=" . urlencode($sortorder);
4093
-// Show navigation bar
4278
+        if ($sortfield) {
4279
+                    $options .= "&sortfield=" . urlencode($sortfield);
4280
+        }
4281
+        if ($sortorder) {
4282
+                    $options .= "&sortorder=" . urlencode($sortorder);
4283
+        }
4284
+        // Show navigation bar
4094 4285
         $pagelist = '';
4095 4286
         if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
4096 4287
             if ($totalnboflines) { // If we know total nb of lines
4097 4288
 // Define nb of extra page links before and after selected page + ... + first or last
4098 4289
                 $maxnbofpage = (empty(Globals::$conf->dol_optimize_smallscreen) ? 4 : 1);
4099 4290
 
4100
-                if ($limit > 0)
4101
-                    $nbpages = ceil($totalnboflines / $limit);
4102
-                else
4103
-                    $nbpages = 1;
4291
+                if ($limit > 0) {
4292
+                                    $nbpages = ceil($totalnboflines / $limit);
4293
+                } else {
4294
+                                    $nbpages = 1;
4295
+                }
4104 4296
                 $cpt = ($page - $maxnbofpage);
4105 4297
                 if ($cpt < 0) {
4106 4298
                     $cpt = 0;
@@ -4108,10 +4300,11 @@  discard block
 block discarded – undo
4108 4300
 
4109 4301
                 if ($cpt >= 1) {
4110 4302
                     $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>';
4111
-                    if ($cpt > 2)
4112
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4113
-                    else if ($cpt == 2)
4114
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4303
+                    if ($cpt > 2) {
4304
+                                            $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4305
+                    } else if ($cpt == 2) {
4306
+                                            $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4307
+                    }
4115 4308
                 }
4116 4309
 
4117 4310
                 do {
@@ -4124,14 +4317,14 @@  discard block
 block discarded – undo
4124 4317
                 } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage);
4125 4318
 
4126 4319
                 if ($cpt < $nbpages) {
4127
-                    if ($cpt < $nbpages - 2)
4128
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4129
-                    else if ($cpt == $nbpages - 2)
4130
-                        $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4320
+                    if ($cpt < $nbpages - 2) {
4321
+                                            $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4322
+                    } else if ($cpt == $nbpages - 2) {
4323
+                                            $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4324
+                    }
4131 4325
                     $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>';
4132 4326
                 }
4133
-            }
4134
-            else {
4327
+            } else {
4135 4328
                 $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>";
4136 4329
             }
4137 4330
         }
@@ -4167,18 +4360,21 @@  discard block
 block discarded – undo
4167 4360
             $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
4168 4361
 //$pagesizechoices.=',0:'.$langs->trans("All");     // Not yet supported
4169 4362
 //$pagesizechoices.=',2:2';
4170
-            if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES))
4171
-                $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES;
4363
+            if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) {
4364
+                            $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES;
4365
+            }
4172 4366
 
4173 4367
             print '<li class="pagination">';
4174 4368
             print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">';
4175 4369
             $tmpchoice = explode(',', $pagesizechoices);
4176 4370
             $tmpkey = $limit . ':' . $limit;
4177
-            if (!in_array($tmpkey, $tmpchoice))
4178
-                $tmpchoice[] = $tmpkey;
4371
+            if (!in_array($tmpkey, $tmpchoice)) {
4372
+                            $tmpchoice[] = $tmpkey;
4373
+            }
4179 4374
             $tmpkey = Globals::$conf->liste_limit . ':' . Globals::$conf->liste_limit;
4180
-            if (!in_array($tmpkey, $tmpchoice))
4181
-                $tmpchoice[] = $tmpkey;
4375
+            if (!in_array($tmpkey, $tmpchoice)) {
4376
+                            $tmpchoice[] = $tmpkey;
4377
+            }
4182 4378
             asort($tmpchoice, SORT_NUMERIC);
4183 4379
             $found = false;
4184 4380
             foreach ($tmpchoice as $val) {
@@ -4254,14 +4450,15 @@  discard block
 block discarded – undo
4254 4450
         }
4255 4451
 
4256 4452
 // If rate is '9/9/9' we don't change it.  If rate is '9.000' we apply price()
4257
-        if (!preg_match('/\//', $rate))
4258
-            $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4259
-        else {
4453
+        if (!preg_match('/\//', $rate)) {
4454
+                    $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4455
+        } else {
4260 4456
 // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
4261 4457
             $ret = $rate . ($addpercent ? '%' : '');
4262 4458
         }
4263
-        if (($info_bits & 1) && $usestarfornpr >= 0)
4264
-            $ret .= ' *';
4459
+        if (($info_bits & 1) && $usestarfornpr >= 0) {
4460
+                    $ret .= ' *';
4461
+        }
4265 4462
         $ret .= $morelabel;
4266 4463
         return $ret;
4267 4464
     }
@@ -4285,11 +4482,14 @@  discard block
 block discarded – undo
4285 4482
     {
4286 4483
        // global $langs, Globals::$conf;
4287 4484
 // Clean parameters
4288
-        if (empty($amount))
4289
-            $amount = 0; // To have a numeric value if amount not defined or = ''
4485
+        if (empty($amount)) {
4486
+                    $amount = 0;
4487
+        }
4488
+        // To have a numeric value if amount not defined or = ''
4290 4489
         $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
4291
-        if ($rounding < 0)
4292
-            $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT);
4490
+        if ($rounding < 0) {
4491
+                    $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT);
4492
+        }
4293 4493
         $nbdecimal = $rounding;
4294 4494
 
4295 4495
 // Output separators by default (french)
@@ -4297,18 +4497,22 @@  discard block
 block discarded – undo
4297 4497
         $thousand = ' ';
4298 4498
 
4299 4499
 // If $outlangs not forced, we use use language
4300
-        if (!is_object($outlangs))
4301
-            $outlangs = $langs;
4302
-
4303
-        if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4304
-            $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4305
-        if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4306
-            $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4307
-        if ($thousand == 'None')
4308
-            $thousand = '';
4309
-        else if ($thousand == 'Space')
4310
-            $thousand = ' ';
4311
-//print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4500
+        if (!is_object($outlangs)) {
4501
+                    $outlangs = $langs;
4502
+        }
4503
+
4504
+        if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4505
+                    $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4506
+        }
4507
+        if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4508
+                    $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4509
+        }
4510
+        if ($thousand == 'None') {
4511
+                    $thousand = '';
4512
+        } else if ($thousand == 'Space') {
4513
+                    $thousand = ' ';
4514
+        }
4515
+        //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4312 4516
 //print "amount=".$amount."-";
4313 4517
         $amount = str_replace(',', '.', $amount); // should be useless
4314 4518
 //print $amount."-";
@@ -4319,9 +4523,10 @@  discard block
 block discarded – undo
4319 4523
         $end = '';
4320 4524
 
4321 4525
 // We increase nbdecimal if there is more decimal than asked (to not loose information)
4322
-        if (dol_strlen($decpart) > $nbdecimal)
4323
-            $nbdecimal = dol_strlen($decpart);
4324
-// Si on depasse max
4526
+        if (dol_strlen($decpart) > $nbdecimal) {
4527
+                    $nbdecimal = dol_strlen($decpart);
4528
+        }
4529
+        // Si on depasse max
4325 4530
         if ($trunc && $nbdecimal > Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN) {
4326 4531
             $nbdecimal = Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN;
4327 4532
             if (preg_match('/\.\.\./i', Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
@@ -4331,8 +4536,9 @@  discard block
 block discarded – undo
4331 4536
         }
4332 4537
 
4333 4538
 // If force rounding
4334
-        if ($forcerounding >= 0)
4335
-            $nbdecimal = $forcerounding;
4539
+        if ($forcerounding >= 0) {
4540
+                    $nbdecimal = $forcerounding;
4541
+        }
4336 4542
 
4337 4543
 // Format number
4338 4544
         $output = number_format($amount, $nbdecimal, $dec, $thousand);
@@ -4343,13 +4549,14 @@  discard block
 block discarded – undo
4343 4549
 // Add symbol of currency if requested
4344 4550
         $cursymbolbefore = $cursymbolafter = '';
4345 4551
         if ($currency_code) {
4346
-            if ($currency_code == 'auto')
4347
-                $currency_code = Globals::$conf->currency;
4552
+            if ($currency_code == 'auto') {
4553
+                            $currency_code = Globals::$conf->currency;
4554
+            }
4348 4555
 
4349 4556
             $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
4350
-            if (in_array($currency_code, $listofcurrenciesbefore))
4351
-                $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4352
-            else {
4557
+            if (in_array($currency_code, $listofcurrenciesbefore)) {
4558
+                            $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4559
+            } else {
4353 4560
                 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4354 4561
                 $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
4355 4562
             }
@@ -4382,15 +4589,18 @@  discard block
 block discarded – undo
4382 4589
 // Decimal delimiter for PHP and database SQL requests must be '.'
4383 4590
         $dec = ',';
4384 4591
         $thousand = ' ';
4385
-        if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4386
-            $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
4387
-        if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4388
-            $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
4389
-        if ($thousand == 'None')
4390
-            $thousand = '';
4391
-        elseif ($thousand == 'Space')
4392
-            $thousand = ' ';
4393
-//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4592
+        if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4593
+                    $dec = $langs->transnoentitiesnoconv("SeparatorDecimal");
4594
+        }
4595
+        if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4596
+                    $thousand = $langs->transnoentitiesnoconv("SeparatorThousand");
4597
+        }
4598
+        if ($thousand == 'None') {
4599
+                    $thousand = '';
4600
+        } elseif ($thousand == 'Space') {
4601
+                    $thousand = ' ';
4602
+        }
4603
+        //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4394 4604
 // Convert value to universal number format (no thousand separator, '.' as decimal separator)
4395 4605
         if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
4396 4606
 //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
@@ -4405,8 +4615,10 @@  discard block
 block discarded – undo
4405 4615
             }
4406 4616
 //print "QQ".$amount.'<br>';
4407 4617
 // Now make replace (the main goal of function)
4408
-            if ($thousand != ',' && $thousand != '.')
4409
-                $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4618
+            if ($thousand != ',' && $thousand != '.') {
4619
+                            $amount = str_replace(',', '.', $amount);
4620
+            }
4621
+            // To accept 2 notations for french users
4410 4622
             $amount = str_replace(' ', '', $amount);  // To avoid spaces
4411 4623
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4412 4624
             $amount = str_replace($dec, '.', $amount);
@@ -4415,20 +4627,24 @@  discard block
 block discarded – undo
4415 4627
 // Now, make a rounding if required
4416 4628
         if ($rounding) {
4417 4629
             $nbofdectoround = '';
4418
-            if ($rounding == 'MU')
4419
-                $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT;
4420
-            elseif ($rounding == 'MT')
4421
-                $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT;
4422
-            elseif ($rounding == 'MS')
4423
-                $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK;
4424
-            elseif (is_numeric($rounding))
4425
-                $nbofdectoround = $rounding;
4426
-//print "RR".$amount.' - '.$nbofdectoround.'<br>';
4427
-            if (dol_strlen($nbofdectoround))
4428
-                $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0.
4429
-            else
4430
-                return 'ErrorBadParameterProvidedToFunction';
4431
-//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
4630
+            if ($rounding == 'MU') {
4631
+                            $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT;
4632
+            } elseif ($rounding == 'MT') {
4633
+                            $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT;
4634
+            } elseif ($rounding == 'MS') {
4635
+                            $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK;
4636
+            } elseif (is_numeric($rounding)) {
4637
+                            $nbofdectoround = $rounding;
4638
+            }
4639
+            //print "RR".$amount.' - '.$nbofdectoround.'<br>';
4640
+            if (dol_strlen($nbofdectoround)) {
4641
+                            $amount = round($amount, $nbofdectoround);
4642
+            }
4643
+            // $nbofdectoround can be 0.
4644
+            else {
4645
+                            return 'ErrorBadParameterProvidedToFunction';
4646
+            }
4647
+            //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
4432 4648
 // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
4433 4649
 // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
4434 4650
             if (is_numeric($amount)) {
@@ -4441,8 +4657,10 @@  discard block
 block discarded – undo
4441 4657
 //print "TT".$amount.'<br>';
4442 4658
 // Always make replace because each math static function (like round) replace
4443 4659
 // with local values and we want a number that has a SQL string format x.y
4444
-            if ($thousand != ',' && $thousand != '.')
4445
-                $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4660
+            if ($thousand != ',' && $thousand != '.') {
4661
+                            $amount = str_replace(',', '.', $amount);
4662
+            }
4663
+            // To accept 2 notations for french users
4446 4664
             $amount = str_replace(' ', '', $amount);  // To avoid spaces
4447 4665
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4448 4666
             $amount = str_replace($dec, '.', $amount);
@@ -4501,8 +4719,9 @@  discard block
 block discarded – undo
4501 4719
     {
4502 4720
        // global $db, Globals::$conf, $mysoc;
4503 4721
 
4504
-        if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4505
-            $thirdparty_seller = $mysoc;
4722
+        if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
4723
+                    $thirdparty_seller = $mysoc;
4724
+        }
4506 4725
 
4507 4726
         dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . "  thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj);
4508 4727
 
@@ -4520,37 +4739,43 @@  discard block
 block discarded – undo
4520 4739
 // Some test to guess with no need to make database access
4521 4740
         if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
4522 4741
             if ($local == 1) {
4523
-                if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0")
4524
-                    return 0;
4742
+                if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") {
4743
+                                    return 0;
4744
+                }
4525 4745
                 if ($thirdparty_seller->id == $mysoc->id) {
4526
-                    if (!$thirdparty_buyer->localtax1_assuj)
4527
-                        return 0;
4528
-                }
4529
-                else {
4530
-                    if (!$thirdparty_seller->localtax1_assuj)
4531
-                        return 0;
4746
+                    if (!$thirdparty_buyer->localtax1_assuj) {
4747
+                                            return 0;
4748
+                    }
4749
+                } else {
4750
+                    if (!$thirdparty_seller->localtax1_assuj) {
4751
+                                            return 0;
4752
+                    }
4532 4753
                 }
4533 4754
             }
4534 4755
 
4535 4756
             if ($local == 2) {
4536 4757
 //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0;
4537
-                if (!$mysoc->localtax2_assuj)
4538
-                    return 0;  // If main vat is 0, IRPF may be different than 0.
4758
+                if (!$mysoc->localtax2_assuj) {
4759
+                                    return 0;
4760
+                }
4761
+                // If main vat is 0, IRPF may be different than 0.
4539 4762
                 if ($thirdparty_seller->id == $mysoc->id) {
4540
-                    if (!$thirdparty_buyer->localtax2_assuj)
4541
-                        return 0;
4542
-                }
4543
-                else {
4544
-                    if (!$thirdparty_seller->localtax2_assuj)
4545
-                        return 0;
4763
+                    if (!$thirdparty_buyer->localtax2_assuj) {
4764
+                                            return 0;
4765
+                    }
4766
+                } else {
4767
+                    if (!$thirdparty_seller->localtax2_assuj) {
4768
+                                            return 0;
4769
+                    }
4546 4770
                 }
4547 4771
             }
4548
-        }
4549
-        else {
4550
-            if ($local == 1 && !$thirdparty_seller->localtax1_assuj)
4551
-                return 0;
4552
-            if ($local == 2 && !$thirdparty_seller->localtax2_assuj)
4553
-                return 0;
4772
+        } else {
4773
+            if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
4774
+                            return 0;
4775
+            }
4776
+            if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
4777
+                            return 0;
4778
+            }
4554 4779
         }
4555 4780
 
4556 4781
 // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on.
@@ -4592,19 +4817,23 @@  discard block
 block discarded – undo
4592 4817
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4593 4818
         $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'";
4594 4819
         $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4595
-        if ($vatratecode)
4596
-            $sql .= " AND t.code ='" . $vatratecode . "'";  // If we have the code, we use it in priority
4597
-        else
4598
-            $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4820
+        if ($vatratecode) {
4821
+                    $sql .= " AND t.code ='" . $vatratecode . "'";
4822
+        }
4823
+        // If we have the code, we use it in priority
4824
+        else {
4825
+                    $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4826
+        }
4599 4827
         dol_syslog("get_localtax", LOG_DEBUG);
4600 4828
         $resql = $db->query($sql);
4601 4829
 
4602 4830
         if ($resql) {
4603 4831
             $obj = $db->fetch_object($resql);
4604
-            if ($local == 1)
4605
-                return $obj->localtax1;
4606
-            elseif ($local == 2)
4607
-                return $obj->localtax2;
4832
+            if ($local == 1) {
4833
+                            return $obj->localtax1;
4834
+            } elseif ($local == 2) {
4835
+                            return $obj->localtax2;
4836
+            }
4608 4837
         }
4609 4838
 
4610 4839
         return 0;
@@ -4650,10 +4879,11 @@  discard block
 block discarded – undo
4650 4879
         $resql = $db->query($sql);
4651 4880
         if ($resql) {
4652 4881
             $obj = $db->fetch_object($resql);
4653
-            if ($local == 1)
4654
-                return $obj->localtax1;
4655
-            elseif ($local == 2)
4656
-                return $obj->localtax2;
4882
+            if ($local == 1) {
4883
+                            return $obj->localtax1;
4884
+            } elseif ($local == 2) {
4885
+                            return $obj->localtax2;
4886
+            }
4657 4887
         }
4658 4888
 
4659 4889
         return 0;
@@ -4679,9 +4909,9 @@  discard block
 block discarded – undo
4679 4909
 // Search local taxes
4680 4910
         $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
4681 4911
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4682
-        if ($firstparamisid)
4683
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4684
-        else {
4912
+        if ($firstparamisid) {
4913
+                    $sql .= " WHERE t.rowid = " . (int) $vatrate;
4914
+        } else {
4685 4915
             $vatratecleaned = $vatrate;
4686 4916
             $vatratecode = '';
4687 4917
             if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
@@ -4694,19 +4924,22 @@  discard block
 block discarded – undo
4694 4924
               else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */
4695 4925
             $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4696 4926
             $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4697
-            if ($vatratecode)
4698
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4927
+            if ($vatratecode) {
4928
+                            $sql .= " AND t.code = '" . $vatratecode . "'";
4929
+            }
4699 4930
         }
4700 4931
 
4701 4932
         $resql = $db->query($sql);
4702 4933
         if ($resql) {
4703 4934
             $obj = $db->fetch_object($resql);
4704
-            if ($obj)
4705
-                return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
4706
-            else
4707
-                return array();
4708
-        } else
4709
-            dol_print_error($db);
4935
+            if ($obj) {
4936
+                            return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy);
4937
+            } else {
4938
+                            return array();
4939
+            }
4940
+        } else {
4941
+                    dol_print_error($db);
4942
+        }
4710 4943
 
4711 4944
         return array();
4712 4945
     }
@@ -4736,9 +4969,9 @@  discard block
 block discarded – undo
4736 4969
 // Search local taxes
4737 4970
         $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
4738 4971
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4739
-        if ($firstparamisid)
4740
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4741
-        else {
4972
+        if ($firstparamisid) {
4973
+                    $sql .= " WHERE t.rowid = " . (int) $vatrate;
4974
+        } else {
4742 4975
             $vatratecleaned = $vatrate;
4743 4976
             $vatratecode = '';
4744 4977
             if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "x.x (yy)"
@@ -4747,13 +4980,17 @@  discard block
 block discarded – undo
4747 4980
             }
4748 4981
 
4749 4982
             $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4750
-            if ($mysoc->country_code == 'ES')
4751
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";    // local tax in spain use the buyer country ??
4752
-            else
4753
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4983
+            if ($mysoc->country_code == 'ES') {
4984
+                            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
4985
+            }
4986
+            // local tax in spain use the buyer country ??
4987
+            else {
4988
+                            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4989
+            }
4754 4990
             $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4755
-            if ($vatratecode)
4756
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4991
+            if ($vatratecode) {
4992
+                            $sql .= " AND t.code = '" . $vatratecode . "'";
4993
+            }
4757 4994
         }
4758 4995
 
4759 4996
         $resql = $db->query($sql);
@@ -4799,17 +5036,17 @@  discard block
 block discarded – undo
4799 5036
                 if ($idprodfournprice > 0) {     // We want vat for product for a "supplier" object
4800 5037
                     $product->get_buyprice($idprodfournprice, 0, 0, 0);
4801 5038
                     $ret = $product->vatrate_supplier;
4802
-                    if ($product->default_vat_code)
4803
-                        $ret .= ' (' . $product->default_vat_code . ')';
4804
-                }
4805
-                else {
5039
+                    if ($product->default_vat_code) {
5040
+                                            $ret .= ' (' . $product->default_vat_code . ')';
5041
+                    }
5042
+                } else {
4806 5043
                     $ret = $product->tva_tx;    // Default vat of product we defined
4807
-                    if ($product->default_vat_code)
4808
-                        $ret .= ' (' . $product->default_vat_code . ')';
5044
+                    if ($product->default_vat_code) {
5045
+                                            $ret .= ' (' . $product->default_vat_code . ')';
5046
+                    }
4809 5047
                 }
4810 5048
                 $found = 1;
4811
-            }
4812
-            else {
5049
+            } else {
4813 5050
 // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
4814 5051
 // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on
4815 5052
             }
@@ -4829,14 +5066,18 @@  discard block
 block discarded – undo
4829 5066
                     $obj = $db->fetch_object($resql);
4830 5067
                     if ($obj) {
4831 5068
                         $ret = $obj->vat_rate;
4832
-                        if ($obj->default_vat_code)
4833
-                            $ret .= ' (' . $obj->default_vat_code . ')';
5069
+                        if ($obj->default_vat_code) {
5070
+                                                    $ret .= ' (' . $obj->default_vat_code . ')';
5071
+                        }
4834 5072
                     }
4835 5073
                     $db->free($sql);
4836
-                } else
4837
-                    dol_print_error($db);
4838
-            } else
4839
-                $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;    // Forced value if autodetect fails
5074
+                } else {
5075
+                                    dol_print_error($db);
5076
+                }
5077
+            } else {
5078
+                            $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
5079
+            }
5080
+            // Forced value if autodetect fails
4840 5081
         }
4841 5082
 
4842 5083
         dol_syslog("get_product_vat_for_country: ret=" . $ret);
@@ -4891,13 +5132,15 @@  discard block
 block discarded – undo
4891 5132
             if ($resql) {
4892 5133
                 $obj = $db->fetch_object($resql);
4893 5134
                 if ($obj) {
4894
-                    if ($local == 1)
4895
-                        $ret = $obj->localtax1;
4896
-                    elseif ($local == 2)
4897
-                        $ret = $obj->localtax2;
5135
+                    if ($local == 1) {
5136
+                                            $ret = $obj->localtax1;
5137
+                    } elseif ($local == 2) {
5138
+                                            $ret = $obj->localtax2;
5139
+                    }
4898 5140
                 }
4899
-            } else
4900
-                dol_print_error($db);
5141
+            } else {
5142
+                            dol_print_error($db);
5143
+            }
4901 5144
         }
4902 5145
 
4903 5146
         dol_syslog("get_product_localtax_for_country: ret=" . $ret);
@@ -5000,15 +5243,16 @@  discard block
 block discarded – undo
5000 5243
        // global $db;
5001 5244
 
5002 5245
         if ($idprodfournprice > 0) {
5003
-            if (!class_exists('ProductFournisseur'))
5004
-                require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5246
+            if (!class_exists('ProductFournisseur')) {
5247
+                            require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5248
+            }
5005 5249
             $prodprice = new ProductFournisseur($db);
5006 5250
             $prodprice->fetch_product_fournisseur_price($idprodfournprice);
5007 5251
             return $prodprice->fourn_tva_npr;
5008
-        }
5009
-        elseif ($idprod > 0) {
5010
-            if (!class_exists('Product'))
5011
-                require_once DOL_BASE_PATH . 'product/class/product.class.php';
5252
+        } elseif ($idprod > 0) {
5253
+            if (!class_exists('Product')) {
5254
+                            require_once DOL_BASE_PATH . 'product/class/product.class.php';
5255
+            }
5012 5256
             $prod = new Product($db);
5013 5257
             $prod->fetch($idprod);
5014 5258
             return $prod->tva_npr;
@@ -5034,30 +5278,35 @@  discard block
 block discarded – undo
5034 5278
     {
5035 5279
        // global $mysoc;
5036 5280
 
5037
-        if (!is_object($thirdparty_seller))
5038
-            return -1;
5039
-        if (!is_object($thirdparty_buyer))
5040
-            return -1;
5281
+        if (!is_object($thirdparty_seller)) {
5282
+                    return -1;
5283
+        }
5284
+        if (!is_object($thirdparty_buyer)) {
5285
+                    return -1;
5286
+        }
5041 5287
 
5042 5288
         if ($local == 1) { // Localtax 1
5043 5289
             if ($mysoc->country_code == 'ES') {
5044
-                if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj)
5045
-                    return 0;
5046
-            }
5047
-            else {
5290
+                if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
5291
+                                    return 0;
5292
+                }
5293
+            } else {
5048 5294
 // Si vendeur non assujeti a Localtax1, localtax1 par default=0
5049
-                if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj)
5050
-                    return 0;
5051
-                if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off')
5052
-                    return 0;
5053
-            }
5054
-        }
5055
-        elseif ($local == 2) { //I Localtax 2
5295
+                if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
5296
+                                    return 0;
5297
+                }
5298
+                if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') {
5299
+                                    return 0;
5300
+                }
5301
+            }
5302
+        } elseif ($local == 2) { //I Localtax 2
5056 5303
 // Si vendeur non assujeti a Localtax2, localtax2 par default=0
5057
-            if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj)
5058
-                return 0;
5059
-            if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off')
5060
-                return 0;
5304
+            if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
5305
+                            return 0;
5306
+            }
5307
+            if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') {
5308
+                            return 0;
5309
+            }
5061 5310
         }
5062 5311
 
5063 5312
         if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
@@ -5082,31 +5331,38 @@  discard block
 block discarded – undo
5082 5331
         $classname = '';
5083 5332
         if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') {  // A mettre avant test sur no a cause du == 0
5084 5333
             $result = $langs->trans('yes');
5085
-            if ($case == 1 || $case == 3)
5086
-                $result = $langs->trans("Yes");
5087
-            if ($case == 2)
5088
-                $result = '<input type="checkbox" value="1" checked disabled>';
5089
-            if ($case == 3)
5090
-                $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5334
+            if ($case == 1 || $case == 3) {
5335
+                            $result = $langs->trans("Yes");
5336
+            }
5337
+            if ($case == 2) {
5338
+                            $result = '<input type="checkbox" value="1" checked disabled>';
5339
+            }
5340
+            if ($case == 3) {
5341
+                            $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5342
+            }
5091 5343
 
5092 5344
             $classname = 'ok';
5093
-        }
5094
-        elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5345
+        } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5095 5346
             $result = $langs->trans("no");
5096
-            if ($case == 1 || $case == 3)
5097
-                $result = $langs->trans("No");
5098
-            if ($case == 2)
5099
-                $result = '<input type="checkbox" value="0" disabled>';
5100
-            if ($case == 3)
5101
-                $result = '<input type="checkbox" value="0" disabled> ' . $result;
5102
-
5103
-            if ($color == 2)
5104
-                $classname = 'ok';
5105
-            else
5106
-                $classname = 'error';
5107
-        }
5108
-        if ($color)
5109
-            return '<font class="' . $classname . '">' . $result . '</font>';
5347
+            if ($case == 1 || $case == 3) {
5348
+                            $result = $langs->trans("No");
5349
+            }
5350
+            if ($case == 2) {
5351
+                            $result = '<input type="checkbox" value="0" disabled>';
5352
+            }
5353
+            if ($case == 3) {
5354
+                            $result = '<input type="checkbox" value="0" disabled> ' . $result;
5355
+            }
5356
+
5357
+            if ($color == 2) {
5358
+                            $classname = 'ok';
5359
+            } else {
5360
+                            $classname = 'error';
5361
+            }
5362
+        }
5363
+        if ($color) {
5364
+                    return '<font class="' . $classname . '">' . $result . '</font>';
5365
+        }
5110 5366
         return $result;
5111 5367
     }
5112 5368
 
@@ -5132,23 +5388,27 @@  discard block
 block discarded – undo
5132 5388
         $path = '';
5133 5389
 
5134 5390
         $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
5135
-        if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
5136
-            $arrayforoldpath[] = 'product';
5391
+        if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
5392
+                    $arrayforoldpath[] = 'product';
5393
+        }
5137 5394
         if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
5138 5395
 // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided.
5139
-            if (empty($alpha))
5140
-                $num = preg_replace('/([^0-9])/i', '', $num);
5141
-            else
5142
-                $num = preg_replace('/^.*\-/i', '', $num);
5396
+            if (empty($alpha)) {
5397
+                            $num = preg_replace('/([^0-9])/i', '', $num);
5398
+            } else {
5399
+                            $num = preg_replace('/^.*\-/i', '', $num);
5400
+            }
5143 5401
             $num = substr("000" . $num, -$level);
5144
-            if ($level == 1)
5145
-                $path = substr($num, 0, 1);
5146
-            if ($level == 2)
5147
-                $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5148
-            if ($level == 3)
5149
-                $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5150
-        }
5151
-        else {
5402
+            if ($level == 1) {
5403
+                            $path = substr($num, 0, 1);
5404
+            }
5405
+            if ($level == 2) {
5406
+                            $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5407
+            }
5408
+            if ($level == 3) {
5409
+                            $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5410
+            }
5411
+        } else {
5152 5412
 // TODO
5153 5413
 // We will enhance here a common way of forging path for document storage
5154 5414
 // Here, object->id, object->ref and modulepart are required.
@@ -5159,8 +5419,9 @@  discard block
 block discarded – undo
5159 5419
             }
5160 5420
         }
5161 5421
 
5162
-        if (empty($withoutslash) && !empty($path))
5163
-            $path .= '/';
5422
+        if (empty($withoutslash) && !empty($path)) {
5423
+                    $path .= '/';
5424
+        }
5164 5425
 
5165 5426
         return $path;
5166 5427
     }
@@ -5180,8 +5441,9 @@  discard block
 block discarded – undo
5180 5441
         dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5181 5442
 
5182 5443
         $dir_osencoded = dol_osencode($dir);
5183
-        if (@is_dir($dir_osencoded))
5184
-            return 0;
5444
+        if (@is_dir($dir_osencoded)) {
5445
+                    return 0;
5446
+        }
5185 5447
 
5186 5448
         $nberr = 0;
5187 5449
         $nbcreated = 0;
@@ -5196,12 +5458,15 @@  discard block
 block discarded – undo
5196 5458
         $cdir = explode("/", $dir);
5197 5459
         $num = count($cdir);
5198 5460
         for ($i = 0; $i < $num; $i++) {
5199
-            if ($i > 0)
5200
-                $ccdir .= '/' . $cdir[$i];
5201
-            else
5202
-                $ccdir .= $cdir[$i];
5203
-            if (preg_match("/^.:$/", $ccdir, $regs))
5204
-                continue; // Si chemin Windows incomplet, on poursuit par rep suivant
5461
+            if ($i > 0) {
5462
+                            $ccdir .= '/' . $cdir[$i];
5463
+            } else {
5464
+                            $ccdir .= $cdir[$i];
5465
+            }
5466
+            if (preg_match("/^.:$/", $ccdir, $regs)) {
5467
+                            continue;
5468
+            }
5469
+            // Si chemin Windows incomplet, on poursuit par rep suivant
5205 5470
 
5206 5471
 
5207 5472
 
@@ -5293,8 +5558,9 @@  discard block
 block discarded – undo
5293 5558
      */
5294 5559
     static function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0)
5295 5560
     {
5296
-        if ($removelinefeed == 2)
5297
-            $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5561
+        if ($removelinefeed == 2) {
5562
+                    $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5563
+        }
5298 5564
         $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
5299 5565
 
5300 5566
         if ($strip_tags) {
@@ -5311,8 +5577,9 @@  discard block
 block discarded – undo
5311 5577
         $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
5312 5578
 
5313 5579
 // Supprime aussi les retours
5314
-        if ($removelinefeed == 1)
5315
-            $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5580
+        if ($removelinefeed == 1) {
5581
+                    $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5582
+        }
5316 5583
 
5317 5584
 // et les espaces doubles
5318 5585
         while (strpos($temp, "  ")) {
@@ -5398,18 +5665,21 @@  discard block
 block discarded – undo
5398 5665
             if ($charset == 'UTF-8') {
5399 5666
                 $pattern = '/(<br[^>]*>)/Uu';
5400 5667
             } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5401
-            else
5402
-                $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5668
+            else {
5669
+                            $pattern = '/(<br[^>]*>)/U';
5670
+            }
5671
+            // /U is to have UNGREEDY regex to limit to one html tag.
5403 5672
             $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5404 5673
 
5405 5674
             $firstline = '';
5406 5675
             $i = 0;
5407 5676
             $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
5408 5677
             while (($i < $nba) && ($i < ($nboflines * 2))) {
5409
-                if ($i % 2 == 0)
5410
-                    $firstline .= $a[$i];
5411
-                elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1)))
5412
-                    $firstline .= ($ishtml ? "<br>\n" : "\n");
5678
+                if ($i % 2 == 0) {
5679
+                                    $firstline .= $a[$i];
5680
+                } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
5681
+                                    $firstline .= ($ishtml ? "<br>\n" : "\n");
5682
+                }
5413 5683
                 $i++;
5414 5684
             }
5415 5685
             unset($a);
@@ -5458,15 +5728,18 @@  discard block
 block discarded – undo
5458 5728
         $newstring = $stringtoencode;
5459 5729
         if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
5460 5730
             $newstring = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
5461
-            if ($removelasteolbr)
5462
-                $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
5731
+            if ($removelasteolbr) {
5732
+                            $newstring = preg_replace('/<br>$/i', '', $newstring);
5733
+            }
5734
+            // Remove last <br> (remove only last one)
5463 5735
             $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
5464 5736
             $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding
5465 5737
             $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
5466
-        }
5467
-        else {
5468
-            if ($removelasteolbr)
5469
-                $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
5738
+        } else {
5739
+            if ($removelasteolbr) {
5740
+                            $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring);
5741
+            }
5742
+            // Remove last \n (may remove several)
5470 5743
             $newstring = dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode);
5471 5744
         }
5472 5745
 // Other substitutions that htmlentities does not do
@@ -5568,8 +5841,9 @@  discard block
 block discarded – undo
5568 5841
      */
5569 5842
     static function dol_nboflines($s, $maxchar = 0)
5570 5843
     {
5571
-        if ($s == '')
5572
-            return 0;
5844
+        if ($s == '') {
5845
+                    return 0;
5846
+        }
5573 5847
         $arraystring = explode("\n", $s);
5574 5848
         $nb = count($arraystring);
5575 5849
 
@@ -5588,15 +5862,18 @@  discard block
 block discarded – undo
5588 5862
     static function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
5589 5863
     {
5590 5864
         $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
5591
-        if (dol_textishtml($text))
5592
-            $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5865
+        if (dol_textishtml($text)) {
5866
+                    $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5867
+        }
5593 5868
 
5594 5869
         $text = strtr($text, $repTable);
5595 5870
         if ($charset == 'UTF-8') {
5596 5871
             $pattern = '/(<br[^>]*>)/Uu';
5597 5872
         } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5598
-        else
5599
-            $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5873
+        else {
5874
+                    $pattern = '/(<br[^>]*>)/U';
5875
+        }
5876
+        // /U is to have UNGREEDY regex to limit to one html tag.
5600 5877
         $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5601 5878
 
5602 5879
         $nblines = (int) floor((count($a) + 1) / 2);
@@ -5643,39 +5920,47 @@  discard block
 block discarded – undo
5643 5920
     static function dol_textishtml($msg, $option = 0)
5644 5921
     {
5645 5922
         if ($option == 1) {
5646
-            if (preg_match('/<html/i', $msg))
5647
-                return true;
5648
-            elseif (preg_match('/<body/i', $msg))
5649
-                return true;
5650
-            elseif (preg_match('/<br/i', $msg))
5651
-                return true;
5923
+            if (preg_match('/<html/i', $msg)) {
5924
+                            return true;
5925
+            } elseif (preg_match('/<body/i', $msg)) {
5926
+                            return true;
5927
+            } elseif (preg_match('/<br/i', $msg)) {
5928
+                            return true;
5929
+            }
5652 5930
             return false;
5653
-        }
5654
-        else {
5655
-            if (preg_match('/<html/i', $msg))
5656
-                return true;
5657
-            elseif (preg_match('/<body/i', $msg))
5658
-                return true;
5659
-            elseif (preg_match('/<(b|em|i|u)>/i', $msg))
5660
-                return true;
5661
-            elseif (preg_match('/<br\/>/i', $msg))
5662
-                return true;
5663
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
5664
-                return true;
5665
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
5666
-                return true;
5667
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
5668
-                return true;
5669
-            elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
5670
-                return true; // must accept <img src="http://example.com/aaa.png" />
5671
-            elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
5672
-                return true; // must accept <a href="http://example.com/aaa.png" />
5673
-            elseif (preg_match('/<h[0-9]>/i', $msg))
5674
-                return true;
5675
-            elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
5676
-                return true;    // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5677
-            elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
5678
-                return true;    // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5931
+        } else {
5932
+            if (preg_match('/<html/i', $msg)) {
5933
+                            return true;
5934
+            } elseif (preg_match('/<body/i', $msg)) {
5935
+                            return true;
5936
+            } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) {
5937
+                            return true;
5938
+            } elseif (preg_match('/<br\/>/i', $msg)) {
5939
+                            return true;
5940
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
5941
+                            return true;
5942
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) {
5943
+                            return true;
5944
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) {
5945
+                            return true;
5946
+            } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
5947
+                            return true;
5948
+            }
5949
+            // must accept <img src="http://example.com/aaa.png" />
5950
+            elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
5951
+                            return true;
5952
+            }
5953
+            // must accept <a href="http://example.com/aaa.png" />
5954
+            elseif (preg_match('/<h[0-9]>/i', $msg)) {
5955
+                            return true;
5956
+            } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) {
5957
+                            return true;
5958
+            }
5959
+            // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5960
+            elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) {
5961
+                            return true;
5962
+            }
5963
+            // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5679 5964
 
5680 5965
             return false;
5681 5966
         }
@@ -5827,12 +6112,14 @@  discard block
 block discarded – undo
5827 6112
                 $birthday = dol_print_date($object->birth, 'day');
5828 6113
 
5829 6114
                 $substitutionarray['__MEMBER_ID__'] = $object->id;
5830
-                if (method_exists($object, 'getCivilityLabel'))
5831
-                    $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6115
+                if (method_exists($object, 'getCivilityLabel')) {
6116
+                                    $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6117
+                }
5832 6118
                 $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->firstname) : $object->firstname;
5833 6119
                 $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->lastname) : $object->lastname;
5834
-                if (method_exists($object, 'getFullName'))
5835
-                    $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6120
+                if (method_exists($object, 'getFullName')) {
6121
+                                    $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6122
+                }
5836 6123
                 $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe;
5837 6124
                 $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address;
5838 6125
                 $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip;
@@ -5880,10 +6167,12 @@  discard block
 block discarded – undo
5880 6167
                     $dateplannedstart = '';
5881 6168
                     $datenextexpiration = '';
5882 6169
                     foreach ($object->lines as $line) {
5883
-                        if ($line->date_ouverture_prevue > $dateplannedstart)
5884
-                            $dateplannedstart = $line->date_ouverture_prevue;
5885
-                        if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration))
5886
-                            $datenextexpiration = $line->date_fin_prevue;
6170
+                        if ($line->date_ouverture_prevue > $dateplannedstart) {
6171
+                                                    $dateplannedstart = $line->date_ouverture_prevue;
6172
+                        }
6173
+                        if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) {
6174
+                                                    $datenextexpiration = $line->date_fin_prevue;
6175
+                        }
5887 6176
                     }
5888 6177
                     $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
5889 6178
                     $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
@@ -5893,8 +6182,9 @@  discard block
 block discarded – undo
5893 6182
 
5894 6183
 // Create dynamic tags for __EXTRAFIELD_FIELD__
5895 6184
                 if ($object->table_element && $object->id > 0) {
5896
-                    if (!is_object($extrafields))
5897
-                        $extrafields = new ExtraFields($db);
6185
+                    if (!is_object($extrafields)) {
6186
+                                            $extrafields = new ExtraFields($db);
6187
+                    }
5898 6188
                     $extrafields->fetch_name_optionals_label($object->table_element, true);
5899 6189
 
5900 6190
                     if ($object->fetch_optionals() > 0) {
@@ -5915,12 +6205,15 @@  discard block
 block discarded – undo
5915 6205
                     require_once DOL_BASE_PATH . '/core/lib/payments.lib.php';
5916 6206
                     $outputlangs->loadLangs(array('paypal', 'other'));
5917 6207
                     $typeforonlinepayment = 'free';
5918
-                    if (is_object($object) && $object->element == 'commande')
5919
-                        $typeforonlinepayment = 'order';
5920
-                    if (is_object($object) && $object->element == 'facture')
5921
-                        $typeforonlinepayment = 'invoice';
5922
-                    if (is_object($object) && $object->element == 'member')
5923
-                        $typeforonlinepayment = 'member';
6208
+                    if (is_object($object) && $object->element == 'commande') {
6209
+                                            $typeforonlinepayment = 'order';
6210
+                    }
6211
+                    if (is_object($object) && $object->element == 'facture') {
6212
+                                            $typeforonlinepayment = 'invoice';
6213
+                    }
6214
+                    if (is_object($object) && $object->element == 'member') {
6215
+                                            $typeforonlinepayment = 'member';
6216
+                    }
5924 6217
                     $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']);
5925 6218
                     $paymenturl = $url;
5926 6219
                 }
@@ -5930,16 +6223,19 @@  discard block
 block discarded – undo
5930 6223
 
5931 6224
                 if (!empty(Globals::$conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
5932 6225
                     $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
5933
-                } else
5934
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6226
+                } else {
6227
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6228
+                }
5935 6229
                 if (!empty(Globals::$conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
5936 6230
                     $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
5937
-                } else
5938
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6231
+                } else {
6232
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6233
+                }
5939 6234
                 if (!empty(Globals::$conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
5940 6235
                     $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
5941
-                } else
5942
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6236
+                } else {
6237
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6238
+                }
5943 6239
             }
5944 6240
         }
5945 6241
         if (empty($exclude) || !in_array('objectamount', $exclude)) {
@@ -5949,18 +6245,22 @@  discard block
 block discarded – undo
5949 6245
             $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : '';
5950 6246
             $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : '';
5951 6247
             $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : '';
5952
-            if ($onlykey != 2 || $mysoc->useLocalTax(1))
5953
-                $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
5954
-            if ($onlykey != 2 || $mysoc->useLocalTax(2))
5955
-                $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6248
+            if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6249
+                            $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
6250
+            }
6251
+            if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6252
+                            $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6253
+            }
5956 6254
 
5957 6255
             $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
5958 6256
             $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
5959 6257
             $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? ($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : price($object->total_tva, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency)) : '';
5960
-            if ($onlykey != 2 || $mysoc->useLocalTax(1))
5961
-                $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
5962
-            if ($onlykey != 2 || $mysoc->useLocalTax(2))
5963
-                $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6258
+            if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6259
+                            $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6260
+            }
6261
+            if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6262
+                            $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6263
+            }
5964 6264
 
5965 6265
 // TODO Add keys for foreign multicurrency
5966 6266
 // For backward compatibility
@@ -6030,23 +6330,27 @@  discard block
 block discarded – undo
6030 6330
     {
6031 6331
        // global Globals::$conf, $langs;
6032 6332
 
6033
-        if (!is_array($substitutionarray))
6034
-            return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6333
+        if (!is_array($substitutionarray)) {
6334
+                    return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6335
+        }
6035 6336
 
6036
-        if (empty($outputlangs))
6037
-            $outputlangs = Globals::$langs;
6337
+        if (empty($outputlangs)) {
6338
+                    $outputlangs = Globals::$langs;
6339
+        }
6038 6340
 
6039 6341
 // Make substitution for language keys
6040 6342
         if (is_object($outputlangs)) {
6041 6343
             while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
6042 6344
                 $msgishtml = 0;
6043
-                if (DolUtils::dol_textishtml($text, 1))
6044
-                    $msgishtml = 1;
6345
+                if (DolUtils::dol_textishtml($text, 1)) {
6346
+                                    $msgishtml = 1;
6347
+                }
6045 6348
 
6046 6349
 // If key is __(TranslationKey|langfile)__, then force load of langfile.lang
6047 6350
                 $tmp = explode('|', $reg[1]);
6048
-                if (!empty($tmp[1]))
6049
-                    $outputlangs->load($tmp[1]);
6351
+                if (!empty($tmp[1])) {
6352
+                                    $outputlangs->load($tmp[1]);
6353
+                }
6050 6354
 
6051 6355
                 $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6052 6356
             }
@@ -6056,23 +6360,29 @@  discard block
 block discarded – undo
6056 6360
 // it is also converted.
6057 6361
         while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
6058 6362
             $msgishtml = 0;
6059
-            if (DolUtils::dol_textishtml($text, 1))
6060
-                $msgishtml = 1;
6363
+            if (DolUtils::dol_textishtml($text, 1)) {
6364
+                            $msgishtml = 1;
6365
+            }
6061 6366
 
6062 6367
             $keyfound = $reg[1];
6063
-            if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
6064
-                $newval = '*****forbidden*****';
6065
-            else
6066
-                $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound;
6368
+            if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) {
6369
+                            $newval = '*****forbidden*****';
6370
+            } else {
6371
+                            $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound;
6372
+            }
6067 6373
             $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text);
6068 6374
         }
6069 6375
 
6070 6376
 // Make substitition for array $substitutionarray
6071 6377
         foreach ($substitutionarray as $key => $value) {
6072
-            if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6073
-                $value = '';  // Protection
6074
-            if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6075
-                $value = ''; // Protection
6378
+            if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6379
+                            $value = '';
6380
+            }
6381
+            // Protection
6382
+            if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6383
+                            $value = '';
6384
+            }
6385
+            // Protection
6076 6386
 
6077 6387
             $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
6078 6388
         }
@@ -6118,8 +6428,9 @@  discard block
 block discarded – undo
6118 6428
             $dir = dol_buildpath($reldir, 0);
6119 6429
 
6120 6430
 // Check if directory exists
6121
-            if (!dol_is_dir($dir))
6122
-                continue;
6431
+            if (!dol_is_dir($dir)) {
6432
+                            continue;
6433
+            }
6123 6434
 
6124 6435
             $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_');
6125 6436
             foreach ($substitfiles as $substitfile) {
@@ -6131,8 +6442,9 @@  discard block
 block discarded – undo
6131 6442
                     require_once $dir . $substitfile['name'];
6132 6443
                     // Call the user's function, and only if it is defined
6133 6444
                     $function_name = $module . "_" . $callfunc;
6134
-                    if (function_exists($function_name))
6135
-                        $function_name($substitutionarray, $outputlangs, $object, $parameters);
6445
+                    if (function_exists($function_name)) {
6446
+                                            $function_name($substitutionarray, $outputlangs, $object, $parameters);
6447
+                    }
6136 6448
                 }
6137 6449
             }
6138 6450
         }
@@ -6168,8 +6480,9 @@  discard block
 block discarded – undo
6168 6480
 
6169 6481
         $out = '';
6170 6482
 
6171
-        if (!is_object($outputlangs))
6172
-            $outputlangs = $langs;
6483
+        if (!is_object($outputlangs)) {
6484
+                    $outputlangs = $langs;
6485
+        }
6173 6486
 
6174 6487
         if ($date_start && $date_end) {
6175 6488
             $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
@@ -6198,20 +6511,22 @@  discard block
 block discarded – undo
6198 6511
 
6199 6512
         $ret = '';
6200 6513
 // If order not defined, we use the setup
6201
-        if ($nameorder < 0)
6202
-            $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6514
+        if ($nameorder < 0) {
6515
+                    $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6516
+        }
6203 6517
         if ($nameorder && ((string) $nameorder != '2')) {
6204 6518
             $ret .= $firstname;
6205
-            if ($firstname && $lastname)
6206
-                $ret .= ' ';
6519
+            if ($firstname && $lastname) {
6520
+                            $ret .= ' ';
6521
+            }
6207 6522
             $ret .= $lastname;
6208
-        }
6209
-        else if ($nameorder == 2) {
6523
+        } else if ($nameorder == 2) {
6210 6524
             $ret .= $firstname;
6211 6525
         } else {
6212 6526
             $ret .= $lastname;
6213
-            if ($firstname && $lastname)
6214
-                $ret .= ' ';
6527
+            if ($firstname && $lastname) {
6528
+                            $ret .= ' ';
6529
+            }
6215 6530
             $ret .= $firstname;
6216 6531
         }
6217 6532
         return $ret;
@@ -6231,13 +6546,14 @@  discard block
 block discarded – undo
6231 6546
     {
6232 6547
 //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);		This is not deprecated, it is used by setEventMessages function
6233 6548
         if (!is_array($mesgs)) {  // If mesgs is a string
6234
-            if ($mesgs)
6235
-                $_SESSION['dol_events'][$style][] = $mesgs;
6236
-        }
6237
-        else {      // If mesgs is an array
6549
+            if ($mesgs) {
6550
+                            $_SESSION['dol_events'][$style][] = $mesgs;
6551
+            }
6552
+        } else {      // If mesgs is an array
6238 6553
             foreach ($mesgs as $mesg) {
6239
-                if ($mesg)
6240
-                    $_SESSION['dol_events'][$style][] = $mesg;
6554
+                if ($mesg) {
6555
+                                    $_SESSION['dol_events'][$style][] = $mesg;
6556
+                }
6241 6557
             }
6242 6558
         }
6243 6559
     }
@@ -6257,13 +6573,16 @@  discard block
 block discarded – undo
6257 6573
         if (empty($mesg) && empty($mesgs)) {
6258 6574
             dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
6259 6575
         } else {
6260
-            if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
6261
-                dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6262
-            if (empty($mesgs))
6263
-                setEventMessage($mesg, $style);
6264
-            else {
6265
-                if (!empty($mesg) && !in_array($mesg, $mesgs))
6266
-                    setEventMessage($mesg, $style); // Add message string if not already into array
6576
+            if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) {
6577
+                            dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6578
+            }
6579
+            if (empty($mesgs)) {
6580
+                            setEventMessage($mesg, $style);
6581
+            } else {
6582
+                if (!empty($mesg) && !in_array($mesg, $mesgs)) {
6583
+                                    setEventMessage($mesg, $style);
6584
+                }
6585
+                // Add message string if not already into array
6267 6586
                 setEventMessage($mesgs, $style);
6268 6587
             }
6269 6588
         }
@@ -6282,22 +6601,25 @@  discard block
 block discarded – undo
6282 6601
     {
6283 6602
 // Show mesgs
6284 6603
         if (isset($_SESSION['dol_events']['mesgs'])) {
6285
-            if (empty($disabledoutputofmessages))
6286
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6604
+            if (empty($disabledoutputofmessages)) {
6605
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6606
+            }
6287 6607
             unset($_SESSION['dol_events']['mesgs']);
6288 6608
         }
6289 6609
 
6290 6610
 // Show errors
6291 6611
         if (isset($_SESSION['dol_events']['errors'])) {
6292
-            if (empty($disabledoutputofmessages))
6293
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6612
+            if (empty($disabledoutputofmessages)) {
6613
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6614
+            }
6294 6615
             unset($_SESSION['dol_events']['errors']);
6295 6616
         }
6296 6617
 
6297 6618
 // Show warnings
6298 6619
         if (isset($_SESSION['dol_events']['warnings'])) {
6299
-            if (empty($disabledoutputofmessages))
6300
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6620
+            if (empty($disabledoutputofmessages)) {
6621
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6622
+            }
6301 6623
             unset($_SESSION['dol_events']['warnings']);
6302 6624
         }
6303 6625
     }
@@ -6338,8 +6660,9 @@  discard block
 block discarded – undo
6338 6660
                 foreach ($mesgarray as $message) {
6339 6661
                     $ret++;
6340 6662
                     $out .= $langs->trans($message);
6341
-                    if ($ret < count($mesgarray))
6342
-                        $out .= "<br>\n";
6663
+                    if ($ret < count($mesgarray)) {
6664
+                                            $out .= "<br>\n";
6665
+                    }
6343 6666
                 }
6344 6667
             }
6345 6668
             if ($mesgstring) {
@@ -6405,8 +6728,9 @@  discard block
 block discarded – undo
6405 6728
      */
6406 6729
     static function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0)
6407 6730
     {
6408
-        if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0))
6409
-            return;
6731
+        if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
6732
+                    return;
6733
+        }
6410 6734
 
6411 6735
         $iserror = 0;
6412 6736
         $iswarning = 0;
@@ -6421,14 +6745,17 @@  discard block
 block discarded – undo
6421 6745
                     break;
6422 6746
                 }
6423 6747
             }
6424
-        } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
6425
-            $iserror++;
6426
-        else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
6427
-            $iswarning++;
6428
-        if ($style == 'error')
6429
-            $iserror++;
6430
-        if ($style == 'warning')
6431
-            $iswarning++;
6748
+        } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) {
6749
+                    $iserror++;
6750
+        } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) {
6751
+                    $iswarning++;
6752
+        }
6753
+        if ($style == 'error') {
6754
+                    $iserror++;
6755
+        }
6756
+        if ($style == 'warning') {
6757
+                    $iswarning++;
6758
+        }
6432 6759
 
6433 6760
         if ($iserror || $iswarning) {
6434 6761
 // Remove div from texts
@@ -6447,8 +6774,9 @@  discard block
 block discarded – undo
6447 6774
                 $mesgarray = $newmesgarray;
6448 6775
             }
6449 6776
             print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded);
6450
-        } else
6451
-            print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6777
+        } else {
6778
+                    print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6779
+        }
6452 6780
     }
6453 6781
 
6454 6782
     /**
@@ -6489,15 +6817,17 @@  discard block
 block discarded – undo
6489 6817
             $sizearray = count($array);
6490 6818
             if ($sizearray > 0) {
6491 6819
                 $temp = array();
6492
-                foreach (array_keys($array) as $key)
6493
-                    $temp[$key] = $array[$key][$index];
6820
+                foreach (array_keys($array) as $key) {
6821
+                                    $temp[$key] = $array[$key][$index];
6822
+                }
6494 6823
 
6495
-                if (!$natsort)
6496
-                    ($order == 'asc') ? asort($temp) : arsort($temp);
6497
-                else {
6824
+                if (!$natsort) {
6825
+                                    ($order == 'asc') ? asort($temp) : arsort($temp);
6826
+                } else {
6498 6827
                     ($case_sensitive) ? natsort($temp) : natcasesort($temp);
6499
-                    if ($order != 'asc')
6500
-                        $temp = array_reverse($temp, true);
6828
+                    if ($order != 'asc') {
6829
+                                            $temp = array_reverse($temp, true);
6830
+                    }
6501 6831
                 }
6502 6832
 
6503 6833
                 $sorted = array();
@@ -6523,23 +6853,38 @@  discard block
 block discarded – undo
6523 6853
 // We must use here a binary strlen static function (so not dol_strlen)
6524 6854
         $strLength = dol_strlen($str);
6525 6855
         for ($i = 0; $i < $strLength; $i++) {
6526
-            if (ord($str[$i]) < 0x80)
6527
-                continue; // 0bbbbbbb
6528
-            elseif ((ord($str[$i]) & 0xE0) == 0xC0)
6529
-                $n = 1; // 110bbbbb
6530
-            elseif ((ord($str[$i]) & 0xF0) == 0xE0)
6531
-                $n = 2; // 1110bbbb
6532
-            elseif ((ord($str[$i]) & 0xF8) == 0xF0)
6533
-                $n = 3; // 11110bbb
6534
-            elseif ((ord($str[$i]) & 0xFC) == 0xF8)
6535
-                $n = 4; // 111110bb
6536
-            elseif ((ord($str[$i]) & 0xFE) == 0xFC)
6537
-                $n = 5; // 1111110b
6538
-            else
6539
-                return false; // Does not match any model
6856
+            if (ord($str[$i]) < 0x80) {
6857
+                            continue;
6858
+            }
6859
+            // 0bbbbbbb
6860
+            elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
6861
+                            $n = 1;
6862
+            }
6863
+            // 110bbbbb
6864
+            elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
6865
+                            $n = 2;
6866
+            }
6867
+            // 1110bbbb
6868
+            elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
6869
+                            $n = 3;
6870
+            }
6871
+            // 11110bbb
6872
+            elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
6873
+                            $n = 4;
6874
+            }
6875
+            // 111110bb
6876
+            elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
6877
+                            $n = 5;
6878
+            }
6879
+            // 1111110b
6880
+            else {
6881
+                            return false;
6882
+            }
6883
+            // Does not match any model
6540 6884
             for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
6541
-                if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80))
6542
-                    return false;
6885
+                if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
6886
+                                    return false;
6887
+                }
6543 6888
             }
6544 6889
         }
6545 6890
         return true;
@@ -6557,15 +6902,21 @@  discard block
 block discarded – undo
6557 6902
        // global Globals::$conf;
6558 6903
 
6559 6904
         $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6560
-        if (empty($tmp) && !empty($_SERVER["WINDIR"]))
6561
-            $tmp = 'iso-8859-1'; // By default for windows
6562
-        if (empty($tmp))
6563
-            $tmp = 'utf-8';          // By default for other
6564
-        if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING))
6565
-            $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING;
6566
-
6567
-        if ($tmp == 'iso-8859-1')
6568
-            return utf8_decode($str);
6905
+        if (empty($tmp) && !empty($_SERVER["WINDIR"])) {
6906
+                    $tmp = 'iso-8859-1';
6907
+        }
6908
+        // By default for windows
6909
+        if (empty($tmp)) {
6910
+                    $tmp = 'utf-8';
6911
+        }
6912
+        // By default for other
6913
+        if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) {
6914
+                    $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING;
6915
+        }
6916
+
6917
+        if ($tmp == 'iso-8859-1') {
6918
+                    return utf8_decode($str);
6919
+        }
6569 6920
         return $str;
6570 6921
     }
6571 6922
 
@@ -6586,8 +6937,9 @@  discard block
 block discarded – undo
6586 6937
     {
6587 6938
        // global $cache_codes;
6588 6939
 // If key empty
6589
-        if ($key == '')
6590
-            return '';
6940
+        if ($key == '') {
6941
+                    return '';
6942
+        }
6591 6943
 
6592 6944
 // Check in cache
6593 6945
         if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
@@ -6599,20 +6951,21 @@  discard block
 block discarded – undo
6599 6951
         $sql = "SELECT " . $fieldid . " as valuetoget";
6600 6952
         $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
6601 6953
         $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'";
6602
-        if (!empty($entityfilter))
6603
-            $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6954
+        if (!empty($entityfilter)) {
6955
+                    $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6956
+        }
6604 6957
 
6605 6958
         $resql = $db->query($sql);
6606 6959
         if ($resql) {
6607 6960
             $obj = $db->fetch_object($resql);
6608
-            if ($obj)
6609
-                $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6610
-            else
6611
-                $cache_codes[$tablename][$key][$fieldid] = '';
6961
+            if ($obj) {
6962
+                            $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6963
+            } else {
6964
+                            $cache_codes[$tablename][$key][$fieldid] = '';
6965
+            }
6612 6966
             $db->free($resql);
6613 6967
             return $cache_codes[$tablename][$key][$fieldid];
6614
-        }
6615
-        else {
6968
+        } else {
6616 6969
             return -1;
6617 6970
         }
6618 6971
     }
@@ -6658,16 +7011,17 @@  discard block
 block discarded – undo
6658 7011
         // global $soc;       // For backward compatibility
6659 7012
 //print $s."<br>\n";
6660 7013
         if ($returnvalue) {
6661
-            if ($hideerrors)
6662
-                return @eval('return ' . $s . ';');
6663
-            else
6664
-                return eval('return ' . $s . ';');
6665
-        }
6666
-        else {
6667
-            if ($hideerrors)
6668
-                @eval($s);
6669
-            else
6670
-                eval($s);
7014
+            if ($hideerrors) {
7015
+                            return @eval('return ' . $s . ';');
7016
+            } else {
7017
+                            return eval('return ' . $s . ';');
7018
+            }
7019
+        } else {
7020
+            if ($hideerrors) {
7021
+                            @eval($s);
7022
+            } else {
7023
+                            eval($s);
7024
+            }
6671 7025
         }
6672 7026
     }
6673 7027
 
@@ -6693,8 +7047,9 @@  discard block
 block discarded – undo
6693 7047
     {
6694 7048
        // global $langs;
6695 7049
 
6696
-        if (empty($codelang))
6697
-            return '';
7050
+        if (empty($codelang)) {
7051
+                    return '';
7052
+        }
6698 7053
 
6699 7054
         if ($codelang == 'auto') {
6700 7055
             return '<span class="fa fa-globe"></span>';
@@ -6708,9 +7063,9 @@  discard block
 block discarded – undo
6708 7063
             'sv_SV' => 'se'
6709 7064
         );
6710 7065
 
6711
-        if (isset($langtocountryflag[$codelang]))
6712
-            $flagImage = $langtocountryflag[$codelang];
6713
-        else {
7066
+        if (isset($langtocountryflag[$codelang])) {
7067
+                    $flagImage = $langtocountryflag[$codelang];
7068
+        } else {
6714 7069
             $tmparray = explode('_', $codelang);
6715 7070
             $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
6716 7071
         }
@@ -6728,15 +7083,20 @@  discard block
 block discarded – undo
6728 7083
     {
6729 7084
        // global $mysoc;
6730 7085
 
6731
-        if (strtoupper($countrycode) == 'MQ')
6732
-            return 'fr_CA';
6733
-        if (strtoupper($countrycode) == 'SE')
6734
-            return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
7086
+        if (strtoupper($countrycode) == 'MQ') {
7087
+                    return 'fr_CA';
7088
+        }
7089
+        if (strtoupper($countrycode) == 'SE') {
7090
+                    return 'sv_SE';
7091
+        }
7092
+        // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
6735 7093
         if (strtoupper($countrycode) == 'CH') {
6736
-            if ($mysoc->country_code == 'FR')
6737
-                return 'fr_CH';
6738
-            if ($mysoc->country_code == 'DE')
6739
-                return 'de_CH';
7094
+            if ($mysoc->country_code == 'FR') {
7095
+                            return 'fr_CH';
7096
+            }
7097
+            if ($mysoc->country_code == 'DE') {
7098
+                            return 'de_CH';
7099
+            }
6740 7100
         }
6741 7101
 
6742 7102
 // Locale list taken from:
@@ -6914,8 +7274,9 @@  discard block
 block discarded – undo
6914 7274
         );
6915 7275
 
6916 7276
         $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode);
6917
-        if (in_array($buildprimarykeytotest, $locales))
6918
-            return strtolower($countrycode) . '_' . strtoupper($countrycode);
7277
+        if (in_array($buildprimarykeytotest, $locales)) {
7278
+                    return strtolower($countrycode) . '_' . strtoupper($countrycode);
7279
+        }
6919 7280
 
6920 7281
         foreach ($locales as $locale) {
6921 7282
             $locale_language = locale_get_primary_language($locale);
@@ -6969,18 +7330,21 @@  discard block
 block discarded – undo
6969 7330
 
6970 7331
                 if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
6971 7332
                     if (count($values) == 6) {       // new declaration with permissions:  $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
6972
-                        if ($values[0] != $type)
6973
-                            continue;
7333
+                        if ($values[0] != $type) {
7334
+                                                    continue;
7335
+                        }
6974 7336
 
6975 7337
                         if (verifCond($values[4])) {
6976
-                            if ($values[3])
6977
-                                $langs->load($values[3]);
7338
+                            if ($values[3]) {
7339
+                                                            $langs->load($values[3]);
7340
+                            }
6978 7341
                             if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
6979 7342
                                 $substitutionarray = array();
6980 7343
                                 complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
6981 7344
                                 $label = make_substitutions($reg[1], $substitutionarray);
6982
-                            } else
6983
-                                $label = $langs->trans($values[2]);
7345
+                            } else {
7346
+                                                            $label = $langs->trans($values[2]);
7347
+                            }
6984 7348
 
6985 7349
                             //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
6986 7350
                             $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
@@ -6988,30 +7352,32 @@  discard block
 block discarded – undo
6988 7352
                             $head[$h][2] = str_replace('+', '', $values[1]);
6989 7353
                             $h++;
6990 7354
                         }
6991
-                    }
6992
-                    else if (count($values) == 5) {       // deprecated
7355
+                    } else if (count($values) == 5) {       // deprecated
6993 7356
                         dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
6994 7357
 
6995
-                        if ($values[0] != $type)
6996
-                            continue;
6997
-                        if ($values[3])
6998
-                            $langs->load($values[3]);
7358
+                        if ($values[0] != $type) {
7359
+                                                    continue;
7360
+                        }
7361
+                        if ($values[3]) {
7362
+                                                    $langs->load($values[3]);
7363
+                        }
6999 7364
                         if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
7000 7365
                             $substitutionarray = array();
7001 7366
                             complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2]));
7002 7367
                             $label = make_substitutions($reg[1], $substitutionarray);
7003
-                        } else
7004
-                            $label = $langs->trans($values[2]);
7368
+                        } else {
7369
+                                                    $label = $langs->trans($values[2]);
7370
+                        }
7005 7371
 
7006 7372
                         $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
7007 7373
                         $head[$h][1] = $label;
7008 7374
                         $head[$h][2] = str_replace('+', '', $values[1]);
7009 7375
                         $h++;
7010 7376
                     }
7011
-                }
7012
-                else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
7013
-                    if ($values[0] != $type)
7014
-                        continue;
7377
+                } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
7378
+                    if ($values[0] != $type) {
7379
+                                            continue;
7380
+                    }
7015 7381
                     $tabname = str_replace('-', '', $values[1]);
7016 7382
                     foreach ($head as $key => $val) {
7017 7383
                         $condition = (!empty($values[3]) ? verifCond($values[3]) : 1);
@@ -7053,10 +7419,11 @@  discard block
 block discarded – undo
7053 7419
         // global $action;
7054 7420
         // global $micro_start_time;
7055 7421
 
7056
-        if ($zone == 'private')
7057
-            print "\n" . '<!-- Common footer for private page -->' . "\n";
7058
-        else
7059
-            print "\n" . '<!-- Common footer for public page -->' . "\n";
7422
+        if ($zone == 'private') {
7423
+                    print "\n" . '<!-- Common footer for private page -->' . "\n";
7424
+        } else {
7425
+                    print "\n" . '<!-- Common footer for public page -->' . "\n";
7426
+        }
7060 7427
 
7061 7428
 // A div to store page_y POST parameter so we can read it using javascript
7062 7429
         print "\n<!-- A div to store page_y POST paramater -->\n";
@@ -7065,8 +7432,9 @@  discard block
 block discarded – undo
7065 7432
         $parameters = array();
7066 7433
         $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
7067 7434
         if (empty($reshook)) {
7068
-            if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER))
7069
-                print Globals::$conf->global->MAIN_HTML_FOOTER . "\n";
7435
+            if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) {
7436
+                            print Globals::$conf->global->MAIN_HTML_FOOTER . "\n";
7437
+            }
7070 7438
 
7071 7439
             print "\n";
7072 7440
             if (!empty(Globals::$conf->use_javascript_ajax)) {
@@ -7089,8 +7457,9 @@  discard block
 block discarded – undo
7089 7457
                     print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n";
7090 7458
                     $relativepathstring = $_SERVER["PHP_SELF"];
7091 7459
                     // Clean $relativepathstring
7092
-                    if (constant('DOL_BASE_URI'))
7093
-                        $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
7460
+                    if (constant('DOL_BASE_URI')) {
7461
+                                            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
7462
+                    }
7094 7463
                     $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
7095 7464
                     $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
7096 7465
                     $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
@@ -7101,14 +7470,17 @@  discard block
 block discarded – undo
7101 7470
                                 $tmpqueryarraytohave = explode('&', $defkey);
7102 7471
                                 $foundintru = 0;
7103 7472
                                 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7104
-                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7105
-                                        $foundintru = 1;
7473
+                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7474
+                                                                            $foundintru = 1;
7475
+                                    }
7106 7476
                                 }
7107
-                                if (!$foundintru)
7108
-                                    $qualified = 1;
7477
+                                if (!$foundintru) {
7478
+                                                                    $qualified = 1;
7479
+                                }
7109 7480
                                 //var_dump($defkey.'-'.$qualified);
7110
-                            } else
7111
-                                $qualified = 1;
7481
+                            } else {
7482
+                                                            $qualified = 1;
7483
+                            }
7112 7484
 
7113 7485
                             if ($qualified) {
7114 7486
                                 foreach ($defval as $paramkey => $paramval) {
@@ -7127,14 +7499,17 @@  discard block
 block discarded – undo
7127 7499
                                 $tmpqueryarraytohave = explode('&', $defkey);
7128 7500
                                 $foundintru = 0;
7129 7501
                                 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7130
-                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7131
-                                        $foundintru = 1;
7502
+                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7503
+                                                                            $foundintru = 1;
7504
+                                    }
7132 7505
                                 }
7133
-                                if (!$foundintru)
7134
-                                    $qualified = 1;
7506
+                                if (!$foundintru) {
7507
+                                                                    $qualified = 1;
7508
+                                }
7135 7509
                                 //var_dump($defkey.'-'.$qualified);
7136
-                            } else
7137
-                                $qualified = 1;
7510
+                            } else {
7511
+                                                            $qualified = 1;
7512
+                            }
7138 7513
 
7139 7514
                             if ($qualified) {
7140 7515
                                 foreach ($defval as $paramkey => $paramval) {
@@ -7173,8 +7548,9 @@  discard block
 block discarded – undo
7173 7548
                     print "\n";
7174 7549
                     print "/* JS CODE TO ENABLE to add memory info */\n";
7175 7550
                     print 'window.console && console.log("';
7176
-                    if (!empty(Globals::$conf->global->MEMCACHED_SERVER))
7177
-                        print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - ';
7551
+                    if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) {
7552
+                                            print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - ';
7553
+                    }
7178 7554
                     print 'MAIN_OPTIMIZE_SPEED=' . (isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7179 7555
                     if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in// global variable.
7180 7556
                         $micro_end_time = microtime(true);
@@ -7304,8 +7680,9 @@  discard block
 block discarded – undo
7304 7680
 
7305 7681
         $crits = explode(' ', $value);
7306 7682
         $res = '';
7307
-        if (!is_array($fields))
7308
-            $fields = array($fields);
7683
+        if (!is_array($fields)) {
7684
+                    $fields = array($fields);
7685
+        }
7309 7686
 
7310 7687
         $nboffields = count($fields);
7311 7688
         $end2 = count($crits);
@@ -7368,8 +7745,9 @@  discard block
 block discarded – undo
7368 7745
                     $tmpcrits = explode('|', $crit);
7369 7746
                     $i3 = 0;
7370 7747
                     foreach ($tmpcrits as $tmpcrit) {
7371
-                        if (empty($tmpcrit))
7372
-                            continue;
7748
+                        if (empty($tmpcrit)) {
7749
+                                                    continue;
7750
+                        }
7373 7751
 
7374 7752
                         $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
7375 7753
 
@@ -7405,8 +7783,9 @@  discard block
 block discarded – undo
7405 7783
                 }
7406 7784
                 $i++;
7407 7785
             }
7408
-            if ($newres)
7409
-                $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7786
+            if ($newres) {
7787
+                            $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7788
+            }
7410 7789
             $j++;
7411 7790
         }
7412 7791
         $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
@@ -7446,29 +7825,37 @@  discard block
 block discarded – undo
7446 7825
     static function getImageFileNameForSize($file, $extName, $extImgTarget = '')
7447 7826
     {
7448 7827
         $dirName = dirname($file);
7449
-        if ($dirName == '.')
7450
-            $dirName = '';
7828
+        if ($dirName == '.') {
7829
+                    $dirName = '';
7830
+        }
7451 7831
 
7452 7832
         $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
7453 7833
         $fileName = basename($fileName);
7454 7834
 
7455
-        if (empty($extImgTarget))
7456
-            $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7457
-        if (empty($extImgTarget))
7458
-            $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7459
-        if (empty($extImgTarget))
7460
-            $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7461
-        if (empty($extImgTarget))
7462
-            $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7463
-        if (empty($extImgTarget))
7464
-            $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7465
-
7466
-        if (!$extImgTarget)
7467
-            return $file;
7835
+        if (empty($extImgTarget)) {
7836
+                    $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7837
+        }
7838
+        if (empty($extImgTarget)) {
7839
+                    $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7840
+        }
7841
+        if (empty($extImgTarget)) {
7842
+                    $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7843
+        }
7844
+        if (empty($extImgTarget)) {
7845
+                    $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7846
+        }
7847
+        if (empty($extImgTarget)) {
7848
+                    $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7849
+        }
7850
+
7851
+        if (!$extImgTarget) {
7852
+                    return $file;
7853
+        }
7468 7854
 
7469 7855
         $subdir = '';
7470
-        if ($extName)
7471
-            $subdir = 'thumbs/';
7856
+        if ($extName) {
7857
+                    $subdir = 'thumbs/';
7858
+        }
7472 7859
 
7473 7860
         return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb
7474 7861
     }
@@ -7486,8 +7873,9 @@  discard block
 block discarded – undo
7486 7873
     {
7487 7874
        // global Globals::$conf, $langs;
7488 7875
 
7489
-        if (empty(Globals::$conf->use_javascript_ajax))
7490
-            return '';
7876
+        if (empty(Globals::$conf->use_javascript_ajax)) {
7877
+                    return '';
7878
+        }
7491 7879
 
7492 7880
         $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
7493 7881
 //$mime_preview[]='vnd.oasis.opendocument.presentation';
@@ -7495,17 +7883,19 @@  discard block
 block discarded – undo
7495 7883
         $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
7496 7884
 
7497 7885
         if ($alldata == 1) {
7498
-            if ($num_mime !== false)
7499
-                return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7500
-            else
7501
-                return array();
7886
+            if ($num_mime !== false) {
7887
+                            return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),);
7888
+            } else {
7889
+                            return array();
7890
+            }
7502 7891
         }
7503 7892
 
7504 7893
 // old behavior
7505
-        if ($num_mime !== false)
7506
-            return 'javascript:document_preview(\'' . dol_escape_js(DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7507
-        else
7508
-            return '';
7894
+        if ($num_mime !== false) {
7895
+                    return 'javascript:document_preview(\'' . dol_escape_js(DOL_BASE_URI . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')';
7896
+        } else {
7897
+                    return '';
7898
+        }
7509 7899
     }
7510 7900
 
7511 7901
     /**
@@ -7523,8 +7913,9 @@  discard block
 block discarded – undo
7523 7913
 				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
7524 7914
 				});
7525 7915
 		    </script>';
7526
-        if ($addlink)
7527
-            $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7916
+        if ($addlink) {
7917
+                    $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>';
7918
+        }
7528 7919
         return $out;
7529 7920
     }
7530 7921
 
@@ -7906,8 +8297,9 @@  discard block
 block discarded – undo
7906 8297
         if (!isset($dictvalues[$tablename])) {
7907 8298
             $dictvalues[$tablename] = array();
7908 8299
             $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1';
7909
-            if ($checkentity)
7910
-                $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8300
+            if ($checkentity) {
8301
+                            $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8302
+            }
7911 8303
 
7912 8304
             $resql = $db->query($sql);
7913 8305
             if ($resql) {
@@ -7919,11 +8311,14 @@  discard block
 block discarded – undo
7919 8311
             }
7920 8312
         }
7921 8313
 
7922
-        if (!empty($dictvalues[$tablename][$id]))
7923
-            return $dictvalues[$tablename][$id]->{$field}; // Found
8314
+        if (!empty($dictvalues[$tablename][$id])) {
8315
+                    return $dictvalues[$tablename][$id]->{$field};
8316
+        }
8317
+        // Found
7924 8318
         else { // Not found
7925
-            if ($id > 0)
7926
-                return $id;
8319
+            if ($id > 0) {
8320
+                            return $id;
8321
+            }
7927 8322
             return '';
7928 8323
         }
7929 8324
     }
@@ -7953,8 +8348,9 @@  discard block
 block discarded – undo
7953 8348
                 $b = hexdec($hexb);
7954 8349
             }
7955 8350
             $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;    // HSL algorithm
7956
-            if ($bright > 0.6)
7957
-                $res = 1;
8351
+            if ($bright > 0.6) {
8352
+                            $res = 1;
8353
+            }
7958 8354
         }
7959 8355
         return $res;
7960 8356
     }
@@ -7972,8 +8368,10 @@  discard block
 block discarded – undo
7972 8368
        // global Globals::$conf;
7973 8369
 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
7974 8370
 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
7975
-        if (empty($menuentry['enabled']))
7976
-            return 0; // Entry disabled by condition
8371
+        if (empty($menuentry['enabled'])) {
8372
+                    return 0;
8373
+        }
8374
+        // Entry disabled by condition
7977 8375
         if ($type_user && $menuentry['module']) {
7978 8376
             $tmploops = explode('|', $menuentry['module']);
7979 8377
             $found = 0;
@@ -7983,15 +8381,23 @@  discard block
 block discarded – undo
7983 8381
                     break;
7984 8382
                 }
7985 8383
             }
7986
-            if (!$found)
7987
-                return 0; // Entry is for menus all excluded to external users
7988
-        }
7989
-        if (!$menuentry['perms'] && $type_user)
7990
-            return 0;            // No permissions and user is external
7991
-        if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
7992
-            return 0; // No permissions and option to hide when not allowed, even for internal user, is on
7993
-        if (!$menuentry['perms'])
7994
-            return 2;               // No permissions and user is external
8384
+            if (!$found) {
8385
+                            return 0;
8386
+            }
8387
+            // Entry is for menus all excluded to external users
8388
+        }
8389
+        if (!$menuentry['perms'] && $type_user) {
8390
+                    return 0;
8391
+        }
8392
+        // No permissions and user is external
8393
+        if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
8394
+                    return 0;
8395
+        }
8396
+        // No permissions and option to hide when not allowed, even for internal user, is on
8397
+        if (!$menuentry['perms']) {
8398
+                    return 2;
8399
+        }
8400
+        // No permissions and user is external
7995 8401
         return 1;
7996 8402
     }
7997 8403
 
Please login to merge, or discard this patch.
Helpers/Globals.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         }
54 54
 
55 55
         if (!defined('DOL_VERSION')) {
56
-            define('DOL_VERSION', '10.0.0-alpha');  // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
56
+            define('DOL_VERSION', '10.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
57 57
         }
58 58
 
59 59
         if (!defined('EURO')) {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         self::$conf = new Conf();
72 72
 
73
-        include DOL_BASE_PATH . '/conf/conf.php';
73
+        include DOL_BASE_PATH.'/conf/conf.php';
74 74
 
75 75
         // Set properties specific to database
76 76
         Globals::$conf->db->host = $dolibarr_main_db_host;
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
         Globals::$conf->file->mailing_limit_sendbyweb = $dolibarr_mailing_limit_sendbyweb ?? 0;
99 99
         Globals::$conf->file->mailing_limit_sendbycli = $dolibarr_mailing_limit_sendbycli ?? 0;
100 100
         Globals::$conf->file->main_authentication = empty($dolibarr_main_authentication) ? '' : $dolibarr_main_authentication; // Identification mode
101
-        Globals::$conf->file->main_force_https = empty($dolibarr_main_force_https) ? '' : $dolibarr_main_force_https;   // Force https
102
-        Globals::$conf->file->strict_mode = empty($dolibarr_strict_mode) ? '' : $dolibarr_strict_mode;     // Force php strict mode (for debug)
101
+        Globals::$conf->file->main_force_https = empty($dolibarr_main_force_https) ? '' : $dolibarr_main_force_https; // Force https
102
+        Globals::$conf->file->strict_mode = empty($dolibarr_strict_mode) ? '' : $dolibarr_strict_mode; // Force php strict mode (for debug)
103 103
         Globals::$conf->file->cookie_cryptkey = empty($dolibarr_main_cookie_cryptkey) ? '' : $dolibarr_main_cookie_cryptkey; // Cookie cryptkey
104
-        Globals::$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT);        // Define array of document root directories ('/home/htdocs')
105
-        Globals::$conf->file->dol_url_root = array('main' => (string) DOL_BASE_URI);         // Define array of url root path ('' or '/dolibarr')
104
+        Globals::$conf->file->dol_document_root = array('main' => (string) DOL_DOCUMENT_ROOT); // Define array of document root directories ('/home/htdocs')
105
+        Globals::$conf->file->dol_url_root = array('main' => (string) DOL_BASE_URI); // Define array of url root path ('' or '/dolibarr')
106 106
         if (!empty($dolibarr_main_document_root_alt)) {
107 107
             // dolibarr_main_document_root_alt can contains several directories
108 108
             $values = preg_split('/[;,]/', $dolibarr_main_document_root_alt);
109 109
             $i = 0;
110 110
             foreach ($values as $value) {
111
-                Globals::$conf->file->dol_document_root['alt' . ($i++)] = (string) $value;
111
+                Globals::$conf->file->dol_document_root['alt'.($i++)] = (string) $value;
112 112
             }
113 113
             $values = preg_split('/[;,]/', $dolibarr_main_url_root_alt);
114 114
             $i = 0;
@@ -116,11 +116,11 @@  discard block
 block discarded – undo
116 116
                 if (preg_match('/^http(s)?:/', $value)) {
117 117
                     // Show error message
118 118
                     $correct_value = str_replace($dolibarr_main_url_root, '', $value);
119
-                    print '<b>Error:</b><br>' . "\n";
120
-                    print 'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>' . "\n";
121
-                    print 'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>' . "\n";
122
-                    print 'Value found: ' . $value . '<br>' . "\n";
123
-                    print 'Should be replaced by: ' . $correct_value . '<br>' . "\n";
119
+                    print '<b>Error:</b><br>'."\n";
120
+                    print 'Wrong <b>$dolibarr_main_url_root_alt</b> value in <b>conf.php</b> file.<br>'."\n";
121
+                    print 'We now use a relative path to $dolibarr_main_url_root to build alternate URLs.<br>'."\n";
122
+                    print 'Value found: '.$value.'<br>'."\n";
123
+                    print 'Should be replaced by: '.$correct_value.'<br>'."\n";
124 124
                     print "Or something like following examples:<br>\n";
125 125
                     print "\"/extensions\"<br>\n";
126 126
                     print "\"/extensions1,/extensions2,...\"<br>\n";
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
                     print "\"/custom\"<br>\n";
129 129
                     exit;
130 130
                 }
131
-                Globals::$conf->file->dol_url_root['alt' . ($i++)] = (string) $value;
131
+                Globals::$conf->file->dol_url_root['alt'.($i++)] = (string) $value;
132 132
             }
133 133
         }
134 134
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
         if (isset(self::$configFilename)) {
163 163
             return self::$configFilename;
164 164
         }
165
-        $filename = CONFIGURATION_PATH . '/config.yaml';
165
+        $filename = CONFIGURATION_PATH.'/config.yaml';
166 166
         if (file_exists($filename) || is_dir(CONFIGURATION_PATH) || mkdir(CONFIGURATION_PATH, 0777, true)) {
167 167
             self::$configFilename = $filename;
168 168
         }
@@ -227,8 +227,8 @@  discard block
 block discarded – undo
227 227
     {
228 228
         self::$global = self::loadConfigurationFile();
229 229
         if (isset(self::$global['skin'])) {
230
-            $templatesFolder = BASE_PATH . Skin::SKINS_FOLDER;
231
-            $skinFolder = $templatesFolder . '/' . self::$global['skin'];
230
+            $templatesFolder = BASE_PATH.Skin::SKINS_FOLDER;
231
+            $skinFolder = $templatesFolder.'/'.self::$global['skin'];
232 232
             if (is_dir($templatesFolder) && !is_dir($skinFolder)) {
233 233
                 Config::setError("Skin folder '$skinFolder' does not exists!");
234 234
                 //(new EditConfig())->run();
@@ -325,13 +325,13 @@  discard block
 block discarded – undo
325 325
     {
326 326
         if (self::$dbEngine == null) {
327 327
             $dbEngineName = self::$global['dbEngineName'] ?? 'PdoMySql';
328
-            $helperName = 'Sql' . substr($dbEngineName, 3);
328
+            $helperName = 'Sql'.substr($dbEngineName, 3);
329 329
 
330 330
             Debug::addMessage('SQL', "Using '$dbEngineName' engine.");
331 331
             Debug::addMessage('SQL', "Using '$helperName' SQL helper engine.");
332 332
 
333
-            $sqlEngine = '\\Alxarafe\\Database\\SqlHelpers\\' . $helperName;
334
-            $engine = '\\Alxarafe\\Database\\Engines\\' . $dbEngineName;
333
+            $sqlEngine = '\\Alxarafe\\Database\\SqlHelpers\\'.$helperName;
334
+            $engine = '\\Alxarafe\\Database\\Engines\\'.$dbEngineName;
335 335
             try {
336 336
                 Config::$sqlHelper = new $sqlEngine();
337 337
                 Config::$dbEngine = new $engine([
Please login to merge, or discard this patch.
Helpers/Security2.php 2 patches
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $t = '?';
42 42
         if ($mode == 'user')
43
-            $t = getenv('APACHE_RUN_USER');   // $_ENV['APACHE_RUN_USER'] is empty
43
+            $t = getenv('APACHE_RUN_USER'); // $_ENV['APACHE_RUN_USER'] is empty
44 44
         if ($mode == 'group')
45 45
             $t = getenv('APACHE_RUN_GROUP');
46 46
         return $t;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $entitytotest = 1;
65 65
         }
66 66
 
67
-        DolUtils::dol_syslog("checkLoginPassEntity usertotest=" . $usertotest . " entitytotest=" . $entitytotest . " authmode=" . join(',', $authmode));
67
+        DolUtils::dol_syslog("checkLoginPassEntity usertotest=".$usertotest." entitytotest=".$entitytotest." authmode=".join(',', $authmode));
68 68
         $login = '';
69 69
 
70 70
         // Validation of login/pass/entity with standard modules
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 if ($test && $mode && !$login) {
75 75
                     // Validation of login/pass/entity for mode $mode
76 76
                     $mode = trim($mode);
77
-                    $authfile = 'functions_' . $mode . '.php';
77
+                    $authfile = 'functions_'.$mode.'.php';
78 78
                     $fullauthfile = '';
79 79
 
80 80
                     /*
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                     $dirlogin = array_merge(array("/Helpers/login"), (array) Globals::$conf->modules_parts['login']);
94 94
                     foreach ($dirlogin as $reldir) {
95 95
                         // Check if file found (do not use dol_is_file to avoid loading files.lib.php)
96
-                        $tmpnewauthfile = BASE_PATH . $reldir . '/' . $authfile;
96
+                        $tmpnewauthfile = BASE_PATH.$reldir.'/'.$authfile;
97 97
                         if (is_file($tmpnewauthfile)) {
98 98
                             $fullauthfile = $tmpnewauthfile;
99 99
                         }
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
                     }
106 106
                     if ($fullauthfile && $result) {
107 107
                         // Call function to check user/password
108
-                        $function = 'check_user_password_' . $mode;
108
+                        $function = 'check_user_password_'.$mode;
109 109
                         $login = \call_user_func($function, $usertotest, $passwordtotest, $entitytotest);
110 110
                         if ($login) { // Login is successfull
111
-                            $test = false;            // To stop once at first login success
111
+                            $test = false; // To stop once at first login success
112 112
                             Globals::$conf->authmode = $mode; // This properties is defined only when logged to say what mode was successfully used
113 113
                             $dol_tz = DolUtils::GETPOST('tz');
114 114
                             $dol_dst = DolUtils::GETPOST('dst');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                             $dol_screenheight = DolUtils::GETPOST('screenheight');
117 117
                         }
118 118
                     } else {
119
-                        DolUtils::dol_syslog("Authentification ko - failed to load file '" . $authfile . "'", LOG_ERR);
119
+                        DolUtils::dol_syslog("Authentification ko - failed to load file '".$authfile."'", LOG_ERR);
120 120
                         sleep(1);
121 121
                         // Load translation files required by the page
122 122
                         Globals::$langs->loadLangs(array('other', 'main', 'errors'));
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 
157 157
         // Title
158 158
         $appli = constant('DOL_APPLICATION_TITLE');
159
-        $title = $appli . ' ' . constant('DOL_VERSION');
159
+        $title = $appli.' '.constant('DOL_VERSION');
160 160
         if (!empty(Globals::$conf->global->MAIN_APPLICATION_TITLE)) {
161 161
             $title = Globals::$conf->global->MAIN_APPLICATION_TITLE;
162 162
         }
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
         if (!empty(Globals::$conf->modules_parts['tpl'])) { // Using this feature slow down application
184 184
             $dirtpls = array_merge(Globals::$conf->modules_parts['tpl'], array('/core/tpl/'));
185 185
             foreach ($dirtpls as $reldir) {
186
-                $tmp = DolUtils::dol_buildpath($reldir . 'login.tpl.php');
186
+                $tmp = DolUtils::dol_buildpath($reldir.'login.tpl.php');
187 187
                 if (file_exists($tmp)) {
188 188
                     $template_dir = preg_replace('/login\.tpl\.php$/', '', $tmp);
189 189
                     break;
190 190
                 }
191 191
             }
192 192
         } else {
193
-            $template_dir = DOL_DOCUMENT_ROOT . "/core/tpl/";
193
+            $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/";
194 194
         }
195 195
 
196 196
 // Set cookie for timeout management
197 197
         $prefix = DolUtils::dol_getprefix('');
198
-        $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix;
198
+        $sessiontimeout = 'DOLSESSTIMEOUT_'.$prefix;
199 199
         if (!empty(Globals::$conf->global->MAIN_SESSION_TIMEOUT)) {
200 200
             setcookie($sessiontimeout, Globals::$conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, false, true);
201 201
         }
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 
223 223
 // Execute hook getLoginPageOptions (for table)
224 224
         $parameters = array('entity' => DolUtils::GETPOST('entity', 'int'));
225
-        $reshook = Globals::$hookManager->executeHooks('getLoginPageOptions', $parameters);    // Note that $action and $object may have been modified by some hooks.
225
+        $reshook = Globals::$hookManager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
226 226
         if (is_array(Globals::$hookManager->resArray) && !empty(Globals::$hookManager->resArray)) {
227 227
             $morelogincontent = Globals::$hookManager->resArray; // (deprecated) For compatibility
228 228
         } else {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 
232 232
 // Execute hook getLoginPageExtraOptions (eg for js)
233 233
         $parameters = array('entity' => DolUtils::GETPOST('entity', 'int'));
234
-        $reshook = Globals::$hookManager->executeHooks('getLoginPageExtraOptions', $parameters);    // Note that $action and $object may have been modified by some hooks.
234
+        $reshook = Globals::$hookManager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
235 235
         $moreloginextracontent = Globals::$hookManager->resPrint;
236 236
 
237 237
 // Login
@@ -240,17 +240,17 @@  discard block
 block discarded – undo
240 240
 
241 241
 // Show logo (search in order: small company logo, large company logo, theme logo, common logo)
242 242
         $width = 0;
243
-        $urllogo = DOL_BASE_URI . '/theme/login_logo.png';
243
+        $urllogo = DOL_BASE_URI.'/theme/login_logo.png';
244 244
 
245
-        if (!empty($mysoc->logo_small) && is_readable(Globals::$conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_small)) {
246
-            $urllogo = DOL_BASE_URI . '/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file=' . urlencode('logos/thumbs/' . $mysoc->logo_small);
247
-        } elseif (!empty($mysoc->logo) && is_readable(Globals::$conf->mycompany->dir_output . '/logos/' . $mysoc->logo)) {
248
-            $urllogo = DOL_BASE_URI . '/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file=' . urlencode('logos/' . $mysoc->logo);
245
+        if (!empty($mysoc->logo_small) && is_readable(Globals::$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
246
+            $urllogo = DOL_BASE_URI.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
247
+        } elseif (!empty($mysoc->logo) && is_readable(Globals::$conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
248
+            $urllogo = DOL_BASE_URI.'/viewimage.php?cache=1&amp;modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo);
249 249
             $width = 128;
250
-        } elseif (is_readable(DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/dolibarr_logo.png')) {
251
-            $urllogo = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/dolibarr_logo.png';
252
-        } elseif (is_readable(DOL_BASE_URI . '/theme/dolibarr_logo.png')) {
253
-            $urllogo = DOL_BASE_URI . '/theme/dolibarr_logo.png';
250
+        } elseif (is_readable(DOL_BASE_URI.'/theme/'.Globals::$conf->theme.'/img/dolibarr_logo.png')) {
251
+            $urllogo = DOL_BASE_URI.'/theme/'.Globals::$conf->theme.'/img/dolibarr_logo.png';
252
+        } elseif (is_readable(DOL_BASE_URI.'/theme/dolibarr_logo.png')) {
253
+            $urllogo = DOL_BASE_URI.'/theme/dolibarr_logo.png';
254 254
         }
255 255
 
256 256
 // Security graphical code
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
 // Set jquery theme
291 291
         $dol_loginmesg = (!empty($_SESSION["dol_loginmesg"]) ? $_SESSION["dol_loginmesg"] : '');
292
-        $favicon = DolUtils::dol_buildpath('/theme/' . Globals::$conf->theme . '/img/favicon.ico', 1);
292
+        $favicon = DolUtils::dol_buildpath('/theme/'.Globals::$conf->theme.'/img/favicon.ico', 1);
293 293
         if (!empty(Globals::$conf->global->MAIN_FAVICON_URL)) {
294 294
             $favicon = Globals::$conf->global->MAIN_FAVICON_URL;
295 295
         }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
      */
323 323
     function makesalt($type = CRYPT_SALT_LENGTH)
324 324
     {
325
-        DolUtils::dol_syslog("makesalt type=" . $type);
325
+        DolUtils::dol_syslog("makesalt type=".$type);
326 326
         switch ($type) {
327 327
             case 12: // 8 + 4
328 328
                 $saltlen = 8;
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
         while (dol_strlen($salt) < $saltlen)
346 346
             $salt .= chr(mt_rand(64, 126));
347 347
 
348
-        $result = $saltprefix . $salt . $saltsuffix;
349
-        DolUtils::dol_syslog("makesalt return=" . $result);
348
+        $result = $saltprefix.$salt.$saltsuffix;
349
+        DolUtils::dol_syslog("makesalt return=".$result);
350 350
         return $result;
351 351
     }
352 352
 
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
      */
359 359
     function encodedecode_dbpassconf($level = 0)
360 360
     {
361
-        DolUtils::dol_syslog("encodedecode_dbpassconf level=" . $level, LOG_DEBUG);
361
+        DolUtils::dol_syslog("encodedecode_dbpassconf level=".$level, LOG_DEBUG);
362 362
         Globals::$config = '';
363 363
         $passwd = '';
364 364
         $passwd_crypted = '';
365 365
 
366
-        if ($fp = fopen(DOL_DOCUMENT_ROOT . '/conf/conf.php', 'r')) {
366
+        if ($fp = fopen(DOL_DOCUMENT_ROOT.'/conf/conf.php', 'r')) {
367 367
             while (!feof($fp)) {
368 368
                 $buffer = fgets($fp, 4096);
369 369
 
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
                 if ($lineofpass) {
401 401
 // Add value at end of file
402 402
                     if ($level == 0) {
403
-                        Globals::$config .= '$dolibarr_main_db_pass=\'' . $passwd . '\';' . "\n";
403
+                        Globals::$config .= '$dolibarr_main_db_pass=\''.$passwd.'\';'."\n";
404 404
                     }
405 405
                     if ($level == 1) {
406
-                        Globals::$config .= '$dolibarr_main_db_pass=\'crypted:' . $passwd_crypted . '\';' . "\n";
406
+                        Globals::$config .= '$dolibarr_main_db_pass=\'crypted:'.$passwd_crypted.'\';'."\n";
407 407
                     }
408 408
 
409 409
 //print 'passwd = '.$passwd.' - passwd_crypted = '.$passwd_crypted;
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
             fclose($fp);
416 416
 
417 417
 // Write new conf file
418
-            $file = DOL_DOCUMENT_ROOT . '/conf/conf.php';
418
+            $file = DOL_DOCUMENT_ROOT.'/conf/conf.php';
419 419
             if ($fp = @fopen($file, 'w')) {
420 420
                 fputs($fp, Globals::$config);
421 421
                 fflush($fp);
@@ -491,10 +491,10 @@  discard block
 block discarded – undo
491 491
                 $generated_password = str_shuffle($randomCode);
492 492
             }
493 493
         } else if (!empty(Globals::$conf->global->USER_PASSWORD_GENERATED)) {
494
-            $nomclass = "modGeneratePass" . ucfirst(Globals::$conf->global->USER_PASSWORD_GENERATED);
495
-            $nomfichier = $nomclass . ".class.php";
494
+            $nomclass = "modGeneratePass".ucfirst(Globals::$conf->global->USER_PASSWORD_GENERATED);
495
+            $nomfichier = $nomclass.".class.php";
496 496
 //print DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomclass;
497
-            require_once DOL_DOCUMENT_ROOT . "/core/modules/security/generate/" . $nomfichier;
497
+            require_once DOL_DOCUMENT_ROOT."/core/modules/security/generate/".$nomfichier;
498 498
             $genhandler = new $nomclass($db, Globals::$conf, Globals::$langs, $user);
499 499
             $generated_password = $genhandler->getNewGeneratedPassword();
500 500
             unset($genhandler);
Please login to merge, or discard this patch.
Braces   +10 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,10 +39,13 @@  discard block
 block discarded – undo
39 39
     function dol_getwebuser($mode)
40 40
     {
41 41
         $t = '?';
42
-        if ($mode == 'user')
43
-            $t = getenv('APACHE_RUN_USER');   // $_ENV['APACHE_RUN_USER'] is empty
44
-        if ($mode == 'group')
45
-            $t = getenv('APACHE_RUN_GROUP');
42
+        if ($mode == 'user') {
43
+                    $t = getenv('APACHE_RUN_USER');
44
+        }
45
+        // $_ENV['APACHE_RUN_USER'] is empty
46
+        if ($mode == 'group') {
47
+                    $t = getenv('APACHE_RUN_GROUP');
48
+        }
46 49
         return $t;
47 50
     }
48 51
 
@@ -342,8 +345,9 @@  discard block
 block discarded – undo
342 345
                 break;
343 346
         }
344 347
         $salt = '';
345
-        while (dol_strlen($salt) < $saltlen)
346
-            $salt .= chr(mt_rand(64, 126));
348
+        while (dol_strlen($salt) < $saltlen) {
349
+                    $salt .= chr(mt_rand(64, 126));
350
+        }
347 351
 
348 352
         $result = $saltprefix . $salt . $saltsuffix;
349 353
         DolUtils::dol_syslog("makesalt return=" . $result);
Please login to merge, or discard this patch.
Helpers/Security.php 2 patches
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
         }
111 111
         // Salt value
112 112
         if (!empty(Globals::$conf->global->MAIN_SECURITY_SALT)) {
113
-            $chain = Globals::$conf->global->MAIN_SECURITY_SALT . $chain;
113
+            $chain = Globals::$conf->global->MAIN_SECURITY_SALT.$chain;
114 114
         }
115 115
         if ($type == '1' || $type == 'sha1') {
116 116
             return sha1($chain);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             return md5($chain);
123 123
         }
124 124
         if ($type == '4' || $type == 'md5openldap') {
125
-            return '{md5}' . base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
125
+            return '{md5}'.base64_encode(mhash(MHASH_MD5, $chain)); // For OpenLdap with md5 (based on an unencrypted password in base)
126 126
         }
127 127
         if ($type == '5') {
128 128
             return hash('sha256', $chain);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             return false;
203 203
 
204 204
         if ($dbt_select != 'rowid' && $dbt_select != 'id')
205
-            $objectid = "'" . $objectid . "'";
205
+            $objectid = "'".$objectid."'";
206 206
 
207 207
         // Features/modules to check
208 208
         $featuresarray = array($features);
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
                 else if ($feature == 'ftp') {
403 403
                     if (!$user->rights->ftp->write)
404 404
                         $deleteok = 0;
405
-                }else if ($feature == 'salaries') {
405
+                } else if ($feature == 'salaries') {
406 406
                     if (!$user->rights->salaries->delete)
407 407
                         $deleteok = 0;
408 408
                 }
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
                 $feature = 'projet_task';
481 481
 
482 482
             $check = array('adherent', 'banque', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource'); // Test on entity only (Objects with no link to company)
483
-            $checksoc = array('societe');  // Test for societe object
484
-            $checkother = array('contact', 'agenda');  // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
483
+            $checksoc = array('societe'); // Test for societe object
484
+            $checkother = array('contact', 'agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...).
485 485
             $checkproject = array('projet', 'project'); // Test for project object
486 486
             $checktask = array('projet_task');
487 487
             $nocheck = array('barcode', 'stock'); // No test
@@ -489,32 +489,32 @@  discard block
 block discarded – undo
489 489
             // If dbtablename not defined, we use same name for table than module name
490 490
             if (empty($dbtablename)) {
491 491
                 $dbtablename = $feature;
492
-                $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename);  // We change dbtablename, so we set sharedelement too.
492
+                $sharedelement = (!empty($params[1]) ? $params[1] : $dbtablename); // We change dbtablename, so we set sharedelement too.
493 493
             }
494 494
 
495 495
             // Check permission for object with entity
496 496
             if (in_array($feature, $check)) {
497
-                $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
498
-                $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
497
+                $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
498
+                $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
499 499
                 if (($feature == 'user' || $feature == 'usergroup') && !empty($conf->multicompany->enabled)) {
500 500
                     if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
501 501
                         if ($conf->entity == 1 && $user->admin && !$user->entity) {
502
-                            $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
502
+                            $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
503 503
                             $sql .= " AND dbt.entity IS NOT NULL";
504 504
                         } else {
505
-                            $sql .= "," . MAIN_DB_PREFIX . "usergroup_user as ug";
506
-                            $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
505
+                            $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
506
+                            $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
507 507
                             $sql .= " AND (ug.fk_user = dbt.rowid";
508
-                            $sql .= " AND ug.entity IN (" . getEntity('user') . "))";
508
+                            $sql .= " AND ug.entity IN (".getEntity('user')."))";
509 509
                             $sql .= " OR dbt.entity = 0"; // Show always superadmin
510 510
                         }
511 511
                     } else {
512
-                        $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
513
-                        $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
512
+                        $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
513
+                        $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
514 514
                     }
515 515
                 } else {
516
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
517
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
516
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
517
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
518 518
                 }
519 519
             } else if (in_array($feature, $checksoc)) { // We check feature = checksoc
520 520
                 // If external user: Check permission for external users
@@ -525,47 +525,47 @@  discard block
 block discarded – undo
525 525
                 // If internal user: Check permission for internal users that are restricted on their objects
526 526
                 else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
527 527
                     $sql = "SELECT COUNT(sc.fk_soc) as nb";
528
-                    $sql .= " FROM (" . MAIN_DB_PREFIX . "societe_commerciaux as sc";
529
-                    $sql .= ", " . MAIN_DB_PREFIX . "societe as s)";
530
-                    $sql .= " WHERE sc.fk_soc IN (" . $objectid . ")";
531
-                    $sql .= " AND sc.fk_user = " . $user->id;
528
+                    $sql .= " FROM (".MAIN_DB_PREFIX."societe_commerciaux as sc";
529
+                    $sql .= ", ".MAIN_DB_PREFIX."societe as s)";
530
+                    $sql .= " WHERE sc.fk_soc IN (".$objectid.")";
531
+                    $sql .= " AND sc.fk_user = ".$user->id;
532 532
                     $sql .= " AND sc.fk_soc = s.rowid";
533
-                    $sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
533
+                    $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
534 534
                 }
535 535
                 // If multicompany and internal users with all permissions, check user is in correct entity
536 536
                 else if (!empty($conf->multicompany->enabled)) {
537 537
                     $sql = "SELECT COUNT(s.rowid) as nb";
538
-                    $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
539
-                    $sql .= " WHERE s.rowid IN (" . $objectid . ")";
540
-                    $sql .= " AND s.entity IN (" . getEntity($sharedelement, 1) . ")";
538
+                    $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
539
+                    $sql .= " WHERE s.rowid IN (".$objectid.")";
540
+                    $sql .= " AND s.entity IN (".getEntity($sharedelement, 1).")";
541 541
                 }
542 542
             } else if (in_array($feature, $checkother)) { // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
543 543
                 // If external user: Check permission for external users
544 544
                 if ($user->socid > 0) {
545
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
546
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
547
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
548
-                    $sql .= " AND dbt.fk_soc = " . $user->socid;
545
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
546
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
547
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
548
+                    $sql .= " AND dbt.fk_soc = ".$user->socid;
549 549
                 }
550 550
                 // If internal user: Check permission for internal users that are restricted on their objects
551 551
                 else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
552
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
553
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
554
-                    $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '" . $user->id . "'";
555
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
552
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
553
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
554
+                    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON dbt.fk_soc = sc.fk_soc AND sc.fk_user = '".$user->id."'";
555
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
556 556
                     $sql .= " AND (dbt.fk_soc IS NULL OR sc.fk_soc IS NOT NULL)"; // Contact not linked to a company or to a company of user
557
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
557
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
558 558
                 }
559 559
                 // If multicompany and internal users with all permissions, check user is in correct entity
560 560
                 else if (!empty($conf->multicompany->enabled)) {
561
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
562
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
563
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
564
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
561
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
562
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
563
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
564
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
565 565
                 }
566 566
             } else if (in_array($feature, $checkproject)) {
567 567
                 if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) {
568
-                    include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
568
+                    include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
569 569
                     $projectstatic = new Project($db);
570 570
                     $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
571 571
                     $tmparray = explode(',', $tmps);
@@ -573,17 +573,17 @@  discard block
 block discarded – undo
573 573
                         return false;
574 574
                 }
575 575
                 else {
576
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
577
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
578
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
579
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
576
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
577
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
578
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
579
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
580 580
                 }
581 581
             } else if (in_array($feature, $checktask)) {
582 582
                 if (!empty($conf->projet->enabled) && empty($user->rights->projet->all->lire)) {
583 583
                     $task = new Task($db);
584 584
                     $task->fetch($objectid);
585 585
 
586
-                    include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
586
+                    include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
587 587
                     $projectstatic = new Project($db);
588 588
                     $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
589 589
                     $tmparray = explode(',', $tmps);
@@ -591,41 +591,41 @@  discard block
 block discarded – undo
591 591
                         return false;
592 592
                 }
593 593
                 else {
594
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
595
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
596
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
597
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
594
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
595
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
596
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
597
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
598 598
                 }
599 599
             } else if (!in_array($feature, $nocheck)) {  // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
600 600
                 // If external user: Check permission for external users
601 601
                 if ($user->socid > 0) {
602 602
                     if (empty($dbt_keyfield))
603 603
                         dol_print_error('', 'Param dbt_keyfield is required but not defined');
604
-                    $sql = "SELECT COUNT(dbt." . $dbt_keyfield . ") as nb";
605
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
606
-                    $sql .= " WHERE dbt.rowid IN (" . $objectid . ")";
607
-                    $sql .= " AND dbt." . $dbt_keyfield . " = " . $user->socid;
604
+                    $sql = "SELECT COUNT(dbt.".$dbt_keyfield.") as nb";
605
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
606
+                    $sql .= " WHERE dbt.rowid IN (".$objectid.")";
607
+                    $sql .= " AND dbt.".$dbt_keyfield." = ".$user->socid;
608 608
                 }
609 609
                 // If internal user: Check permission for internal users that are restricted on their objects
610 610
                 else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
611 611
                     if (empty($dbt_keyfield))
612 612
                         dol_print_error('', 'Param dbt_keyfield is required but not defined');
613 613
                     $sql = "SELECT COUNT(sc.fk_soc) as nb";
614
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
615
-                    $sql .= ", " . MAIN_DB_PREFIX . "societe as s";
616
-                    $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
617
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
618
-                    $sql .= " AND sc.fk_soc = dbt." . $dbt_keyfield;
619
-                    $sql .= " AND dbt." . $dbt_keyfield . " = s.rowid";
620
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
621
-                    $sql .= " AND sc.fk_user = " . $user->id;
614
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
615
+                    $sql .= ", ".MAIN_DB_PREFIX."societe as s";
616
+                    $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
617
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
618
+                    $sql .= " AND sc.fk_soc = dbt.".$dbt_keyfield;
619
+                    $sql .= " AND dbt.".$dbt_keyfield." = s.rowid";
620
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
621
+                    $sql .= " AND sc.fk_user = ".$user->id;
622 622
                 }
623 623
                 // If multicompany and internal users with all permissions, check user is in correct entity
624 624
                 else if (!empty($conf->multicompany->enabled)) {
625
-                    $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
626
-                    $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
627
-                    $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
628
-                    $sql .= " AND dbt.entity IN (" . getEntity($sharedelement, 1) . ")";
625
+                    $sql = "SELECT COUNT(dbt.".$dbt_select.") as nb";
626
+                    $sql .= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
627
+                    $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
628
+                    $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
629 629
                 }
630 630
             }
631 631
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
     {
659 659
         global $conf, $db, $user, $langs;
660 660
         if (!is_object($langs)) {
661
-            include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php';
661
+            include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
662 662
             $langs = new Translate('', $conf);
663 663
             $langs->setDefaultLang();
664 664
         }
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
         print '<br>';
681 681
         if (empty($showonlymessage)) {
682 682
             if ($user->login) {
683
-                print $langs->trans("CurrentLogin") . ': <font class="error">' . $user->login . '</font><br>';
683
+                print $langs->trans("CurrentLogin").': <font class="error">'.$user->login.'</font><br>';
684 684
                 print $langs->trans("ErrorForbidden2", $langs->trans("Home"), $langs->trans("Users"));
685 685
             } else {
686 686
                 print $langs->trans("ErrorForbidden3");
Please login to merge, or discard this patch.
Braces   +129 added lines, -104 removed lines patch added patch discarded remove patch
@@ -196,24 +196,29 @@  discard block
 block discarded – undo
196 196
         // Get more permissions checks from hooks
197 197
         $parameters = array('features' => $features, 'objectid' => $objectid, 'idtype' => $dbt_select);
198 198
         $reshook = $hookmanager->executeHooks('restrictedArea', $parameters);
199
-        if (!empty($hookmanager->resArray['result']))
200
-            return true;
201
-        if ($reshook > 0)
202
-            return false;
199
+        if (!empty($hookmanager->resArray['result'])) {
200
+                    return true;
201
+        }
202
+        if ($reshook > 0) {
203
+                    return false;
204
+        }
203 205
 
204
-        if ($dbt_select != 'rowid' && $dbt_select != 'id')
205
-            $objectid = "'" . $objectid . "'";
206
+        if ($dbt_select != 'rowid' && $dbt_select != 'id') {
207
+                    $objectid = "'" . $objectid . "'";
208
+        }
206 209
 
207 210
         // Features/modules to check
208 211
         $featuresarray = array($features);
209
-        if (preg_match('/&/', $features))
210
-            $featuresarray = explode("&", $features);
211
-        else if (preg_match('/\|/', $features))
212
-            $featuresarray = explode("|", $features);
212
+        if (preg_match('/&/', $features)) {
213
+                    $featuresarray = explode("&", $features);
214
+        } else if (preg_match('/\|/', $features)) {
215
+                    $featuresarray = explode("|", $features);
216
+        }
213 217
 
214 218
         // More subfeatures to check
215
-        if (!empty($feature2))
216
-            $feature2 = explode("|", $feature2);
219
+        if (!empty($feature2)) {
220
+                    $feature2 = explode("|", $feature2);
221
+        }
217 222
 
218 223
         // More parameters
219 224
         $params = explode('&', $tableandshare);
@@ -227,8 +232,9 @@  discard block
 block discarded – undo
227 232
         $nbko = 0;
228 233
         foreach ($featuresarray as $feature) { // first we check nb of test ko
229 234
             $featureforlistofmodule = $feature;
230
-            if ($featureforlistofmodule == 'produit')
231
-                $featureforlistofmodule = 'product';
235
+            if ($featureforlistofmodule == 'produit') {
236
+                            $featureforlistofmodule = 'product';
237
+            }
232 238
             if (!empty($user->societe_id) && !empty($conf->global->MAIN_MODULES_FOR_EXTERNAL) && !in_array($featureforlistofmodule, $listofmodules)) { // If limits on modules for external users, module must be into list of modules for external users
233 239
                 $readok = 0;
234 240
                 $nbko++;
@@ -290,11 +296,13 @@  discard block
 block discarded – undo
290 296
         }
291 297
 
292 298
         // If a or and at least one ok
293
-        if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
294
-            $readok = 1;
299
+        if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
300
+                    $readok = 1;
301
+        }
295 302
 
296
-        if (!$readok)
297
-            accessforbidden();
303
+        if (!$readok) {
304
+                    accessforbidden();
305
+        }
298 306
         //print "Read access is ok";
299 307
         // Check write permission from module (we need to know write permission to create but also to delete drafts record)
300 308
         $createok = 1;
@@ -351,22 +359,26 @@  discard block
 block discarded – undo
351 359
             }
352 360
 
353 361
             // If a or and at least one ok
354
-            if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
355
-                $createok = 1;
362
+            if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
363
+                            $createok = 1;
364
+            }
356 365
 
357
-            if (GETPOST('action', 'aZ09') == 'create' && !$createok)
358
-                accessforbidden();
366
+            if (GETPOST('action', 'aZ09') == 'create' && !$createok) {
367
+                            accessforbidden();
368
+            }
359 369
             //print "Write access is ok";
360 370
         }
361 371
 
362 372
         // Check create user permission
363 373
         $createuserok = 1;
364 374
         if (GETPOST('action', 'aZ09') == 'confirm_create_user' && GETPOST("confirm", 'aZ09') == 'yes') {
365
-            if (!$user->rights->user->user->creer)
366
-                $createuserok = 0;
375
+            if (!$user->rights->user->user->creer) {
376
+                            $createuserok = 0;
377
+            }
367 378
 
368
-            if (!$createuserok)
369
-                accessforbidden();
379
+            if (!$createuserok) {
380
+                            accessforbidden();
381
+            }
370 382
             //print "Create user access is ok";
371 383
         }
372 384
 
@@ -376,62 +388,66 @@  discard block
 block discarded – undo
376 388
         if ((GETPOST("action", "aZ09") == 'confirm_delete' && GETPOST("confirm", "aZ09") == 'yes') || GETPOST("action", "aZ09") == 'delete') {
377 389
             foreach ($featuresarray as $feature) {
378 390
                 if ($feature == 'contact') {
379
-                    if (!$user->rights->societe->contact->supprimer)
380
-                        $deleteok = 0;
381
-                }
382
-                else if ($feature == 'produit|service') {
383
-                    if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer)
384
-                        $deleteok = 0;
385
-                }
386
-                else if ($feature == 'commande_fournisseur') {
387
-                    if (!$user->rights->fournisseur->commande->supprimer)
388
-                        $deleteok = 0;
389
-                }
390
-                else if ($feature == 'banque') {
391
-                    if (!$user->rights->banque->modifier)
392
-                        $deleteok = 0;
393
-                }
394
-                else if ($feature == 'cheque') {
395
-                    if (!$user->rights->banque->cheque)
396
-                        $deleteok = 0;
397
-                }
398
-                else if ($feature == 'ecm') {
399
-                    if (!$user->rights->ecm->upload)
400
-                        $deleteok = 0;
401
-                }
402
-                else if ($feature == 'ftp') {
403
-                    if (!$user->rights->ftp->write)
404
-                        $deleteok = 0;
405
-                }else if ($feature == 'salaries') {
406
-                    if (!$user->rights->salaries->delete)
407
-                        $deleteok = 0;
408
-                }
409
-                else if ($feature == 'salaries') {
410
-                    if (!$user->rights->salaries->delete)
411
-                        $deleteok = 0;
412
-                }
413
-                else if (!empty($feature2)) { // This should be used for permissions on 2 levels
391
+                    if (!$user->rights->societe->contact->supprimer) {
392
+                                            $deleteok = 0;
393
+                    }
394
+                } else if ($feature == 'produit|service') {
395
+                    if (!$user->rights->produit->supprimer && !$user->rights->service->supprimer) {
396
+                                            $deleteok = 0;
397
+                    }
398
+                } else if ($feature == 'commande_fournisseur') {
399
+                    if (!$user->rights->fournisseur->commande->supprimer) {
400
+                                            $deleteok = 0;
401
+                    }
402
+                } else if ($feature == 'banque') {
403
+                    if (!$user->rights->banque->modifier) {
404
+                                            $deleteok = 0;
405
+                    }
406
+                } else if ($feature == 'cheque') {
407
+                    if (!$user->rights->banque->cheque) {
408
+                                            $deleteok = 0;
409
+                    }
410
+                } else if ($feature == 'ecm') {
411
+                    if (!$user->rights->ecm->upload) {
412
+                                            $deleteok = 0;
413
+                    }
414
+                } else if ($feature == 'ftp') {
415
+                    if (!$user->rights->ftp->write) {
416
+                                            $deleteok = 0;
417
+                    }
418
+                } else if ($feature == 'salaries') {
419
+                    if (!$user->rights->salaries->delete) {
420
+                                            $deleteok = 0;
421
+                    }
422
+                } else if ($feature == 'salaries') {
423
+                    if (!$user->rights->salaries->delete) {
424
+                                            $deleteok = 0;
425
+                    }
426
+                } else if (!empty($feature2)) { // This should be used for permissions on 2 levels
414 427
                     foreach ($feature2 as $subfeature) {
415
-                        if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete))
416
-                            $deleteok = 0;
417
-                        else {
428
+                        if (empty($user->rights->$feature->$subfeature->supprimer) && empty($user->rights->$feature->$subfeature->delete)) {
429
+                                                    $deleteok = 0;
430
+                        } else {
418 431
                             $deleteok = 1;
419 432
                             break;
420 433
                         } // For bypass the second test if the first is ok
421 434
                     }
422 435
                 } else if (!empty($feature)) {  // This is used for permissions on 1 level
423 436
                     //print '<br>feature='.$feature.' creer='.$user->rights->$feature->supprimer.' write='.$user->rights->$feature->delete;
424
-                    if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) && empty($user->rights->$feature->run))
425
-                        $deleteok = 0;
437
+                    if (empty($user->rights->$feature->supprimer) && empty($user->rights->$feature->delete) && empty($user->rights->$feature->run)) {
438
+                                            $deleteok = 0;
439
+                    }
426 440
                 }
427 441
             }
428 442
 
429 443
             // If a or and at least one ok
430
-            if (preg_match('/\|/', $features) && $nbko < count($featuresarray))
431
-                $deleteok = 1;
444
+            if (preg_match('/\|/', $features) && $nbko < count($featuresarray)) {
445
+                            $deleteok = 1;
446
+            }
432 447
 
433
-            if (!$deleteok && !($isdraft && $createok))
434
-                accessforbidden();
448
+            if (!$deleteok && !($isdraft && $createok)) {
449
+                            accessforbidden();
450
+            }
435 451
             //print "Delete access is ok";
436 452
         }
437 453
 
@@ -472,12 +488,15 @@  discard block
 block discarded – undo
472 488
             $sql = '';
473 489
 
474 490
             // For backward compatibility
475
-            if ($feature == 'member')
476
-                $feature = 'adherent';
477
-            if ($feature == 'project')
478
-                $feature = 'projet';
479
-            if ($feature == 'task')
480
-                $feature = 'projet_task';
491
+            if ($feature == 'member') {
492
+                            $feature = 'adherent';
493
+            }
494
+            if ($feature == 'project') {
495
+                            $feature = 'projet';
496
+            }
497
+            if ($feature == 'task') {
498
+                            $feature = 'projet_task';
499
+            }
481 500
 
482 501
             $check = array('adherent', 'banque', 'don', 'user', 'usergroup', 'product', 'produit', 'service', 'produit|service', 'categorie', 'resource'); // Test on entity only (Objects with no link to company)
483 502
             $checksoc = array('societe');  // Test for societe object
@@ -519,8 +538,9 @@  discard block
 block discarded – undo
519 538
             } else if (in_array($feature, $checksoc)) { // We check feature = checksoc
520 539
                 // If external user: Check permission for external users
521 540
                 if ($user->socid > 0) {
522
-                    if ($user->socid <> $objectid)
523
-                        return false;
541
+                    if ($user->socid <> $objectid) {
542
+                                            return false;
543
+                    }
524 544
                 }
525 545
                 // If internal user: Check permission for internal users that are restricted on their objects
526 546
                 else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
@@ -569,10 +589,10 @@  discard block
 block discarded – undo
569 589
                     $projectstatic = new Project($db);
570 590
                     $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
571 591
                     $tmparray = explode(',', $tmps);
572
-                    if (!in_array($objectid, $tmparray))
573
-                        return false;
574
-                }
575
-                else {
592
+                    if (!in_array($objectid, $tmparray)) {
593
+                                            return false;
594
+                    }
595
+                } else {
576 596
                     $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
577 597
                     $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
578 598
                     $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
@@ -587,10 +607,10 @@  discard block
 block discarded – undo
587 607
                     $projectstatic = new Project($db);
588 608
                     $tmps = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, 0);
589 609
                     $tmparray = explode(',', $tmps);
590
-                    if (!in_array($task->fk_project, $tmparray))
591
-                        return false;
592
-                }
593
-                else {
610
+                    if (!in_array($task->fk_project, $tmparray)) {
611
+                                            return false;
612
+                    }
613
+                } else {
594 614
                     $sql = "SELECT COUNT(dbt." . $dbt_select . ") as nb";
595 615
                     $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
596 616
                     $sql .= " WHERE dbt." . $dbt_select . " IN (" . $objectid . ")";
@@ -599,8 +619,9 @@  discard block
 block discarded – undo
599 619
             } else if (!in_array($feature, $nocheck)) {  // By default (case of $checkdefault), we check on object entity + link to third party on field $dbt_keyfield
600 620
                 // If external user: Check permission for external users
601 621
                 if ($user->socid > 0) {
602
-                    if (empty($dbt_keyfield))
603
-                        dol_print_error('', 'Param dbt_keyfield is required but not defined');
622
+                    if (empty($dbt_keyfield)) {
623
+                                            dol_print_error('', 'Param dbt_keyfield is required but not defined');
624
+                    }
604 625
                     $sql = "SELECT COUNT(dbt." . $dbt_keyfield . ") as nb";
605 626
                     $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
606 627
                     $sql .= " WHERE dbt.rowid IN (" . $objectid . ")";
@@ -608,8 +629,9 @@  discard block
 block discarded – undo
608 629
                 }
609 630
                 // If internal user: Check permission for internal users that are restricted on their objects
610 631
                 else if (!empty($conf->societe->enabled) && ($user->rights->societe->lire && !$user->rights->societe->client->voir)) {
611
-                    if (empty($dbt_keyfield))
612
-                        dol_print_error('', 'Param dbt_keyfield is required but not defined');
632
+                    if (empty($dbt_keyfield)) {
633
+                                            dol_print_error('', 'Param dbt_keyfield is required but not defined');
634
+                    }
613 635
                     $sql = "SELECT COUNT(sc.fk_soc) as nb";
614 636
                     $sql .= " FROM " . MAIN_DB_PREFIX . $dbtablename . " as dbt";
615 637
                     $sql .= ", " . MAIN_DB_PREFIX . "societe as s";
@@ -633,10 +655,10 @@  discard block
 block discarded – undo
633 655
                 $resql = $db->query($sql);
634 656
                 if ($resql) {
635 657
                     $obj = $db->fetch_object($resql);
636
-                    if (!$obj || $obj->nb < count(explode(',', $objectid)))
637
-                        return false;
638
-                }
639
-                else {
658
+                    if (!$obj || $obj->nb < count(explode(',', $objectid))) {
659
+                                            return false;
660
+                    }
661
+                } else {
640 662
                     return false;
641 663
                 }
642 664
             }
@@ -666,16 +688,18 @@  discard block
 block discarded – undo
666 688
         $langs->load("errors");
667 689
 
668 690
         if ($printheader) {
669
-            if (function_exists("llxHeader"))
670
-                llxHeader('');
671
-            else if (function_exists("llxHeaderVierge"))
672
-                llxHeaderVierge('');
691
+            if (function_exists("llxHeader")) {
692
+                            llxHeader('');
693
+            } else if (function_exists("llxHeaderVierge")) {
694
+                            llxHeaderVierge('');
695
+            }
673 696
         }
674 697
         print '<div class="error">';
675
-        if (!$message)
676
-            print $langs->trans("ErrorForbidden");
677
-        else
678
-            print $message;
698
+        if (!$message) {
699
+                    print $langs->trans("ErrorForbidden");
700
+        } else {
701
+                    print $message;
702
+        }
679 703
         print '</div>';
680 704
         print '<br>';
681 705
         if (empty($showonlymessage)) {
@@ -686,8 +710,9 @@  discard block
 block discarded – undo
686 710
                 print $langs->trans("ErrorForbidden3");
687 711
             }
688 712
         }
689
-        if ($printfooter && function_exists("llxFooter"))
690
-            llxFooter();
713
+        if ($printfooter && function_exists("llxFooter")) {
714
+                    llxFooter();
715
+        }
691 716
         exit(0);
692 717
     }
693 718
 }
Please login to merge, or discard this patch.
Helpers/DateLib.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
             $monthref = dol_print_date($gmtnow, '%m');
90 90
             $dayref = dol_print_date($gmtnow, '%d');
91 91
             if ($refgmtdate == 'now')
92
-                $newrefgmtdate = $yearref . '-' . $monthref . '-' . $dayref;
92
+                $newrefgmtdate = $yearref.'-'.$monthref.'-'.$dayref;
93 93
             elseif ($refgmtdate == 'summer')
94
-                $newrefgmtdate = $yearref . '-08-01';
94
+                $newrefgmtdate = $yearref.'-08-01';
95 95
             else
96
-                $newrefgmtdate = $yearref . '-01-01';
96
+                $newrefgmtdate = $yearref.'-01-01';
97 97
             $newrefgmtdate .= 'T00:00:00+00:00';
98 98
             $localtz = new DateTimeZone(getServerTimeZoneString());
99 99
             $localdt = new DateTime($newrefgmtdate, $localtz);
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
         global $langs;
202 202
 
203 203
         if (empty($lengthOfDay))
204
-            $lengthOfDay = 86400;         // 1 day = 24 hours
204
+            $lengthOfDay = 86400; // 1 day = 24 hours
205 205
         if (empty($lengthOfWeek))
206
-            $lengthOfWeek = 7;            // 1 week = 7 days
206
+            $lengthOfWeek = 7; // 1 week = 7 days
207 207
 
208 208
         if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') {
209 209
             if ((int) $iSecond === 0)
@@ -226,12 +226,12 @@  discard block
 block discarded – undo
226 226
             if ($lengthOfWeek < 7) {
227 227
                 if ($sDay) {
228 228
                     if ($sDay >= $lengthOfWeek) {
229
-                        $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
229
+                        $sWeek = (int) (($sDay - $sDay % $lengthOfWeek) / $lengthOfWeek);
230 230
                         $sDay = $sDay % $lengthOfWeek;
231 231
                         $weekTranslate = $langs->trans("DurationWeek");
232 232
                         if ($sWeek >= 2)
233 233
                             $weekTranslate = $langs->trans("DurationWeeks");
234
-                        $sTime .= $sWeek . ' ' . $weekTranslate . ' ';
234
+                        $sTime .= $sWeek.' '.$weekTranslate.' ';
235 235
                     }
236 236
                 }
237 237
             }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
                 $dayTranslate = $langs->trans("Day");
240 240
                 if ($sDay > 1)
241 241
                     $dayTranslate = $langs->trans("Days");
242
-                $sTime .= $sDay . ' ' . $dayTranslate . ' ';
242
+                $sTime .= $sDay.' '.$dayTranslate.' ';
243 243
             }
244 244
 
245 245
             if ($format == 'all') {
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                 }
249 249
             }
250 250
             if ($format == 'allhourmin') {
251
-                return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))) . ':' . sprintf("%02d", ((int) floor(($iSecond % 3600) / 60)));
251
+                return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600))).':'.sprintf("%02d", ((int) floor(($iSecond % 3600) / 60)));
252 252
             }
253 253
             if ($format == 'allhour') {
254 254
                 return sprintf("%02d", ($sWeek * $lengthOfWeek * 24 + $sDay * 24 + (int) floor($iSecond / 3600)));
@@ -289,16 +289,16 @@  discard block
 block discarded – undo
289 289
         $sqldate = "";
290 290
         if ($month_date > 0) {
291 291
             if ($year_date > 0 && empty($day_date)) {
292
-                $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_get_first_day($year_date, $month_date, false));
293
-                $sqldate .= "' AND '" . $db->idate(dol_get_last_day($year_date, $month_date, false)) . "'";
292
+                $sqldate .= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, $month_date, false));
293
+                $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, $month_date, false))."'";
294 294
             } else if ($year_date > 0 && !empty($day_date)) {
295
-                $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
296
-                $sqldate .= "' AND '" . $db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date)) . "'";
295
+                $sqldate .= " AND ".$datefield." BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
296
+                $sqldate .= "' AND '".$db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date))."'";
297 297
             } else
298
-                $sqldate .= " AND date_format( " . $datefield . ", '%m') = '" . $db->escape($month_date) . "'";
298
+                $sqldate .= " AND date_format( ".$datefield.", '%m') = '".$db->escape($month_date)."'";
299 299
         } else if ($year_date > 0) {
300
-            $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_get_first_day($year_date, 1, false));
301
-            $sqldate .= "' AND '" . $db->idate(dol_get_last_day($year_date, 12, false)) . "'";
300
+            $sqldate .= " AND ".$datefield." BETWEEN '".$db->idate(dol_get_first_day($year_date, 1, false));
301
+            $sqldate .= "' AND '".$db->idate(dol_get_last_day($year_date, 12, false))."'";
302 302
         }
303 303
         return $sqldate;
304 304
     }
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         }
356 356
 
357 357
         $string = preg_replace('/([^0-9])/i', '', $string);
358
-        $tmp = $string . '000000';
358
+        $tmp = $string.'000000';
359 359
         $date = DolUtils::dol_mktime(substr($tmp, 8, 2), substr($tmp, 10, 2), substr($tmp, 12, 2), substr($tmp, 4, 2), substr($tmp, 6, 2), substr($tmp, 0, 4), ($gm ? 1 : 0));
360 360
         return $date;
361 361
     }
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
             return 'ErrorDates must use same hours and must be GMT dates';
595 595
 
596 596
         $i = 0;
597
-        while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) && ($i < 50000)) {  // Loop end when equals (Test on i is a security loop to avoid infinite loop)
597
+        while ((($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd)) && ($i < 50000)) {  // Loop end when equals (Test on i is a security loop to avoid infinite loop)
598 598
             $ferie = false;
599 599
             $countryfound = 0;
600 600
             $includesaturdayandsunday = 1;
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
         if (empty($country_code))
918 918
             $country_code = $mysoc->country_code;
919 919
 
920
-        dol_syslog('num_open_day timestampStart=' . $timestampStart . ' timestampEnd=' . $timestampEnd . ' bit=' . $lastday . ' country_code=' . $country_code);
920
+        dol_syslog('num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday.' country_code='.$country_code);
921 921
 
922 922
         // Check parameters
923 923
         if (!is_int($timestampStart) && !is_float($timestampStart))
@@ -930,15 +930,15 @@  discard block
 block discarded – undo
930 930
             $numdays = num_between_day($timestampStart, $timestampEnd, $lastday);
931 931
             $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
932 932
             $nbOpenDay = $numdays - $numholidays;
933
-            $nbOpenDay .= " " . $langs->trans("Days");
933
+            $nbOpenDay .= " ".$langs->trans("Days");
934 934
             if ($inhour == 1 && $nbOpenDay <= 3)
935
-                $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
935
+                $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort");
936 936
             return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
937 937
         }
938 938
         elseif ($timestampStart == $timestampEnd) {
939 939
             $nbOpenDay = $lastday;
940 940
             if ($inhour == 1)
941
-                $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
941
+                $nbOpenDay = $nbOpenDay * 24.$langs->trans("HourShort");
942 942
             return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
943 943
         }
944 944
         else {
Please login to merge, or discard this patch.
Braces   +310 added lines, -184 removed lines patch added patch discarded remove patch
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
             $yearref = dol_print_date($gmtnow, '%Y');
89 89
             $monthref = dol_print_date($gmtnow, '%m');
90 90
             $dayref = dol_print_date($gmtnow, '%d');
91
-            if ($refgmtdate == 'now')
92
-                $newrefgmtdate = $yearref . '-' . $monthref . '-' . $dayref;
93
-            elseif ($refgmtdate == 'summer')
94
-                $newrefgmtdate = $yearref . '-08-01';
95
-            else
96
-                $newrefgmtdate = $yearref . '-01-01';
91
+            if ($refgmtdate == 'now') {
92
+                            $newrefgmtdate = $yearref . '-' . $monthref . '-' . $dayref;
93
+            } elseif ($refgmtdate == 'summer') {
94
+                            $newrefgmtdate = $yearref . '-08-01';
95
+            } else {
96
+                            $newrefgmtdate = $yearref . '-01-01';
97
+            }
97 98
             $newrefgmtdate .= 'T00:00:00+00:00';
98 99
             $localtz = new DateTimeZone(getServerTimeZoneString());
99 100
             $localdt = new DateTime($newrefgmtdate, $localtz);
100 101
             $tmp = -1 * $localtz->getOffset($localdt);
101 102
             //print $refgmtdate.'='.$tmp;
102
-        }
103
-        else {
103
+        } else {
104 104
             $tmp = 0;
105 105
             dol_print_error('', 'PHP version must be 5.3+');
106 106
         }
@@ -120,12 +120,15 @@  discard block
 block discarded – undo
120 120
     {
121 121
         global $conf;
122 122
 
123
-        if ($duration_value == 0)
124
-            return $time;
125
-        if ($duration_unit == 'h')
126
-            return $time + (3600 * $duration_value);
127
-        if ($duration_unit == 'w')
128
-            return $time + (3600 * 24 * 7 * $duration_value);
123
+        if ($duration_value == 0) {
124
+                    return $time;
125
+        }
126
+        if ($duration_unit == 'h') {
127
+                    return $time + (3600 * $duration_value);
128
+        }
129
+        if ($duration_unit == 'w') {
130
+                    return $time + (3600 * 24 * 7 * $duration_value);
131
+        }
129 132
 
130 133
         $deltastring = 'P';
131 134
 
@@ -148,15 +151,17 @@  discard block
 block discarded – undo
148 151
         }
149 152
 
150 153
         $date = new DateTime();
151
-        if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT))
152
-            $date->setTimezone(new DateTimeZone('UTC'));
154
+        if (!empty($conf->global->MAIN_DATE_IN_MEMORY_ARE_GMT)) {
155
+                    $date->setTimezone(new DateTimeZone('UTC'));
156
+        }
153 157
         $date->setTimestamp($time);
154 158
         $interval = new DateInterval($deltastring);
155 159
 
156
-        if ($sub)
157
-            $date->sub($interval);
158
-        else
159
-            $date->add($interval);
160
+        if ($sub) {
161
+                    $date->sub($interval);
162
+        } else {
163
+                    $date->add($interval);
164
+        }
160 165
 
161 166
         return $date->getTimestamp();
162 167
     }
@@ -200,14 +205,20 @@  discard block
 block discarded – undo
200 205
     {
201 206
         global $langs;
202 207
 
203
-        if (empty($lengthOfDay))
204
-            $lengthOfDay = 86400;         // 1 day = 24 hours
205
-        if (empty($lengthOfWeek))
206
-            $lengthOfWeek = 7;            // 1 week = 7 days
208
+        if (empty($lengthOfDay)) {
209
+                    $lengthOfDay = 86400;
210
+        }
211
+        // 1 day = 24 hours
212
+        if (empty($lengthOfWeek)) {
213
+                    $lengthOfWeek = 7;
214
+        }
215
+        // 1 week = 7 days
207 216
 
208 217
         if ($format == 'all' || $format == 'allwithouthour' || $format == 'allhour' || $format == 'allhourmin') {
209
-            if ((int) $iSecond === 0)
210
-                return '0'; // This is to avoid having 0 return a 12:00 AM for en_US
218
+            if ((int) $iSecond === 0) {
219
+                            return '0';
220
+            }
221
+            // This is to avoid having 0 return a 12:00 AM for en_US
211 222
 
212 223
             $sTime = '';
213 224
             $sDay = 0;
@@ -219,8 +230,9 @@  discard block
 block discarded – undo
219 230
                     $iSecond -= $lengthOfDay;
220 231
                 }
221 232
                 $dayTranslate = $langs->trans("Day");
222
-                if ($iSecond >= ($lengthOfDay * 2))
223
-                    $dayTranslate = $langs->trans("Days");
233
+                if ($iSecond >= ($lengthOfDay * 2)) {
234
+                                    $dayTranslate = $langs->trans("Days");
235
+                }
224 236
             }
225 237
 
226 238
             if ($lengthOfWeek < 7) {
@@ -229,16 +241,18 @@  discard block
 block discarded – undo
229 241
                         $sWeek = (int) (($sDay - $sDay % $lengthOfWeek ) / $lengthOfWeek);
230 242
                         $sDay = $sDay % $lengthOfWeek;
231 243
                         $weekTranslate = $langs->trans("DurationWeek");
232
-                        if ($sWeek >= 2)
233
-                            $weekTranslate = $langs->trans("DurationWeeks");
244
+                        if ($sWeek >= 2) {
245
+                                                    $weekTranslate = $langs->trans("DurationWeeks");
246
+                        }
234 247
                         $sTime .= $sWeek . ' ' . $weekTranslate . ' ';
235 248
                     }
236 249
                 }
237 250
             }
238 251
             if ($sDay > 0) {
239 252
                 $dayTranslate = $langs->trans("Day");
240
-                if ($sDay > 1)
241
-                    $dayTranslate = $langs->trans("Days");
253
+                if ($sDay > 1) {
254
+                                    $dayTranslate = $langs->trans("Days");
255
+                }
242 256
                 $sTime .= $sDay . ' ' . $dayTranslate . ' ';
243 257
             }
244 258
 
@@ -294,8 +308,9 @@  discard block
 block discarded – undo
294 308
             } else if ($year_date > 0 && !empty($day_date)) {
295 309
                 $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_mktime(0, 0, 0, $month_date, $day_date, $year_date));
296 310
                 $sqldate .= "' AND '" . $db->idate(dol_mktime(23, 59, 59, $month_date, $day_date, $year_date)) . "'";
297
-            } else
298
-                $sqldate .= " AND date_format( " . $datefield . ", '%m') = '" . $db->escape($month_date) . "'";
311
+            } else {
312
+                            $sqldate .= " AND date_format( " . $datefield . ", '%m') = '" . $db->escape($month_date) . "'";
313
+            }
299 314
         } else if ($year_date > 0) {
300 315
             $sqldate .= " AND " . $datefield . " BETWEEN '" . $db->idate(dol_get_first_day($year_date, 1, false));
301 316
             $sqldate .= "' AND '" . $db->idate(dol_get_last_day($year_date, 12, false)) . "'";
@@ -334,13 +349,14 @@  discard block
 block discarded – undo
334 349
             $shour = $reg[4];
335 350
             $smin = $reg[5];
336 351
             $ssec = $reg[6];
337
-            if ($syear < 50)
338
-                $syear += 1900;
339
-            if ($syear >= 50 && $syear < 100)
340
-                $syear += 2000;
352
+            if ($syear < 50) {
353
+                            $syear += 1900;
354
+            }
355
+            if ($syear >= 50 && $syear < 100) {
356
+                            $syear += 2000;
357
+            }
341 358
             $string = sprintf("%04d%02d%02d%02d%02d%02d", $syear, $smonth, $sday, $shour, $smin, $ssec);
342
-        }
343
-        else if (
359
+        } else if (
344 360
             preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/i', $string, $reg) // Convert date with format YYYY-MM-DDTHH:MM:SSZ (RFC3339)
345 361
             || preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/i', $string, $reg) // Convert date with format YYYY-MM-DD HH:MM:SS
346 362
             || preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z$/i', $string, $reg)  // Convert date with format YYYYMMDDTHHMMSSZ
@@ -474,8 +490,9 @@  discard block
 block discarded – undo
474 490
      */
475 491
     function dol_get_first_day($year, $month = 1, $gm = false)
476 492
     {
477
-        if ($year > 9999)
478
-            return '';
493
+        if ($year > 9999) {
494
+                    return '';
495
+        }
479 496
         return dol_mktime(0, 0, 0, $month, 1, $year, $gm);
480 497
     }
481 498
 
@@ -488,8 +505,9 @@  discard block
 block discarded – undo
488 505
      */
489 506
     function dol_get_last_day($year, $month = 12, $gm = false)
490 507
     {
491
-        if ($year > 9999)
492
-            return '';
508
+        if ($year > 9999) {
509
+                    return '';
510
+        }
493 511
         if ($month == 12) {
494 512
             $month = 1;
495 513
             $year += 1;
@@ -525,8 +543,9 @@  discard block
 block discarded – undo
525 543
         $tmparray = dol_getdate($date, true); // detail of current day
526 544
         //Calculate days = offset from current day
527 545
         $days = $start_week - $tmparray['wday'];
528
-        if ($days >= 1)
529
-            $days = 7 - $days;
546
+        if ($days >= 1) {
547
+                    $days = 7 - $days;
548
+        }
530 549
         $days = abs($days);
531 550
         $seconds = $days * 24 * 60 * 60;
532 551
         //print 'start_week='.$start_week.' tmparray[wday]='.$tmparray['wday'].' day offset='.$days.' seconds offset='.$seconds.'<br>';
@@ -590,8 +609,9 @@  discard block
 block discarded – undo
590 609
         $nbFerie = 0;
591 610
 
592 611
         // Check to ensure we use correct parameters
593
-        if ((($timestampEnd - $timestampStart) % 86400) != 0)
594
-            return 'ErrorDates must use same hours and must be GMT dates';
612
+        if ((($timestampEnd - $timestampStart) % 86400) != 0) {
613
+                    return 'ErrorDates must use same hours and must be GMT dates';
614
+        }
595 615
 
596 616
         $i = 0;
597 617
         while (( ($lastday == 0 && $timestampStart < $timestampEnd) || ($lastday && $timestampStart <= $timestampEnd) ) && ($i < 50000)) {  // Loop end when equals (Test on i is a security loop to avoid infinite loop)
@@ -610,12 +630,13 @@  discard block
 block discarded – undo
610 630
                 foreach ($arrayofdaystring as $daystring) {
611 631
                     $tmp = explode('-', $daystring);
612 632
                     if ($tmp[2]) {
613
-                        if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour)
614
-                            $ferie = true;
615
-                    }
616
-                    else {
617
-                        if ($tmp[0] == $mois && $tmp[1] == $jour)
618
-                            $ferie = true;
633
+                        if ($tmp[0] == $annee && $tmp[1] == $mois && $tmp[2] == $jour) {
634
+                                                    $ferie = true;
635
+                        }
636
+                    } else {
637
+                        if ($tmp[0] == $mois && $tmp[1] == $jour) {
638
+                                                    $ferie = true;
639
+                        }
619 640
                     }
620 641
                 }
621 642
             }
@@ -624,22 +645,38 @@  discard block
 block discarded – undo
624 645
                 $countryfound = 1;
625 646
 
626 647
                 // Definition of fixed working days
627
-                if ($jour == 1 && $mois == 1)
628
-                    $ferie = true; // 1er january
629
-                if ($jour == 1 && $mois == 5)
630
-                    $ferie = true; // 1er may
631
-                if ($jour == 8 && $mois == 5)
632
-                    $ferie = true; // 5 may
633
-                if ($jour == 14 && $mois == 7)
634
-                    $ferie = true; // 14 july
635
-                if ($jour == 15 && $mois == 8)
636
-                    $ferie = true; // 15 august
637
-                if ($jour == 1 && $mois == 11)
638
-                    $ferie = true; // 1 november
639
-                if ($jour == 11 && $mois == 11)
640
-                    $ferie = true; // 11 november
641
-                if ($jour == 25 && $mois == 12)
642
-                    $ferie = true; // 25 december
648
+                if ($jour == 1 && $mois == 1) {
649
+                                    $ferie = true;
650
+                }
651
+                // 1er january
652
+                if ($jour == 1 && $mois == 5) {
653
+                                    $ferie = true;
654
+                }
655
+                // 1er may
656
+                if ($jour == 8 && $mois == 5) {
657
+                                    $ferie = true;
658
+                }
659
+                // 5 may
660
+                if ($jour == 14 && $mois == 7) {
661
+                                    $ferie = true;
662
+                }
663
+                // 14 july
664
+                if ($jour == 15 && $mois == 8) {
665
+                                    $ferie = true;
666
+                }
667
+                // 15 august
668
+                if ($jour == 1 && $mois == 11) {
669
+                                    $ferie = true;
670
+                }
671
+                // 1 november
672
+                if ($jour == 11 && $mois == 11) {
673
+                                    $ferie = true;
674
+                }
675
+                // 11 november
676
+                if ($jour == 25 && $mois == 12) {
677
+                                    $ferie = true;
678
+                }
679
+                // 25 december
643 680
 
644 681
 
645 682
                     
@@ -647,8 +684,9 @@  discard block
 block discarded – undo
647 684
                 $date_paques = easter_date($annee);
648 685
                 $jour_paques = date("d", $date_paques);
649 686
                 $mois_paques = date("m", $date_paques);
650
-                if ($jour_paques == $jour && $mois_paques == $mois)
651
-                    $ferie = true;
687
+                if ($jour_paques == $jour && $mois_paques == $mois) {
688
+                                    $ferie = true;
689
+                }
652 690
                 // Pâques
653 691
                 // Calculation for the monday of easter date
654 692
                 $date_lundi_paques = mktime(
@@ -656,8 +694,9 @@  discard block
 block discarded – undo
656 694
                 );
657 695
                 $jour_lundi_ascension = date("d", $date_lundi_paques);
658 696
                 $mois_lundi_ascension = date("m", $date_lundi_paques);
659
-                if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois)
660
-                    $ferie = true;
697
+                if ($jour_lundi_ascension == $jour && $mois_lundi_ascension == $mois) {
698
+                                    $ferie = true;
699
+                }
661 700
                 // Lundi de Pâques
662 701
                 // Calcul du jour de l'ascension (38 days after easter day)
663 702
                 $date_ascension = mktime(
@@ -665,8 +704,9 @@  discard block
 block discarded – undo
665 704
                 );
666 705
                 $jour_ascension = date("d", $date_ascension);
667 706
                 $mois_ascension = date("m", $date_ascension);
668
-                if ($jour_ascension == $jour && $mois_ascension == $mois)
669
-                    $ferie = true;
707
+                if ($jour_ascension == $jour && $mois_ascension == $mois) {
708
+                                    $ferie = true;
709
+                }
670 710
                 // Ascension
671 711
                 // Calculation of "Pentecote" (11 days after easter day)
672 712
                 $date_pentecote = mktime(
@@ -674,8 +714,9 @@  discard block
 block discarded – undo
674 714
                 );
675 715
                 $jour_pentecote = date("d", $date_pentecote);
676 716
                 $mois_pentecote = date("m", $date_pentecote);
677
-                if ($jour_pentecote == $jour && $mois_pentecote == $mois)
678
-                    $ferie = true;
717
+                if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
718
+                                    $ferie = true;
719
+                }
679 720
                 // "Pentecote"
680 721
             }
681 722
 
@@ -685,26 +726,46 @@  discard block
 block discarded – undo
685 726
                 $countryfound = 1;
686 727
 
687 728
                 // Definition des dates feriees fixes
688
-                if ($jour == 1 && $mois == 1)
689
-                    $ferie = true; // Capodanno
690
-                if ($jour == 6 && $mois == 1)
691
-                    $ferie = true; // Epifania
692
-                if ($jour == 25 && $mois == 4)
693
-                    $ferie = true; // Anniversario Liberazione
694
-                if ($jour == 1 && $mois == 5)
695
-                    $ferie = true; // Festa del Lavoro
696
-                if ($jour == 2 && $mois == 6)
697
-                    $ferie = true; // Festa della Repubblica
698
-                if ($jour == 15 && $mois == 8)
699
-                    $ferie = true; // Ferragosto
700
-                if ($jour == 1 && $mois == 11)
701
-                    $ferie = true; // Tutti i Santi
702
-                if ($jour == 8 && $mois == 12)
703
-                    $ferie = true; // Immacolata Concezione
704
-                if ($jour == 25 && $mois == 12)
705
-                    $ferie = true; // 25 decembre
706
-                if ($jour == 26 && $mois == 12)
707
-                    $ferie = true; // Santo Stefano
729
+                if ($jour == 1 && $mois == 1) {
730
+                                    $ferie = true;
731
+                }
732
+                // Capodanno
733
+                if ($jour == 6 && $mois == 1) {
734
+                                    $ferie = true;
735
+                }
736
+                // Epifania
737
+                if ($jour == 25 && $mois == 4) {
738
+                                    $ferie = true;
739
+                }
740
+                // Anniversario Liberazione
741
+                if ($jour == 1 && $mois == 5) {
742
+                                    $ferie = true;
743
+                }
744
+                // Festa del Lavoro
745
+                if ($jour == 2 && $mois == 6) {
746
+                                    $ferie = true;
747
+                }
748
+                // Festa della Repubblica
749
+                if ($jour == 15 && $mois == 8) {
750
+                                    $ferie = true;
751
+                }
752
+                // Ferragosto
753
+                if ($jour == 1 && $mois == 11) {
754
+                                    $ferie = true;
755
+                }
756
+                // Tutti i Santi
757
+                if ($jour == 8 && $mois == 12) {
758
+                                    $ferie = true;
759
+                }
760
+                // Immacolata Concezione
761
+                if ($jour == 25 && $mois == 12) {
762
+                                    $ferie = true;
763
+                }
764
+                // 25 decembre
765
+                if ($jour == 26 && $mois == 12) {
766
+                                    $ferie = true;
767
+                }
768
+                // Santo Stefano
708 769
 
709 770
 
710 771
                     
@@ -712,50 +773,81 @@  discard block
 block discarded – undo
712 773
                 $date_paques = easter_date($annee);
713 774
                 $jour_paques = date("d", $date_paques);
714 775
                 $mois_paques = date("m", $date_paques);
715
-                if ($jour_paques == $jour && $mois_paques == $mois)
716
-                    $ferie = true;
776
+                if ($jour_paques == $jour && $mois_paques == $mois) {
777
+                                    $ferie = true;
778
+                }
717 779
                 // Paques
718 780
             }
719 781
 
720 782
             if ($countrycode == 'IN') {
721 783
                 $countryfound = 1;
722 784
 
723
-                if ($jour == 1 && $mois == 1)
724
-                    $ferie = true; // New Year's Day
725
-                if ($jour == 26 && $mois == 1)
726
-                    $ferie = true; // Republic Day
727
-                if ($jour == 1 && $mois == 5)
728
-                    $ferie = true; // May Day
729
-                if ($jour == 15 && $mois == 8)
730
-                    $ferie = true; // Independence Day
731
-                if ($jour == 2 && $mois == 10)
732
-                    $ferie = true; // Gandhi Jayanti
733
-                if ($jour == 25 && $mois == 12)
734
-                    $ferie = true; // Christmas
785
+                if ($jour == 1 && $mois == 1) {
786
+                                    $ferie = true;
787
+                }
788
+                // New Year's Day
789
+                if ($jour == 26 && $mois == 1) {
790
+                                    $ferie = true;
791
+                }
792
+                // Republic Day
793
+                if ($jour == 1 && $mois == 5) {
794
+                                    $ferie = true;
795
+                }
796
+                // May Day
797
+                if ($jour == 15 && $mois == 8) {
798
+                                    $ferie = true;
799
+                }
800
+                // Independence Day
801
+                if ($jour == 2 && $mois == 10) {
802
+                                    $ferie = true;
803
+                }
804
+                // Gandhi Jayanti
805
+                if ($jour == 25 && $mois == 12) {
806
+                                    $ferie = true;
807
+                }
808
+                // Christmas
735 809
             }
736 810
 
737 811
             if ($countrycode == 'ES') {
738 812
                 $countryfound = 1;
739 813
 
740 814
                 // Definition des dates feriees fixes
741
-                if ($jour == 1 && $mois == 1)
742
-                    $ferie = true; // Año nuevo
743
-                if ($jour == 6 && $mois == 1)
744
-                    $ferie = true; // Día Reyes
745
-                if ($jour == 1 && $mois == 5)
746
-                    $ferie = true; // 1 Mayo
747
-                if ($jour == 15 && $mois == 8)
748
-                    $ferie = true; // 15 Agosto
749
-                if ($jour == 12 && $mois == 10)
750
-                    $ferie = true; // Día Hispanidad
751
-                if ($jour == 1 && $mois == 11)
752
-                    $ferie = true; // 1 noviembre
753
-                if ($jour == 6 && $mois == 12)
754
-                    $ferie = true; // Constitución
755
-                if ($jour == 8 && $mois == 12)
756
-                    $ferie = true; // Inmaculada
757
-                if ($jour == 25 && $mois == 12)
758
-                    $ferie = true; // 25 diciembre
815
+                if ($jour == 1 && $mois == 1) {
816
+                                    $ferie = true;
817
+                }
818
+                // Año nuevo
819
+                if ($jour == 6 && $mois == 1) {
820
+                                    $ferie = true;
821
+                }
822
+                // Día Reyes
823
+                if ($jour == 1 && $mois == 5) {
824
+                                    $ferie = true;
825
+                }
826
+                // 1 Mayo
827
+                if ($jour == 15 && $mois == 8) {
828
+                                    $ferie = true;
829
+                }
830
+                // 15 Agosto
831
+                if ($jour == 12 && $mois == 10) {
832
+                                    $ferie = true;
833
+                }
834
+                // Día Hispanidad
835
+                if ($jour == 1 && $mois == 11) {
836
+                                    $ferie = true;
837
+                }
838
+                // 1 noviembre
839
+                if ($jour == 6 && $mois == 12) {
840
+                                    $ferie = true;
841
+                }
842
+                // Constitución
843
+                if ($jour == 8 && $mois == 12) {
844
+                                    $ferie = true;
845
+                }
846
+                // Inmaculada
847
+                if ($jour == 25 && $mois == 12) {
848
+                                    $ferie = true;
849
+                }
850
+                // 25 diciembre
759 851
 
760 852
 
761 853
                     
@@ -763,8 +855,9 @@  discard block
 block discarded – undo
763 855
                 $date_paques = easter_date($annee);
764 856
                 $jour_paques = date("d", $date_paques);
765 857
                 $mois_paques = date("m", $date_paques);
766
-                if ($jour_paques == $jour && $mois_paques == $mois)
767
-                    $ferie = true;
858
+                if ($jour_paques == $jour && $mois_paques == $mois) {
859
+                                    $ferie = true;
860
+                }
768 861
                 // Paques
769 862
                 // Viernes Santo
770 863
                 $date_viernes = mktime(
@@ -772,8 +865,9 @@  discard block
 block discarded – undo
772 865
                 );
773 866
                 $jour_viernes = date("d", $date_viernes);
774 867
                 $mois_viernes = date("m", $date_viernes);
775
-                if ($jour_viernes == $jour && $mois_viernes == $mois)
776
-                    $ferie = true;
868
+                if ($jour_viernes == $jour && $mois_viernes == $mois) {
869
+                                    $ferie = true;
870
+                }
777 871
                 //Viernes Santo
778 872
             }
779 873
 
@@ -781,28 +875,50 @@  discard block
 block discarded – undo
781 875
                 $countryfound = 1;
782 876
 
783 877
                 // Definition des dates feriees fixes
784
-                if ($jour == 1 && $mois == 1)
785
-                    $ferie = true; // Neujahr
786
-                if ($jour == 6 && $mois == 1)
787
-                    $ferie = true; // Hl. 3 Koenige
788
-                if ($jour == 1 && $mois == 5)
789
-                    $ferie = true; // 1. Mai
790
-                if ($jour == 15 && $mois == 8)
791
-                    $ferie = true; // Mariae Himmelfahrt
792
-                if ($jour == 26 && $mois == 10)
793
-                    $ferie = true; // 26. Oktober
794
-                if ($jour == 1 && $mois == 11)
795
-                    $ferie = true; // Allerheiligen
796
-                if ($jour == 8 && $mois == 12)
797
-                    $ferie = true; // Mariae Empfaengnis
798
-                if ($jour == 24 && $mois == 12)
799
-                    $ferie = true; // Heilig abend
800
-                if ($jour == 25 && $mois == 12)
801
-                    $ferie = true; // Christtag
802
-                if ($jour == 26 && $mois == 12)
803
-                    $ferie = true; // Stefanietag
804
-                if ($jour == 31 && $mois == 12)
805
-                    $ferie = true; // Silvester
878
+                if ($jour == 1 && $mois == 1) {
879
+                                    $ferie = true;
880
+                }
881
+                // Neujahr
882
+                if ($jour == 6 && $mois == 1) {
883
+                                    $ferie = true;
884
+                }
885
+                // Hl. 3 Koenige
886
+                if ($jour == 1 && $mois == 5) {
887
+                                    $ferie = true;
888
+                }
889
+                // 1. Mai
890
+                if ($jour == 15 && $mois == 8) {
891
+                                    $ferie = true;
892
+                }
893
+                // Mariae Himmelfahrt
894
+                if ($jour == 26 && $mois == 10) {
895
+                                    $ferie = true;
896
+                }
897
+                // 26. Oktober
898
+                if ($jour == 1 && $mois == 11) {
899
+                                    $ferie = true;
900
+                }
901
+                // Allerheiligen
902
+                if ($jour == 8 && $mois == 12) {
903
+                                    $ferie = true;
904
+                }
905
+                // Mariae Empfaengnis
906
+                if ($jour == 24 && $mois == 12) {
907
+                                    $ferie = true;
908
+                }
909
+                // Heilig abend
910
+                if ($jour == 25 && $mois == 12) {
911
+                                    $ferie = true;
912
+                }
913
+                // Christtag
914
+                if ($jour == 26 && $mois == 12) {
915
+                                    $ferie = true;
916
+                }
917
+                // Stefanietag
918
+                if ($jour == 31 && $mois == 12) {
919
+                                    $ferie = true;
920
+                }
921
+                // Silvester
806 922
 
807 923
 
808 924
                     
@@ -810,8 +926,9 @@  discard block
 block discarded – undo
810 926
                 $date_paques = easter_date($annee);
811 927
                 $jour_paques = date("d", $date_paques);
812 928
                 $mois_paques = date("m", $date_paques);
813
-                if ($jour_paques == $jour && $mois_paques == $mois)
814
-                    $ferie = true;
929
+                if ($jour_paques == $jour && $mois_paques == $mois) {
930
+                                    $ferie = true;
931
+                }
815 932
                 // Easter sunday
816 933
                 // Monday after easter
817 934
                 $date_eastermonday = mktime(
@@ -819,8 +936,9 @@  discard block
 block discarded – undo
819 936
                 );
820 937
                 $jour_eastermonday = date("d", $date_eastermonday);
821 938
                 $mois_eastermonday = date("m", $date_eastermonday);
822
-                if ($jour_eastermonday == $jour && $mois_eastermonday == $mois)
823
-                    $ferie = true;
939
+                if ($jour_eastermonday == $jour && $mois_eastermonday == $mois) {
940
+                                    $ferie = true;
941
+                }
824 942
                 // Easter monday
825 943
                 // Christi Himmelfahrt (39 days after easter sunday)
826 944
                 $date_ch = mktime(
@@ -828,8 +946,9 @@  discard block
 block discarded – undo
828 946
                 );
829 947
                 $jour_ch = date("d", $date_ch);
830 948
                 $mois_ch = date("m", $date_ch);
831
-                if ($jour_ch == $jour && $mois_ch == $mois)
832
-                    $ferie = true;
949
+                if ($jour_ch == $jour && $mois_ch == $mois) {
950
+                                    $ferie = true;
951
+                }
833 952
                 // Christi Himmelfahrt
834 953
                 // Pfingsten (50 days after easter sunday)
835 954
                 $date_pentecote = mktime(
@@ -837,8 +956,9 @@  discard block
 block discarded – undo
837 956
                 );
838 957
                 $jour_pentecote = date("d", $date_pentecote);
839 958
                 $mois_pentecote = date("m", $date_pentecote);
840
-                if ($jour_pentecote == $jour && $mois_pentecote == $mois)
841
-                    $ferie = true;
959
+                if ($jour_pentecote == $jour && $mois_pentecote == $mois) {
960
+                                    $ferie = true;
961
+                }
842 962
                 // Pfingsten
843 963
                 // Fronleichnam (60 days after easter sunday)
844 964
                 $date_fronleichnam = mktime(
@@ -846,8 +966,9 @@  discard block
 block discarded – undo
846 966
                 );
847 967
                 $jour_fronleichnam = date("d", $date_fronleichnam);
848 968
                 $mois_fronleichnam = date("m", $date_fronleichnam);
849
-                if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois)
850
-                    $ferie = true;
969
+                if ($jour_fronleichnam == $jour && $mois_fronleichnam == $mois) {
970
+                                    $ferie = true;
971
+                }
851 972
                 // Fronleichnam
852 973
             }
853 974
 
@@ -855,14 +976,16 @@  discard block
 block discarded – undo
855 976
             if ($includesaturdayandsunday) {
856 977
                 $jour_julien = unixtojd($timestampStart);
857 978
                 $jour_semaine = jddayofweek($jour_julien, 0);
858
-                if ($jour_semaine == 0 || $jour_semaine == 6)
859
-                    $ferie = true;
979
+                if ($jour_semaine == 0 || $jour_semaine == 6) {
980
+                                    $ferie = true;
981
+                }
860 982
                 //Saturday (6) and Sunday (0)
861 983
             }
862 984
 
863 985
             // On incremente compteur
864
-            if ($ferie)
865
-                $nbFerie++;
986
+            if ($ferie) {
987
+                            $nbFerie++;
988
+            }
866 989
 
867 990
             // Increase number of days (on go up into loop)
868 991
             $timestampStart = dol_time_plus_duree($timestampStart, 1, 'd');
@@ -914,16 +1037,19 @@  discard block
 block discarded – undo
914 1037
     {
915 1038
         global $langs, $mysoc;
916 1039
 
917
-        if (empty($country_code))
918
-            $country_code = $mysoc->country_code;
1040
+        if (empty($country_code)) {
1041
+                    $country_code = $mysoc->country_code;
1042
+        }
919 1043
 
920 1044
         dol_syslog('num_open_day timestampStart=' . $timestampStart . ' timestampEnd=' . $timestampEnd . ' bit=' . $lastday . ' country_code=' . $country_code);
921 1045
 
922 1046
         // Check parameters
923
-        if (!is_int($timestampStart) && !is_float($timestampStart))
924
-            return 'ErrorBadParameter_num_open_day';
925
-        if (!is_int($timestampEnd) && !is_float($timestampEnd))
926
-            return 'ErrorBadParameter_num_open_day';
1047
+        if (!is_int($timestampStart) && !is_float($timestampStart)) {
1048
+                    return 'ErrorBadParameter_num_open_day';
1049
+        }
1050
+        if (!is_int($timestampEnd) && !is_float($timestampEnd)) {
1051
+                    return 'ErrorBadParameter_num_open_day';
1052
+        }
927 1053
 
928 1054
         //print 'num_open_day timestampStart='.$timestampStart.' timestampEnd='.$timestampEnd.' bit='.$lastday;
929 1055
         if ($timestampStart < $timestampEnd) {
@@ -931,17 +1057,17 @@  discard block
 block discarded – undo
931 1057
             $numholidays = num_public_holiday($timestampStart, $timestampEnd, $country_code, $lastday);
932 1058
             $nbOpenDay = $numdays - $numholidays;
933 1059
             $nbOpenDay .= " " . $langs->trans("Days");
934
-            if ($inhour == 1 && $nbOpenDay <= 3)
935
-                $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
1060
+            if ($inhour == 1 && $nbOpenDay <= 3) {
1061
+                            $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
1062
+            }
936 1063
             return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
937
-        }
938
-        elseif ($timestampStart == $timestampEnd) {
1064
+        } elseif ($timestampStart == $timestampEnd) {
939 1065
             $nbOpenDay = $lastday;
940
-            if ($inhour == 1)
941
-                $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
1066
+            if ($inhour == 1) {
1067
+                            $nbOpenDay = $nbOpenDay * 24 . $langs->trans("HourShort");
1068
+            }
942 1069
             return $nbOpenDay - (($inhour == 1 ? 12 : 0.5) * abs($halfday));
943
-        }
944
-        else {
1070
+        } else {
945 1071
             return $langs->trans("Error");
946 1072
         }
947 1073
     }
Please login to merge, or discard this patch.
Helpers/triggers/interface_50_modLdap_Ldapsynchro.class.php 3 patches
Indentation   +771 added lines, -771 removed lines patch added patch discarded remove patch
@@ -31,781 +31,781 @@
 block discarded – undo
31 31
  */
32 32
 class InterfaceLdapsynchro extends DolibarrTriggers
33 33
 {
34
-	public $family = 'ldap';
35
-	public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
36
-
37
-	/**
38
-	 * Version of the trigger
39
-	 * @var string
40
-	 */
41
-	public $version = self::VERSION_DOLIBARR;
42
-
43
-	/**
44
-	 * @var string Image of the trigger
45
-	 */
46
-	public $picto = 'technic';
47
-
48
-	/**
49
-	 * Function called when a Dolibarrr business event is done.
50
-	 * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
51
-	 *
52
-	 * @param string		$action		Event action code
53
-	 * @param Object		$object     Object
54
-	 * @param User		    $user       Object user
55
-	 * @param Translate 	$langs      Object langs
56
-	 * @param conf		    $conf       Object conf
57
-	 * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
58
-	 */
59
-	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60
-	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
63
-
64
-		if (! function_exists('ldap_connect'))
65
-		{
66
-			dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67
-			return 0;
68
-		}
69
-
70
-		require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71
-		require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72
-
73
-		$result=0;
74
-
75
-		// Users
76
-		if ($action == 'USER_CREATE')
77
-		{
78
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80
-			{
81
-				$ldap=new Ldap();
82
-				$result=$ldap->connect_bind();
83
-
84
-				if ($result > 0)
85
-				{
86
-					$info=$object->_load_ldap_info();
87
-					$dn=$object->_load_ldap_dn($info);
88
-
89
-					$result=$ldap->add($dn,$info,$user);
90
-				}
91
-
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
93
-			}
94
-		}
95
-		elseif ($action == 'USER_MODIFY')
96
-		{
97
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99
-			{
100
-				$ldap=new Ldap();
101
-				$result=$ldap->connect_bind();
102
-
103
-				if ($result > 0)
104
-				{
105
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
106
-					{
107
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108
-						$object->oldcopy = clone $object;
109
-					}
110
-
111
-					$oldinfo=$object->oldcopy->_load_ldap_info();
112
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
113
-
114
-					// Verify if entry exist
115
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
-					$records=$ldap->search($container,$search);
118
-					if (count($records) && $records['count'] == 0)
119
-					{
120
-						$olddn = '';
121
-					}
122
-
123
-					$info=$object->_load_ldap_info();
124
-					$dn=$object->_load_ldap_dn($info);
125
-					$newrdn=$object->_load_ldap_dn($info,2);
126
-					$newparent=$object->_load_ldap_dn($info,1);
127
-
128
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129
-				}
130
-
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
132
-			}
133
-		}
134
-		elseif ($action == 'USER_NEW_PASSWORD')
135
-		{
136
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138
-			{
139
-				$ldap=new Ldap();
140
-				$result=$ldap->connect_bind();
141
-
142
-				if ($result > 0)
143
-				{
144
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
145
-					{
146
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147
-						$object->oldcopy = clone $object;
148
-					}
149
-
150
-					$oldinfo=$object->oldcopy->_load_ldap_info();
151
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
152
-
153
-					// Verify if entry exist
154
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
-					$records=$ldap->search($container,$search);
157
-					if (count($records) && $records['count'] == 0)
158
-					{
159
-						$olddn = '';
160
-					}
161
-
162
-					$info=$object->_load_ldap_info();
163
-					$dn=$object->_load_ldap_dn($info);
164
-
165
-					$result=$ldap->update($dn,$info,$user,$olddn);
166
-				}
167
-
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
169
-			}
170
-		}
171
-		elseif ($action == 'USER_ENABLEDISABLE')
172
-		{
173
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
-		}
175
-		elseif ($action == 'USER_DELETE')
176
-		{
177
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179
-			{
180
-				$ldap=new Ldap();
181
-				$result=$ldap->connect_bind();
182
-
183
-				if ($result > 0)
184
-				{
185
-					$info=$object->_load_ldap_info();
186
-					$dn=$object->_load_ldap_dn($info);
187
-
188
-					$result=$ldap->delete($dn);
189
-				}
190
-
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
192
-			}
193
-		}
194
-		elseif ($action == 'USER_SETINGROUP')
195
-		{
196
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198
-			{
199
-				$ldap=new Ldap();
200
-				$result=$ldap->connect_bind();
201
-
202
-				if ($result > 0)
203
-				{
204
-					// Must edit $object->newgroupid
205
-					$usergroup=new UserGroup($this->db);
206
-					if ($object->newgroupid > 0)
207
-					{
208
-						$usergroup->fetch($object->newgroupid);
209
-
210
-						$oldinfo=$usergroup->_load_ldap_info();
211
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
212
-
213
-						// Verify if entry exist
214
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
215
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
-						$records=$ldap->search($container,$search);
217
-						if (count($records) && $records['count'] == 0)
218
-						{
219
-							$olddn = '';
220
-						}
221
-
222
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
-						$dn=$usergroup->_load_ldap_dn($info);
224
-
225
-						$result=$ldap->update($dn,$info,$user,$olddn);
226
-					}
227
-				}
228
-
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
230
-			}
231
-		}
232
-		elseif ($action == 'USER_REMOVEFROMGROUP')
233
-		{
234
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236
-			{
237
-				$ldap=new Ldap();
238
-				$result=$ldap->connect_bind();
239
-
240
-				if ($result > 0)
241
-				{
242
-					// Must edit $object->newgroupid
243
-					$usergroup=new UserGroup($this->db);
244
-					if ($object->oldgroupid > 0)
245
-					{
246
-						$usergroup->fetch($object->oldgroupid);
247
-
248
-						$oldinfo=$usergroup->_load_ldap_info();
249
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
250
-
251
-						// Verify if entry exist
252
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
253
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
-						$records=$ldap->search($container,$search);
255
-						if (count($records) && $records['count'] == 0)
256
-						{
257
-							$olddn = '';
258
-						}
259
-
260
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
-						$dn=$usergroup->_load_ldap_dn($info);
262
-
263
-						$result=$ldap->update($dn,$info,$user,$olddn);
264
-					}
265
-				}
266
-
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
268
-			}
269
-		}
270
-
271
-		// Groupes
272
-		elseif ($action == 'GROUP_CREATE')
273
-		{
274
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276
-			{
277
-				$ldap=new Ldap();
278
-				$result=$ldap->connect_bind();
279
-
280
-				if ($result > 0)
281
-				{
282
-					$info=$object->_load_ldap_info();
283
-					$dn=$object->_load_ldap_dn($info);
284
-
285
-					// Get a gid number for objectclass PosixGroup
286
-					if (in_array('posixGroup',$info['objectclass'])) {
287
-						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288
-					}
289
-
290
-					$result=$ldap->add($dn,$info,$user);
291
-				}
292
-
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
294
-			}
295
-		}
296
-		elseif ($action == 'GROUP_MODIFY')
297
-		{
298
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300
-			{
301
-				$ldap=new Ldap();
302
-				$result=$ldap->connect_bind();
303
-
304
-				if ($result > 0)
305
-				{
306
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
307
-					{
308
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309
-						$object->oldcopy = clone $object;
310
-					}
311
-
312
-					$oldinfo=$object->oldcopy->_load_ldap_info();
313
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
314
-
315
-					// Verify if entry exist
316
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
-					$records=$ldap->search($container,$search);
319
-					if (count($records) && $records['count'] == 0)
320
-					{
321
-						$olddn = '';
322
-					}
323
-
324
-					$info=$object->_load_ldap_info();
325
-					$dn=$object->_load_ldap_dn($info);
326
-
327
-					$result=$ldap->update($dn,$info,$user,$olddn);
328
-				}
329
-
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
331
-			}
332
-		}
333
-		elseif ($action == 'GROUP_DELETE')
334
-		{
335
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337
-			{
338
-				$ldap=new Ldap();
339
-				$result=$ldap->connect_bind();
340
-
341
-				if ($result > 0)
342
-				{
343
-					$info=$object->_load_ldap_info();
344
-					$dn=$object->_load_ldap_dn($info);
345
-
346
-					$result=$ldap->delete($dn);
347
-				}
348
-
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
350
-			}
351
-		}
352
-
353
-		// Contacts
354
-		elseif ($action == 'CONTACT_CREATE')
355
-		{
356
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
358
-			{
359
-				$ldap=new Ldap();
360
-				$result=$ldap->connect_bind();
361
-
362
-				if ($result > 0)
363
-				{
364
-					$info=$object->_load_ldap_info();
365
-					$dn=$object->_load_ldap_dn($info);
366
-
367
-					$result=$ldap->add($dn,$info,$user);
368
-				}
369
-
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
371
-			}
372
-		}
373
-		elseif ($action == 'CONTACT_MODIFY')
374
-		{
375
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
377
-			{
378
-				$ldap=new Ldap();
379
-				$result=$ldap->connect_bind();
380
-
381
-				if ($result > 0)
382
-				{
383
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
384
-					{
385
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386
-						$object->oldcopy = clone $object;
387
-					}
388
-
389
-					$oldinfo=$object->oldcopy->_load_ldap_info();
390
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
391
-
392
-					// Verify if entry exist
393
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
-					$records=$ldap->search($container,$search);
396
-					if (count($records) && $records['count'] == 0)
397
-					{
398
-						$olddn = '';
399
-					}
400
-
401
-					$info=$object->_load_ldap_info();
402
-					$dn=$object->_load_ldap_dn($info);
403
-
404
-					$result=$ldap->update($dn,$info,$user,$olddn);
405
-				}
406
-
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
408
-			}
409
-		}
410
-		elseif ($action == 'CONTACT_DELETE')
411
-		{
412
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
414
-			{
415
-				$ldap=new Ldap();
416
-				$result=$ldap->connect_bind();
417
-
418
-				if ($result > 0)
419
-				{
420
-					$info=$object->_load_ldap_info();
421
-					$dn=$object->_load_ldap_dn($info);
422
-
423
-					$result=$ldap->delete($dn);
424
-				}
425
-
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
427
-			}
428
-		}
429
-
430
-		// Members
431
-		elseif ($action == 'MEMBER_CREATE')
432
-		{
433
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435
-			{
436
-				$ldap=new Ldap();
437
-				$result=$ldap->connect_bind();
438
-
439
-				if ($result > 0)
440
-				{
441
-					$info=$object->_load_ldap_info();
442
-					$dn=$object->_load_ldap_dn($info);
443
-
444
-					$result=$ldap->add($dn,$info,$user);
445
-
446
-					// For member type
447
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448
-					{
449
-						$membertype=new AdherentType($this->db);
450
-						if ($object->typeid > 0)
451
-						{
452
-							$membertype->fetch($object->typeid);
453
-							$membertype->listMembersForMemberType('', 1);
454
-
455
-							$oldinfo=$membertype->_load_ldap_info();
456
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
457
-
458
-							// Verify if entry exist
459
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
460
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
-							$records=$ldap->search($container,$search);
462
-							if (count($records) && $records['count'] == 0)
463
-							{
464
-								$olddn = '';
465
-							}
466
-
467
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
-							$dn=$membertype->_load_ldap_dn($info);
469
-
470
-							$result=$ldap->update($dn,$info,$user,$olddn);
471
-						}
472
-					}
473
-				}
474
-
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
476
-			}
477
-		}
478
-		elseif ($action == 'MEMBER_VALIDATE')
479
-		{
480
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482
-			{
483
-				// If status field is setup to be synchronized
484
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485
-				{
486
-					$ldap=new Ldap();
487
-					$result=$ldap->connect_bind();
488
-
489
-					if ($result > 0)
490
-					{
491
-						$info=$object->_load_ldap_info();
492
-						$dn=$object->_load_ldap_dn($info);
493
-						$olddn=$dn;	// We know olddn=dn as we change only status
494
-
495
-						$result=$ldap->update($dn,$info,$user,$olddn);
496
-					}
497
-
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
499
-				}
500
-			}
501
-		}
502
-		elseif ($action == 'MEMBER_SUBSCRIPTION')
503
-		{
504
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506
-			{
507
-				// If subscriptions fields are setup to be synchronized
508
-				if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
509
-					|| $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
510
-					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
511
-					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512
-					|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513
-				{
514
-					$ldap=new Ldap();
515
-					$result=$ldap->connect_bind();
516
-
517
-					if ($result > 0)
518
-					{
519
-						$info=$object->_load_ldap_info();
520
-						$dn=$object->_load_ldap_dn($info);
521
-						$olddn=$dn;	// We know olddn=dn as we change only subscriptions
522
-
523
-						$result=$ldap->update($dn,$info,$user,$olddn);
524
-					}
525
-
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
527
-				}
528
-			}
529
-		}
530
-		elseif ($action == 'MEMBER_MODIFY')
531
-		{
532
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534
-			{
535
-				$ldap=new Ldap();
536
-				$result=$ldap->connect_bind();
537
-
538
-				if ($result > 0)
539
-				{
540
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
541
-					{
542
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543
-						$object->oldcopy = clone $object;
544
-					}
545
-
546
-					$oldinfo=$object->oldcopy->_load_ldap_info();
547
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
548
-
549
-					// Verify if entry exist
550
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
-					$records=$ldap->search($container,$search);
553
-					if (count($records) && $records['count'] == 0)
554
-					{
555
-						$olddn = '';
556
-					}
557
-
558
-					$info=$object->_load_ldap_info();
559
-					$dn=$object->_load_ldap_dn($info);
560
-					$newrdn=$object->_load_ldap_dn($info,2);
561
-					$newparent=$object->_load_ldap_dn($info,1);
562
-
563
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
564
-
565
-					// For member type
566
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567
-					{
568
-						/*
34
+    public $family = 'ldap';
35
+    public $description = "Triggers of this module allows to synchronize Dolibarr toward a LDAP database.";
36
+
37
+    /**
38
+     * Version of the trigger
39
+     * @var string
40
+     */
41
+    public $version = self::VERSION_DOLIBARR;
42
+
43
+    /**
44
+     * @var string Image of the trigger
45
+     */
46
+    public $picto = 'technic';
47
+
48
+    /**
49
+     * Function called when a Dolibarrr business event is done.
50
+     * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared)
51
+     *
52
+     * @param string		$action		Event action code
53
+     * @param Object		$object     Object
54
+     * @param User		    $user       Object user
55
+     * @param Translate 	$langs      Object langs
56
+     * @param conf		    $conf       Object conf
57
+     * @return int         				<0 if KO, 0 if no triggered ran, >0 if OK
58
+     */
59
+    public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60
+    {
61
+        if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
+        if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
63
+
64
+        if (! function_exists('ldap_connect'))
65
+        {
66
+            dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67
+            return 0;
68
+        }
69
+
70
+        require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71
+        require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72
+
73
+        $result=0;
74
+
75
+        // Users
76
+        if ($action == 'USER_CREATE')
77
+        {
78
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80
+            {
81
+                $ldap=new Ldap();
82
+                $result=$ldap->connect_bind();
83
+
84
+                if ($result > 0)
85
+                {
86
+                    $info=$object->_load_ldap_info();
87
+                    $dn=$object->_load_ldap_dn($info);
88
+
89
+                    $result=$ldap->add($dn,$info,$user);
90
+                }
91
+
92
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
93
+            }
94
+        }
95
+        elseif ($action == 'USER_MODIFY')
96
+        {
97
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99
+            {
100
+                $ldap=new Ldap();
101
+                $result=$ldap->connect_bind();
102
+
103
+                if ($result > 0)
104
+                {
105
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
106
+                    {
107
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108
+                        $object->oldcopy = clone $object;
109
+                    }
110
+
111
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
112
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
113
+
114
+                    // Verify if entry exist
115
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
+                    $records=$ldap->search($container,$search);
118
+                    if (count($records) && $records['count'] == 0)
119
+                    {
120
+                        $olddn = '';
121
+                    }
122
+
123
+                    $info=$object->_load_ldap_info();
124
+                    $dn=$object->_load_ldap_dn($info);
125
+                    $newrdn=$object->_load_ldap_dn($info,2);
126
+                    $newparent=$object->_load_ldap_dn($info,1);
127
+
128
+                    $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129
+                }
130
+
131
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
132
+            }
133
+        }
134
+        elseif ($action == 'USER_NEW_PASSWORD')
135
+        {
136
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138
+            {
139
+                $ldap=new Ldap();
140
+                $result=$ldap->connect_bind();
141
+
142
+                if ($result > 0)
143
+                {
144
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
145
+                    {
146
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147
+                        $object->oldcopy = clone $object;
148
+                    }
149
+
150
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
151
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
152
+
153
+                    // Verify if entry exist
154
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
+                    $records=$ldap->search($container,$search);
157
+                    if (count($records) && $records['count'] == 0)
158
+                    {
159
+                        $olddn = '';
160
+                    }
161
+
162
+                    $info=$object->_load_ldap_info();
163
+                    $dn=$object->_load_ldap_dn($info);
164
+
165
+                    $result=$ldap->update($dn,$info,$user,$olddn);
166
+                }
167
+
168
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
169
+            }
170
+        }
171
+        elseif ($action == 'USER_ENABLEDISABLE')
172
+        {
173
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
+        }
175
+        elseif ($action == 'USER_DELETE')
176
+        {
177
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179
+            {
180
+                $ldap=new Ldap();
181
+                $result=$ldap->connect_bind();
182
+
183
+                if ($result > 0)
184
+                {
185
+                    $info=$object->_load_ldap_info();
186
+                    $dn=$object->_load_ldap_dn($info);
187
+
188
+                    $result=$ldap->delete($dn);
189
+                }
190
+
191
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
192
+            }
193
+        }
194
+        elseif ($action == 'USER_SETINGROUP')
195
+        {
196
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198
+            {
199
+                $ldap=new Ldap();
200
+                $result=$ldap->connect_bind();
201
+
202
+                if ($result > 0)
203
+                {
204
+                    // Must edit $object->newgroupid
205
+                    $usergroup=new UserGroup($this->db);
206
+                    if ($object->newgroupid > 0)
207
+                    {
208
+                        $usergroup->fetch($object->newgroupid);
209
+
210
+                        $oldinfo=$usergroup->_load_ldap_info();
211
+                        $olddn=$usergroup->_load_ldap_dn($oldinfo);
212
+
213
+                        // Verify if entry exist
214
+                        $container=$usergroup->_load_ldap_dn($oldinfo,1);
215
+                        $search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
+                        $records=$ldap->search($container,$search);
217
+                        if (count($records) && $records['count'] == 0)
218
+                        {
219
+                            $olddn = '';
220
+                        }
221
+
222
+                        $info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
+                        $dn=$usergroup->_load_ldap_dn($info);
224
+
225
+                        $result=$ldap->update($dn,$info,$user,$olddn);
226
+                    }
227
+                }
228
+
229
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
230
+            }
231
+        }
232
+        elseif ($action == 'USER_REMOVEFROMGROUP')
233
+        {
234
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236
+            {
237
+                $ldap=new Ldap();
238
+                $result=$ldap->connect_bind();
239
+
240
+                if ($result > 0)
241
+                {
242
+                    // Must edit $object->newgroupid
243
+                    $usergroup=new UserGroup($this->db);
244
+                    if ($object->oldgroupid > 0)
245
+                    {
246
+                        $usergroup->fetch($object->oldgroupid);
247
+
248
+                        $oldinfo=$usergroup->_load_ldap_info();
249
+                        $olddn=$usergroup->_load_ldap_dn($oldinfo);
250
+
251
+                        // Verify if entry exist
252
+                        $container=$usergroup->_load_ldap_dn($oldinfo,1);
253
+                        $search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
+                        $records=$ldap->search($container,$search);
255
+                        if (count($records) && $records['count'] == 0)
256
+                        {
257
+                            $olddn = '';
258
+                        }
259
+
260
+                        $info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
+                        $dn=$usergroup->_load_ldap_dn($info);
262
+
263
+                        $result=$ldap->update($dn,$info,$user,$olddn);
264
+                    }
265
+                }
266
+
267
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
268
+            }
269
+        }
270
+
271
+        // Groupes
272
+        elseif ($action == 'GROUP_CREATE')
273
+        {
274
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276
+            {
277
+                $ldap=new Ldap();
278
+                $result=$ldap->connect_bind();
279
+
280
+                if ($result > 0)
281
+                {
282
+                    $info=$object->_load_ldap_info();
283
+                    $dn=$object->_load_ldap_dn($info);
284
+
285
+                    // Get a gid number for objectclass PosixGroup
286
+                    if (in_array('posixGroup',$info['objectclass'])) {
287
+                        $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288
+                    }
289
+
290
+                    $result=$ldap->add($dn,$info,$user);
291
+                }
292
+
293
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
294
+            }
295
+        }
296
+        elseif ($action == 'GROUP_MODIFY')
297
+        {
298
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300
+            {
301
+                $ldap=new Ldap();
302
+                $result=$ldap->connect_bind();
303
+
304
+                if ($result > 0)
305
+                {
306
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
307
+                    {
308
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309
+                        $object->oldcopy = clone $object;
310
+                    }
311
+
312
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
313
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
314
+
315
+                    // Verify if entry exist
316
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
+                    $records=$ldap->search($container,$search);
319
+                    if (count($records) && $records['count'] == 0)
320
+                    {
321
+                        $olddn = '';
322
+                    }
323
+
324
+                    $info=$object->_load_ldap_info();
325
+                    $dn=$object->_load_ldap_dn($info);
326
+
327
+                    $result=$ldap->update($dn,$info,$user,$olddn);
328
+                }
329
+
330
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
331
+            }
332
+        }
333
+        elseif ($action == 'GROUP_DELETE')
334
+        {
335
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
+            if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337
+            {
338
+                $ldap=new Ldap();
339
+                $result=$ldap->connect_bind();
340
+
341
+                if ($result > 0)
342
+                {
343
+                    $info=$object->_load_ldap_info();
344
+                    $dn=$object->_load_ldap_dn($info);
345
+
346
+                    $result=$ldap->delete($dn);
347
+                }
348
+
349
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
350
+            }
351
+        }
352
+
353
+        // Contacts
354
+        elseif ($action == 'CONTACT_CREATE')
355
+        {
356
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
358
+            {
359
+                $ldap=new Ldap();
360
+                $result=$ldap->connect_bind();
361
+
362
+                if ($result > 0)
363
+                {
364
+                    $info=$object->_load_ldap_info();
365
+                    $dn=$object->_load_ldap_dn($info);
366
+
367
+                    $result=$ldap->add($dn,$info,$user);
368
+                }
369
+
370
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
371
+            }
372
+        }
373
+        elseif ($action == 'CONTACT_MODIFY')
374
+        {
375
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
377
+            {
378
+                $ldap=new Ldap();
379
+                $result=$ldap->connect_bind();
380
+
381
+                if ($result > 0)
382
+                {
383
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
384
+                    {
385
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386
+                        $object->oldcopy = clone $object;
387
+                    }
388
+
389
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
390
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
391
+
392
+                    // Verify if entry exist
393
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
+                    $records=$ldap->search($container,$search);
396
+                    if (count($records) && $records['count'] == 0)
397
+                    {
398
+                        $olddn = '';
399
+                    }
400
+
401
+                    $info=$object->_load_ldap_info();
402
+                    $dn=$object->_load_ldap_dn($info);
403
+
404
+                    $result=$ldap->update($dn,$info,$user,$olddn);
405
+                }
406
+
407
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
408
+            }
409
+        }
410
+        elseif ($action == 'CONTACT_DELETE')
411
+        {
412
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
+            if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
414
+            {
415
+                $ldap=new Ldap();
416
+                $result=$ldap->connect_bind();
417
+
418
+                if ($result > 0)
419
+                {
420
+                    $info=$object->_load_ldap_info();
421
+                    $dn=$object->_load_ldap_dn($info);
422
+
423
+                    $result=$ldap->delete($dn);
424
+                }
425
+
426
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
427
+            }
428
+        }
429
+
430
+        // Members
431
+        elseif ($action == 'MEMBER_CREATE')
432
+        {
433
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435
+            {
436
+                $ldap=new Ldap();
437
+                $result=$ldap->connect_bind();
438
+
439
+                if ($result > 0)
440
+                {
441
+                    $info=$object->_load_ldap_info();
442
+                    $dn=$object->_load_ldap_dn($info);
443
+
444
+                    $result=$ldap->add($dn,$info,$user);
445
+
446
+                    // For member type
447
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448
+                    {
449
+                        $membertype=new AdherentType($this->db);
450
+                        if ($object->typeid > 0)
451
+                        {
452
+                            $membertype->fetch($object->typeid);
453
+                            $membertype->listMembersForMemberType('', 1);
454
+
455
+                            $oldinfo=$membertype->_load_ldap_info();
456
+                            $olddn=$membertype->_load_ldap_dn($oldinfo);
457
+
458
+                            // Verify if entry exist
459
+                            $container=$membertype->_load_ldap_dn($oldinfo,1);
460
+                            $search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
+                            $records=$ldap->search($container,$search);
462
+                            if (count($records) && $records['count'] == 0)
463
+                            {
464
+                                $olddn = '';
465
+                            }
466
+
467
+                            $info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
+                            $dn=$membertype->_load_ldap_dn($info);
469
+
470
+                            $result=$ldap->update($dn,$info,$user,$olddn);
471
+                        }
472
+                    }
473
+                }
474
+
475
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
476
+            }
477
+        }
478
+        elseif ($action == 'MEMBER_VALIDATE')
479
+        {
480
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482
+            {
483
+                // If status field is setup to be synchronized
484
+                if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485
+                {
486
+                    $ldap=new Ldap();
487
+                    $result=$ldap->connect_bind();
488
+
489
+                    if ($result > 0)
490
+                    {
491
+                        $info=$object->_load_ldap_info();
492
+                        $dn=$object->_load_ldap_dn($info);
493
+                        $olddn=$dn;	// We know olddn=dn as we change only status
494
+
495
+                        $result=$ldap->update($dn,$info,$user,$olddn);
496
+                    }
497
+
498
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
499
+                }
500
+            }
501
+        }
502
+        elseif ($action == 'MEMBER_SUBSCRIPTION')
503
+        {
504
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506
+            {
507
+                // If subscriptions fields are setup to be synchronized
508
+                if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
509
+                    || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT
510
+                    || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE
511
+                    || $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512
+                    || $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513
+                {
514
+                    $ldap=new Ldap();
515
+                    $result=$ldap->connect_bind();
516
+
517
+                    if ($result > 0)
518
+                    {
519
+                        $info=$object->_load_ldap_info();
520
+                        $dn=$object->_load_ldap_dn($info);
521
+                        $olddn=$dn;	// We know olddn=dn as we change only subscriptions
522
+
523
+                        $result=$ldap->update($dn,$info,$user,$olddn);
524
+                    }
525
+
526
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
527
+                }
528
+            }
529
+        }
530
+        elseif ($action == 'MEMBER_MODIFY')
531
+        {
532
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534
+            {
535
+                $ldap=new Ldap();
536
+                $result=$ldap->connect_bind();
537
+
538
+                if ($result > 0)
539
+                {
540
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
541
+                    {
542
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543
+                        $object->oldcopy = clone $object;
544
+                    }
545
+
546
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
547
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
548
+
549
+                    // Verify if entry exist
550
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
+                    $records=$ldap->search($container,$search);
553
+                    if (count($records) && $records['count'] == 0)
554
+                    {
555
+                        $olddn = '';
556
+                    }
557
+
558
+                    $info=$object->_load_ldap_info();
559
+                    $dn=$object->_load_ldap_dn($info);
560
+                    $newrdn=$object->_load_ldap_dn($info,2);
561
+                    $newparent=$object->_load_ldap_dn($info,1);
562
+
563
+                    $result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
564
+
565
+                    // For member type
566
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567
+                    {
568
+                        /*
569 569
 						 * Change member info
570 570
 						 */
571
-						$newmembertype=new AdherentType($this->db);
572
-						$newmembertype->fetch($object->typeid);
573
-						$newmembertype->listMembersForMemberType('', 1);
574
-
575
-						$oldinfo=$newmembertype->_load_ldap_info();
576
-						$olddn=$newmembertype->_load_ldap_dn($oldinfo);
577
-
578
-						// Verify if entry exist
579
-						$container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
-						$search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
-						$records=$ldap->search($container,$search);
582
-						if (count($records) && $records['count'] == 0)
583
-						{
584
-							$olddn = '';
585
-						}
586
-
587
-						$info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
-						$dn=$newmembertype->_load_ldap_dn($info);
589
-
590
-						$result=$ldap->update($dn,$info,$user,$olddn);
591
-
592
-						if ($object->oldcopy->typeid != $object->typeid)
593
-						{
594
-							/*
571
+                        $newmembertype=new AdherentType($this->db);
572
+                        $newmembertype->fetch($object->typeid);
573
+                        $newmembertype->listMembersForMemberType('', 1);
574
+
575
+                        $oldinfo=$newmembertype->_load_ldap_info();
576
+                        $olddn=$newmembertype->_load_ldap_dn($oldinfo);
577
+
578
+                        // Verify if entry exist
579
+                        $container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
+                        $search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
+                        $records=$ldap->search($container,$search);
582
+                        if (count($records) && $records['count'] == 0)
583
+                        {
584
+                            $olddn = '';
585
+                        }
586
+
587
+                        $info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
+                        $dn=$newmembertype->_load_ldap_dn($info);
589
+
590
+                        $result=$ldap->update($dn,$info,$user,$olddn);
591
+
592
+                        if ($object->oldcopy->typeid != $object->typeid)
593
+                        {
594
+                            /*
595 595
 							 * Remove member in old member type
596 596
 							 */
597
-							$oldmembertype=new AdherentType($this->db);
598
-							$oldmembertype->fetch($object->oldcopy->typeid);
599
-							$oldmembertype->listMembersForMemberType('', 1);
600
-
601
-							$oldinfo=$oldmembertype->_load_ldap_info();
602
-							$olddn=$oldmembertype->_load_ldap_dn($oldinfo);
603
-
604
-							// Verify if entry exist
605
-							$container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
-							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
-							$records=$ldap->search($container,$search);
608
-							if (count($records) && $records['count'] == 0)
609
-							{
610
-								$olddn = '';
611
-							}
612
-
613
-							$info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
-							$dn=$oldmembertype->_load_ldap_dn($info);
615
-
616
-							$result=$ldap->update($dn,$info,$user,$olddn);
617
-						}
618
-					}
619
-				}
620
-
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
622
-			}
623
-		}
624
-		elseif ($action == 'MEMBER_NEW_PASSWORD')
625
-		{
626
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628
-			{
629
-				// If password field is setup to be synchronized
630
-				if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631
-				{
632
-					$ldap=new Ldap();
633
-					$result=$ldap->connect_bind();
634
-
635
-					if ($result > 0)
636
-					{
637
-						$info=$object->_load_ldap_info();
638
-						$dn=$object->_load_ldap_dn($info);
639
-						$olddn=$dn;	// We know olddn=dn as we change only password
640
-
641
-						$result=$ldap->update($dn,$info,$user,$olddn);
642
-					}
643
-
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
645
-				}
646
-			}
647
-		}
648
-		elseif ($action == 'MEMBER_RESILIATE')
649
-		{
650
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652
-			{
653
-				// If status field is setup to be synchronized
654
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655
-				{
656
-					$ldap=new Ldap();
657
-					$result=$ldap->connect_bind();
658
-
659
-					if ($result > 0)
660
-					{
661
-						$info=$object->_load_ldap_info();
662
-						$dn=$object->_load_ldap_dn($info);
663
-						$olddn=$dn;	// We know olddn=dn as we change only status
664
-
665
-						$result=$ldap->update($dn,$info,$user,$olddn);
666
-					}
667
-
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
669
-				}
670
-			}
671
-		}
672
-		elseif ($action == 'MEMBER_DELETE')
673
-		{
674
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676
-			{
677
-				$ldap=new Ldap();
678
-				$result=$ldap->connect_bind();
679
-
680
-				if ($result > 0)
681
-				{
682
-					$info=$object->_load_ldap_info();
683
-					$dn=$object->_load_ldap_dn($info);
684
-
685
-					$result=$ldap->delete($dn);
686
-
687
-					// For member type
688
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689
-					{
690
-						if ($object->typeid > 0)
691
-						{
692
-							/*
597
+                            $oldmembertype=new AdherentType($this->db);
598
+                            $oldmembertype->fetch($object->oldcopy->typeid);
599
+                            $oldmembertype->listMembersForMemberType('', 1);
600
+
601
+                            $oldinfo=$oldmembertype->_load_ldap_info();
602
+                            $olddn=$oldmembertype->_load_ldap_dn($oldinfo);
603
+
604
+                            // Verify if entry exist
605
+                            $container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
+                            $search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
+                            $records=$ldap->search($container,$search);
608
+                            if (count($records) && $records['count'] == 0)
609
+                            {
610
+                                $olddn = '';
611
+                            }
612
+
613
+                            $info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
+                            $dn=$oldmembertype->_load_ldap_dn($info);
615
+
616
+                            $result=$ldap->update($dn,$info,$user,$olddn);
617
+                        }
618
+                    }
619
+                }
620
+
621
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
622
+            }
623
+        }
624
+        elseif ($action == 'MEMBER_NEW_PASSWORD')
625
+        {
626
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628
+            {
629
+                // If password field is setup to be synchronized
630
+                if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631
+                {
632
+                    $ldap=new Ldap();
633
+                    $result=$ldap->connect_bind();
634
+
635
+                    if ($result > 0)
636
+                    {
637
+                        $info=$object->_load_ldap_info();
638
+                        $dn=$object->_load_ldap_dn($info);
639
+                        $olddn=$dn;	// We know olddn=dn as we change only password
640
+
641
+                        $result=$ldap->update($dn,$info,$user,$olddn);
642
+                    }
643
+
644
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
645
+                }
646
+            }
647
+        }
648
+        elseif ($action == 'MEMBER_RESILIATE')
649
+        {
650
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652
+            {
653
+                // If status field is setup to be synchronized
654
+                if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655
+                {
656
+                    $ldap=new Ldap();
657
+                    $result=$ldap->connect_bind();
658
+
659
+                    if ($result > 0)
660
+                    {
661
+                        $info=$object->_load_ldap_info();
662
+                        $dn=$object->_load_ldap_dn($info);
663
+                        $olddn=$dn;	// We know olddn=dn as we change only status
664
+
665
+                        $result=$ldap->update($dn,$info,$user,$olddn);
666
+                    }
667
+
668
+                    if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
669
+                }
670
+            }
671
+        }
672
+        elseif ($action == 'MEMBER_DELETE')
673
+        {
674
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
+            if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676
+            {
677
+                $ldap=new Ldap();
678
+                $result=$ldap->connect_bind();
679
+
680
+                if ($result > 0)
681
+                {
682
+                    $info=$object->_load_ldap_info();
683
+                    $dn=$object->_load_ldap_dn($info);
684
+
685
+                    $result=$ldap->delete($dn);
686
+
687
+                    // For member type
688
+                    if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689
+                    {
690
+                        if ($object->typeid > 0)
691
+                        {
692
+                            /*
693 693
 							 * Remove member in member type
694 694
 							 */
695
-							$membertype=new AdherentType($this->db);
696
-							$membertype->fetch($object->typeid);
697
-							$membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
698
-
699
-							$oldinfo=$membertype->_load_ldap_info();
700
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
701
-
702
-							// Verify if entry exist
703
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
704
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
-							$records=$ldap->search($container,$search);
706
-							if (count($records) && $records['count'] == 0)
707
-							{
708
-								$olddn = '';
709
-							}
710
-
711
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
-							$dn=$membertype->_load_ldap_dn($info);
713
-
714
-							$result=$ldap->update($dn,$info,$user,$olddn);
715
-						}
716
-					}
717
-				}
718
-
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
720
-			}
721
-		}
722
-
723
-		// Members types
724
-		elseif ($action == 'MEMBER_TYPE_CREATE')
725
-		{
726
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728
-			{
729
-				$ldap=new Ldap();
730
-				$result=$ldap->connect_bind();
731
-
732
-				if ($result > 0)
733
-				{
734
-					$info=$object->_load_ldap_info();
735
-					$dn=$object->_load_ldap_dn($info);
736
-
737
-					// Get a gid number for objectclass PosixGroup
738
-					if (in_array('posixGroup',$info['objectclass'])) {
739
-						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740
-					}
741
-
742
-					$result=$ldap->add($dn,$info,$user);
743
-				}
744
-
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
746
-			}
747
-		}
748
-		elseif ($action == 'MEMBER_TYPE_MODIFY')
749
-		{
750
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752
-			{
753
-				$ldap=new Ldap();
754
-				$result=$ldap->connect_bind();
755
-
756
-				if ($result > 0)
757
-				{
758
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
759
-					{
760
-						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761
-						$object->oldcopy = clone $object;
762
-					}
763
-
764
-					$object->oldcopy->listMembersForMemberType('', 1);
765
-
766
-					$oldinfo=$object->oldcopy->_load_ldap_info();
767
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
768
-
769
-					// Verify if entry exist
770
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
-					$records=$ldap->search($container,$search);
773
-					if (count($records) && $records['count'] == 0)
774
-					{
775
-						$olddn = '';
776
-					}
777
-
778
-					$object->listMembersForMemberType('', 1);
779
-
780
-					$info=$object->_load_ldap_info();
781
-					$dn=$object->_load_ldap_dn($info);
782
-
783
-					$result=$ldap->update($dn,$info,$user,$olddn);
784
-				}
785
-
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
787
-			}
788
-		}
789
-		elseif ($action == 'MEMBER_TYPE_DELETE')
790
-		{
791
-			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793
-			{
794
-				$ldap=new Ldap();
795
-				$result=$ldap->connect_bind();
796
-
797
-				if ($result > 0)
798
-				{
799
-					$info=$object->_load_ldap_info();
800
-					$dn=$object->_load_ldap_dn($info);
801
-
802
-					$result=$ldap->delete($dn);
803
-				}
804
-
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
806
-			}
807
-		}
808
-
809
-		return $result;
810
-	}
695
+                            $membertype=new AdherentType($this->db);
696
+                            $membertype->fetch($object->typeid);
697
+                            $membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
698
+
699
+                            $oldinfo=$membertype->_load_ldap_info();
700
+                            $olddn=$membertype->_load_ldap_dn($oldinfo);
701
+
702
+                            // Verify if entry exist
703
+                            $container=$membertype->_load_ldap_dn($oldinfo,1);
704
+                            $search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
+                            $records=$ldap->search($container,$search);
706
+                            if (count($records) && $records['count'] == 0)
707
+                            {
708
+                                $olddn = '';
709
+                            }
710
+
711
+                            $info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
+                            $dn=$membertype->_load_ldap_dn($info);
713
+
714
+                            $result=$ldap->update($dn,$info,$user,$olddn);
715
+                        }
716
+                    }
717
+                }
718
+
719
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
720
+            }
721
+        }
722
+
723
+        // Members types
724
+        elseif ($action == 'MEMBER_TYPE_CREATE')
725
+        {
726
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728
+            {
729
+                $ldap=new Ldap();
730
+                $result=$ldap->connect_bind();
731
+
732
+                if ($result > 0)
733
+                {
734
+                    $info=$object->_load_ldap_info();
735
+                    $dn=$object->_load_ldap_dn($info);
736
+
737
+                    // Get a gid number for objectclass PosixGroup
738
+                    if (in_array('posixGroup',$info['objectclass'])) {
739
+                        $info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740
+                    }
741
+
742
+                    $result=$ldap->add($dn,$info,$user);
743
+                }
744
+
745
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
746
+            }
747
+        }
748
+        elseif ($action == 'MEMBER_TYPE_MODIFY')
749
+        {
750
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752
+            {
753
+                $ldap=new Ldap();
754
+                $result=$ldap->connect_bind();
755
+
756
+                if ($result > 0)
757
+                {
758
+                    if (empty($object->oldcopy) || ! is_object($object->oldcopy))
759
+                    {
760
+                        dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761
+                        $object->oldcopy = clone $object;
762
+                    }
763
+
764
+                    $object->oldcopy->listMembersForMemberType('', 1);
765
+
766
+                    $oldinfo=$object->oldcopy->_load_ldap_info();
767
+                    $olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
768
+
769
+                    // Verify if entry exist
770
+                    $container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
+                    $search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
+                    $records=$ldap->search($container,$search);
773
+                    if (count($records) && $records['count'] == 0)
774
+                    {
775
+                        $olddn = '';
776
+                    }
777
+
778
+                    $object->listMembersForMemberType('', 1);
779
+
780
+                    $info=$object->_load_ldap_info();
781
+                    $dn=$object->_load_ldap_dn($info);
782
+
783
+                    $result=$ldap->update($dn,$info,$user,$olddn);
784
+                }
785
+
786
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
787
+            }
788
+        }
789
+        elseif ($action == 'MEMBER_TYPE_DELETE')
790
+        {
791
+            dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
+            if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793
+            {
794
+                $ldap=new Ldap();
795
+                $result=$ldap->connect_bind();
796
+
797
+                if ($result > 0)
798
+                {
799
+                    $info=$object->_load_ldap_info();
800
+                    $dn=$object->_load_ldap_dn($info);
801
+
802
+                    $result=$ldap->delete($dn);
803
+                }
804
+
805
+                if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
806
+            }
807
+        }
808
+
809
+        return $result;
810
+    }
811 811
 }
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60 60
 	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
61
+		if (empty($conf->ldap->enabled)) return 0; // Module not active, we do nothing
62
+		if (defined('DISABLE_LDAP_SYNCHRO')) return 0; // If constant defined, we do nothing
63 63
 
64
-		if (! function_exists('ldap_connect'))
64
+		if (!function_exists('ldap_connect'))
65 65
 		{
66 66
 			dol_syslog("Warning, module LDAP is enabled but LDAP functions not available in this PHP", LOG_WARNING);
67 67
 			return 0;
@@ -70,102 +70,102 @@  discard block
 block discarded – undo
70 70
 		require_once DOL_DOCUMENT_ROOT."/core/class/ldap.class.php";
71 71
 		require_once DOL_DOCUMENT_ROOT."/user/class/usergroup.class.php";
72 72
 
73
-		$result=0;
73
+		$result = 0;
74 74
 
75 75
 		// Users
76 76
 		if ($action == 'USER_CREATE')
77 77
 		{
78 78
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
79
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
79
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
80 80
 			{
81
-				$ldap=new Ldap();
82
-				$result=$ldap->connect_bind();
81
+				$ldap = new Ldap();
82
+				$result = $ldap->connect_bind();
83 83
 
84 84
 				if ($result > 0)
85 85
 				{
86
-					$info=$object->_load_ldap_info();
87
-					$dn=$object->_load_ldap_dn($info);
86
+					$info = $object->_load_ldap_info();
87
+					$dn = $object->_load_ldap_dn($info);
88 88
 
89
-					$result=$ldap->add($dn,$info,$user);
89
+					$result = $ldap->add($dn, $info, $user);
90 90
 				}
91 91
 
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
92
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
93 93
 			}
94 94
 		}
95 95
 		elseif ($action == 'USER_MODIFY')
96 96
 		{
97 97
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
98
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
99 99
 			{
100
-				$ldap=new Ldap();
101
-				$result=$ldap->connect_bind();
100
+				$ldap = new Ldap();
101
+				$result = $ldap->connect_bind();
102 102
 
103 103
 				if ($result > 0)
104 104
 				{
105
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
105
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
106 106
 					{
107 107
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
108 108
 						$object->oldcopy = clone $object;
109 109
 					}
110 110
 
111
-					$oldinfo=$object->oldcopy->_load_ldap_info();
112
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
111
+					$oldinfo = $object->oldcopy->_load_ldap_info();
112
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
113 113
 
114 114
 					// Verify if entry exist
115
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
116
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
117
-					$records=$ldap->search($container,$search);
115
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
116
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
117
+					$records = $ldap->search($container, $search);
118 118
 					if (count($records) && $records['count'] == 0)
119 119
 					{
120 120
 						$olddn = '';
121 121
 					}
122 122
 
123
-					$info=$object->_load_ldap_info();
124
-					$dn=$object->_load_ldap_dn($info);
125
-					$newrdn=$object->_load_ldap_dn($info,2);
126
-					$newparent=$object->_load_ldap_dn($info,1);
123
+					$info = $object->_load_ldap_info();
124
+					$dn = $object->_load_ldap_dn($info);
125
+					$newrdn = $object->_load_ldap_dn($info, 2);
126
+					$newparent = $object->_load_ldap_dn($info, 1);
127 127
 
128
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
128
+					$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
129 129
 				}
130 130
 
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
131
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
132 132
 			}
133 133
 		}
134 134
 		elseif ($action == 'USER_NEW_PASSWORD')
135 135
 		{
136 136
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
137
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
138 138
 			{
139
-				$ldap=new Ldap();
140
-				$result=$ldap->connect_bind();
139
+				$ldap = new Ldap();
140
+				$result = $ldap->connect_bind();
141 141
 
142 142
 				if ($result > 0)
143 143
 				{
144
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
144
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
145 145
 					{
146 146
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
147 147
 						$object->oldcopy = clone $object;
148 148
 					}
149 149
 
150
-					$oldinfo=$object->oldcopy->_load_ldap_info();
151
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
150
+					$oldinfo = $object->oldcopy->_load_ldap_info();
151
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
152 152
 
153 153
 					// Verify if entry exist
154
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
155
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
156
-					$records=$ldap->search($container,$search);
154
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
155
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
156
+					$records = $ldap->search($container, $search);
157 157
 					if (count($records) && $records['count'] == 0)
158 158
 					{
159 159
 						$olddn = '';
160 160
 					}
161 161
 
162
-					$info=$object->_load_ldap_info();
163
-					$dn=$object->_load_ldap_dn($info);
162
+					$info = $object->_load_ldap_info();
163
+					$dn = $object->_load_ldap_dn($info);
164 164
 
165
-					$result=$ldap->update($dn,$info,$user,$olddn);
165
+					$result = $ldap->update($dn, $info, $user, $olddn);
166 166
 				}
167 167
 
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
168
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
169 169
 			}
170 170
 		}
171 171
 		elseif ($action == 'USER_ENABLEDISABLE')
@@ -175,96 +175,96 @@  discard block
 block discarded – undo
175 175
 		elseif ($action == 'USER_DELETE')
176 176
 		{
177 177
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
178
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
179 179
 			{
180
-				$ldap=new Ldap();
181
-				$result=$ldap->connect_bind();
180
+				$ldap = new Ldap();
181
+				$result = $ldap->connect_bind();
182 182
 
183 183
 				if ($result > 0)
184 184
 				{
185
-					$info=$object->_load_ldap_info();
186
-					$dn=$object->_load_ldap_dn($info);
185
+					$info = $object->_load_ldap_info();
186
+					$dn = $object->_load_ldap_dn($info);
187 187
 
188
-					$result=$ldap->delete($dn);
188
+					$result = $ldap->delete($dn);
189 189
 				}
190 190
 
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
191
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
192 192
 			}
193 193
 		}
194 194
 		elseif ($action == 'USER_SETINGROUP')
195 195
 		{
196 196
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
197
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
198 198
 			{
199
-				$ldap=new Ldap();
200
-				$result=$ldap->connect_bind();
199
+				$ldap = new Ldap();
200
+				$result = $ldap->connect_bind();
201 201
 
202 202
 				if ($result > 0)
203 203
 				{
204 204
 					// Must edit $object->newgroupid
205
-					$usergroup=new UserGroup($this->db);
205
+					$usergroup = new UserGroup($this->db);
206 206
 					if ($object->newgroupid > 0)
207 207
 					{
208 208
 						$usergroup->fetch($object->newgroupid);
209 209
 
210
-						$oldinfo=$usergroup->_load_ldap_info();
211
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
210
+						$oldinfo = $usergroup->_load_ldap_info();
211
+						$olddn = $usergroup->_load_ldap_dn($oldinfo);
212 212
 
213 213
 						// Verify if entry exist
214
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
215
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
216
-						$records=$ldap->search($container,$search);
214
+						$container = $usergroup->_load_ldap_dn($oldinfo, 1);
215
+						$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
216
+						$records = $ldap->search($container, $search);
217 217
 						if (count($records) && $records['count'] == 0)
218 218
 						{
219 219
 							$olddn = '';
220 220
 						}
221 221
 
222
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
223
-						$dn=$usergroup->_load_ldap_dn($info);
222
+						$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
223
+						$dn = $usergroup->_load_ldap_dn($info);
224 224
 
225
-						$result=$ldap->update($dn,$info,$user,$olddn);
225
+						$result = $ldap->update($dn, $info, $user, $olddn);
226 226
 					}
227 227
 				}
228 228
 
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
229
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
230 230
 			}
231 231
 		}
232 232
 		elseif ($action == 'USER_REMOVEFROMGROUP')
233 233
 		{
234 234
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
235
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
236 236
 			{
237
-				$ldap=new Ldap();
238
-				$result=$ldap->connect_bind();
237
+				$ldap = new Ldap();
238
+				$result = $ldap->connect_bind();
239 239
 
240 240
 				if ($result > 0)
241 241
 				{
242 242
 					// Must edit $object->newgroupid
243
-					$usergroup=new UserGroup($this->db);
243
+					$usergroup = new UserGroup($this->db);
244 244
 					if ($object->oldgroupid > 0)
245 245
 					{
246 246
 						$usergroup->fetch($object->oldgroupid);
247 247
 
248
-						$oldinfo=$usergroup->_load_ldap_info();
249
-						$olddn=$usergroup->_load_ldap_dn($oldinfo);
248
+						$oldinfo = $usergroup->_load_ldap_info();
249
+						$olddn = $usergroup->_load_ldap_dn($oldinfo);
250 250
 
251 251
 						// Verify if entry exist
252
-						$container=$usergroup->_load_ldap_dn($oldinfo,1);
253
-						$search = "(".$usergroup->_load_ldap_dn($oldinfo,2).")";
254
-						$records=$ldap->search($container,$search);
252
+						$container = $usergroup->_load_ldap_dn($oldinfo, 1);
253
+						$search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")";
254
+						$records = $ldap->search($container, $search);
255 255
 						if (count($records) && $records['count'] == 0)
256 256
 						{
257 257
 							$olddn = '';
258 258
 						}
259 259
 
260
-						$info=$usergroup->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
261
-						$dn=$usergroup->_load_ldap_dn($info);
260
+						$info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
261
+						$dn = $usergroup->_load_ldap_dn($info);
262 262
 
263
-						$result=$ldap->update($dn,$info,$user,$olddn);
263
+						$result = $ldap->update($dn, $info, $user, $olddn);
264 264
 					}
265 265
 				}
266 266
 
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
267
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
268 268
 			}
269 269
 		}
270 270
 
@@ -272,81 +272,81 @@  discard block
 block discarded – undo
272 272
 		elseif ($action == 'GROUP_CREATE')
273 273
 		{
274 274
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
275
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
275
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
276 276
 			{
277
-				$ldap=new Ldap();
278
-				$result=$ldap->connect_bind();
277
+				$ldap = new Ldap();
278
+				$result = $ldap->connect_bind();
279 279
 
280 280
 				if ($result > 0)
281 281
 				{
282
-					$info=$object->_load_ldap_info();
283
-					$dn=$object->_load_ldap_dn($info);
282
+					$info = $object->_load_ldap_info();
283
+					$dn = $object->_load_ldap_dn($info);
284 284
 
285 285
 					// Get a gid number for objectclass PosixGroup
286
-					if (in_array('posixGroup',$info['objectclass'])) {
286
+					if (in_array('posixGroup', $info['objectclass'])) {
287 287
 						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_GROUPS');
288 288
 					}
289 289
 
290
-					$result=$ldap->add($dn,$info,$user);
290
+					$result = $ldap->add($dn, $info, $user);
291 291
 				}
292 292
 
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
293
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
294 294
 			}
295 295
 		}
296 296
 		elseif ($action == 'GROUP_MODIFY')
297 297
 		{
298 298
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
299
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
300 300
 			{
301
-				$ldap=new Ldap();
302
-				$result=$ldap->connect_bind();
301
+				$ldap = new Ldap();
302
+				$result = $ldap->connect_bind();
303 303
 
304 304
 				if ($result > 0)
305 305
 				{
306
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
306
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
307 307
 					{
308 308
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
309 309
 						$object->oldcopy = clone $object;
310 310
 					}
311 311
 
312
-					$oldinfo=$object->oldcopy->_load_ldap_info();
313
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
312
+					$oldinfo = $object->oldcopy->_load_ldap_info();
313
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
314 314
 
315 315
 					// Verify if entry exist
316
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
317
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
318
-					$records=$ldap->search($container,$search);
316
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
317
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
318
+					$records = $ldap->search($container, $search);
319 319
 					if (count($records) && $records['count'] == 0)
320 320
 					{
321 321
 						$olddn = '';
322 322
 					}
323 323
 
324
-					$info=$object->_load_ldap_info();
325
-					$dn=$object->_load_ldap_dn($info);
324
+					$info = $object->_load_ldap_info();
325
+					$dn = $object->_load_ldap_dn($info);
326 326
 
327
-					$result=$ldap->update($dn,$info,$user,$olddn);
327
+					$result = $ldap->update($dn, $info, $user, $olddn);
328 328
 				}
329 329
 
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
330
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
331 331
 			}
332 332
 		}
333 333
 		elseif ($action == 'GROUP_DELETE')
334 334
 		{
335 335
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336
-			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
336
+			if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
337 337
 			{
338
-				$ldap=new Ldap();
339
-				$result=$ldap->connect_bind();
338
+				$ldap = new Ldap();
339
+				$result = $ldap->connect_bind();
340 340
 
341 341
 				if ($result > 0)
342 342
 				{
343
-					$info=$object->_load_ldap_info();
344
-					$dn=$object->_load_ldap_dn($info);
343
+					$info = $object->_load_ldap_info();
344
+					$dn = $object->_load_ldap_dn($info);
345 345
 
346
-					$result=$ldap->delete($dn);
346
+					$result = $ldap->delete($dn);
347 347
 				}
348 348
 
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
349
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
350 350
 			}
351 351
 		}
352 352
 
@@ -354,76 +354,76 @@  discard block
 block discarded – undo
354 354
 		elseif ($action == 'CONTACT_CREATE')
355 355
 		{
356 356
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
357
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
357
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
358 358
 			{
359
-				$ldap=new Ldap();
360
-				$result=$ldap->connect_bind();
359
+				$ldap = new Ldap();
360
+				$result = $ldap->connect_bind();
361 361
 
362 362
 				if ($result > 0)
363 363
 				{
364
-					$info=$object->_load_ldap_info();
365
-					$dn=$object->_load_ldap_dn($info);
364
+					$info = $object->_load_ldap_info();
365
+					$dn = $object->_load_ldap_dn($info);
366 366
 
367
-					$result=$ldap->add($dn,$info,$user);
367
+					$result = $ldap->add($dn, $info, $user);
368 368
 				}
369 369
 
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
370
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
371 371
 			}
372 372
 		}
373 373
 		elseif ($action == 'CONTACT_MODIFY')
374 374
 		{
375 375
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
376
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
377 377
 			{
378
-				$ldap=new Ldap();
379
-				$result=$ldap->connect_bind();
378
+				$ldap = new Ldap();
379
+				$result = $ldap->connect_bind();
380 380
 
381 381
 				if ($result > 0)
382 382
 				{
383
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
383
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
384 384
 					{
385 385
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
386 386
 						$object->oldcopy = clone $object;
387 387
 					}
388 388
 
389
-					$oldinfo=$object->oldcopy->_load_ldap_info();
390
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
389
+					$oldinfo = $object->oldcopy->_load_ldap_info();
390
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
391 391
 
392 392
 					// Verify if entry exist
393
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
394
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
395
-					$records=$ldap->search($container,$search);
393
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
394
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
395
+					$records = $ldap->search($container, $search);
396 396
 					if (count($records) && $records['count'] == 0)
397 397
 					{
398 398
 						$olddn = '';
399 399
 					}
400 400
 
401
-					$info=$object->_load_ldap_info();
402
-					$dn=$object->_load_ldap_dn($info);
401
+					$info = $object->_load_ldap_info();
402
+					$dn = $object->_load_ldap_dn($info);
403 403
 
404
-					$result=$ldap->update($dn,$info,$user,$olddn);
404
+					$result = $ldap->update($dn, $info, $user, $olddn);
405 405
 				}
406 406
 
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
407
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
408 408
 			}
409 409
 		}
410 410
 		elseif ($action == 'CONTACT_DELETE')
411 411
 		{
412 412
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413
-			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
413
+			if (!empty($conf->global->LDAP_CONTACT_ACTIVE))
414 414
 			{
415
-				$ldap=new Ldap();
416
-				$result=$ldap->connect_bind();
415
+				$ldap = new Ldap();
416
+				$result = $ldap->connect_bind();
417 417
 
418 418
 				if ($result > 0)
419 419
 				{
420
-					$info=$object->_load_ldap_info();
421
-					$dn=$object->_load_ldap_dn($info);
420
+					$info = $object->_load_ldap_info();
421
+					$dn = $object->_load_ldap_dn($info);
422 422
 
423
-					$result=$ldap->delete($dn);
423
+					$result = $ldap->delete($dn);
424 424
 				}
425 425
 
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
426
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
427 427
 			}
428 428
 		}
429 429
 
@@ -431,78 +431,78 @@  discard block
 block discarded – undo
431 431
 		elseif ($action == 'MEMBER_CREATE')
432 432
 		{
433 433
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
434
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
434
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
435 435
 			{
436
-				$ldap=new Ldap();
437
-				$result=$ldap->connect_bind();
436
+				$ldap = new Ldap();
437
+				$result = $ldap->connect_bind();
438 438
 
439 439
 				if ($result > 0)
440 440
 				{
441
-					$info=$object->_load_ldap_info();
442
-					$dn=$object->_load_ldap_dn($info);
441
+					$info = $object->_load_ldap_info();
442
+					$dn = $object->_load_ldap_dn($info);
443 443
 
444
-					$result=$ldap->add($dn,$info,$user);
444
+					$result = $ldap->add($dn, $info, $user);
445 445
 
446 446
 					// For member type
447
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
447
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
448 448
 					{
449
-						$membertype=new AdherentType($this->db);
449
+						$membertype = new AdherentType($this->db);
450 450
 						if ($object->typeid > 0)
451 451
 						{
452 452
 							$membertype->fetch($object->typeid);
453 453
 							$membertype->listMembersForMemberType('', 1);
454 454
 
455
-							$oldinfo=$membertype->_load_ldap_info();
456
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
455
+							$oldinfo = $membertype->_load_ldap_info();
456
+							$olddn = $membertype->_load_ldap_dn($oldinfo);
457 457
 
458 458
 							// Verify if entry exist
459
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
460
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
461
-							$records=$ldap->search($container,$search);
459
+							$container = $membertype->_load_ldap_dn($oldinfo, 1);
460
+							$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
461
+							$records = $ldap->search($container, $search);
462 462
 							if (count($records) && $records['count'] == 0)
463 463
 							{
464 464
 								$olddn = '';
465 465
 							}
466 466
 
467
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
468
-							$dn=$membertype->_load_ldap_dn($info);
467
+							$info = $membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
468
+							$dn = $membertype->_load_ldap_dn($info);
469 469
 
470
-							$result=$ldap->update($dn,$info,$user,$olddn);
470
+							$result = $ldap->update($dn, $info, $user, $olddn);
471 471
 						}
472 472
 					}
473 473
 				}
474 474
 
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
475
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
476 476
 			}
477 477
 		}
478 478
 		elseif ($action == 'MEMBER_VALIDATE')
479 479
 		{
480 480
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
481
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
482 482
 			{
483 483
 				// If status field is setup to be synchronized
484
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
484
+				if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
485 485
 				{
486
-					$ldap=new Ldap();
487
-					$result=$ldap->connect_bind();
486
+					$ldap = new Ldap();
487
+					$result = $ldap->connect_bind();
488 488
 
489 489
 					if ($result > 0)
490 490
 					{
491
-						$info=$object->_load_ldap_info();
492
-						$dn=$object->_load_ldap_dn($info);
493
-						$olddn=$dn;	// We know olddn=dn as we change only status
491
+						$info = $object->_load_ldap_info();
492
+						$dn = $object->_load_ldap_dn($info);
493
+						$olddn = $dn; // We know olddn=dn as we change only status
494 494
 
495
-						$result=$ldap->update($dn,$info,$user,$olddn);
495
+						$result = $ldap->update($dn, $info, $user, $olddn);
496 496
 					}
497 497
 
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
498
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
499 499
 				}
500 500
 			}
501 501
 		}
502 502
 		elseif ($action == 'MEMBER_SUBSCRIPTION')
503 503
 		{
504 504
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
505
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
506 506
 			{
507 507
 				// If subscriptions fields are setup to be synchronized
508 508
 				if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE
@@ -511,212 +511,212 @@  discard block
 block discarded – undo
511 511
 					|| $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT
512 512
 					|| $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION)
513 513
 				{
514
-					$ldap=new Ldap();
515
-					$result=$ldap->connect_bind();
514
+					$ldap = new Ldap();
515
+					$result = $ldap->connect_bind();
516 516
 
517 517
 					if ($result > 0)
518 518
 					{
519
-						$info=$object->_load_ldap_info();
520
-						$dn=$object->_load_ldap_dn($info);
521
-						$olddn=$dn;	// We know olddn=dn as we change only subscriptions
519
+						$info = $object->_load_ldap_info();
520
+						$dn = $object->_load_ldap_dn($info);
521
+						$olddn = $dn; // We know olddn=dn as we change only subscriptions
522 522
 
523
-						$result=$ldap->update($dn,$info,$user,$olddn);
523
+						$result = $ldap->update($dn, $info, $user, $olddn);
524 524
 					}
525 525
 
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
526
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
527 527
 				}
528 528
 			}
529 529
 		}
530 530
 		elseif ($action == 'MEMBER_MODIFY')
531 531
 		{
532 532
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
533
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
534 534
 			{
535
-				$ldap=new Ldap();
536
-				$result=$ldap->connect_bind();
535
+				$ldap = new Ldap();
536
+				$result = $ldap->connect_bind();
537 537
 
538 538
 				if ($result > 0)
539 539
 				{
540
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
540
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
541 541
 					{
542 542
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
543 543
 						$object->oldcopy = clone $object;
544 544
 					}
545 545
 
546
-					$oldinfo=$object->oldcopy->_load_ldap_info();
547
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
546
+					$oldinfo = $object->oldcopy->_load_ldap_info();
547
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
548 548
 
549 549
 					// Verify if entry exist
550
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
551
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
552
-					$records=$ldap->search($container,$search);
550
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
551
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
552
+					$records = $ldap->search($container, $search);
553 553
 					if (count($records) && $records['count'] == 0)
554 554
 					{
555 555
 						$olddn = '';
556 556
 					}
557 557
 
558
-					$info=$object->_load_ldap_info();
559
-					$dn=$object->_load_ldap_dn($info);
560
-					$newrdn=$object->_load_ldap_dn($info,2);
561
-					$newparent=$object->_load_ldap_dn($info,1);
558
+					$info = $object->_load_ldap_info();
559
+					$dn = $object->_load_ldap_dn($info);
560
+					$newrdn = $object->_load_ldap_dn($info, 2);
561
+					$newparent = $object->_load_ldap_dn($info, 1);
562 562
 
563
-					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
563
+					$result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent);
564 564
 
565 565
 					// For member type
566
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
566
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
567 567
 					{
568 568
 						/*
569 569
 						 * Change member info
570 570
 						 */
571
-						$newmembertype=new AdherentType($this->db);
571
+						$newmembertype = new AdherentType($this->db);
572 572
 						$newmembertype->fetch($object->typeid);
573 573
 						$newmembertype->listMembersForMemberType('', 1);
574 574
 
575
-						$oldinfo=$newmembertype->_load_ldap_info();
576
-						$olddn=$newmembertype->_load_ldap_dn($oldinfo);
575
+						$oldinfo = $newmembertype->_load_ldap_info();
576
+						$olddn = $newmembertype->_load_ldap_dn($oldinfo);
577 577
 
578 578
 						// Verify if entry exist
579
-						$container=$newmembertype->_load_ldap_dn($oldinfo,1);
580
-						$search = "(".$newmembertype->_load_ldap_dn($oldinfo,2).")";
581
-						$records=$ldap->search($container,$search);
579
+						$container = $newmembertype->_load_ldap_dn($oldinfo, 1);
580
+						$search = "(".$newmembertype->_load_ldap_dn($oldinfo, 2).")";
581
+						$records = $ldap->search($container, $search);
582 582
 						if (count($records) && $records['count'] == 0)
583 583
 						{
584 584
 							$olddn = '';
585 585
 						}
586 586
 
587
-						$info=$newmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
588
-						$dn=$newmembertype->_load_ldap_dn($info);
587
+						$info = $newmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
588
+						$dn = $newmembertype->_load_ldap_dn($info);
589 589
 
590
-						$result=$ldap->update($dn,$info,$user,$olddn);
590
+						$result = $ldap->update($dn, $info, $user, $olddn);
591 591
 
592 592
 						if ($object->oldcopy->typeid != $object->typeid)
593 593
 						{
594 594
 							/*
595 595
 							 * Remove member in old member type
596 596
 							 */
597
-							$oldmembertype=new AdherentType($this->db);
597
+							$oldmembertype = new AdherentType($this->db);
598 598
 							$oldmembertype->fetch($object->oldcopy->typeid);
599 599
 							$oldmembertype->listMembersForMemberType('', 1);
600 600
 
601
-							$oldinfo=$oldmembertype->_load_ldap_info();
602
-							$olddn=$oldmembertype->_load_ldap_dn($oldinfo);
601
+							$oldinfo = $oldmembertype->_load_ldap_info();
602
+							$olddn = $oldmembertype->_load_ldap_dn($oldinfo);
603 603
 
604 604
 							// Verify if entry exist
605
-							$container=$oldmembertype->_load_ldap_dn($oldinfo,1);
606
-							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo,2).")";
607
-							$records=$ldap->search($container,$search);
605
+							$container = $oldmembertype->_load_ldap_dn($oldinfo, 1);
606
+							$search = "(".$oldmembertype->_load_ldap_dn($oldinfo, 2).")";
607
+							$records = $ldap->search($container, $search);
608 608
 							if (count($records) && $records['count'] == 0)
609 609
 							{
610 610
 								$olddn = '';
611 611
 							}
612 612
 
613
-							$info=$oldmembertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
614
-							$dn=$oldmembertype->_load_ldap_dn($info);
613
+							$info = $oldmembertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
614
+							$dn = $oldmembertype->_load_ldap_dn($info);
615 615
 
616
-							$result=$ldap->update($dn,$info,$user,$olddn);
616
+							$result = $ldap->update($dn, $info, $user, $olddn);
617 617
 						}
618 618
 					}
619 619
 				}
620 620
 
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
621
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
622 622
 			}
623 623
 		}
624 624
 		elseif ($action == 'MEMBER_NEW_PASSWORD')
625 625
 		{
626 626
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
627
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
628 628
 			{
629 629
 				// If password field is setup to be synchronized
630 630
 				if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED)
631 631
 				{
632
-					$ldap=new Ldap();
633
-					$result=$ldap->connect_bind();
632
+					$ldap = new Ldap();
633
+					$result = $ldap->connect_bind();
634 634
 
635 635
 					if ($result > 0)
636 636
 					{
637
-						$info=$object->_load_ldap_info();
638
-						$dn=$object->_load_ldap_dn($info);
639
-						$olddn=$dn;	// We know olddn=dn as we change only password
637
+						$info = $object->_load_ldap_info();
638
+						$dn = $object->_load_ldap_dn($info);
639
+						$olddn = $dn; // We know olddn=dn as we change only password
640 640
 
641
-						$result=$ldap->update($dn,$info,$user,$olddn);
641
+						$result = $ldap->update($dn, $info, $user, $olddn);
642 642
 					}
643 643
 
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
644
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
645 645
 				}
646 646
 			}
647 647
 		}
648 648
 		elseif ($action == 'MEMBER_RESILIATE')
649 649
 		{
650 650
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
651
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
652 652
 			{
653 653
 				// If status field is setup to be synchronized
654
-				if (! empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
654
+				if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS))
655 655
 				{
656
-					$ldap=new Ldap();
657
-					$result=$ldap->connect_bind();
656
+					$ldap = new Ldap();
657
+					$result = $ldap->connect_bind();
658 658
 
659 659
 					if ($result > 0)
660 660
 					{
661
-						$info=$object->_load_ldap_info();
662
-						$dn=$object->_load_ldap_dn($info);
663
-						$olddn=$dn;	// We know olddn=dn as we change only status
661
+						$info = $object->_load_ldap_info();
662
+						$dn = $object->_load_ldap_dn($info);
663
+						$olddn = $dn; // We know olddn=dn as we change only status
664 664
 
665
-						$result=$ldap->update($dn,$info,$user,$olddn);
665
+						$result = $ldap->update($dn, $info, $user, $olddn);
666 666
 					}
667 667
 
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
668
+					if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
669 669
 				}
670 670
 			}
671 671
 		}
672 672
 		elseif ($action == 'MEMBER_DELETE')
673 673
 		{
674 674
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675
-			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
675
+			if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
676 676
 			{
677
-				$ldap=new Ldap();
678
-				$result=$ldap->connect_bind();
677
+				$ldap = new Ldap();
678
+				$result = $ldap->connect_bind();
679 679
 
680 680
 				if ($result > 0)
681 681
 				{
682
-					$info=$object->_load_ldap_info();
683
-					$dn=$object->_load_ldap_dn($info);
682
+					$info = $object->_load_ldap_info();
683
+					$dn = $object->_load_ldap_dn($info);
684 684
 
685
-					$result=$ldap->delete($dn);
685
+					$result = $ldap->delete($dn);
686 686
 
687 687
 					// For member type
688
-					if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
688
+					if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
689 689
 					{
690 690
 						if ($object->typeid > 0)
691 691
 						{
692 692
 							/*
693 693
 							 * Remove member in member type
694 694
 							 */
695
-							$membertype=new AdherentType($this->db);
695
+							$membertype = new AdherentType($this->db);
696 696
 							$membertype->fetch($object->typeid);
697
-							$membertype->listMembersForMemberType('a.rowid != ' . $object->id, 1); // remove deleted member from the list
697
+							$membertype->listMembersForMemberType('a.rowid != '.$object->id, 1); // remove deleted member from the list
698 698
 
699
-							$oldinfo=$membertype->_load_ldap_info();
700
-							$olddn=$membertype->_load_ldap_dn($oldinfo);
699
+							$oldinfo = $membertype->_load_ldap_info();
700
+							$olddn = $membertype->_load_ldap_dn($oldinfo);
701 701
 
702 702
 							// Verify if entry exist
703
-							$container=$membertype->_load_ldap_dn($oldinfo,1);
704
-							$search = "(".$membertype->_load_ldap_dn($oldinfo,2).")";
705
-							$records=$ldap->search($container,$search);
703
+							$container = $membertype->_load_ldap_dn($oldinfo, 1);
704
+							$search = "(".$membertype->_load_ldap_dn($oldinfo, 2).")";
705
+							$records = $ldap->search($container, $search);
706 706
 							if (count($records) && $records['count'] == 0)
707 707
 							{
708 708
 								$olddn = '';
709 709
 							}
710 710
 
711
-							$info=$membertype->_load_ldap_info();    // Contains all members, included the new one (insert already done before trigger call)
712
-							$dn=$membertype->_load_ldap_dn($info);
711
+							$info = $membertype->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call)
712
+							$dn = $membertype->_load_ldap_dn($info);
713 713
 
714
-							$result=$ldap->update($dn,$info,$user,$olddn);
714
+							$result = $ldap->update($dn, $info, $user, $olddn);
715 715
 						}
716 716
 					}
717 717
 				}
718 718
 
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
719
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
720 720
 			}
721 721
 		}
722 722
 
@@ -724,38 +724,38 @@  discard block
 block discarded – undo
724 724
 		elseif ($action == 'MEMBER_TYPE_CREATE')
725 725
 		{
726 726
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
727
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
727
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
728 728
 			{
729
-				$ldap=new Ldap();
730
-				$result=$ldap->connect_bind();
729
+				$ldap = new Ldap();
730
+				$result = $ldap->connect_bind();
731 731
 
732 732
 				if ($result > 0)
733 733
 				{
734
-					$info=$object->_load_ldap_info();
735
-					$dn=$object->_load_ldap_dn($info);
734
+					$info = $object->_load_ldap_info();
735
+					$dn = $object->_load_ldap_dn($info);
736 736
 
737 737
 					// Get a gid number for objectclass PosixGroup
738
-					if (in_array('posixGroup',$info['objectclass'])) {
738
+					if (in_array('posixGroup', $info['objectclass'])) {
739 739
 						$info['gidNumber'] = $ldap->getNextGroupGid('LDAP_KEY_MEMBERS_TYPE');
740 740
 					}
741 741
 
742
-					$result=$ldap->add($dn,$info,$user);
742
+					$result = $ldap->add($dn, $info, $user);
743 743
 				}
744 744
 
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
745
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
746 746
 			}
747 747
 		}
748 748
 		elseif ($action == 'MEMBER_TYPE_MODIFY')
749 749
 		{
750 750
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
751
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
752 752
 			{
753
-				$ldap=new Ldap();
754
-				$result=$ldap->connect_bind();
753
+				$ldap = new Ldap();
754
+				$result = $ldap->connect_bind();
755 755
 
756 756
 				if ($result > 0)
757 757
 				{
758
-					if (empty($object->oldcopy) || ! is_object($object->oldcopy))
758
+					if (empty($object->oldcopy) || !is_object($object->oldcopy))
759 759
 					{
760 760
 						dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
761 761
 						$object->oldcopy = clone $object;
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 
764 764
 					$object->oldcopy->listMembersForMemberType('', 1);
765 765
 
766
-					$oldinfo=$object->oldcopy->_load_ldap_info();
767
-					$olddn=$object->oldcopy->_load_ldap_dn($oldinfo);
766
+					$oldinfo = $object->oldcopy->_load_ldap_info();
767
+					$olddn = $object->oldcopy->_load_ldap_dn($oldinfo);
768 768
 
769 769
 					// Verify if entry exist
770
-					$container=$object->oldcopy->_load_ldap_dn($oldinfo,1);
771
-					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo,2).")";
772
-					$records=$ldap->search($container,$search);
770
+					$container = $object->oldcopy->_load_ldap_dn($oldinfo, 1);
771
+					$search = "(".$object->oldcopy->_load_ldap_dn($oldinfo, 2).")";
772
+					$records = $ldap->search($container, $search);
773 773
 					if (count($records) && $records['count'] == 0)
774 774
 					{
775 775
 						$olddn = '';
@@ -777,32 +777,32 @@  discard block
 block discarded – undo
777 777
 
778 778
 					$object->listMembersForMemberType('', 1);
779 779
 
780
-					$info=$object->_load_ldap_info();
781
-					$dn=$object->_load_ldap_dn($info);
780
+					$info = $object->_load_ldap_info();
781
+					$dn = $object->_load_ldap_dn($info);
782 782
 
783
-					$result=$ldap->update($dn,$info,$user,$olddn);
783
+					$result = $ldap->update($dn, $info, $user, $olddn);
784 784
 				}
785 785
 
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
786
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
787 787
 			}
788 788
 		}
789 789
 		elseif ($action == 'MEMBER_TYPE_DELETE')
790 790
 		{
791 791
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792
-			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
792
+			if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
793 793
 			{
794
-				$ldap=new Ldap();
795
-				$result=$ldap->connect_bind();
794
+				$ldap = new Ldap();
795
+				$result = $ldap->connect_bind();
796 796
 
797 797
 				if ($result > 0)
798 798
 				{
799
-					$info=$object->_load_ldap_info();
800
-					$dn=$object->_load_ldap_dn($info);
799
+					$info = $object->_load_ldap_info();
800
+					$dn = $object->_load_ldap_dn($info);
801 801
 
802
-					$result=$ldap->delete($dn);
802
+					$result = $ldap->delete($dn);
803 803
 				}
804 804
 
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
805
+				if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error;
806 806
 			}
807 807
 		}
808 808
 
Please login to merge, or discard this patch.
Braces   +92 added lines, -60 removed lines patch added patch discarded remove patch
@@ -58,8 +58,14 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
60 60
 	{
61
-		if (empty($conf->ldap->enabled)) return 0;		// Module not active, we do nothing
62
-		if (defined('DISABLE_LDAP_SYNCHRO')) return 0;	// If constant defined, we do nothing
61
+		if (empty($conf->ldap->enabled)) {
62
+		    return 0;
63
+		}
64
+		// Module not active, we do nothing
65
+		if (defined('DISABLE_LDAP_SYNCHRO')) {
66
+		    return 0;
67
+		}
68
+		// If constant defined, we do nothing
63 69
 
64 70
 		if (! function_exists('ldap_connect'))
65 71
 		{
@@ -89,10 +95,11 @@  discard block
 block discarded – undo
89 95
 					$result=$ldap->add($dn,$info,$user);
90 96
 				}
91 97
 
92
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
98
+				if ($result < 0) {
99
+				    $this->error="ErrorLDAP ".$ldap->error;
100
+				}
93 101
 			}
94
-		}
95
-		elseif ($action == 'USER_MODIFY')
102
+		} elseif ($action == 'USER_MODIFY')
96 103
 		{
97 104
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
98 105
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -128,10 +135,11 @@  discard block
 block discarded – undo
128 135
 					$result=$ldap->update($dn,$info,$user,$olddn,$newrdn,$newparent);
129 136
 				}
130 137
 
131
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
138
+				if ($result < 0) {
139
+				    $this->error="ErrorLDAP ".$ldap->error;
140
+				}
132 141
 			}
133
-		}
134
-		elseif ($action == 'USER_NEW_PASSWORD')
142
+		} elseif ($action == 'USER_NEW_PASSWORD')
135 143
 		{
136 144
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
137 145
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -165,14 +173,14 @@  discard block
 block discarded – undo
165 173
 					$result=$ldap->update($dn,$info,$user,$olddn);
166 174
 				}
167 175
 
168
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
176
+				if ($result < 0) {
177
+				    $this->error="ErrorLDAP ".$ldap->error;
178
+				}
169 179
 			}
170
-		}
171
-		elseif ($action == 'USER_ENABLEDISABLE')
180
+		} elseif ($action == 'USER_ENABLEDISABLE')
172 181
 		{
173 182
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
174
-		}
175
-		elseif ($action == 'USER_DELETE')
183
+		} elseif ($action == 'USER_DELETE')
176 184
 		{
177 185
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
178 186
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -188,10 +196,11 @@  discard block
 block discarded – undo
188 196
 					$result=$ldap->delete($dn);
189 197
 				}
190 198
 
191
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
199
+				if ($result < 0) {
200
+				    $this->error="ErrorLDAP ".$ldap->error;
201
+				}
192 202
 			}
193
-		}
194
-		elseif ($action == 'USER_SETINGROUP')
203
+		} elseif ($action == 'USER_SETINGROUP')
195 204
 		{
196 205
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
197 206
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -226,10 +235,11 @@  discard block
 block discarded – undo
226 235
 					}
227 236
 				}
228 237
 
229
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
238
+				if ($result < 0) {
239
+				    $this->error="ErrorLDAP ".$ldap->error;
240
+				}
230 241
 			}
231
-		}
232
-		elseif ($action == 'USER_REMOVEFROMGROUP')
242
+		} elseif ($action == 'USER_REMOVEFROMGROUP')
233 243
 		{
234 244
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
235 245
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -264,7 +274,9 @@  discard block
 block discarded – undo
264 274
 					}
265 275
 				}
266 276
 
267
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
277
+				if ($result < 0) {
278
+				    $this->error="ErrorLDAP ".$ldap->error;
279
+				}
268 280
 			}
269 281
 		}
270 282
 
@@ -290,10 +302,11 @@  discard block
 block discarded – undo
290 302
 					$result=$ldap->add($dn,$info,$user);
291 303
 				}
292 304
 
293
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
305
+				if ($result < 0) {
306
+				    $this->error="ErrorLDAP ".$ldap->error;
307
+				}
294 308
 			}
295
-		}
296
-		elseif ($action == 'GROUP_MODIFY')
309
+		} elseif ($action == 'GROUP_MODIFY')
297 310
 		{
298 311
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
299 312
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -327,10 +340,11 @@  discard block
 block discarded – undo
327 340
 					$result=$ldap->update($dn,$info,$user,$olddn);
328 341
 				}
329 342
 
330
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
343
+				if ($result < 0) {
344
+				    $this->error="ErrorLDAP ".$ldap->error;
345
+				}
331 346
 			}
332
-		}
333
-		elseif ($action == 'GROUP_DELETE')
347
+		} elseif ($action == 'GROUP_DELETE')
334 348
 		{
335 349
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
336 350
 			if (! empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap')
@@ -346,7 +360,9 @@  discard block
 block discarded – undo
346 360
 					$result=$ldap->delete($dn);
347 361
 				}
348 362
 
349
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
363
+				if ($result < 0) {
364
+				    $this->error="ErrorLDAP ".$ldap->error;
365
+				}
350 366
 			}
351 367
 		}
352 368
 
@@ -367,10 +383,11 @@  discard block
 block discarded – undo
367 383
 					$result=$ldap->add($dn,$info,$user);
368 384
 				}
369 385
 
370
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
386
+				if ($result < 0) {
387
+				    $this->error="ErrorLDAP ".$ldap->error;
388
+				}
371 389
 			}
372
-		}
373
-		elseif ($action == 'CONTACT_MODIFY')
390
+		} elseif ($action == 'CONTACT_MODIFY')
374 391
 		{
375 392
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
376 393
 			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
@@ -404,10 +421,11 @@  discard block
 block discarded – undo
404 421
 					$result=$ldap->update($dn,$info,$user,$olddn);
405 422
 				}
406 423
 
407
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
424
+				if ($result < 0) {
425
+				    $this->error="ErrorLDAP ".$ldap->error;
426
+				}
408 427
 			}
409
-		}
410
-		elseif ($action == 'CONTACT_DELETE')
428
+		} elseif ($action == 'CONTACT_DELETE')
411 429
 		{
412 430
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
413 431
 			if (! empty($conf->global->LDAP_CONTACT_ACTIVE))
@@ -423,7 +441,9 @@  discard block
 block discarded – undo
423 441
 					$result=$ldap->delete($dn);
424 442
 				}
425 443
 
426
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
444
+				if ($result < 0) {
445
+				    $this->error="ErrorLDAP ".$ldap->error;
446
+				}
427 447
 			}
428 448
 		}
429 449
 
@@ -472,10 +492,11 @@  discard block
 block discarded – undo
472 492
 					}
473 493
 				}
474 494
 
475
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
495
+				if ($result < 0) {
496
+				    $this->error="ErrorLDAP ".$ldap->error;
497
+				}
476 498
 			}
477
-		}
478
-		elseif ($action == 'MEMBER_VALIDATE')
499
+		} elseif ($action == 'MEMBER_VALIDATE')
479 500
 		{
480 501
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
481 502
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -495,11 +516,12 @@  discard block
 block discarded – undo
495 516
 						$result=$ldap->update($dn,$info,$user,$olddn);
496 517
 					}
497 518
 
498
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
519
+					if ($result < 0) {
520
+					    $this->error="ErrorLDAP ".$ldap->error;
521
+					}
499 522
 				}
500 523
 			}
501
-		}
502
-		elseif ($action == 'MEMBER_SUBSCRIPTION')
524
+		} elseif ($action == 'MEMBER_SUBSCRIPTION')
503 525
 		{
504 526
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
505 527
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -523,11 +545,12 @@  discard block
 block discarded – undo
523 545
 						$result=$ldap->update($dn,$info,$user,$olddn);
524 546
 					}
525 547
 
526
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
548
+					if ($result < 0) {
549
+					    $this->error="ErrorLDAP ".$ldap->error;
550
+					}
527 551
 				}
528 552
 			}
529
-		}
530
-		elseif ($action == 'MEMBER_MODIFY')
553
+		} elseif ($action == 'MEMBER_MODIFY')
531 554
 		{
532 555
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
533 556
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -618,10 +641,11 @@  discard block
 block discarded – undo
618 641
 					}
619 642
 				}
620 643
 
621
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
644
+				if ($result < 0) {
645
+				    $this->error="ErrorLDAP ".$ldap->error;
646
+				}
622 647
 			}
623
-		}
624
-		elseif ($action == 'MEMBER_NEW_PASSWORD')
648
+		} elseif ($action == 'MEMBER_NEW_PASSWORD')
625 649
 		{
626 650
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
627 651
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -641,11 +665,12 @@  discard block
 block discarded – undo
641 665
 						$result=$ldap->update($dn,$info,$user,$olddn);
642 666
 					}
643 667
 
644
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
668
+					if ($result < 0) {
669
+					    $this->error="ErrorLDAP ".$ldap->error;
670
+					}
645 671
 				}
646 672
 			}
647
-		}
648
-		elseif ($action == 'MEMBER_RESILIATE')
673
+		} elseif ($action == 'MEMBER_RESILIATE')
649 674
 		{
650 675
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
651 676
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -665,11 +690,12 @@  discard block
 block discarded – undo
665 690
 						$result=$ldap->update($dn,$info,$user,$olddn);
666 691
 					}
667 692
 
668
-					if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
693
+					if ($result < 0) {
694
+					    $this->error="ErrorLDAP ".$ldap->error;
695
+					}
669 696
 				}
670 697
 			}
671
-		}
672
-		elseif ($action == 'MEMBER_DELETE')
698
+		} elseif ($action == 'MEMBER_DELETE')
673 699
 		{
674 700
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
675 701
 			if (! empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1')
@@ -716,7 +742,9 @@  discard block
 block discarded – undo
716 742
 					}
717 743
 				}
718 744
 
719
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
745
+				if ($result < 0) {
746
+				    $this->error="ErrorLDAP ".$ldap->error;
747
+				}
720 748
 			}
721 749
 		}
722 750
 
@@ -742,10 +770,11 @@  discard block
 block discarded – undo
742 770
 					$result=$ldap->add($dn,$info,$user);
743 771
 				}
744 772
 
745
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
773
+				if ($result < 0) {
774
+				    $this->error="ErrorLDAP ".$ldap->error;
775
+				}
746 776
 			}
747
-		}
748
-		elseif ($action == 'MEMBER_TYPE_MODIFY')
777
+		} elseif ($action == 'MEMBER_TYPE_MODIFY')
749 778
 		{
750 779
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
751 780
 			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
@@ -783,10 +812,11 @@  discard block
 block discarded – undo
783 812
 					$result=$ldap->update($dn,$info,$user,$olddn);
784 813
 				}
785 814
 
786
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
815
+				if ($result < 0) {
816
+				    $this->error="ErrorLDAP ".$ldap->error;
817
+				}
787 818
 			}
788
-		}
789
-		elseif ($action == 'MEMBER_TYPE_DELETE')
819
+		} elseif ($action == 'MEMBER_TYPE_DELETE')
790 820
 		{
791 821
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
792 822
 			if (! empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1')
@@ -802,7 +832,9 @@  discard block
 block discarded – undo
802 832
 					$result=$ldap->delete($dn);
803 833
 				}
804 834
 
805
-				if ($result < 0) $this->error="ErrorLDAP ".$ldap->error;
835
+				if ($result < 0) {
836
+				    $this->error="ErrorLDAP ".$ldap->error;
837
+				}
806 838
 			}
807 839
 		}
808 840
 
Please login to merge, or discard this patch.