Passed
Push — master ( 3cffbe...0f9140 )
by Alxarafe
23:50
created
dolibarr/htdocs/install/step1.php 1 patch
Braces   +27 added lines, -20 removed lines patch added patch discarded remove patch
@@ -227,18 +227,21 @@  discard block
 block discarded – undo
227 227
             if (empty($db_create_database) && $db->connected && !$db->database_selected) {
228 228
                 print '<div class="error">' . $langs->trans("ErrorConnectedButDatabaseNotFound", $db_name) . '</div>';
229 229
                 print '<br>';
230
-                if (!$db->connected)
231
-                    print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate") . '<br><br>';
230
+                if (!$db->connected) {
231
+                                    print $langs->trans("IfDatabaseNotExistsGoBackAndUncheckCreate") . '<br><br>';
232
+                }
232 233
                 print $langs->trans("ErrorGoBackAndCorrectParameters");
233 234
                 $error++;
234 235
             } elseif ($db->error && !(!empty($db_create_database) && $db->connected)) {
235 236
                 // Note: you may experience error here with message "No such file or directory" when mysql was installed for the first time but not yet launched.
236
-                if ($db->error == "No such file or directory")
237
-                    print '<div class="error">' . $langs->trans("ErrorToConnectToMysqlCheckInstance") . '</div>';
238
-                else
239
-                    print '<div class="error">' . $db->error . '</div>';
240
-                if (!$db->connected)
241
-                    print $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
237
+                if ($db->error == "No such file or directory") {
238
+                                    print '<div class="error">' . $langs->trans("ErrorToConnectToMysqlCheckInstance") . '</div>';
239
+                } else {
240
+                                    print '<div class="error">' . $db->error . '</div>';
241
+                }
242
+                if (!$db->connected) {
243
+                                    print $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
244
+                }
242 245
                 //print '<a href="#" onClick="javascript: history.back();">';
243 246
                 print $langs->trans("ErrorGoBackAndCorrectParameters");
244 247
                 //print '</a>';
@@ -251,16 +254,16 @@  discard block
 block discarded – undo
251 254
 
252 255
             if ($db->error) {
253 256
                 print '<div class="error">' . $db->error . '</div>';
254
-                if (!$db->connected)
255
-                    print $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
257
+                if (!$db->connected) {
258
+                                    print $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
259
+                }
256 260
                 //print '<a href="#" onClick="javascript: history.back();">';
257 261
                 print $langs->trans("ErrorGoBackAndCorrectParameters");
258 262
                 //print '</a>';
259 263
                 $error++;
260 264
             }
261 265
         }
262
-    }
263
-    else {
266
+    } else {
264 267
         print "<br>\nFailed to include_once(\"" . $main_dir . "/core/db/" . $db_type . ".class.php\")<br>\n";
265 268
         print '<div class="error">' . $langs->trans("ErrorWrongValueForParameter", $langs->transnoentities("WebPagesDirectory")) . '</div>';
266 269
         //print '<a href="#" onClick="javascript: history.back();">';
@@ -269,10 +272,12 @@  discard block
 block discarded – undo
269 272
         $error++;
270 273
     }
271 274
 } else {
272
-    if (isset($db))
273
-        print $db->lasterror();
274
-    if (isset($db) && !$db->connected)
275
-        print '<br>' . $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
275
+    if (isset($db)) {
276
+            print $db->lasterror();
277
+    }
278
+    if (isset($db) && !$db->connected) {
279
+            print '<br>' . $langs->trans("BecauseConnectionFailedParametersMayBeWrong") . '<br><br>';
280
+    }
276 281
     print $langs->trans("ErrorGoBackAndCorrectParameters");
277 282
     $error++;
278 283
 }
@@ -710,8 +715,9 @@  discard block
 block discarded – undo
710 715
 
711 716
 <?php
712 717
 $ret = 0;
713
-if ($error && isset($argv[1]))
714
-    $ret = 1;
718
+if ($error && isset($argv[1])) {
719
+    $ret = 1;
720
+}
715 721
 dolibarr_install_syslog("Exit " . $ret);
716 722
 
717 723
 dolibarr_install_syslog("--- step1: end");
@@ -719,8 +725,9 @@  discard block
 block discarded – undo
719 725
 pFooter($error ? 1 : 0, $setuplang, 'jsinfo', 1);
720 726
 
721 727
 // Return code if ran from command line
722
-if ($ret)
723
-    exit($ret);
728
+if ($ret) {
729
+    exit($ret);
730
+}
724 731
 
725 732
 /**
726 733
  *  Create main file. No particular permissions are set by installer.
Please login to merge, or discard this patch.
dolibarr/htdocs/install/step5.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -131,8 +131,9 @@  discard block
 block discarded – undo
131 131
             $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
132 132
             $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
133 133
             $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this as it is used to know the password was initially crypted
134
-        } else
135
-            $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
134
+        } else {
135
+                    $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
136
+        }
136 137
     }
137 138
 
138 139
     $conf->db->type = $dolibarr_main_db_type;
@@ -285,8 +286,9 @@  discard block
 block discarded – undo
285 286
                         $res = dol_include_once("/core/modules/" . $file);
286 287
 
287 288
                         $res = activateModule($modtoactivatenew, 1);
288
-                        if (!empty($res['errors']))
289
-                            print 'ERROR in activating module file=' . $file;
289
+                        if (!empty($res['errors'])) {
290
+                                                    print 'ERROR in activating module file=' . $file;
291
+                        }
290 292
                     }
291 293
                 }
292 294
 
Please login to merge, or discard this patch.
dolibarr/htdocs/install/inc.php 1 patch
Braces   +95 added lines, -61 removed lines patch added patch discarded remove patch
@@ -31,8 +31,9 @@  discard block
 block discarded – undo
31 31
  * 	\brief      File that define environment for support pages
32 32
  */
33 33
 // Just to define version DOL_VERSION
34
-if (!defined('DOL_INC_FOR_VERSION_ERROR'))
34
+if (!defined('DOL_INC_FOR_VERSION_ERROR')) {
35 35
     define('DOL_INC_FOR_VERSION_ERROR', '1');
36
+}
36 37
 require_once DOL_BASE_PATH . '/filefunc.inc.php';
37 38
 
38 39
 require_once DOL_BASE_PATH . '/core/class/translate.class.php';
@@ -151,23 +152,31 @@  discard block
 block discarded – undo
151 152
 define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : ''));           // URL relative root
152 153
 $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT'));  // $uri contains url without http*
153 154
 $suburi = strstr($uri, '/');       // $suburi contains url without domain
154
-if ($suburi == '/')
155
-    $suburi = '';   // If $suburi is /, it is now ''
155
+if ($suburi == '/') {
156
+    $suburi = '';
157
+}
158
+// If $suburi is /, it is now ''
156 159
 define('DOL_URL_ROOT', $suburi);    // URL relative root ('', '/dolibarr', ...)
157 160
 
158 161
 
159
-if (empty($conf->file->character_set_client))
162
+if (empty($conf->file->character_set_client)) {
160 163
     $conf->file->character_set_client = "utf-8";
161
-if (empty($conf->db->character_set))
164
+}
165
+if (empty($conf->db->character_set)) {
162 166
     $conf->db->character_set = 'utf8';
163
-if (empty($conf->db->dolibarr_main_db_collation))
167
+}
168
+if (empty($conf->db->dolibarr_main_db_collation)) {
164 169
     $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci';
165
-if (empty($conf->db->dolibarr_main_db_encryption))
170
+}
171
+if (empty($conf->db->dolibarr_main_db_encryption)) {
166 172
     $conf->db->dolibarr_main_db_encryption = 0;
167
-if (empty($conf->db->dolibarr_main_db_cryptkey))
173
+}
174
+if (empty($conf->db->dolibarr_main_db_cryptkey)) {
168 175
     $conf->db->dolibarr_main_db_cryptkey = '';
169
-if (empty($conf->db->user))
176
+}
177
+if (empty($conf->db->user)) {
170 178
     $conf->db->user = '';
179
+}
171 180
 
172 181
 // Define array of document root directories
173 182
 $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT);
@@ -224,19 +233,24 @@  discard block
 block discarded – undo
224 233
 // Force usage of log file for install and upgrades
225 234
 $conf->syslog->enabled = 1;
226 235
 $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
227
-if (!defined('SYSLOG_HANDLERS'))
236
+if (!defined('SYSLOG_HANDLERS')) {
228 237
     define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
238
+}
229 239
 if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined
230
-    if (@is_writable('/tmp'))
231
-        define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
232
-    else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"]))
233
-        define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log');
234
-    else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"]))
235
-        define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log');
236
-    else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat'))
237
-        define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
238
-    else if (@is_writable('../../'))
239
-        define('SYSLOG_FILE', '../../dolibarr_install.log');    // For others
240
+    if (@is_writable('/tmp')) {
241
+            define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
242
+    } else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) {
243
+            define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log');
244
+    } else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) {
245
+            define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log');
246
+    } else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) {
247
+            define('SYSLOG_FILE', '../../../../dolibarr_install.log');
248
+    }
249
+    // For DoliWamp
250
+    else if (@is_writable('../../')) {
251
+            define('SYSLOG_FILE', '../../dolibarr_install.log');
252
+    }
253
+    // For others
240 254
 
241 255
 
242 256
 
@@ -254,10 +268,12 @@  discard block
 block discarded – undo
254 268
         
255 269
 //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
256 270
 }
257
-if (defined('SYSLOG_FILE'))
271
+if (defined('SYSLOG_FILE')) {
258 272
     $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
259
-if (!defined('SYSLOG_FILE_NO_ERROR'))
273
+}
274
+if (!defined('SYSLOG_FILE_NO_ERROR')) {
260 275
     define('SYSLOG_FILE_NO_ERROR', 1);
276
+}
261 277
 // We init log handler for install
262 278
 $handlers = array('mod_syslog_file');
263 279
 foreach ($handlers as $handler) {
@@ -272,9 +288,10 @@  discard block
 block discarded – undo
272 288
         throw new Exception('Log handler does not extend LogHandlerInterface');
273 289
     }
274 290
 
275
-    if (empty($conf->loghandlers[$handler]))
276
-        $conf->loghandlers[$handler] = $loghandlerinstance;
277
-}
291
+    if (empty($conf->loghandlers[$handler])) {
292
+            $conf->loghandlers[$handler] = $loghandlerinstance;
293
+    }
294
+    }
278 295
 
279 296
 // Removed magic_quotes
280 297
 if (function_exists('get_magic_quotes_gpc')) { // magic_quotes_* removed in PHP 5.4
@@ -298,10 +315,11 @@  discard block
 block discarded – undo
298 315
 
299 316
 // Defini objet langs
300 317
 $langs = new Translate('..', $conf);
301
-if (GETPOST('lang', 'aZ09'))
318
+if (GETPOST('lang', 'aZ09')) {
302 319
     $langs->setDefaultLang(GETPOST('lang', 'aZ09'));
303
-else
320
+} else {
304 321
     $langs->setDefaultLang('auto');
322
+}
305 323
 
306 324
 $bc[false] = ' class="bg1"';
307 325
 $bc[true] = ' class="bg2"';
@@ -324,8 +342,9 @@  discard block
 block discarded – undo
324 342
     global $character_set_client;
325 343
 
326 344
     $return = include_once $dolibarr_main_document_root . '/core/class/conf.class.php';
327
-    if (!$return)
328
-        return -1;
345
+    if (!$return) {
346
+            return -1;
347
+    }
329 348
 
330 349
     $conf = new Conf();
331 350
     $conf->db->type = trim($dolibarr_main_db_type);
@@ -336,40 +355,51 @@  discard block
 block discarded – undo
336 355
     $conf->db->pass = trim($dolibarr_main_db_pass);
337 356
 
338 357
     // Mysql driver support has been removed in favor of mysqli
339
-    if ($conf->db->type == 'mysql')
340
-        $conf->db->type = 'mysqli';
341
-    if (empty($character_set_client))
342
-        $character_set_client = "UTF-8";
358
+    if ($conf->db->type == 'mysql') {
359
+            $conf->db->type = 'mysqli';
360
+    }
361
+    if (empty($character_set_client)) {
362
+            $character_set_client = "UTF-8";
363
+    }
343 364
     $conf->file->character_set_client = strtoupper($character_set_client);
344
-    if (empty($dolibarr_main_db_character_set))
345
-        $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : '');
365
+    if (empty($dolibarr_main_db_character_set)) {
366
+            $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : '');
367
+    }
346 368
     $conf->db->character_set = $dolibarr_main_db_character_set;
347
-    if (empty($dolibarr_main_db_collation))
348
-        $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : '');
369
+    if (empty($dolibarr_main_db_collation)) {
370
+            $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : '');
371
+    }
349 372
     $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation;
350
-    if (empty($dolibarr_main_db_encryption))
351
-        $dolibarr_main_db_encryption = 0;
373
+    if (empty($dolibarr_main_db_encryption)) {
374
+            $dolibarr_main_db_encryption = 0;
375
+    }
352 376
     $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption;
353
-    if (empty($dolibarr_main_db_cryptkey))
354
-        $dolibarr_main_db_cryptkey = '';
377
+    if (empty($dolibarr_main_db_cryptkey)) {
378
+            $dolibarr_main_db_cryptkey = '';
379
+    }
355 380
     $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
356 381
 
357 382
     // Force usage of log file for install and upgrades
358 383
     $conf->syslog->enabled = 1;
359 384
     $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG');
360
-    if (!defined('SYSLOG_HANDLERS'))
361
-        define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
385
+    if (!defined('SYSLOG_HANDLERS')) {
386
+            define('SYSLOG_HANDLERS', '["mod_syslog_file"]');
387
+    }
362 388
     if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined
363
-        if (@is_writable('/tmp'))
364
-            define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
365
-        else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"]))
366
-            define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log');
367
-        else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"]))
368
-            define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log');
369
-        else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat'))
370
-            define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp
371
-        else if (@is_writable('../../'))
372
-            define('SYSLOG_FILE', '../../dolibarr_install.log');    // For others
389
+        if (@is_writable('/tmp')) {
390
+                    define('SYSLOG_FILE', '/tmp/dolibarr_install.log');
391
+        } else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) {
392
+                    define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log');
393
+        } else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) {
394
+                    define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log');
395
+        } else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) {
396
+                    define('SYSLOG_FILE', '../../../../dolibarr_install.log');
397
+        }
398
+        // For DoliWamp
399
+        else if (@is_writable('../../')) {
400
+                    define('SYSLOG_FILE', '../../dolibarr_install.log');
401
+        }
402
+        // For others
373 403
 
374 404
 
375 405
 
@@ -387,10 +417,12 @@  discard block
 block discarded – undo
387 417
             
388 418
 //print 'SYSLOG_FILE='.SYSLOG_FILE;exit;
389 419
     }
390
-    if (defined('SYSLOG_FILE'))
391
-        $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
392
-    if (!defined('SYSLOG_FILE_NO_ERROR'))
393
-        define('SYSLOG_FILE_NO_ERROR', 1);
420
+    if (defined('SYSLOG_FILE')) {
421
+            $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
422
+    }
423
+    if (!defined('SYSLOG_FILE_NO_ERROR')) {
424
+            define('SYSLOG_FILE_NO_ERROR', 1);
425
+    }
394 426
     // We init log handler for install
395 427
     $handlers = array('mod_syslog_file');
396 428
     foreach ($handlers as $handler) {
@@ -405,8 +437,9 @@  discard block
 block discarded – undo
405 437
             throw new Exception('Log handler does not extend LogHandlerInterface');
406 438
         }
407 439
 
408
-        if (empty($conf->loghandlers[$handler]))
409
-            $conf->loghandlers[$handler] = $loghandlerinstance;
440
+        if (empty($conf->loghandlers[$handler])) {
441
+                    $conf->loghandlers[$handler] = $loghandlerinstance;
442
+        }
410 443
     }
411 444
 
412 445
     return 1;
@@ -571,8 +604,9 @@  discard block
 block discarded – undo
571 604
  */
572 605
 function dolibarr_install_syslog($message, $level = LOG_DEBUG)
573 606
 {
574
-    if (!defined('LOG_DEBUG'))
575
-        define('LOG_DEBUG', 6);
607
+    if (!defined('LOG_DEBUG')) {
608
+            define('LOG_DEBUG', 6);
609
+    }
576 610
     dol_syslog($message, $level);
577 611
 }
578 612
 
Please login to merge, or discard this patch.
dolibarr/htdocs/install/step2.php 1 patch
Braces   +57 added lines, -42 removed lines patch added patch discarded remove patch
@@ -49,23 +49,29 @@  discard block
 block discarded – undo
49 49
 $langs->loadLangs(array("admin", "install"));
50 50
 
51 51
 $choix = 0;
52
-if ($dolibarr_main_db_type == "mysqli")
53
-    $choix = 1;
54
-if ($dolibarr_main_db_type == "pgsql")
55
-    $choix = 2;
56
-if ($dolibarr_main_db_type == "mssql")
57
-    $choix = 3;
58
-if ($dolibarr_main_db_type == "sqlite")
59
-    $choix = 4;
60
-if ($dolibarr_main_db_type == "sqlite3")
61
-    $choix = 5;
52
+if ($dolibarr_main_db_type == "mysqli") {
53
+    $choix = 1;
54
+}
55
+if ($dolibarr_main_db_type == "pgsql") {
56
+    $choix = 2;
57
+}
58
+if ($dolibarr_main_db_type == "mssql") {
59
+    $choix = 3;
60
+}
61
+if ($dolibarr_main_db_type == "sqlite") {
62
+    $choix = 4;
63
+}
64
+if ($dolibarr_main_db_type == "sqlite3") {
65
+    $choix = 5;
66
+}
62 67
 
63 68
 //if (empty($choix)) dol_print_error('','Database type '.$dolibarr_main_db_type.' not supported into step2.php page');
64 69
 // Now we load forced values from install.forced.php file.
65 70
 $useforcedwizard = false;
66 71
 $forcedfile = "./install.forced.php";
67
-if ($conffile == "/etc/dolibarr/conf.php")
68
-    $forcedfile = "/etc/dolibarr/install.forced.php";
72
+if ($conffile == "/etc/dolibarr/conf.php") {
73
+    $forcedfile = "/etc/dolibarr/install.forced.php";
74
+}
69 75
 if (@file_exists($forcedfile)) {
70 76
     $useforcedwizard = true;
71 77
     include_once $forcedfile;
@@ -301,8 +307,9 @@  discard block
 block discarded – undo
301 307
                     }
302 308
 
303 309
                     // Ajout ligne si non commentaire
304
-                    if (!preg_match('/^--/i', $buf))
305
-                        $buffer .= $buf;
310
+                    if (!preg_match('/^--/i', $buf)) {
311
+                                            $buffer .= $buf;
312
+                    }
306 313
                 }
307 314
                 fclose($fp);
308 315
 
@@ -366,16 +373,16 @@  discard block
 block discarded – undo
366 373
      * ************************************************************************************* */
367 374
     if ($ok && $createfunctions) {
368 375
         // For this file, we use a directory according to database type
369
-        if ($choix == 1)
370
-            //$dir = "mysql/functions/";
371
-            $dir = DOL_BASE_PATH . "/install/mysql/functions/";
372
-        elseif ($choix == 2)
373
-        //$dir = "pgsql/functions/";
374
-            $dir = DOL_BASE_PATH . "/install/pgsql/functions/";
375
-        elseif ($choix == 3)
376
-            //$dir = "mssql/functions/";
377
-            $dir = DOL_BASE_PATH . "/install/mssql/functions/";
378
-        elseif ($choix == 4) {
376
+        if ($choix == 1) {
377
+                    //$dir = "mysql/functions/";
378
+            $dir = DOL_BASE_PATH . "/install/mysql/functions/";
379
+        } elseif ($choix == 2) {
380
+                //$dir = "pgsql/functions/";
381
+            $dir = DOL_BASE_PATH . "/install/pgsql/functions/";
382
+        } elseif ($choix == 3) {
383
+                    //$dir = "mssql/functions/";
384
+            $dir = DOL_BASE_PATH . "/install/mssql/functions/";
385
+        } elseif ($choix == 4) {
379 386
             //$dir = "sqlite3/functions/";
380 387
             $dir = DOL_BASE_PATH . "/install/sqlite3/functions/";
381 388
         }
@@ -452,8 +459,10 @@  discard block
 block discarded – undo
452 459
         if (is_resource($handle)) {
453 460
             while (($file = readdir($handle)) !== false) {
454 461
                 if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file)) {
455
-                    if (preg_match('/^llx_accounting_account_/', $file))
456
-                        continue; // We discard data file of chart of account. Will be loaded when a chart is selected.
462
+                    if (preg_match('/^llx_accounting_account_/', $file)) {
463
+                                            continue;
464
+                    }
465
+                    // We discard data file of chart of account. Will be loaded when a chart is selected.
457 466
 
458 467
 
459 468
                         
@@ -483,16 +492,18 @@  discard block
 block discarded – undo
483 492
                     $buffer = fgets($fp, 4096);
484 493
                     $buffer = trim($buffer);
485 494
                     if ($buffer) {
486
-                        if (substr($buffer, 0, 2) == '--')
487
-                            continue;
495
+                        if (substr($buffer, 0, 2) == '--') {
496
+                                                    continue;
497
+                        }
488 498
 
489 499
                         if ($linefound && ($linefound % $sizeofgroup) == 0) {
490 500
                             $linegroup++;
491 501
                         }
492
-                        if (empty($arrayofrequests[$linegroup]))
493
-                            $arrayofrequests[$linegroup] = $buffer;
494
-                        else
495
-                            $arrayofrequests[$linegroup] .= " " . $buffer;
502
+                        if (empty($arrayofrequests[$linegroup])) {
503
+                                                    $arrayofrequests[$linegroup] = $buffer;
504
+                        } else {
505
+                                                    $arrayofrequests[$linegroup] .= " " . $buffer;
506
+                        }
496 507
 
497 508
                         $linefound++;
498 509
                     }
@@ -526,10 +537,11 @@  discard block
 block discarded – undo
526 537
                     }
527 538
                 }
528 539
 
529
-                if ($okallfile)
530
-                    $db->commit();
531
-                else
532
-                    $db->rollback();
540
+                if ($okallfile) {
541
+                                    $db->commit();
542
+                } else {
543
+                                    $db->rollback();
544
+                }
533 545
             }
534 546
         }
535 547
 
@@ -548,17 +560,20 @@  discard block
 block discarded – undo
548 560
 
549 561
 
550 562
 $ret = 0;
551
-if (!$ok && isset($argv[1]))
552
-    $ret = 1;
563
+if (!$ok && isset($argv[1])) {
564
+    $ret = 1;
565
+}
553 566
 dolibarr_install_syslog("Exit " . $ret);
554 567
 
555 568
 dolibarr_install_syslog("- step2: end");
556 569
 
557 570
 pFooter($ok ? 0 : 1, $setuplang);
558 571
 
559
-if (isset($db) && is_object($db))
560
-    $db->close();
572
+if (isset($db) && is_object($db)) {
573
+    $db->close();
574
+}
561 575
 
562 576
 // Return code if ran from command line
563
-if ($ret)
564
-    exit($ret);
577
+if ($ret) {
578
+    exit($ret);
579
+}
Please login to merge, or discard this patch.
dolibarr/htdocs/install/step4.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -39,8 +39,9 @@
 block discarded – undo
39 39
 // Now we load forced value from install.forced.php file.
40 40
 $useforcedwizard = false;
41 41
 $forcedfile = "./install.forced.php";
42
-if ($conffile == "/etc/dolibarr/conf.php")
43
-    $forcedfile = "/etc/dolibarr/install.forced.php";
42
+if ($conffile == "/etc/dolibarr/conf.php") {
43
+    $forcedfile = "/etc/dolibarr/install.forced.php";
44
+}
44 45
 if (@file_exists($forcedfile)) {
45 46
     $useforcedwizard = true;
46 47
     include_once $forcedfile;
Please login to merge, or discard this patch.
Helpers/AlSecurity2.php 1 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
 
@@ -341,8 +344,9 @@  discard block
 block discarded – undo
341 344
                 break;
342 345
         }
343 346
         $salt = '';
344
-        while (dol_strlen($salt) < $saltlen)
345
-            $salt .= chr(mt_rand(64, 126));
347
+        while (dol_strlen($salt) < $saltlen) {
348
+                    $salt .= chr(mt_rand(64, 126));
349
+        }
346 350
 
347 351
         $result = $saltprefix . $salt . $saltsuffix;
348 352
         AlDolUtils::dol_syslog("makesalt return=" . $result);
Please login to merge, or discard this patch.
Helpers/AlDolUtils.php 1 patch
Braces   +1340 added lines, -963 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
         }
@@ -391,14 +393,17 @@  discard block
 block discarded – undo
391 393
                                             $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
392 394
                                             $foundintru = 0;
393 395
                                             foreach ($tmpqueryarraytohave as $tmpquerytohave) {
394
-                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
395
-                                                    $foundintru = 1;
396
+                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
397
+                                                                                                    $foundintru = 1;
398
+                                                }
396 399
                                             }
397
-                                            if (!$foundintru)
398
-                                                $qualified = 1;
400
+                                            if (!$foundintru) {
401
+                                                                                            $qualified = 1;
402
+                                            }
399 403
                                             //var_dump($defkey.'-'.$qualified);
400
-                                        } else
401
-                                            $qualified = 1;
404
+                                        } else {
405
+                                                                                    $qualified = 1;
406
+                                        }
402 407
 
403 408
                                         if ($qualified) {
404 409
                                             //var_dump($user->default_values[$relativepathstring][$defkey]['createform']);
@@ -425,20 +430,24 @@  discard block
 block discarded – undo
425 430
                                                 $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
426 431
                                                 $foundintru = 0;
427 432
                                                 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
428
-                                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
429
-                                                        $foundintru = 1;
433
+                                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
434
+                                                                                                            $foundintru = 1;
435
+                                                    }
430 436
                                                 }
431
-                                                if (!$foundintru)
432
-                                                    $qualified = 1;
437
+                                                if (!$foundintru) {
438
+                                                                                                    $qualified = 1;
439
+                                                }
433 440
                                                 //var_dump($defkey.'-'.$qualified);
434
-                                            } else
435
-                                                $qualified = 1;
441
+                                            } else {
442
+                                                                                            $qualified = 1;
443
+                                            }
436 444
 
437 445
                                             if ($qualified) {
438 446
                                                 $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "=");  // we accept _, -, . and ,
439 447
                                                 foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) {
440
-                                                    if ($out)
441
-                                                        $out .= ', ';
448
+                                                    if ($out) {
449
+                                                                                                            $out .= ', ';
450
+                                                    }
442 451
                                                     if ($paramname == 'sortfield') {
443 452
                                                         $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace);
444 453
                                                     }
@@ -458,14 +467,17 @@  discard block
 block discarded – undo
458 467
                                             $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
459 468
                                             $foundintru = 0;
460 469
                                             foreach ($tmpqueryarraytohave as $tmpquerytohave) {
461
-                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
462
-                                                    $foundintru = 1;
470
+                                                if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
471
+                                                                                                    $foundintru = 1;
472
+                                                }
463 473
                                             }
464
-                                            if (!$foundintru)
465
-                                                $qualified = 1;
474
+                                            if (!$foundintru) {
475
+                                                                                            $qualified = 1;
476
+                                            }
466 477
                                             //var_dump($defkey.'-'.$qualified);
467
-                                        } else
468
-                                            $qualified = 1;
478
+                                        } else {
479
+                                                                                    $qualified = 1;
480
+                                        }
469 481
 
470 482
                                         if ($qualified) {
471 483
                                             if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) {
@@ -556,18 +568,20 @@  discard block
 block discarded – undo
556 568
                 }
557 569
                 break;
558 570
             case 'intcomma':
559
-                if (preg_match('/[^0-9,-]+/i', $out))
560
-                    $out = '';
571
+                if (preg_match('/[^0-9,-]+/i', $out)) {
572
+                                    $out = '';
573
+                }
561 574
                 break;
562 575
             case 'alpha':
563 576
                 if (!is_array($out)) {
564 577
                     $out = trim($out);
565 578
                     // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
566 579
                     // '../' is dangerous because it allows dir transversals
567
-                    if (preg_match('/"/', $out))
568
-                        $out = '';
569
-                    else if (preg_match('/\.\.\//', $out))
570
-                        $out = '';
580
+                    if (preg_match('/"/', $out)) {
581
+                                            $out = '';
582
+                    } else if (preg_match('/\.\.\//', $out)) {
583
+                                            $out = '';
584
+                    }
571 585
                 }
572 586
                 break;
573 587
             case 'san_alpha':
@@ -576,27 +590,31 @@  discard block
 block discarded – undo
576 590
             case 'aZ':
577 591
                 if (!is_array($out)) {
578 592
                     $out = trim($out);
579
-                    if (preg_match('/[^a-z]+/i', $out))
580
-                        $out = '';
593
+                    if (preg_match('/[^a-z]+/i', $out)) {
594
+                                            $out = '';
595
+                    }
581 596
                 }
582 597
                 break;
583 598
             case 'aZ09':
584 599
                 if (!is_array($out)) {
585 600
                     $out = trim($out);
586
-                    if (preg_match('/[^a-z0-9_\-\.]+/i', $out))
587
-                        $out = '';
601
+                    if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) {
602
+                                            $out = '';
603
+                    }
588 604
                 }
589 605
                 break;
590 606
             case 'aZ09comma':  // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh
591 607
                 if (!is_array($out)) {
592 608
                     $out = trim($out);
593
-                    if (preg_match('/[^a-z0-9_\-\.,]+/i', $out))
594
-                        $out = '';
609
+                    if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) {
610
+                                            $out = '';
611
+                    }
595 612
                 }
596 613
                 break;
597 614
             case 'array':
598
-                if (!is_array($out) || empty($out))
599
-                    $out = array();
615
+                if (!is_array($out) || empty($out)) {
616
+                                    $out = array();
617
+                }
600 618
                 break;
601 619
             case 'nohtml':  // Recommended for most scalar parameters
602 620
                 $out = dol_string_nohtmltag($out, 0);
@@ -606,16 +624,18 @@  discard block
 block discarded – undo
606 624
                     $out = trim($out);
607 625
                     // '"' is dangerous because param in url can close the href= or src= and add javascript functions.
608 626
                     // '../' is dangerous because it allows dir transversals
609
-                    if (preg_match('/"/', $out))
610
-                        $out = '';
611
-                    else if (preg_match('/\.\.\//', $out))
612
-                        $out = '';
627
+                    if (preg_match('/"/', $out)) {
628
+                                            $out = '';
629
+                    } else if (preg_match('/\.\.\//', $out)) {
630
+                                            $out = '';
631
+                    }
613 632
                     $out = dol_string_nohtmltag($out);
614 633
                 }
615 634
                 break;
616 635
             case 'custom':
617
-                if (empty($filter))
618
-                    return 'BadFourthParameterForDolUtils::GETPOST';
636
+                if (empty($filter)) {
637
+                                    return 'BadFourthParameterForDolUtils::GETPOST';
638
+                }
619 639
                 $out = filter_var($out, $filter, $options);
620 640
                 break;
621 641
         }
@@ -733,11 +753,11 @@  discard block
 block discarded – undo
733 753
                 }
734 754
             }
735 755
             if ($returnemptyifnotfound) {        // Not found into alternate dir
736
-                if ($returnemptyifnotfound == 1 || !file_exists($res))
737
-                    return '';
756
+                if ($returnemptyifnotfound == 1 || !file_exists($res)) {
757
+                                    return '';
758
+                }
738 759
             }
739
-        }
740
-        else {    // For an url path
760
+        } else {    // For an url path
741 761
 // We try to get local path of file on filesystem from url
742 762
 // Note that trying to know if a file on disk exist by forging path on disk from url
743 763
 // works only for some web server and some setup. This is bugged when
@@ -831,12 +851,14 @@  discard block
 block discarded – undo
831 851
     static function dol_size($size, $type = '')
832 852
     {
833 853
         //global Globals::$conf;
834
-        if (empty(Globals::$conf->dol_optimize_smallscreen))
835
-            return $size;
836
-        if ($type == 'width' && $size > 250)
837
-            return 250;
838
-        else
839
-            return 10;
854
+        if (empty(Globals::$conf->dol_optimize_smallscreen)) {
855
+                    return $size;
856
+        }
857
+        if ($type == 'width' && $size > 250) {
858
+                    return 250;
859
+        } else {
860
+                    return 10;
861
+        }
840 862
     }
841 863
 
842 864
     /**
@@ -936,9 +958,10 @@  discard block
 block discarded – undo
936 958
     {
937 959
         $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°');  // more complete than dol_sanitizeFileName
938 960
         $forbidden_chars_to_remove = array();
939
-        if (is_array($badcharstoreplace))
940
-            $forbidden_chars_to_replace = $badcharstoreplace;
941
-//$forbidden_chars_to_remove=array("(",")");
961
+        if (is_array($badcharstoreplace)) {
962
+                    $forbidden_chars_to_replace = $badcharstoreplace;
963
+        }
964
+        //$forbidden_chars_to_remove=array("(",")");
942 965
 
943 966
         return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str));
944 967
     }
@@ -974,9 +997,9 @@  discard block
 block discarded – undo
974 997
         if (empty($mode)) {
975 998
             $substitjs["'"] = "\\'";
976 999
             $substitjs['"'] = "\\'";
977
-        } else if ($mode == 1)
978
-            $substitjs["'"] = "\\'";
979
-        else if ($mode == 2) {
1000
+        } else if ($mode == 1) {
1001
+                    $substitjs["'"] = "\\'";
1002
+        } else if ($mode == 2) {
980 1003
             $substitjs['"'] = '\\"';
981 1004
         } else if ($mode == 3) {
982 1005
             $substitjs["'"] = "\\'";
@@ -998,10 +1021,12 @@  discard block
 block discarded – undo
998 1021
     {
999 1022
 // escape quotes and backslashes, newlines, etc.
1000 1023
         $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8');  // TODO Use htmlspecialchars_decode instead, that make only required change for html tags
1001
-        if (!$keepb)
1002
-            $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1003
-        if (!$keepn)
1004
-            $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1024
+        if (!$keepb) {
1025
+                    $tmp = strtr($tmp, array("<b>" => '', '</b>' => ''));
1026
+        }
1027
+        if (!$keepn) {
1028
+                    $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n'));
1029
+        }
1005 1030
         return htmlentities($tmp, ENT_COMPAT, 'UTF-8');      // TODO Use htmlspecialchars instead, that make only required change for html tags
1006 1031
     }
1007 1032
 
@@ -1051,8 +1076,9 @@  discard block
 block discarded – undo
1051 1076
     {
1052 1077
         // global Globals::$conf, $user;
1053 1078
 // If syslog module enabled
1054
-        if (empty(Globals::$conf->syslog->enabled))
1055
-            return;
1079
+        if (empty(Globals::$conf->syslog->enabled)) {
1080
+                    return;
1081
+        }
1056 1082
 
1057 1083
         if ($ident < 0) {
1058 1084
             foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
@@ -1066,8 +1092,9 @@  discard block
 block discarded – undo
1066 1092
             if (!in_array($level, $logLevels, true)) {
1067 1093
                 throw new Exception('Incorrect log level');
1068 1094
             }
1069
-            if ($level > Globals::$conf->global->SYSLOG_LEVEL)
1070
-                return;
1095
+            if ($level > Globals::$conf->global->SYSLOG_LEVEL) {
1096
+                            return;
1097
+            }
1071 1098
 
1072 1099
             $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log
1073 1100
 // If adding log inside HTML page is required
@@ -1092,24 +1119,30 @@  discard block
 block discarded – undo
1092 1119
             );
1093 1120
 
1094 1121
 // This is when server run behind a reverse proxy
1095
-            if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
1096
-                $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1097
-// This is when server run normally on a server
1098
-            else if (!empty($_SERVER["REMOTE_ADDR"]))
1099
-                $data['ip'] = $_SERVER['REMOTE_ADDR'];
1100
-// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
1101
-            else if (!empty($_SERVER['SERVER_ADDR']))
1102
-                $data['ip'] = $_SERVER['SERVER_ADDR'];
1103
-// 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).
1104
-            else if (!empty($_SERVER['COMPUTERNAME']))
1105
-                $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1106
-// 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).
1107
-            else if (!empty($_SERVER['LOGNAME']))
1108
-                $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1109
-// Loop on each log handler and send output
1122
+            if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
1123
+                            $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']);
1124
+            }
1125
+            // This is when server run normally on a server
1126
+            else if (!empty($_SERVER["REMOTE_ADDR"])) {
1127
+                            $data['ip'] = $_SERVER['REMOTE_ADDR'];
1128
+            }
1129
+            // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
1130
+            else if (!empty($_SERVER['SERVER_ADDR'])) {
1131
+                            $data['ip'] = $_SERVER['SERVER_ADDR'];
1132
+            }
1133
+            // 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).
1134
+            else if (!empty($_SERVER['COMPUTERNAME'])) {
1135
+                            $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']);
1136
+            }
1137
+            // 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).
1138
+            else if (!empty($_SERVER['LOGNAME'])) {
1139
+                            $data['ip'] = '???@' . $_SERVER['LOGNAME'];
1140
+            }
1141
+            // Loop on each log handler and send output
1110 1142
             foreach (Globals::$conf->loghandlers as $loghandlerinstance) {
1111
-                if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler)
1112
-                    continue;
1143
+                if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) {
1144
+                                    continue;
1145
+                }
1113 1146
                 $loghandlerinstance->export($data, $suffixinfilename);
1114 1147
             }
1115 1148
             unset($data);
@@ -1165,13 +1198,15 @@  discard block
 block discarded – undo
1165 1198
 
1166 1199
 // Show title
1167 1200
         $showtitle = 1;
1168
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
1169
-            $showtitle = 0;
1201
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1202
+                    $showtitle = 0;
1203
+        }
1170 1204
         if (!empty($title) && $showtitle) {
1171 1205
             $limittitle = 30;
1172 1206
             $out .= '<a class="tabTitle">';
1173
-            if ($picto)
1174
-                $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1207
+            if ($picto) {
1208
+                            $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' ';
1209
+            }
1175 1210
             $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>';
1176 1211
             $out .= '</a>';
1177 1212
         }
@@ -1180,12 +1215,14 @@  discard block
 block discarded – undo
1180 1215
         $maxkey = -1;
1181 1216
         if (is_array($links) && !empty($links)) {
1182 1217
             $keys = array_keys($links);
1183
-            if (count($keys))
1184
-                $maxkey = max($keys);
1218
+            if (count($keys)) {
1219
+                            $maxkey = max($keys);
1220
+            }
1185 1221
         }
1186 1222
 
1187
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
1188
-            Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2;
1223
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1224
+                    Globals::$conf->global->MAIN_MAXTABS_IN_CARD = 2;
1225
+        }
1189 1226
 
1190 1227
 // Show tabs
1191 1228
         $bactive = false;
@@ -1198,8 +1235,9 @@  discard block
 block discarded – undo
1198 1235
         for ($i = 0; $i <= $maxkey; $i++) {
1199 1236
             if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) {
1200 1237
 // If active tab is already present
1201
-                if ($i >= $limittoshow)
1202
-                    $limittoshow--;
1238
+                if ($i >= $limittoshow) {
1239
+                                    $limittoshow--;
1240
+                }
1203 1241
             }
1204 1242
         }
1205 1243
 
@@ -1240,12 +1278,12 @@  discard block
 block discarded – undo
1240 1278
                 }
1241 1279
                 $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">';
1242 1280
                 if (isset($links[$i][2]) && $links[$i][2] == 'image') {
1243
-                    if (!empty($links[$i][0]))
1244
-                        $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1245
-                    else
1246
-                        $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1247
-                }
1248
-                else if (!empty($links[$i][1])) {
1281
+                    if (!empty($links[$i][0])) {
1282
+                                            $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n";
1283
+                    } else {
1284
+                                            $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n";
1285
+                    }
1286
+                } else if (!empty($links[$i][1])) {
1249 1287
                     $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">';
1250 1288
                     $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.
1251 1289
                     $outmore .= '</a>' . "\n";
@@ -1256,8 +1294,9 @@  discard block
 block discarded – undo
1256 1294
             }
1257 1295
             $displaytab = $i;
1258 1296
         }
1259
-        if ($popuptab)
1260
-            $outmore .= '</div>';
1297
+        if ($popuptab) {
1298
+                    $outmore .= '</div>';
1299
+        }
1261 1300
 
1262 1301
         if ($displaytab > $limittoshow) {
1263 1302
             $left = (Globals::$langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left');
@@ -1280,8 +1319,9 @@  discard block
 block discarded – undo
1280 1319
 
1281 1320
         $out .= "</div>\n";
1282 1321
 
1283
-        if (!$notab || $notab == -1)
1284
-            $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1322
+        if (!$notab || $notab == -1) {
1323
+                    $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n";
1324
+        }
1285 1325
 
1286 1326
         $parameters = array('tabname' => $active, 'out' => $out);
1287 1327
         $reshook = Globals::$hookManager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead"
@@ -1311,10 +1351,11 @@  discard block
 block discarded – undo
1311 1351
      */
1312 1352
     static function dol_get_fiche_end($notab = 0)
1313 1353
     {
1314
-        if (!$notab || $notab == -1)
1315
-            return "\n</div>\n";
1316
-        else
1317
-            return '';
1354
+        if (!$notab || $notab == -1) {
1355
+                    return "\n</div>\n";
1356
+        } else {
1357
+                    return '';
1358
+        }
1318 1359
     }
1319 1360
 
1320 1361
     /**
@@ -1346,8 +1387,9 @@  discard block
 block discarded – undo
1346 1387
         $showimage = 1;
1347 1388
         $entity = (empty($object->entity) ? Globals::$conf->entity : $object->entity);
1348 1389
         $showbarcode = empty(Globals::$conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0);
1349
-        if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance))
1350
-            $showbarcode = 0;
1390
+        if (!empty(Globals::$conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1391
+                    $showbarcode = 0;
1392
+        }
1351 1393
         $modulepart = 'unknown';
1352 1394
 
1353 1395
         if ($object->element == 'societe') {
@@ -1452,8 +1494,10 @@  discard block
 block discarded – undo
1452 1494
                         } else {
1453 1495
                             $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart);
1454 1496
                         }
1455
-                        if (empty($subdir))
1456
-                            $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path
1497
+                        if (empty($subdir)) {
1498
+                                                    $subdir = 'errorgettingsubdirofobject';
1499
+                        }
1500
+                        // Protection to avoid to return empty path
1457 1501
 
1458 1502
                         $filepath = $dir_output . $subdir . "/";
1459 1503
 
@@ -1474,14 +1518,16 @@  discard block
 block discarded – undo
1474 1518
                                 if (empty(Globals::$conf->global->MAIN_DISABLE_PDF_THUMBS)) {  // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
1475 1519
                                     include_once DOL_BASE_PATH . '/core/lib/files.lib.php';
1476 1520
                                     $ret = dol_convert_file($file, 'png', $fileimage);
1477
-                                    if ($ret < 0)
1478
-                                        $error++;
1521
+                                    if ($ret < 0) {
1522
+                                                                            $error++;
1523
+                                    }
1479 1524
                                 }
1480 1525
                             }
1481 1526
 
1482 1527
                             $heightforphotref = 70;
1483
-                            if (!empty(Globals::$conf->dol_optimize_smallscreen))
1484
-                                $heightforphotref = 60;
1528
+                            if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
1529
+                                                            $heightforphotref = 60;
1530
+                            }
1485 1531
                             // Si fichier png PDF d'1 page trouve
1486 1532
                             if (file_exists($fileimage)) {
1487 1533
                                 $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">';
@@ -1517,8 +1563,10 @@  discard block
 block discarded – undo
1517 1563
                         $width = 14;
1518 1564
                         $cssclass = 'photorefcenter';
1519 1565
                         $picto = $object->picto;
1520
-                        if ($object->element == 'project' && !$object->public)
1521
-                            $picto = 'project'; // instead of projectpub
1566
+                        if ($object->element == 'project' && !$object->public) {
1567
+                                                    $picto = 'project';
1568
+                        }
1569
+                        // instead of projectpub
1522 1570
                         $nophoto = img_picto('', 'object_' . $picto, '', false, 1);
1523 1571
                     }
1524 1572
                     $morehtmlleft .= '<!-- No photo to show -->';
@@ -1529,8 +1577,9 @@  discard block
 block discarded – undo
1529 1577
             }
1530 1578
         }
1531 1579
 
1532
-        if ($showbarcode)
1533
-            $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1580
+        if ($showbarcode) {
1581
+                    $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>';
1582
+        }
1534 1583
 
1535 1584
         if ($object->element == 'societe') {
1536 1585
             if (!empty(Globals::$conf->use_javascript_ajax) && $user->rights->societe->creer && !empty(Globals::$conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
@@ -1554,35 +1603,37 @@  discard block
 block discarded – undo
1554 1603
             }
1555 1604
         } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) {
1556 1605
             $tmptxt = $object->getLibStatut(6, $object->totalpaye);
1557
-            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone')
1558
-                $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1606
+            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') {
1607
+                            $tmptxt = $object->getLibStatut(5, $object->totalpaye);
1608
+            }
1559 1609
             $morehtmlstatus .= $tmptxt;
1560
-        }
1561
-        elseif ($object->element == 'contrat' || $object->element == 'contract') {
1562
-            if ($object->statut == 0)
1563
-                $morehtmlstatus .= $object->getLibStatut(5);
1564
-            else
1565
-                $morehtmlstatus .= $object->getLibStatut(4);
1566
-        }
1567
-        elseif ($object->element == 'facturerec') {
1568
-            if ($object->frequency == 0)
1569
-                $morehtmlstatus .= $object->getLibStatut(2);
1570
-            else
1571
-                $morehtmlstatus .= $object->getLibStatut(5);
1572
-        }
1573
-        elseif ($object->element == 'project_task') {
1610
+        } elseif ($object->element == 'contrat' || $object->element == 'contract') {
1611
+            if ($object->statut == 0) {
1612
+                            $morehtmlstatus .= $object->getLibStatut(5);
1613
+            } else {
1614
+                            $morehtmlstatus .= $object->getLibStatut(4);
1615
+            }
1616
+        } elseif ($object->element == 'facturerec') {
1617
+            if ($object->frequency == 0) {
1618
+                            $morehtmlstatus .= $object->getLibStatut(2);
1619
+            } else {
1620
+                            $morehtmlstatus .= $object->getLibStatut(5);
1621
+            }
1622
+        } elseif ($object->element == 'project_task') {
1574 1623
             $object->fk_statut = 1;
1575
-            if ($object->progress > 0)
1576
-                $object->fk_statut = 2;
1577
-            if ($object->progress >= 100)
1578
-                $object->fk_statut = 3;
1624
+            if ($object->progress > 0) {
1625
+                            $object->fk_statut = 2;
1626
+            }
1627
+            if ($object->progress >= 100) {
1628
+                            $object->fk_statut = 3;
1629
+            }
1579 1630
             $tmptxt = $object->getLibStatut(5);
1580 1631
             $morehtmlstatus .= $tmptxt;  // No status on task
1581
-        }
1582
-        else { // Generic case
1632
+        } else { // Generic case
1583 1633
             $tmptxt = $object->getLibStatut(6);
1584
-            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone')
1585
-                $tmptxt = $object->getLibStatut(5);
1634
+            if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || Globals::$conf->browser->layout == 'phone') {
1635
+                            $tmptxt = $object->getLibStatut(5);
1636
+            }
1586 1637
             $morehtmlstatus .= $tmptxt;
1587 1638
         }
1588 1639
 
@@ -1596,13 +1647,15 @@  discard block
 block discarded – undo
1596 1647
         }
1597 1648
 
1598 1649
 // Add alias for thirdparty
1599
-        if (!empty($object->name_alias))
1600
-            $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1650
+        if (!empty($object->name_alias)) {
1651
+                    $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>';
1652
+        }
1601 1653
 
1602 1654
 // Add label
1603 1655
         if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') {
1604
-            if (!empty($object->label))
1605
-                $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1656
+            if (!empty($object->label)) {
1657
+                            $morehtmlref .= '<div class="refidno">' . $object->label . '</div>';
1658
+            }
1606 1659
         }
1607 1660
 
1608 1661
         if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') {
@@ -1635,15 +1688,19 @@  discard block
 block discarded – undo
1635 1688
     {
1636 1689
         // global Globals::$conf, Globals::$langs;
1637 1690
         $ret = '';
1638
-        if ($fieldrequired)
1639
-            $ret .= '<span class="fieldrequired">';
1640
-        if ((Globals::$conf->dol_use_jmobile != 4))
1641
-            $ret .= '<label for="' . $fieldkey . '">';
1691
+        if ($fieldrequired) {
1692
+                    $ret .= '<span class="fieldrequired">';
1693
+        }
1694
+        if ((Globals::$conf->dol_use_jmobile != 4)) {
1695
+                    $ret .= '<label for="' . $fieldkey . '">';
1696
+        }
1642 1697
         $ret .= Globals::$langs->trans($langkey);
1643
-        if ((Globals::$conf->dol_use_jmobile != 4))
1644
-            $ret .= '</label>';
1645
-        if ($fieldrequired)
1646
-            $ret .= '</span>';
1698
+        if ((Globals::$conf->dol_use_jmobile != 4)) {
1699
+                    $ret .= '</label>';
1700
+        }
1701
+        if ($fieldrequired) {
1702
+                    $ret .= '</span>';
1703
+        }
1647 1704
         return $ret;
1648 1705
     }
1649 1706
 
@@ -1658,8 +1715,9 @@  discard block
 block discarded – undo
1658 1715
     {
1659 1716
         // global $bc;
1660 1717
         $ret = ' ' . $bc[$var];
1661
-        if ($moreclass)
1662
-            $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1718
+        if ($moreclass) {
1719
+                    $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret);
1720
+        }
1663 1721
         return $ret;
1664 1722
     }
1665 1723
 
@@ -1690,18 +1748,18 @@  discard block
 block discarded – undo
1690 1748
             if ($object->state) {
1691 1749
                 $ret .= ($ret ? ", " : '') . $object->state;
1692 1750
             }
1693
-            if ($object->zip)
1694
-                $ret .= ($ret ? ", " : '') . $object->zip;
1695
-        }
1696
-        else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1751
+            if ($object->zip) {
1752
+                            $ret .= ($ret ? ", " : '') . $object->zip;
1753
+            }
1754
+        } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country
1697 1755
             $ret .= ($ret ? $sep : '' ) . $object->town;
1698 1756
             if ($object->state) {
1699 1757
                 $ret .= ($ret ? ", " : '') . $object->state;
1700 1758
             }
1701
-            if ($object->zip)
1702
-                $ret .= ($ret ? $sep : '' ) . $object->zip;
1703
-        }
1704
-        else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1759
+            if ($object->zip) {
1760
+                            $ret .= ($ret ? $sep : '' ) . $object->zip;
1761
+            }
1762
+        } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country
1705 1763
             $ret .= ($ret ? $sep : '' ) . $object->zip;
1706 1764
             $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : '');
1707 1765
             if ($object->state) {
@@ -1718,8 +1776,9 @@  discard block
 block discarded – undo
1718 1776
                 $ret .= ($ret ? ", " : '') . $object->state;
1719 1777
             }
1720 1778
         }
1721
-        if (!is_object($outputlangs))
1722
-            $outputlangs = Globals::$langs;
1779
+        if (!is_object($outputlangs)) {
1780
+                    $outputlangs = Globals::$langs;
1781
+        }
1723 1782
         if ($withcountry) {
1724 1783
             Globals::$langs->load("dict");
1725 1784
             $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : '');
@@ -1740,8 +1799,9 @@  discard block
 block discarded – undo
1740 1799
     {
1741 1800
         if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range
1742 1801
             return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts);
1743
-        } else
1744
-            return 'Error date into a not supported range';
1802
+        } else {
1803
+                    return 'Error date into a not supported range';
1804
+        }
1745 1805
     }
1746 1806
 
1747 1807
     /**
@@ -1787,10 +1847,12 @@  discard block
 block discarded – undo
1787 1847
                 }
1788 1848
             }
1789 1849
         }
1790
-        if (!is_object($outputlangs))
1791
-            $outputlangs = Globals::$langs;
1792
-        if (!$format)
1793
-            $format = 'daytextshort';
1850
+        if (!is_object($outputlangs)) {
1851
+                    $outputlangs = Globals::$langs;
1852
+        }
1853
+        if (!$format) {
1854
+                    $format = 'daytextshort';
1855
+        }
1794 1856
         $reduceformat = (!empty(Globals::$conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0;
1795 1857
         $formatwithoutreduce = preg_replace('/reduceformat/', '', $format);
1796 1858
         if ($formatwithoutreduce != $format) {
@@ -1799,40 +1861,46 @@  discard block
 block discarded – undo
1799 1861
         }  // so format 'dayreduceformat' is processed like day
1800 1862
 // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
1801 1863
 // TODO Add format daysmallyear and dayhoursmallyear
1802
-        if ($format == 'day')
1803
-            $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
1804
-        else if ($format == 'hour')
1805
-            $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
1806
-        else if ($format == 'hourduration')
1807
-            $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
1808
-        else if ($format == 'daytext')
1809
-            $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
1810
-        else if ($format == 'daytextshort')
1811
-// Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1812
-            $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
1813
-        else if ($format == 'dayhour')
1814
-            $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short ?? "%d/%m/%Y %H:%M");
1815
-        else if ($format == 'dayhoursec')
1816
-            $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
1817
-        else if ($format == 'dayhourtext')
1818
-            $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
1819
-        else if ($format == 'dayhourtextshort')
1820
-            $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
1821
-// Format not sensitive to language
1822
-        else if ($format == 'dayhourlog')
1823
-            $format = '%Y%m%d%H%M%S';
1824
-        else if ($format == 'dayhourldap')
1825
-            $format = '%Y%m%d%H%M%SZ';
1826
-        else if ($format == 'dayhourxcard')
1827
-            $format = '%Y%m%dT%H%M%SZ';
1828
-        else if ($format == 'dayxcard')
1829
-            $format = '%Y%m%d';
1830
-        else if ($format == 'dayrfc')
1831
-            $format = '%Y-%m-%d';             // DATE_RFC3339
1832
-        else if ($format == 'dayhourrfc')
1833
-            $format = '%Y-%m-%dT%H:%M:%SZ';   // DATETIME RFC3339
1834
-        else if ($format == 'standard')
1835
-            $format = '%Y-%m-%d %H:%M:%S';
1864
+        if ($format == 'day') {
1865
+                    $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : Globals::$conf->format_date_short);
1866
+        } else if ($format == 'hour') {
1867
+                    $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : Globals::$conf->format_hour_short);
1868
+        } else if ($format == 'hourduration') {
1869
+                    $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : Globals::$conf->format_hour_short_duration);
1870
+        } else if ($format == 'daytext') {
1871
+                    $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : Globals::$conf->format_date_text);
1872
+        } else if ($format == 'daytextshort') {
1873
+            // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781
1874
+            $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : Globals::$conf->format_date_text_short);
1875
+        } else if ($format == 'dayhour') {
1876
+                    $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : Globals::$conf->format_date_hour_short ?? "%d/%m/%Y %H:%M");
1877
+        } else if ($format == 'dayhoursec') {
1878
+                    $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : Globals::$conf->format_date_hour_sec_short);
1879
+        } else if ($format == 'dayhourtext') {
1880
+                    $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : Globals::$conf->format_date_hour_text);
1881
+        } else if ($format == 'dayhourtextshort') {
1882
+                    $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : Globals::$conf->format_date_hour_text_short);
1883
+        }
1884
+        // Format not sensitive to language
1885
+        else if ($format == 'dayhourlog') {
1886
+                    $format = '%Y%m%d%H%M%S';
1887
+        } else if ($format == 'dayhourldap') {
1888
+                    $format = '%Y%m%d%H%M%SZ';
1889
+        } else if ($format == 'dayhourxcard') {
1890
+                    $format = '%Y%m%dT%H%M%SZ';
1891
+        } else if ($format == 'dayxcard') {
1892
+                    $format = '%Y%m%d';
1893
+        } else if ($format == 'dayrfc') {
1894
+                    $format = '%Y-%m-%d';
1895
+        }
1896
+        // DATE_RFC3339
1897
+        else if ($format == 'dayhourrfc') {
1898
+                    $format = '%Y-%m-%dT%H:%M:%SZ';
1899
+        }
1900
+        // DATETIME RFC3339
1901
+        else if ($format == 'standard') {
1902
+                    $format = '%Y-%m-%d %H:%M:%S';
1903
+        }
1836 1904
 
1837 1905
         if ($reduceformat) {
1838 1906
             $format = str_replace('%Y', '%y', $format);
@@ -1840,8 +1908,10 @@  discard block
 block discarded – undo
1840 1908
         }
1841 1909
 
1842 1910
 // If date undefined or "", we return ""
1843
-        if (AlDolUtils::dol_strlen($time) == 0)
1844
-            return '';  // $time=0 allowed (it means 01/01/1970 00:00:00)
1911
+        if (AlDolUtils::dol_strlen($time) == 0) {
1912
+                    return '';
1913
+        }
1914
+        // $time=0 allowed (it means 01/01/1970 00:00:00)
1845 1915
 
1846 1916
 
1847 1917
 
@@ -1928,8 +1998,9 @@  discard block
 block discarded – undo
1928 1998
                 $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with static function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
1929 1999
 
1930 2000
                 $ret = adodb_strftime($format, $timetouse, $to_gmt);
1931
-            } else
1932
-                $ret = 'Bad value ' . $time . ' for date';
2001
+            } else {
2002
+                            $ret = 'Bad value ' . $time . ' for date';
2003
+            }
1933 2004
         }
1934 2005
 
1935 2006
         if (preg_match('/__b__/i', $format)) {
@@ -2000,10 +2071,14 @@  discard block
 block discarded – undo
2000 2071
         // global Globals::$conf;
2001 2072
 
2002 2073
         $usealternatemethod = false;
2003
-        if ($timestamp <= 0)
2004
-            $usealternatemethod = true;    // <= 1970
2005
-        if ($timestamp >= 2145913200)
2006
-            $usealternatemethod = true;  // >= 2038
2074
+        if ($timestamp <= 0) {
2075
+                    $usealternatemethod = true;
2076
+        }
2077
+        // <= 1970
2078
+        if ($timestamp >= 2145913200) {
2079
+                    $usealternatemethod = true;
2080
+        }
2081
+        // >= 2038
2007 2082
 
2008 2083
         if ($usealternatemethod) {
2009 2084
             $arrayinfo = adodb_getdate($timestamp, $fast);
@@ -2038,27 +2113,36 @@  discard block
 block discarded – undo
2038 2113
         // global Globals::$conf;
2039 2114
 //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
2040 2115
 // Clean parameters
2041
-        if ($hour == -1 || empty($hour))
2042
-            $hour = 0;
2043
-        if ($minute == -1 || empty($minute))
2044
-            $minute = 0;
2045
-        if ($second == -1 || empty($second))
2046
-            $second = 0;
2116
+        if ($hour == -1 || empty($hour)) {
2117
+                    $hour = 0;
2118
+        }
2119
+        if ($minute == -1 || empty($minute)) {
2120
+                    $minute = 0;
2121
+        }
2122
+        if ($second == -1 || empty($second)) {
2123
+                    $second = 0;
2124
+        }
2047 2125
 
2048 2126
 // Check parameters
2049 2127
         if ($check) {
2050
-            if (!$month || !$day)
2051
-                return '';
2052
-            if ($day > 31)
2053
-                return '';
2054
-            if ($month > 12)
2055
-                return '';
2056
-            if ($hour < 0 || $hour > 24)
2057
-                return '';
2058
-            if ($minute < 0 || $minute > 60)
2059
-                return '';
2060
-            if ($second < 0 || $second > 60)
2061
-                return '';
2128
+            if (!$month || !$day) {
2129
+                            return '';
2130
+            }
2131
+            if ($day > 31) {
2132
+                            return '';
2133
+            }
2134
+            if ($month > 12) {
2135
+                            return '';
2136
+            }
2137
+            if ($hour < 0 || $hour > 24) {
2138
+                            return '';
2139
+            }
2140
+            if ($minute < 0 || $minute > 60) {
2141
+                            return '';
2142
+            }
2143
+            if ($second < 0 || $second > 60) {
2144
+                            return '';
2145
+            }
2062 2146
         }
2063 2147
 
2064 2148
         if (method_exists('DateTime', 'getTimestamp')) {
@@ -2115,8 +2199,10 @@  discard block
 block discarded – undo
2115 2199
 
2116 2200
 // Note that gmmktime and mktime return same value (GMT) when used without parameters
2117 2201
 //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() static function instead
2118
-        if ($mode == 'gmt')
2119
-            $ret = time(); // Time for now at greenwich.
2202
+        if ($mode == 'gmt') {
2203
+                    $ret = time();
2204
+        }
2205
+        // Time for now at greenwich.
2120 2206
         else if ($mode == 'tzserver') {  // Time for now with PHP server timezone added
2121 2207
             require_once DOL_BASE_PATH . '/core/lib/date.lib.php';
2122 2208
             $tzsecond = getServerTimeZoneInt('now');    // Contains tz+dayling saving time
@@ -2150,8 +2236,9 @@  discard block
 block discarded – undo
2150 2236
         // global Globals::$conf, Globals::$langs;
2151 2237
         $level = 1024;
2152 2238
 
2153
-        if (!empty(Globals::$conf->dol_optimize_smallscreen))
2154
-            $shortunit = 1;
2239
+        if (!empty(Globals::$conf->dol_optimize_smallscreen)) {
2240
+                    $shortunit = 1;
2241
+        }
2155 2242
 
2156 2243
 // Set value text
2157 2244
         if (empty($shortvalue) || $size < ($level * 10)) {
@@ -2186,19 +2273,23 @@  discard block
 block discarded – undo
2186 2273
     {
2187 2274
         // global Globals::$langs;
2188 2275
 
2189
-        if (empty($url))
2190
-            return '';
2276
+        if (empty($url)) {
2277
+                    return '';
2278
+        }
2191 2279
 
2192 2280
         $link = '<a href="';
2193
-        if (!preg_match('/^http/i', $url))
2194
-            $link .= 'http://';
2281
+        if (!preg_match('/^http/i', $url)) {
2282
+                    $link .= 'http://';
2283
+        }
2195 2284
         $link .= $url;
2196 2285
         $link .= '"';
2197
-        if ($target)
2198
-            $link .= ' target="' . $target . '"';
2286
+        if ($target) {
2287
+                    $link .= ' target="' . $target . '"';
2288
+        }
2199 2289
         $link .= '>';
2200
-        if (!preg_match('/^http/i', $url))
2201
-            $link .= 'http://';
2290
+        if (!preg_match('/^http/i', $url)) {
2291
+                    $link .= 'http://';
2292
+        }
2202 2293
         $link .= dol_trunc($url, $max);
2203 2294
         $link .= '</a>';
2204 2295
         return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto(Globals::$langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>';
@@ -2222,13 +2313,15 @@  discard block
 block discarded – undo
2222 2313
 
2223 2314
         $newemail = $email;
2224 2315
 
2225
-        if (empty($email))
2226
-            return '&nbsp;';
2316
+        if (empty($email)) {
2317
+                    return '&nbsp;';
2318
+        }
2227 2319
 
2228 2320
         if (!empty($addlink)) {
2229 2321
             $newemail = '<a style="text-overflow: ellipsis;" href="';
2230
-            if (!preg_match('/^mailto:/i', $email))
2231
-                $newemail .= 'mailto:';
2322
+            if (!preg_match('/^mailto:/i', $email)) {
2323
+                            $newemail .= 'mailto:';
2324
+            }
2232 2325
             $newemail .= $email;
2233 2326
             $newemail .= '">';
2234 2327
             $newemail .= dol_trunc($email, $max);
@@ -2241,13 +2334,14 @@  discard block
 block discarded – undo
2241 2334
             if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2242 2335
                 $type = 'AC_EMAIL';
2243 2336
                 $link = '';
2244
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL))
2245
-                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2246
-                if ($link)
2247
-                    $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2337
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFOREMAIL)) {
2338
+                                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2339
+                }
2340
+                if ($link) {
2341
+                                    $newemail = '<div>' . $newemail . ' ' . $link . '</div>';
2342
+                }
2248 2343
             }
2249
-        }
2250
-        else {
2344
+        } else {
2251 2345
             if ($showinvalid && !isValidEmail($email)) {
2252 2346
                 Globals::$langs->load("errors");
2253 2347
                 $newemail .= img_warning(Globals::$langs->trans("ErrorBadEMail", $email));
@@ -2279,8 +2373,9 @@  discard block
 block discarded – undo
2279 2373
 
2280 2374
         $newskype = $value;
2281 2375
 
2282
-        if (empty($value))
2283
-            return '&nbsp;';
2376
+        if (empty($value)) {
2377
+                    return '&nbsp;';
2378
+        }
2284 2379
 
2285 2380
         if (!empty($type)) {
2286 2381
             $newskype = '<div class="divsocialnetwork inline-block valignmiddle">';
@@ -2301,13 +2396,13 @@  discard block
 block discarded – undo
2301 2396
             if (($cid || $socid) && !empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') {
2302 2397
                 $addlink = 'AC_SKYPE';
2303 2398
                 $link = '';
2304
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE))
2305
-                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2399
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORSKYPE)) {
2400
+                                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2401
+                }
2306 2402
                 $newskype .= ($link ? ' ' . $link : '');
2307 2403
             }
2308 2404
             $newskype .= '</div>';
2309
-        }
2310
-        else {
2405
+        } else {
2311 2406
             Globals::$langs->load("errors");
2312 2407
             $newskype .= img_warning(Globals::$langs->trans("ErrorBadSocialNetworkValue", $value));
2313 2408
         }
@@ -2336,12 +2431,14 @@  discard block
 block discarded – undo
2336 2431
         if (empty($phone)) {
2337 2432
             return '';
2338 2433
         }
2339
-        if (empty($countrycode))
2340
-            $countrycode = $mysoc->country_code;
2434
+        if (empty($countrycode)) {
2435
+                    $countrycode = $mysoc->country_code;
2436
+        }
2341 2437
 
2342 2438
 // Short format for small screens
2343
-        if (Globals::$conf->dol_optimize_smallscreen)
2344
-            $separ = '';
2439
+        if (Globals::$conf->dol_optimize_smallscreen) {
2440
+                    $separ = '';
2441
+        }
2345 2442
 
2346 2443
         $newphone = $phone;
2347 2444
         if (strtoupper($countrycode) == "FR") {
@@ -2507,15 +2604,18 @@  discard block
 block discarded – undo
2507 2604
                 $newphone = '<a href="tel:' . $phone . '"';
2508 2605
                 $newphone .= '>' . $phone . '</a>';
2509 2606
             } else if (!empty(Globals::$conf->clicktodial->enabled) && $addlink == 'AC_TEL') {  // If click to dial, we use click to dial url
2510
-                if (empty($user->clicktodial_loaded))
2511
-                    $user->fetch_clicktodial();
2607
+                if (empty($user->clicktodial_loaded)) {
2608
+                                    $user->fetch_clicktodial();
2609
+                }
2512 2610
 
2513 2611
 // Define urlmask
2514 2612
                 $urlmask = 'ErrorClickToDialModuleNotConfigured';
2515
-                if (!empty(Globals::$conf->global->CLICKTODIAL_URL))
2516
-                    $urlmask = Globals::$conf->global->CLICKTODIAL_URL;
2517
-                if (!empty($user->clicktodial_url))
2518
-                    $urlmask = $user->clicktodial_url;
2613
+                if (!empty(Globals::$conf->global->CLICKTODIAL_URL)) {
2614
+                                    $urlmask = Globals::$conf->global->CLICKTODIAL_URL;
2615
+                }
2616
+                if (!empty($user->clicktodial_url)) {
2617
+                                    $urlmask = $user->clicktodial_url;
2618
+                }
2519 2619
 
2520 2620
                 $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : '');
2521 2621
                 $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : '');
@@ -2530,8 +2630,9 @@  discard block
 block discarded – undo
2530 2630
                 $url = make_substitutions($url, $substitarray);
2531 2631
                 $newphonesav = $newphone;
2532 2632
                 $newphone = '<a href="' . $url . '"';
2533
-                if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET))
2534
-                    $newphone .= ' target="_blank"';
2633
+                if (!empty(Globals::$conf->global->CLICKTODIAL_FORCENEWTARGET)) {
2634
+                                    $newphone .= ' target="_blank"';
2635
+                }
2535 2636
                 $newphone .= '>' . $newphonesav . '</a>';
2536 2637
             }
2537 2638
 
@@ -2539,12 +2640,15 @@  discard block
 block discarded – undo
2539 2640
             if (!empty(Globals::$conf->agenda->enabled) && $user->rights->agenda->myactions->create) {
2540 2641
                 $type = 'AC_TEL';
2541 2642
                 $link = '';
2542
-                if ($addlink == 'AC_FAX')
2543
-                    $type = 'AC_FAX';
2544
-                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE))
2545
-                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2546
-                if ($link)
2547
-                    $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2643
+                if ($addlink == 'AC_FAX') {
2644
+                                    $type = 'AC_FAX';
2645
+                }
2646
+                if (!empty(Globals::$conf->global->AGENDA_ADDACTIONFORPHONE)) {
2647
+                                    $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(Globals::$langs->trans("AddAction"), "calendar") . '</a>';
2648
+                }
2649
+                if ($link) {
2650
+                                    $newphone = '<div>' . $newphone . ' ' . $link . '</div>';
2651
+                }
2548 2652
             }
2549 2653
         }
2550 2654
 
@@ -2571,15 +2675,17 @@  discard block
 block discarded – undo
2571 2675
                     $picto = '';
2572 2676
                 }
2573 2677
             }
2574
-            if ($adddivfloat)
2575
-                $rep .= '<div class="nospan float" style="margin-right: 10px">';
2576
-            else
2577
-                $rep .= '<span style="margin-right: 10px;">';
2678
+            if ($adddivfloat) {
2679
+                            $rep .= '<div class="nospan float" style="margin-right: 10px">';
2680
+            } else {
2681
+                            $rep .= '<span style="margin-right: 10px;">';
2682
+            }
2578 2683
             $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone;
2579
-            if ($adddivfloat)
2580
-                $rep .= '</div>';
2581
-            else
2582
-                $rep .= '</span>';
2684
+            if ($adddivfloat) {
2685
+                            $rep .= '</div>';
2686
+            } else {
2687
+                            $rep .= '</span>';
2688
+            }
2583 2689
         }
2584 2690
 
2585 2691
         return $rep;
@@ -2609,8 +2715,9 @@  discard block
 block discarded – undo
2609 2715
             if ($countrycode) { // If success, countrycode is us, fr, ...
2610 2716
                 if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) {
2611 2717
                     $ret .= ' ' . img_picto($countrycode . ' ' . Globals::$langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1);
2612
-                } else
2613
-                    $ret .= ' (' . $countrycode . ')';
2718
+                } else {
2719
+                                    $ret .= ' (' . $countrycode . ')';
2720
+                }
2614 2721
             }
2615 2722
         }
2616 2723
 
@@ -2707,26 +2814,33 @@  discard block
 block discarded – undo
2707 2814
                 $out .= Globals::$hookManager->resPrint;
2708 2815
             }
2709 2816
             if (empty($reshook)) {
2710
-                if (empty($charfornl))
2711
-                    $out .= nl2br($address);
2712
-                else
2713
-                    $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2817
+                if (empty($charfornl)) {
2818
+                                    $out .= nl2br($address);
2819
+                } else {
2820
+                                    $out .= preg_replace('/[\r\n]+/', $charfornl, $address);
2821
+                }
2714 2822
 
2715 2823
                 $showgmap = $showomap = 0;
2716 2824
 
2717 2825
 // TODO Add a hook here
2718
-                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS))
2719
-                    $showgmap = 1;
2720
-                if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS))
2721
-                    $showgmap = 1;
2722
-                if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS))
2723
-                    $showgmap = 1;
2724
-                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS))
2725
-                    $showomap = 1;
2726
-                if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS))
2727
-                    $showomap = 1;
2728
-                if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS))
2729
-                    $showomap = 1;
2826
+                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS)) {
2827
+                                    $showgmap = 1;
2828
+                }
2829
+                if ($mode == 'contact' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) {
2830
+                                    $showgmap = 1;
2831
+                }
2832
+                if ($mode == 'member' && !empty(Globals::$conf->google->enabled) && !empty(Globals::$conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) {
2833
+                                    $showgmap = 1;
2834
+                }
2835
+                if (($mode == 'thirdparty' || $mode == 'societe') && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS)) {
2836
+                                    $showomap = 1;
2837
+                }
2838
+                if ($mode == 'contact' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) {
2839
+                                    $showomap = 1;
2840
+                }
2841
+                if ($mode == 'member' && !empty(Globals::$conf->openstreetmap->enabled) && !empty(Globals::$conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) {
2842
+                                    $showomap = 1;
2843
+                }
2730 2844
 
2731 2845
                 if ($showgmap) {
2732 2846
                     $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1);
@@ -2738,10 +2852,11 @@  discard block
 block discarded – undo
2738 2852
                 }
2739 2853
             }
2740 2854
         }
2741
-        if ($noprint)
2742
-            return $out;
2743
-        else
2744
-            print $out;
2855
+        if ($noprint) {
2856
+                    return $out;
2857
+        } else {
2858
+                    print $out;
2859
+        }
2745 2860
     }
2746 2861
 
2747 2862
     /**
@@ -2753,10 +2868,12 @@  discard block
 block discarded – undo
2753 2868
      */
2754 2869
     static function isValidEmail($address, $acceptsupervisorkey = 0)
2755 2870
     {
2756
-        if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__')
2757
-            return true;
2758
-        if (filter_var($address, FILTER_VALIDATE_EMAIL))
2759
-            return true;
2871
+        if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') {
2872
+                    return true;
2873
+        }
2874
+        if (filter_var($address, FILTER_VALIDATE_EMAIL)) {
2875
+                    return true;
2876
+        }
2760 2877
 
2761 2878
         return false;
2762 2879
     }
@@ -2778,10 +2895,12 @@  discard block
 block discarded – undo
2778 2895
                 $mxhosts = array();
2779 2896
                 $weight = array();
2780 2897
                 getmxrr(idn_to_ascii($domain), $mxhosts, $weight);
2781
-                if (count($mxhosts) > 1)
2782
-                    return 1;
2783
-                if (count($mxhosts) == 1 && !empty($mxhosts[0]))
2784
-                    return 1;
2898
+                if (count($mxhosts) > 1) {
2899
+                                    return 1;
2900
+                }
2901
+                if (count($mxhosts) == 1 && !empty($mxhosts[0])) {
2902
+                                    return 1;
2903
+                }
2785 2904
 
2786 2905
                 return 0;
2787 2906
             }
@@ -2810,10 +2929,11 @@  discard block
 block discarded – undo
2810 2929
      */
2811 2930
     static function dol_strlen($string, $stringencoding = 'UTF-8')
2812 2931
     {
2813
-        if (function_exists('mb_strlen'))
2814
-            return mb_strlen($string, $stringencoding);
2815
-        else
2816
-            return strlen($string);
2932
+        if (function_exists('mb_strlen')) {
2933
+                    return mb_strlen($string, $stringencoding);
2934
+        } else {
2935
+                    return strlen($string);
2936
+        }
2817 2937
     }
2818 2938
 
2819 2939
     /**
@@ -2830,8 +2950,9 @@  discard block
 block discarded – undo
2830 2950
     {
2831 2951
         // global Globals::$langs;
2832 2952
 
2833
-        if (empty($stringencoding))
2834
-            $stringencoding = Globals::$langs->charset_output;
2953
+        if (empty($stringencoding)) {
2954
+                    $stringencoding = Globals::$langs->charset_output;
2955
+        }
2835 2956
 
2836 2957
         $ret = '';
2837 2958
         if (empty($trunconbytes)) {
@@ -2867,48 +2988,55 @@  discard block
 block discarded – undo
2867 2988
     {
2868 2989
         // global Globals::$conf;
2869 2990
 
2870
-        if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC))
2871
-            return $string;
2991
+        if ($size == 0 || !empty(Globals::$conf->global->MAIN_DISABLE_TRUNC)) {
2992
+                    return $string;
2993
+        }
2872 2994
 
2873
-        if (empty($stringencoding))
2874
-            $stringencoding = 'UTF-8';
2875
-// reduce for small screen
2876
-        if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1)
2877
-            $size = round($size / 3);
2995
+        if (empty($stringencoding)) {
2996
+                    $stringencoding = 'UTF-8';
2997
+        }
2998
+        // reduce for small screen
2999
+        if (Globals::$conf->dol_optimize_smallscreen == 1 && $display == 1) {
3000
+                    $size = round($size / 3);
3001
+        }
2878 3002
 
2879 3003
 // We go always here
2880 3004
         if ($trunc == 'right') {
2881 3005
             $newstring = AlDolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2882
-            if (AlDolUtils::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 ...
2883
-                return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
2884
-            else
2885
-            //return 'u'.$size.'-'.$newstring.'-'.DolUtils::dol_strlen($newstring,$stringencoding).'-'.$string;
2886
-                return $string;
2887
-        }
2888
-        elseif ($trunc == 'middle') {
3006
+            if (AlDolUtils::dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3007
+                // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3008
+                return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...');
3009
+            } else {
3010
+                        //return 'u'.$size.'-'.$newstring.'-'.DolUtils::dol_strlen($newstring,$stringencoding).'-'.$string;
3011
+                return $string;
3012
+            }
3013
+        } elseif ($trunc == 'middle') {
2889 3014
             $newstring = AlDolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2890 3015
             if (AlDolUtils::dol_strlen($newstring, $stringencoding) > 2 && AlDolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1)) {
2891 3016
                 $size1 = round($size / 2);
2892 3017
                 $size2 = round($size / 2);
2893 3018
                 return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, AlDolUtils::dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding);
2894
-            } else
2895
-                return $string;
2896
-        }
2897
-        elseif ($trunc == 'left') {
3019
+            } else {
3020
+                            return $string;
3021
+            }
3022
+        } elseif ($trunc == 'left') {
2898 3023
             $newstring = AlDolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2899
-            if (AlDolUtils::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 ...
2900
-                return '...' . dol_substr($newstring, AlDolUtils::dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
2901
-            else
2902
-                return $string;
2903
-        }
2904
-        elseif ($trunc == 'wrap') {
3024
+            if (AlDolUtils::dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
3025
+                // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ...
3026
+                return '...' . dol_substr($newstring, AlDolUtils::dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
3027
+            } else {
3028
+                            return $string;
3029
+            }
3030
+        } elseif ($trunc == 'wrap') {
2905 3031
             $newstring = AlDolUtils::dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
2906
-            if (AlDolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1))
2907
-                return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, AlDolUtils::dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
2908
-            else
2909
-                return $string;
2910
-        } else
2911
-            return 'BadParam3CallingDolTrunc';
3032
+            if (AlDolUtils::dol_strlen($newstring, $stringencoding) > ($size + 1)) {
3033
+                            return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, AlDolUtils::dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc);
3034
+            } else {
3035
+                            return $string;
3036
+            }
3037
+        } else {
3038
+                    return 'BadParam3CallingDolTrunc';
3039
+        }
2912 3040
     }
2913 3041
 
2914 3042
     /**
@@ -3118,8 +3246,9 @@  discard block
 block discarded – undo
3118 3246
     {
3119 3247
         // global Globals::$conf;
3120 3248
 
3121
-        if (!preg_match('/(\.png|\.gif)$/i', $picto))
3122
-            $picto .= '.png';
3249
+        if (!preg_match('/(\.png|\.gif)$/i', $picto)) {
3250
+                    $picto .= '.png';
3251
+        }
3123 3252
 
3124 3253
 //$path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
3125 3254
         $path = DOL_BASE_URI . '/theme/' . Globals::$conf->theme . '/img/weather/' . $picto;
@@ -3195,8 +3324,9 @@  discard block
 block discarded – undo
3195 3324
                 $numaction = 0;
3196 3325
             }
3197 3326
         }
3198
-        if (!is_numeric($numaction))
3199
-            $numaction = 0;
3327
+        if (!is_numeric($numaction)) {
3328
+                    $numaction = 0;
3329
+        }
3200 3330
 
3201 3331
         return img_picto($titlealt, 'stcomm' . $numaction . '.png');
3202 3332
     }
@@ -3212,8 +3342,9 @@  discard block
 block discarded – undo
3212 3342
     {
3213 3343
         // global Globals::$conf, Globals::$langs;
3214 3344
 
3215
-        if ($titlealt == 'default')
3216
-            $titlealt = Globals::$langs->trans('Show');
3345
+        if ($titlealt == 'default') {
3346
+                    $titlealt = Globals::$langs->trans('Show');
3347
+        }
3217 3348
 
3218 3349
         return img_picto($titlealt, 'pdf' . $size . '.png');
3219 3350
     }
@@ -3229,8 +3360,9 @@  discard block
 block discarded – undo
3229 3360
     {
3230 3361
         // global Globals::$conf, Globals::$langs;
3231 3362
 
3232
-        if ($titlealt == 'default')
3233
-            $titlealt = Globals::$langs->trans('Add');
3363
+        if ($titlealt == 'default') {
3364
+                    $titlealt = Globals::$langs->trans('Add');
3365
+        }
3234 3366
 
3235 3367
         return img_picto($titlealt, 'edit_add.png', $other);
3236 3368
     }
@@ -3246,8 +3378,9 @@  discard block
 block discarded – undo
3246 3378
     {
3247 3379
         // global Globals::$conf, Globals::$langs;
3248 3380
 
3249
-        if ($titlealt == 'default')
3250
-            $titlealt = Globals::$langs->trans('Remove');
3381
+        if ($titlealt == 'default') {
3382
+                    $titlealt = Globals::$langs->trans('Remove');
3383
+        }
3251 3384
 
3252 3385
         return img_picto($titlealt, 'edit_remove.png', $other);
3253 3386
     }
@@ -3264,8 +3397,9 @@  discard block
 block discarded – undo
3264 3397
     {
3265 3398
         // global Globals::$conf, Globals::$langs;
3266 3399
 
3267
-        if ($titlealt == 'default')
3268
-            $titlealt = Globals::$langs->trans('Modify');
3400
+        if ($titlealt == 'default') {
3401
+                    $titlealt = Globals::$langs->trans('Modify');
3402
+        }
3269 3403
 
3270 3404
         return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . (Globals::$langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : ''));
3271 3405
     }
@@ -3282,8 +3416,9 @@  discard block
 block discarded – undo
3282 3416
     {
3283 3417
         // global Globals::$conf, Globals::$langs;
3284 3418
 
3285
-        if ($titlealt == 'default')
3286
-            $titlealt = Globals::$langs->trans('View');
3419
+        if ($titlealt == 'default') {
3420
+                    $titlealt = Globals::$langs->trans('View');
3421
+        }
3287 3422
 
3288 3423
         $moreatt = ($float ? 'style="float: right" ' : '') . $other;
3289 3424
 
@@ -3301,8 +3436,9 @@  discard block
 block discarded – undo
3301 3436
     {
3302 3437
         // global Globals::$conf, Globals::$langs;
3303 3438
 
3304
-        if ($titlealt == 'default')
3305
-            $titlealt = Globals::$langs->trans('Delete');
3439
+        if ($titlealt == 'default') {
3440
+                    $titlealt = Globals::$langs->trans('Delete');
3441
+        }
3306 3442
 
3307 3443
         return img_picto($titlealt, 'delete.png', $other);
3308 3444
 //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>';
@@ -3318,8 +3454,9 @@  discard block
 block discarded – undo
3318 3454
     static function img_printer($titlealt = "default", $other = '')
3319 3455
     {
3320 3456
         // global Globals::$conf, Globals::$langs;
3321
-        if ($titlealt == "default")
3322
-            $titlealt = Globals::$langs->trans("Print");
3457
+        if ($titlealt == "default") {
3458
+                    $titlealt = Globals::$langs->trans("Print");
3459
+        }
3323 3460
         return img_picto($titlealt, 'printer.png', $other);
3324 3461
     }
3325 3462
 
@@ -3334,8 +3471,9 @@  discard block
 block discarded – undo
3334 3471
     {
3335 3472
         // global Globals::$conf, Globals::$langs;
3336 3473
 
3337
-        if ($titlealt == 'default')
3338
-            $titlealt = Globals::$langs->trans('Split');
3474
+        if ($titlealt == 'default') {
3475
+                    $titlealt = Globals::$langs->trans('Split');
3476
+        }
3339 3477
 
3340 3478
         return img_picto($titlealt, 'split.png', $other);
3341 3479
     }
@@ -3352,10 +3490,11 @@  discard block
 block discarded – undo
3352 3490
         // global Globals::$conf, Globals::$langs;
3353 3491
 
3354 3492
         if ($usealttitle) {
3355
-            if (is_string($usealttitle))
3356
-                $usealttitle = AlDolUtils::dol_escape_htmltag($usealttitle);
3357
-            else
3358
-                $usealttitle = Globals::$langs->trans('Info');
3493
+            if (is_string($usealttitle)) {
3494
+                            $usealttitle = AlDolUtils::dol_escape_htmltag($usealttitle);
3495
+            } else {
3496
+                            $usealttitle = Globals::$langs->trans('Info');
3497
+            }
3359 3498
         }
3360 3499
 
3361 3500
         return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"');
@@ -3371,8 +3510,9 @@  discard block
 block discarded – undo
3371 3510
     {
3372 3511
         // global Globals::$conf, Globals::$langs;
3373 3512
 
3374
-        if ($titlealt == 'default')
3375
-            $titlealt = Globals::$langs->trans('Informations');
3513
+        if ($titlealt == 'default') {
3514
+                    $titlealt = Globals::$langs->trans('Informations');
3515
+        }
3376 3516
 
3377 3517
         return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"');
3378 3518
     }
@@ -3388,8 +3528,9 @@  discard block
 block discarded – undo
3388 3528
     {
3389 3529
         // global Globals::$conf, Globals::$langs;
3390 3530
 
3391
-        if ($titlealt == 'default')
3392
-            $titlealt = Globals::$langs->trans('Warning');
3531
+        if ($titlealt == 'default') {
3532
+                    $titlealt = Globals::$langs->trans('Warning');
3533
+        }
3393 3534
 
3394 3535
 //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>';
3395 3536
         return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : ''));
@@ -3405,8 +3546,9 @@  discard block
 block discarded – undo
3405 3546
     {
3406 3547
         // global Globals::$conf, Globals::$langs;
3407 3548
 
3408
-        if ($titlealt == 'default')
3409
-            $titlealt = Globals::$langs->trans('Error');
3549
+        if ($titlealt == 'default') {
3550
+                    $titlealt = Globals::$langs->trans('Error');
3551
+        }
3410 3552
 
3411 3553
         return img_picto($titlealt, 'error.png', 'class="valigntextbottom"');
3412 3554
     }
@@ -3422,8 +3564,9 @@  discard block
 block discarded – undo
3422 3564
     {
3423 3565
         // global Globals::$conf, Globals::$langs;
3424 3566
 
3425
-        if ($titlealt == 'default')
3426
-            $titlealt = Globals::$langs->trans('Next');
3567
+        if ($titlealt == 'default') {
3568
+                    $titlealt = Globals::$langs->trans('Next');
3569
+        }
3427 3570
 
3428 3571
 //return img_picto($titlealt, 'next.png', $moreatt);
3429 3572
         return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . AlDolUtils::dol_escape_htmltag($titlealt) . '"></span>';
@@ -3440,8 +3583,9 @@  discard block
 block discarded – undo
3440 3583
     {
3441 3584
         // global Globals::$conf, Globals::$langs;
3442 3585
 
3443
-        if ($titlealt == 'default')
3444
-            $titlealt = Globals::$langs->trans('Previous');
3586
+        if ($titlealt == 'default') {
3587
+                    $titlealt = Globals::$langs->trans('Previous');
3588
+        }
3445 3589
 
3446 3590
 //return img_picto($titlealt, 'previous.png', $moreatt);
3447 3591
         return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . AlDolUtils::dol_escape_htmltag($titlealt) . '"></span>';
@@ -3459,8 +3603,9 @@  discard block
 block discarded – undo
3459 3603
     {
3460 3604
         // global Globals::$conf, Globals::$langs;
3461 3605
 
3462
-        if ($titlealt == 'default')
3463
-            $titlealt = Globals::$langs->trans('Down');
3606
+        if ($titlealt == 'default') {
3607
+                    $titlealt = Globals::$langs->trans('Down');
3608
+        }
3464 3609
 
3465 3610
         return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"');
3466 3611
     }
@@ -3477,8 +3622,9 @@  discard block
 block discarded – undo
3477 3622
     {
3478 3623
         // global Globals::$conf, Globals::$langs;
3479 3624
 
3480
-        if ($titlealt == 'default')
3481
-            $titlealt = Globals::$langs->trans('Up');
3625
+        if ($titlealt == 'default') {
3626
+                    $titlealt = Globals::$langs->trans('Up');
3627
+        }
3482 3628
 
3483 3629
         return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"');
3484 3630
     }
@@ -3495,8 +3641,9 @@  discard block
 block discarded – undo
3495 3641
     {
3496 3642
         // global Globals::$conf, Globals::$langs;
3497 3643
 
3498
-        if ($titlealt == 'default')
3499
-            $titlealt = Globals::$langs->trans('Left');
3644
+        if ($titlealt == 'default') {
3645
+                    $titlealt = Globals::$langs->trans('Left');
3646
+        }
3500 3647
 
3501 3648
         return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt);
3502 3649
     }
@@ -3513,8 +3660,9 @@  discard block
 block discarded – undo
3513 3660
     {
3514 3661
         // global Globals::$conf, Globals::$langs;
3515 3662
 
3516
-        if ($titlealt == 'default')
3517
-            $titlealt = Globals::$langs->trans('Right');
3663
+        if ($titlealt == 'default') {
3664
+                    $titlealt = Globals::$langs->trans('Right');
3665
+        }
3518 3666
 
3519 3667
         return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt);
3520 3668
     }
@@ -3530,11 +3678,13 @@  discard block
 block discarded – undo
3530 3678
     {
3531 3679
         // global Globals::$conf, Globals::$langs;
3532 3680
 
3533
-        if ($titlealt == 'default')
3534
-            $titlealt = Globals::$langs->trans('Active');
3681
+        if ($titlealt == 'default') {
3682
+                    $titlealt = Globals::$langs->trans('Active');
3683
+        }
3535 3684
 
3536
-        if ($allow == 1)
3537
-            return img_picto($titlealt, 'tick.png');
3685
+        if ($allow == 1) {
3686
+                    return img_picto($titlealt, 'tick.png');
3687
+        }
3538 3688
 
3539 3689
         return '-';
3540 3690
     }
@@ -3582,8 +3732,9 @@  discard block
 block discarded – undo
3582 3732
         $mimeimg = dol_mimetype($file, '', 2);
3583 3733
         $mimefa = dol_mimetype($file, '', 4);
3584 3734
 
3585
-        if (empty($titlealt))
3586
-            $titlealt = 'Mime type: ' . $mimetype;
3735
+        if (empty($titlealt)) {
3736
+                    $titlealt = 'Mime type: ' . $mimetype;
3737
+        }
3587 3738
 
3588 3739
 //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"');
3589 3740
         return '<i class="fa fa-' . $mimefa . ' paddingright"></i>';
@@ -3605,13 +3756,15 @@  discard block
 block discarded – undo
3605 3756
 
3606 3757
         // global Globals::$conf, Globals::$langs;
3607 3758
 
3608
-        if ($titlealt == 'default')
3609
-            $titlealt = Globals::$langs->trans('Call');
3759
+        if ($titlealt == 'default') {
3760
+                    $titlealt = Globals::$langs->trans('Call');
3761
+        }
3610 3762
 
3611
-        if ($option == 1)
3612
-            $img = 'call';
3613
-        else
3614
-            $img = 'call_out';
3763
+        if ($option == 1) {
3764
+                    $img = 'call';
3765
+        } else {
3766
+                    $img = 'call_out';
3767
+        }
3615 3768
 
3616 3769
         return img_picto($titlealt, $img);
3617 3770
     }
@@ -3627,8 +3780,9 @@  discard block
 block discarded – undo
3627 3780
     {
3628 3781
         // global Globals::$conf, Globals::$langs;
3629 3782
 
3630
-        if ($titlealt == 'default')
3631
-            $titlealt = Globals::$langs->trans('Search');
3783
+        if ($titlealt == 'default') {
3784
+                    $titlealt = Globals::$langs->trans('Search');
3785
+        }
3632 3786
 
3633 3787
         $img = img_picto($titlealt, 'search.png', $other, false, 1);
3634 3788
 
@@ -3649,8 +3803,9 @@  discard block
 block discarded – undo
3649 3803
     {
3650 3804
         // global Globals::$conf, Globals::$langs;
3651 3805
 
3652
-        if ($titlealt == 'default')
3653
-            $titlealt = Globals::$langs->trans('Search');
3806
+        if ($titlealt == 'default') {
3807
+                    $titlealt = Globals::$langs->trans('Search');
3808
+        }
3654 3809
 
3655 3810
         $img = img_picto($titlealt, 'searchclear.png', $other, false, 1);
3656 3811
 
@@ -4078,12 +4233,15 @@  discard block
 block discarded – undo
4078 4233
         $savtotalnboflines = $totalnboflines;
4079 4234
         $totalnboflines = abs($totalnboflines);
4080 4235
 
4081
-        if ($picto == 'setup')
4082
-            $picto = 'title_setup.png';
4083
-        if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png')
4084
-            $picto = 'title.gif';
4085
-        if ($limit < 0)
4086
-            $limit = Globals::$conf->liste_limit;
4236
+        if ($picto == 'setup') {
4237
+                    $picto = 'title_setup.png';
4238
+        }
4239
+        if ((Globals::$conf->browser->name == 'ie') && $picto == 'title_generic.png') {
4240
+                    $picto = 'title.gif';
4241
+        }
4242
+        if ($limit < 0) {
4243
+                    $limit = Globals::$conf->liste_limit;
4244
+        }
4087 4245
         if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) {
4088 4246
             $nextpage = 1;
4089 4247
         } else {
@@ -4097,11 +4255,13 @@  discard block
 block discarded – undo
4097 4255
 // Left
4098 4256
 //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>';
4099 4257
         print '<td class="nobordernopadding valignmiddle">';
4100
-        if ($picto && $titre)
4101
-            print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4258
+        if ($picto && $titre) {
4259
+                    print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath);
4260
+        }
4102 4261
         print '<div class="titre inline-block">' . $titre;
4103
-        if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '')
4104
-            print ' (' . $totalnboflines . ')';
4262
+        if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') {
4263
+                    print ' (' . $totalnboflines . ')';
4264
+        }
4105 4265
         print '</div></td>';
4106 4266
 
4107 4267
 // Center
@@ -4111,21 +4271,24 @@  discard block
 block discarded – undo
4111 4271
 
4112 4272
 // Right
4113 4273
         print '<td class="nobordernopadding valignmiddle" align="right">';
4114
-        if ($sortfield)
4115
-            $options .= "&sortfield=" . urlencode($sortfield);
4116
-        if ($sortorder)
4117
-            $options .= "&sortorder=" . urlencode($sortorder);
4118
-// Show navigation bar
4274
+        if ($sortfield) {
4275
+                    $options .= "&sortfield=" . urlencode($sortfield);
4276
+        }
4277
+        if ($sortorder) {
4278
+                    $options .= "&sortorder=" . urlencode($sortorder);
4279
+        }
4280
+        // Show navigation bar
4119 4281
         $pagelist = '';
4120 4282
         if ($savlimit != 0 && ($page > 0 || $num > $limit)) {
4121 4283
             if ($totalnboflines) { // If we know total nb of lines
4122 4284
 // Define nb of extra page links before and after selected page + ... + first or last
4123 4285
                 $maxnbofpage = (empty(Globals::$conf->dol_optimize_smallscreen) ? 4 : 1);
4124 4286
 
4125
-                if ($limit > 0)
4126
-                    $nbpages = ceil($totalnboflines / $limit);
4127
-                else
4128
-                    $nbpages = 1;
4287
+                if ($limit > 0) {
4288
+                                    $nbpages = ceil($totalnboflines / $limit);
4289
+                } else {
4290
+                                    $nbpages = 1;
4291
+                }
4129 4292
                 $cpt = ($page - $maxnbofpage);
4130 4293
                 if ($cpt < 0) {
4131 4294
                     $cpt = 0;
@@ -4133,10 +4296,11 @@  discard block
 block discarded – undo
4133 4296
 
4134 4297
                 if ($cpt >= 1) {
4135 4298
                     $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>';
4136
-                    if ($cpt > 2)
4137
-                        $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4138
-                    else if ($cpt == 2)
4139
-                        $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4299
+                    if ($cpt > 2) {
4300
+                                            $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4301
+                    } else if ($cpt == 2) {
4302
+                                            $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>';
4303
+                    }
4140 4304
                 }
4141 4305
 
4142 4306
                 do {
@@ -4149,14 +4313,14 @@  discard block
 block discarded – undo
4149 4313
                 } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage);
4150 4314
 
4151 4315
                 if ($cpt < $nbpages) {
4152
-                    if ($cpt < $nbpages - 2)
4153
-                        $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4154
-                    else if ($cpt == $nbpages - 2)
4155
-                        $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4316
+                    if ($cpt < $nbpages - 2) {
4317
+                                            $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>';
4318
+                    } else if ($cpt == $nbpages - 2) {
4319
+                                            $pagelist .= '<li' . ( (Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>';
4320
+                    }
4156 4321
                     $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>';
4157 4322
                 }
4158
-            }
4159
-            else {
4323
+            } else {
4160 4324
                 $pagelist .= '<li' . ((Globals::$conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . ((Globals::$conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>";
4161 4325
             }
4162 4326
         }
@@ -4192,18 +4356,21 @@  discard block
 block discarded – undo
4192 4356
             $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
4193 4357
 //$pagesizechoices.=',0:'.Globals::$langs->trans("All");     // Not yet supported
4194 4358
 //$pagesizechoices.=',2:2';
4195
-            if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES))
4196
-                $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES;
4359
+            if (!empty(Globals::$conf->global->MAIN_PAGESIZE_CHOICES)) {
4360
+                            $pagesizechoices = Globals::$conf->global->MAIN_PAGESIZE_CHOICES;
4361
+            }
4197 4362
 
4198 4363
             print '<li class="pagination">';
4199 4364
             print '<select class="flat selectlimit" name="limit" title="' . AlDolUtils::dol_escape_htmltag(Globals::$langs->trans("MaxNbOfRecordPerPage")) . '">';
4200 4365
             $tmpchoice = explode(',', $pagesizechoices);
4201 4366
             $tmpkey = $limit . ':' . $limit;
4202
-            if (!in_array($tmpkey, $tmpchoice))
4203
-                $tmpchoice[] = $tmpkey;
4367
+            if (!in_array($tmpkey, $tmpchoice)) {
4368
+                            $tmpchoice[] = $tmpkey;
4369
+            }
4204 4370
             $tmpkey = Globals::$conf->liste_limit . ':' . Globals::$conf->liste_limit;
4205
-            if (!in_array($tmpkey, $tmpchoice))
4206
-                $tmpchoice[] = $tmpkey;
4371
+            if (!in_array($tmpkey, $tmpchoice)) {
4372
+                            $tmpchoice[] = $tmpkey;
4373
+            }
4207 4374
             asort($tmpchoice, SORT_NUMERIC);
4208 4375
             $found = false;
4209 4376
             foreach ($tmpchoice as $val) {
@@ -4279,14 +4446,15 @@  discard block
 block discarded – undo
4279 4446
         }
4280 4447
 
4281 4448
 // If rate is '9/9/9' we don't change it.  If rate is '9.000' we apply price()
4282
-        if (!preg_match('/\//', $rate))
4283
-            $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4284
-        else {
4449
+        if (!preg_match('/\//', $rate)) {
4450
+                    $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : '');
4451
+        } else {
4285 4452
 // TODO Split on / and output with a price2num to have clean numbers without ton of 000.
4286 4453
             $ret = $rate . ($addpercent ? '%' : '');
4287 4454
         }
4288
-        if (($info_bits & 1) && $usestarfornpr >= 0)
4289
-            $ret .= ' *';
4455
+        if (($info_bits & 1) && $usestarfornpr >= 0) {
4456
+                    $ret .= ' *';
4457
+        }
4290 4458
         $ret .= $morelabel;
4291 4459
         return $ret;
4292 4460
     }
@@ -4310,11 +4478,14 @@  discard block
 block discarded – undo
4310 4478
     {
4311 4479
         // global Globals::$langs, Globals::$conf;
4312 4480
 // Clean parameters
4313
-        if (empty($amount))
4314
-            $amount = 0; // To have a numeric value if amount not defined or = ''
4481
+        if (empty($amount)) {
4482
+                    $amount = 0;
4483
+        }
4484
+        // To have a numeric value if amount not defined or = ''
4315 4485
         $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number)
4316
-        if ($rounding < 0)
4317
-            $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT);
4486
+        if ($rounding < 0) {
4487
+                    $rounding = min(Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT, Globals::$conf->global->MAIN_MAX_DECIMALS_TOT);
4488
+        }
4318 4489
         $nbdecimal = $rounding;
4319 4490
 
4320 4491
 // Output separators by default (french)
@@ -4322,18 +4493,22 @@  discard block
 block discarded – undo
4322 4493
         $thousand = ' ';
4323 4494
 
4324 4495
 // If $outlangs not forced, we use use language
4325
-        if (!is_object($outlangs))
4326
-            $outlangs = Globals::$langs;
4327
-
4328
-        if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4329
-            $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4330
-        if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4331
-            $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4332
-        if ($thousand == 'None')
4333
-            $thousand = '';
4334
-        else if ($thousand == 'Space')
4335
-            $thousand = ' ';
4336
-//print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4496
+        if (!is_object($outlangs)) {
4497
+                    $outlangs = Globals::$langs;
4498
+        }
4499
+
4500
+        if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4501
+                    $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal");
4502
+        }
4503
+        if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4504
+                    $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand");
4505
+        }
4506
+        if ($thousand == 'None') {
4507
+                    $thousand = '';
4508
+        } else if ($thousand == 'Space') {
4509
+                    $thousand = ' ';
4510
+        }
4511
+        //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4337 4512
 //print "amount=".$amount."-";
4338 4513
         $amount = str_replace(',', '.', $amount); // should be useless
4339 4514
 //print $amount."-";
@@ -4344,9 +4519,10 @@  discard block
 block discarded – undo
4344 4519
         $end = '';
4345 4520
 
4346 4521
 // We increase nbdecimal if there is more decimal than asked (to not loose information)
4347
-        if (AlDolUtils::dol_strlen($decpart) > $nbdecimal)
4348
-            $nbdecimal = AlDolUtils::dol_strlen($decpart);
4349
-// Si on depasse max
4522
+        if (AlDolUtils::dol_strlen($decpart) > $nbdecimal) {
4523
+                    $nbdecimal = AlDolUtils::dol_strlen($decpart);
4524
+        }
4525
+        // Si on depasse max
4350 4526
         if ($trunc && $nbdecimal > Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN) {
4351 4527
             $nbdecimal = Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN;
4352 4528
             if (preg_match('/\.\.\./i', Globals::$conf->global->MAIN_MAX_DECIMALS_SHOWN)) {
@@ -4356,8 +4532,9 @@  discard block
 block discarded – undo
4356 4532
         }
4357 4533
 
4358 4534
 // If force rounding
4359
-        if ($forcerounding >= 0)
4360
-            $nbdecimal = $forcerounding;
4535
+        if ($forcerounding >= 0) {
4536
+                    $nbdecimal = $forcerounding;
4537
+        }
4361 4538
 
4362 4539
 // Format number
4363 4540
         $output = number_format($amount, $nbdecimal, $dec, $thousand);
@@ -4368,13 +4545,14 @@  discard block
 block discarded – undo
4368 4545
 // Add symbol of currency if requested
4369 4546
         $cursymbolbefore = $cursymbolafter = '';
4370 4547
         if ($currency_code) {
4371
-            if ($currency_code == 'auto')
4372
-                $currency_code = Globals::$conf->currency;
4548
+            if ($currency_code == 'auto') {
4549
+                            $currency_code = Globals::$conf->currency;
4550
+            }
4373 4551
 
4374 4552
             $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY');
4375
-            if (in_array($currency_code, $listofcurrenciesbefore))
4376
-                $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4377
-            else {
4553
+            if (in_array($currency_code, $listofcurrenciesbefore)) {
4554
+                            $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code);
4555
+            } else {
4378 4556
                 $tmpcur = $outlangs->getCurrencySymbol($currency_code);
4379 4557
                 $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur);
4380 4558
             }
@@ -4407,15 +4585,18 @@  discard block
 block discarded – undo
4407 4585
 // Decimal delimiter for PHP and database SQL requests must be '.'
4408 4586
         $dec = ',';
4409 4587
         $thousand = ' ';
4410
-        if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal")
4411
-            $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal");
4412
-        if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand")
4413
-            $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand");
4414
-        if ($thousand == 'None')
4415
-            $thousand = '';
4416
-        elseif ($thousand == 'Space')
4417
-            $thousand = ' ';
4418
-//print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4588
+        if (Globals::$langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") {
4589
+                    $dec = Globals::$langs->transnoentitiesnoconv("SeparatorDecimal");
4590
+        }
4591
+        if (Globals::$langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") {
4592
+                    $thousand = Globals::$langs->transnoentitiesnoconv("SeparatorThousand");
4593
+        }
4594
+        if ($thousand == 'None') {
4595
+                    $thousand = '';
4596
+        } elseif ($thousand == 'Space') {
4597
+                    $thousand = ' ';
4598
+        }
4599
+        //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>";
4419 4600
 // Convert value to universal number format (no thousand separator, '.' as decimal separator)
4420 4601
         if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format
4421 4602
 //print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
@@ -4430,8 +4611,10 @@  discard block
 block discarded – undo
4430 4611
             }
4431 4612
 //print "QQ".$amount.'<br>';
4432 4613
 // Now make replace (the main goal of function)
4433
-            if ($thousand != ',' && $thousand != '.')
4434
-                $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4614
+            if ($thousand != ',' && $thousand != '.') {
4615
+                            $amount = str_replace(',', '.', $amount);
4616
+            }
4617
+            // To accept 2 notations for french users
4435 4618
             $amount = str_replace(' ', '', $amount);  // To avoid spaces
4436 4619
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4437 4620
             $amount = str_replace($dec, '.', $amount);
@@ -4440,20 +4623,24 @@  discard block
 block discarded – undo
4440 4623
 // Now, make a rounding if required
4441 4624
         if ($rounding) {
4442 4625
             $nbofdectoround = '';
4443
-            if ($rounding == 'MU')
4444
-                $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT;
4445
-            elseif ($rounding == 'MT')
4446
-                $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT;
4447
-            elseif ($rounding == 'MS')
4448
-                $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK;
4449
-            elseif (is_numeric($rounding))
4450
-                $nbofdectoround = $rounding;
4451
-//print "RR".$amount.' - '.$nbofdectoround.'<br>';
4452
-            if (AlDolUtils::dol_strlen($nbofdectoround))
4453
-                $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0.
4454
-            else
4455
-                return 'ErrorBadParameterProvidedToFunction';
4456
-//print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
4626
+            if ($rounding == 'MU') {
4627
+                            $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_UNIT;
4628
+            } elseif ($rounding == 'MT') {
4629
+                            $nbofdectoround = Globals::$conf->global->MAIN_MAX_DECIMALS_TOT;
4630
+            } elseif ($rounding == 'MS') {
4631
+                            $nbofdectoround = empty(Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : Globals::$conf->global->MAIN_MAX_DECIMALS_STOCK;
4632
+            } elseif (is_numeric($rounding)) {
4633
+                            $nbofdectoround = $rounding;
4634
+            }
4635
+            //print "RR".$amount.' - '.$nbofdectoround.'<br>';
4636
+            if (AlDolUtils::dol_strlen($nbofdectoround)) {
4637
+                            $amount = round($amount, $nbofdectoround);
4638
+            }
4639
+            // $nbofdectoround can be 0.
4640
+            else {
4641
+                            return 'ErrorBadParameterProvidedToFunction';
4642
+            }
4643
+            //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>';
4457 4644
 // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number
4458 4645
 // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup.
4459 4646
             if (is_numeric($amount)) {
@@ -4466,8 +4653,10 @@  discard block
 block discarded – undo
4466 4653
 //print "TT".$amount.'<br>';
4467 4654
 // Always make replace because each math static function (like round) replace
4468 4655
 // with local values and we want a number that has a SQL string format x.y
4469
-            if ($thousand != ',' && $thousand != '.')
4470
-                $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users
4656
+            if ($thousand != ',' && $thousand != '.') {
4657
+                            $amount = str_replace(',', '.', $amount);
4658
+            }
4659
+            // To accept 2 notations for french users
4471 4660
             $amount = str_replace(' ', '', $amount);  // To avoid spaces
4472 4661
             $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is .
4473 4662
             $amount = str_replace($dec, '.', $amount);
@@ -4526,8 +4715,9 @@  discard block
 block discarded – undo
4526 4715
     {
4527 4716
         // global $db, Globals::$conf, $mysoc;
4528 4717
 
4529
-        if (empty($thirdparty_seller) || !is_object($thirdparty_seller))
4530
-            $thirdparty_seller = $mysoc;
4718
+        if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) {
4719
+                    $thirdparty_seller = $mysoc;
4720
+        }
4531 4721
 
4532 4722
         AlDolUtils::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);
4533 4723
 
@@ -4545,37 +4735,43 @@  discard block
 block discarded – undo
4545 4735
 // Some test to guess with no need to make database access
4546 4736
         if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax
4547 4737
             if ($local == 1) {
4548
-                if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0")
4549
-                    return 0;
4738
+                if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") {
4739
+                                    return 0;
4740
+                }
4550 4741
                 if ($thirdparty_seller->id == $mysoc->id) {
4551
-                    if (!$thirdparty_buyer->localtax1_assuj)
4552
-                        return 0;
4553
-                }
4554
-                else {
4555
-                    if (!$thirdparty_seller->localtax1_assuj)
4556
-                        return 0;
4742
+                    if (!$thirdparty_buyer->localtax1_assuj) {
4743
+                                            return 0;
4744
+                    }
4745
+                } else {
4746
+                    if (!$thirdparty_seller->localtax1_assuj) {
4747
+                                            return 0;
4748
+                    }
4557 4749
                 }
4558 4750
             }
4559 4751
 
4560 4752
             if ($local == 2) {
4561 4753
 //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0;
4562
-                if (!$mysoc->localtax2_assuj)
4563
-                    return 0;  // If main vat is 0, IRPF may be different than 0.
4754
+                if (!$mysoc->localtax2_assuj) {
4755
+                                    return 0;
4756
+                }
4757
+                // If main vat is 0, IRPF may be different than 0.
4564 4758
                 if ($thirdparty_seller->id == $mysoc->id) {
4565
-                    if (!$thirdparty_buyer->localtax2_assuj)
4566
-                        return 0;
4567
-                }
4568
-                else {
4569
-                    if (!$thirdparty_seller->localtax2_assuj)
4570
-                        return 0;
4759
+                    if (!$thirdparty_buyer->localtax2_assuj) {
4760
+                                            return 0;
4761
+                    }
4762
+                } else {
4763
+                    if (!$thirdparty_seller->localtax2_assuj) {
4764
+                                            return 0;
4765
+                    }
4571 4766
                 }
4572 4767
             }
4573
-        }
4574
-        else {
4575
-            if ($local == 1 && !$thirdparty_seller->localtax1_assuj)
4576
-                return 0;
4577
-            if ($local == 2 && !$thirdparty_seller->localtax2_assuj)
4578
-                return 0;
4768
+        } else {
4769
+            if ($local == 1 && !$thirdparty_seller->localtax1_assuj) {
4770
+                            return 0;
4771
+            }
4772
+            if ($local == 2 && !$thirdparty_seller->localtax2_assuj) {
4773
+                            return 0;
4774
+            }
4579 4775
         }
4580 4776
 
4581 4777
 // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on.
@@ -4617,19 +4813,23 @@  discard block
 block discarded – undo
4617 4813
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c";
4618 4814
         $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'";
4619 4815
         $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4620
-        if ($vatratecode)
4621
-            $sql .= " AND t.code ='" . $vatratecode . "'";  // If we have the code, we use it in priority
4622
-        else
4623
-            $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4816
+        if ($vatratecode) {
4817
+                    $sql .= " AND t.code ='" . $vatratecode . "'";
4818
+        }
4819
+        // If we have the code, we use it in priority
4820
+        else {
4821
+                    $sql .= " AND t.recuperableonly ='" . $vatnpr . "'";
4822
+        }
4624 4823
         AlDolUtils::dol_syslog("get_localtax", LOG_DEBUG);
4625 4824
         $resql = $db->query($sql);
4626 4825
 
4627 4826
         if ($resql) {
4628 4827
             $obj = $db->fetch_object($resql);
4629
-            if ($local == 1)
4630
-                return $obj->localtax1;
4631
-            elseif ($local == 2)
4632
-                return $obj->localtax2;
4828
+            if ($local == 1) {
4829
+                            return $obj->localtax1;
4830
+            } elseif ($local == 2) {
4831
+                            return $obj->localtax2;
4832
+            }
4633 4833
         }
4634 4834
 
4635 4835
         return 0;
@@ -4675,10 +4875,11 @@  discard block
 block discarded – undo
4675 4875
         $resql = $db->query($sql);
4676 4876
         if ($resql) {
4677 4877
             $obj = $db->fetch_object($resql);
4678
-            if ($local == 1)
4679
-                return $obj->localtax1;
4680
-            elseif ($local == 2)
4681
-                return $obj->localtax2;
4878
+            if ($local == 1) {
4879
+                            return $obj->localtax1;
4880
+            } elseif ($local == 2) {
4881
+                            return $obj->localtax2;
4882
+            }
4682 4883
         }
4683 4884
 
4684 4885
         return 0;
@@ -4704,9 +4905,9 @@  discard block
 block discarded – undo
4704 4905
 // Search local taxes
4705 4906
         $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy";
4706 4907
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4707
-        if ($firstparamisid)
4708
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4709
-        else {
4908
+        if ($firstparamisid) {
4909
+                    $sql .= " WHERE t.rowid = " . (int) $vatrate;
4910
+        } else {
4710 4911
             $vatratecleaned = $vatrate;
4711 4912
             $vatratecode = '';
4712 4913
             if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "xx (yy)"
@@ -4719,19 +4920,22 @@  discard block
 block discarded – undo
4719 4920
               else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */
4720 4921
             $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4721 4922
             $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4722
-            if ($vatratecode)
4723
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4923
+            if ($vatratecode) {
4924
+                            $sql .= " AND t.code = '" . $vatratecode . "'";
4925
+            }
4724 4926
         }
4725 4927
 
4726 4928
         $resql = $db->query($sql);
4727 4929
         if ($resql) {
4728 4930
             $obj = $db->fetch_object($resql);
4729
-            if ($obj)
4730
-                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);
4731
-            else
4732
-                return array();
4733
-        } else
4734
-            dol_print_error($db);
4931
+            if ($obj) {
4932
+                            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);
4933
+            } else {
4934
+                            return array();
4935
+            }
4936
+        } else {
4937
+                    dol_print_error($db);
4938
+        }
4735 4939
 
4736 4940
         return array();
4737 4941
     }
@@ -4761,9 +4965,9 @@  discard block
 block discarded – undo
4761 4965
 // Search local taxes
4762 4966
         $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
4763 4967
         $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t";
4764
-        if ($firstparamisid)
4765
-            $sql .= " WHERE t.rowid = " . (int) $vatrate;
4766
-        else {
4968
+        if ($firstparamisid) {
4969
+                    $sql .= " WHERE t.rowid = " . (int) $vatrate;
4970
+        } else {
4767 4971
             $vatratecleaned = $vatrate;
4768 4972
             $vatratecode = '';
4769 4973
             if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) {      // If vat is "x.x (yy)"
@@ -4772,13 +4976,17 @@  discard block
 block discarded – undo
4772 4976
             }
4773 4977
 
4774 4978
             $sql .= ", " . MAIN_DB_PREFIX . "c_country as c";
4775
-            if ($mysoc->country_code == 'ES')
4776
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";    // local tax in spain use the buyer country ??
4777
-            else
4778
-                $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4979
+            if ($mysoc->country_code == 'ES') {
4980
+                            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'";
4981
+            }
4982
+            // local tax in spain use the buyer country ??
4983
+            else {
4984
+                            $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'";
4985
+            }
4779 4986
             $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1";
4780
-            if ($vatratecode)
4781
-                $sql .= " AND t.code = '" . $vatratecode . "'";
4987
+            if ($vatratecode) {
4988
+                            $sql .= " AND t.code = '" . $vatratecode . "'";
4989
+            }
4782 4990
         }
4783 4991
 
4784 4992
         $resql = $db->query($sql);
@@ -4824,17 +5032,17 @@  discard block
 block discarded – undo
4824 5032
                 if ($idprodfournprice > 0) {     // We want vat for product for a "supplier" object
4825 5033
                     $product->get_buyprice($idprodfournprice, 0, 0, 0);
4826 5034
                     $ret = $product->vatrate_supplier;
4827
-                    if ($product->default_vat_code)
4828
-                        $ret .= ' (' . $product->default_vat_code . ')';
4829
-                }
4830
-                else {
5035
+                    if ($product->default_vat_code) {
5036
+                                            $ret .= ' (' . $product->default_vat_code . ')';
5037
+                    }
5038
+                } else {
4831 5039
                     $ret = $product->tva_tx;    // Default vat of product we defined
4832
-                    if ($product->default_vat_code)
4833
-                        $ret .= ' (' . $product->default_vat_code . ')';
5040
+                    if ($product->default_vat_code) {
5041
+                                            $ret .= ' (' . $product->default_vat_code . ')';
5042
+                    }
4834 5043
                 }
4835 5044
                 $found = 1;
4836
-            }
4837
-            else {
5045
+            } else {
4838 5046
 // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
4839 5047
 // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on
4840 5048
             }
@@ -4854,14 +5062,18 @@  discard block
 block discarded – undo
4854 5062
                     $obj = $db->fetch_object($resql);
4855 5063
                     if ($obj) {
4856 5064
                         $ret = $obj->vat_rate;
4857
-                        if ($obj->default_vat_code)
4858
-                            $ret .= ' (' . $obj->default_vat_code . ')';
5065
+                        if ($obj->default_vat_code) {
5066
+                                                    $ret .= ' (' . $obj->default_vat_code . ')';
5067
+                        }
4859 5068
                     }
4860 5069
                     $db->free($sql);
4861
-                } else
4862
-                    dol_print_error($db);
4863
-            } else
4864
-                $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;    // Forced value if autodetect fails
5070
+                } else {
5071
+                                    dol_print_error($db);
5072
+                }
5073
+            } else {
5074
+                            $ret = Globals::$conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS;
5075
+            }
5076
+            // Forced value if autodetect fails
4865 5077
         }
4866 5078
 
4867 5079
         AlDolUtils::dol_syslog("get_product_vat_for_country: ret=" . $ret);
@@ -4916,13 +5128,15 @@  discard block
 block discarded – undo
4916 5128
             if ($resql) {
4917 5129
                 $obj = $db->fetch_object($resql);
4918 5130
                 if ($obj) {
4919
-                    if ($local == 1)
4920
-                        $ret = $obj->localtax1;
4921
-                    elseif ($local == 2)
4922
-                        $ret = $obj->localtax2;
5131
+                    if ($local == 1) {
5132
+                                            $ret = $obj->localtax1;
5133
+                    } elseif ($local == 2) {
5134
+                                            $ret = $obj->localtax2;
5135
+                    }
4923 5136
                 }
4924
-            } else
4925
-                dol_print_error($db);
5137
+            } else {
5138
+                            dol_print_error($db);
5139
+            }
4926 5140
         }
4927 5141
 
4928 5142
         AlDolUtils::dol_syslog("get_product_localtax_for_country: ret=" . $ret);
@@ -5025,15 +5239,16 @@  discard block
 block discarded – undo
5025 5239
         // global $db;
5026 5240
 
5027 5241
         if ($idprodfournprice > 0) {
5028
-            if (!class_exists('ProductFournisseur'))
5029
-                require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5242
+            if (!class_exists('ProductFournisseur')) {
5243
+                            require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php';
5244
+            }
5030 5245
             $prodprice = new ProductFournisseur($db);
5031 5246
             $prodprice->fetch_product_fournisseur_price($idprodfournprice);
5032 5247
             return $prodprice->fourn_tva_npr;
5033
-        }
5034
-        elseif ($idprod > 0) {
5035
-            if (!class_exists('Product'))
5036
-                require_once DOL_BASE_PATH . 'product/class/product.class.php';
5248
+        } elseif ($idprod > 0) {
5249
+            if (!class_exists('Product')) {
5250
+                            require_once DOL_BASE_PATH . 'product/class/product.class.php';
5251
+            }
5037 5252
             $prod = new Product($db);
5038 5253
             $prod->fetch($idprod);
5039 5254
             return $prod->tva_npr;
@@ -5059,30 +5274,35 @@  discard block
 block discarded – undo
5059 5274
     {
5060 5275
         // global $mysoc;
5061 5276
 
5062
-        if (!is_object($thirdparty_seller))
5063
-            return -1;
5064
-        if (!is_object($thirdparty_buyer))
5065
-            return -1;
5277
+        if (!is_object($thirdparty_seller)) {
5278
+                    return -1;
5279
+        }
5280
+        if (!is_object($thirdparty_buyer)) {
5281
+                    return -1;
5282
+        }
5066 5283
 
5067 5284
         if ($local == 1) { // Localtax 1
5068 5285
             if ($mysoc->country_code == 'ES') {
5069
-                if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj)
5070
-                    return 0;
5071
-            }
5072
-            else {
5286
+                if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) {
5287
+                                    return 0;
5288
+                }
5289
+            } else {
5073 5290
 // Si vendeur non assujeti a Localtax1, localtax1 par default=0
5074
-                if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj)
5075
-                    return 0;
5076
-                if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off')
5077
-                    return 0;
5078
-            }
5079
-        }
5080
-        elseif ($local == 2) { //I Localtax 2
5291
+                if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) {
5292
+                                    return 0;
5293
+                }
5294
+                if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') {
5295
+                                    return 0;
5296
+                }
5297
+            }
5298
+        } elseif ($local == 2) { //I Localtax 2
5081 5299
 // Si vendeur non assujeti a Localtax2, localtax2 par default=0
5082
-            if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj)
5083
-                return 0;
5084
-            if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off')
5085
-                return 0;
5300
+            if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) {
5301
+                            return 0;
5302
+            }
5303
+            if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') {
5304
+                            return 0;
5305
+            }
5086 5306
         }
5087 5307
 
5088 5308
         if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) {
@@ -5107,31 +5327,38 @@  discard block
 block discarded – undo
5107 5327
         $classname = '';
5108 5328
         if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') {  // A mettre avant test sur no a cause du == 0
5109 5329
             $result = Globals::$langs->trans('yes');
5110
-            if ($case == 1 || $case == 3)
5111
-                $result = Globals::$langs->trans("Yes");
5112
-            if ($case == 2)
5113
-                $result = '<input type="checkbox" value="1" checked disabled>';
5114
-            if ($case == 3)
5115
-                $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5330
+            if ($case == 1 || $case == 3) {
5331
+                            $result = Globals::$langs->trans("Yes");
5332
+            }
5333
+            if ($case == 2) {
5334
+                            $result = '<input type="checkbox" value="1" checked disabled>';
5335
+            }
5336
+            if ($case == 3) {
5337
+                            $result = '<input type="checkbox" value="1" checked disabled> ' . $result;
5338
+            }
5116 5339
 
5117 5340
             $classname = 'ok';
5118
-        }
5119
-        elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5341
+        } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') {
5120 5342
             $result = Globals::$langs->trans("no");
5121
-            if ($case == 1 || $case == 3)
5122
-                $result = Globals::$langs->trans("No");
5123
-            if ($case == 2)
5124
-                $result = '<input type="checkbox" value="0" disabled>';
5125
-            if ($case == 3)
5126
-                $result = '<input type="checkbox" value="0" disabled> ' . $result;
5127
-
5128
-            if ($color == 2)
5129
-                $classname = 'ok';
5130
-            else
5131
-                $classname = 'error';
5132
-        }
5133
-        if ($color)
5134
-            return '<font class="' . $classname . '">' . $result . '</font>';
5343
+            if ($case == 1 || $case == 3) {
5344
+                            $result = Globals::$langs->trans("No");
5345
+            }
5346
+            if ($case == 2) {
5347
+                            $result = '<input type="checkbox" value="0" disabled>';
5348
+            }
5349
+            if ($case == 3) {
5350
+                            $result = '<input type="checkbox" value="0" disabled> ' . $result;
5351
+            }
5352
+
5353
+            if ($color == 2) {
5354
+                            $classname = 'ok';
5355
+            } else {
5356
+                            $classname = 'error';
5357
+            }
5358
+        }
5359
+        if ($color) {
5360
+                    return '<font class="' . $classname . '">' . $result . '</font>';
5361
+        }
5135 5362
         return $result;
5136 5363
     }
5137 5364
 
@@ -5157,23 +5384,27 @@  discard block
 block discarded – undo
5157 5384
         $path = '';
5158 5385
 
5159 5386
         $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment');
5160
-        if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
5161
-            $arrayforoldpath[] = 'product';
5387
+        if (!empty(Globals::$conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
5388
+                    $arrayforoldpath[] = 'product';
5389
+        }
5162 5390
         if (!empty($level) && in_array($modulepart, $arrayforoldpath)) {
5163 5391
 // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided.
5164
-            if (empty($alpha))
5165
-                $num = preg_replace('/([^0-9])/i', '', $num);
5166
-            else
5167
-                $num = preg_replace('/^.*\-/i', '', $num);
5392
+            if (empty($alpha)) {
5393
+                            $num = preg_replace('/([^0-9])/i', '', $num);
5394
+            } else {
5395
+                            $num = preg_replace('/^.*\-/i', '', $num);
5396
+            }
5168 5397
             $num = substr("000" . $num, -$level);
5169
-            if ($level == 1)
5170
-                $path = substr($num, 0, 1);
5171
-            if ($level == 2)
5172
-                $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5173
-            if ($level == 3)
5174
-                $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5175
-        }
5176
-        else {
5398
+            if ($level == 1) {
5399
+                            $path = substr($num, 0, 1);
5400
+            }
5401
+            if ($level == 2) {
5402
+                            $path = substr($num, 1, 1) . '/' . substr($num, 0, 1);
5403
+            }
5404
+            if ($level == 3) {
5405
+                            $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1);
5406
+            }
5407
+        } else {
5177 5408
 // TODO
5178 5409
 // We will enhance here a common way of forging path for document storage
5179 5410
 // Here, object->id, object->ref and modulepart are required.
@@ -5184,8 +5415,9 @@  discard block
 block discarded – undo
5184 5415
             }
5185 5416
         }
5186 5417
 
5187
-        if (empty($withoutslash) && !empty($path))
5188
-            $path .= '/';
5418
+        if (empty($withoutslash) && !empty($path)) {
5419
+                    $path .= '/';
5420
+        }
5189 5421
 
5190 5422
         return $path;
5191 5423
     }
@@ -5205,8 +5437,9 @@  discard block
 block discarded – undo
5205 5437
         AlDolUtils::dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO);
5206 5438
 
5207 5439
         $dir_osencoded = dol_osencode($dir);
5208
-        if (@is_dir($dir_osencoded))
5209
-            return 0;
5440
+        if (@is_dir($dir_osencoded)) {
5441
+                    return 0;
5442
+        }
5210 5443
 
5211 5444
         $nberr = 0;
5212 5445
         $nbcreated = 0;
@@ -5221,12 +5454,15 @@  discard block
 block discarded – undo
5221 5454
         $cdir = explode("/", $dir);
5222 5455
         $num = count($cdir);
5223 5456
         for ($i = 0; $i < $num; $i++) {
5224
-            if ($i > 0)
5225
-                $ccdir .= '/' . $cdir[$i];
5226
-            else
5227
-                $ccdir .= $cdir[$i];
5228
-            if (preg_match("/^.:$/", $ccdir, $regs))
5229
-                continue; // Si chemin Windows incomplet, on poursuit par rep suivant
5457
+            if ($i > 0) {
5458
+                            $ccdir .= '/' . $cdir[$i];
5459
+            } else {
5460
+                            $ccdir .= $cdir[$i];
5461
+            }
5462
+            if (preg_match("/^.:$/", $ccdir, $regs)) {
5463
+                            continue;
5464
+            }
5465
+            // Si chemin Windows incomplet, on poursuit par rep suivant
5230 5466
 
5231 5467
 
5232 5468
 
@@ -5337,8 +5573,9 @@  discard block
 block discarded – undo
5337 5573
      */
5338 5574
     static function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0)
5339 5575
     {
5340
-        if ($removelinefeed == 2)
5341
-            $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5576
+        if ($removelinefeed == 2) {
5577
+                    $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean);
5578
+        }
5342 5579
         $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean);
5343 5580
 
5344 5581
         if ($strip_tags) {
@@ -5355,8 +5592,9 @@  discard block
 block discarded – undo
5355 5592
         $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto);
5356 5593
 
5357 5594
 // Supprime aussi les retours
5358
-        if ($removelinefeed == 1)
5359
-            $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5595
+        if ($removelinefeed == 1) {
5596
+                    $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp);
5597
+        }
5360 5598
 
5361 5599
 // et les espaces doubles
5362 5600
         while (strpos($temp, "  ")) {
@@ -5442,18 +5680,21 @@  discard block
 block discarded – undo
5442 5680
             if ($charset == 'UTF-8') {
5443 5681
                 $pattern = '/(<br[^>]*>)/Uu';
5444 5682
             } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5445
-            else
5446
-                $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5683
+            else {
5684
+                            $pattern = '/(<br[^>]*>)/U';
5685
+            }
5686
+            // /U is to have UNGREEDY regex to limit to one html tag.
5447 5687
             $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5448 5688
 
5449 5689
             $firstline = '';
5450 5690
             $i = 0;
5451 5691
             $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
5452 5692
             while (($i < $nba) && ($i < ($nboflines * 2))) {
5453
-                if ($i % 2 == 0)
5454
-                    $firstline .= $a[$i];
5455
-                elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1)))
5456
-                    $firstline .= ($ishtml ? "<br>\n" : "\n");
5693
+                if ($i % 2 == 0) {
5694
+                                    $firstline .= $a[$i];
5695
+                } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) {
5696
+                                    $firstline .= ($ishtml ? "<br>\n" : "\n");
5697
+                }
5457 5698
                 $i++;
5458 5699
             }
5459 5700
             unset($a);
@@ -5502,15 +5743,18 @@  discard block
 block discarded – undo
5502 5743
         $newstring = $stringtoencode;
5503 5744
         if (AlDolUtils::dol_textishtml($stringtoencode)) { // Check if text is already HTML or not
5504 5745
             $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.
5505
-            if ($removelasteolbr)
5506
-                $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one)
5746
+            if ($removelasteolbr) {
5747
+                            $newstring = preg_replace('/<br>$/i', '', $newstring);
5748
+            }
5749
+            // Remove last <br> (remove only last one)
5507 5750
             $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__'));
5508 5751
             $newstring = AlDolUtils::dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding
5509 5752
             $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"'));
5510
-        }
5511
-        else {
5512
-            if ($removelasteolbr)
5513
-                $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several)
5753
+        } else {
5754
+            if ($removelasteolbr) {
5755
+                            $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring);
5756
+            }
5757
+            // Remove last \n (may remove several)
5514 5758
             $newstring = dol_nl2br(AlDolUtils::dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode);
5515 5759
         }
5516 5760
 // Other substitutions that htmlentities does not do
@@ -5612,8 +5856,9 @@  discard block
 block discarded – undo
5612 5856
      */
5613 5857
     static function dol_nboflines($s, $maxchar = 0)
5614 5858
     {
5615
-        if ($s == '')
5616
-            return 0;
5859
+        if ($s == '') {
5860
+                    return 0;
5861
+        }
5617 5862
         $arraystring = explode("\n", $s);
5618 5863
         $nb = count($arraystring);
5619 5864
 
@@ -5632,15 +5877,18 @@  discard block
 block discarded – undo
5632 5877
     static function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8')
5633 5878
     {
5634 5879
         $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
5635
-        if (AlDolUtils::dol_textishtml($text))
5636
-            $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5880
+        if (AlDolUtils::dol_textishtml($text)) {
5881
+                    $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
5882
+        }
5637 5883
 
5638 5884
         $text = strtr($text, $repTable);
5639 5885
         if ($charset == 'UTF-8') {
5640 5886
             $pattern = '/(<br[^>]*>)/Uu';
5641 5887
         } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
5642
-        else
5643
-            $pattern = '/(<br[^>]*>)/U';       // /U is to have UNGREEDY regex to limit to one html tag.
5888
+        else {
5889
+                    $pattern = '/(<br[^>]*>)/U';
5890
+        }
5891
+        // /U is to have UNGREEDY regex to limit to one html tag.
5644 5892
         $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
5645 5893
 
5646 5894
         $nblines = (int) floor((count($a) + 1) / 2);
@@ -5687,39 +5935,47 @@  discard block
 block discarded – undo
5687 5935
     static function dol_textishtml($msg, $option = 0)
5688 5936
     {
5689 5937
         if ($option == 1) {
5690
-            if (preg_match('/<html/i', $msg))
5691
-                return true;
5692
-            elseif (preg_match('/<body/i', $msg))
5693
-                return true;
5694
-            elseif (preg_match('/<br/i', $msg))
5695
-                return true;
5938
+            if (preg_match('/<html/i', $msg)) {
5939
+                            return true;
5940
+            } elseif (preg_match('/<body/i', $msg)) {
5941
+                            return true;
5942
+            } elseif (preg_match('/<br/i', $msg)) {
5943
+                            return true;
5944
+            }
5696 5945
             return false;
5697
-        }
5698
-        else {
5699
-            if (preg_match('/<html/i', $msg))
5700
-                return true;
5701
-            elseif (preg_match('/<body/i', $msg))
5702
-                return true;
5703
-            elseif (preg_match('/<(b|em|i|u)>/i', $msg))
5704
-                return true;
5705
-            elseif (preg_match('/<br\/>/i', $msg))
5706
-                return true;
5707
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg))
5708
-                return true;
5709
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg))
5710
-                return true;
5711
-            elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg))
5712
-                return true;
5713
-            elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg))
5714
-                return true; // must accept <img src="http://example.com/aaa.png" />
5715
-            elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg))
5716
-                return true; // must accept <a href="http://example.com/aaa.png" />
5717
-            elseif (preg_match('/<h[0-9]>/i', $msg))
5718
-                return true;
5719
-            elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg))
5720
-                return true;    // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5721
-            elseif (preg_match('/&#[0-9]{2,3};/i', $msg))
5722
-                return true;    // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5946
+        } else {
5947
+            if (preg_match('/<html/i', $msg)) {
5948
+                            return true;
5949
+            } elseif (preg_match('/<body/i', $msg)) {
5950
+                            return true;
5951
+            } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) {
5952
+                            return true;
5953
+            } elseif (preg_match('/<br\/>/i', $msg)) {
5954
+                            return true;
5955
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) {
5956
+                            return true;
5957
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) {
5958
+                            return true;
5959
+            } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) {
5960
+                            return true;
5961
+            } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) {
5962
+                            return true;
5963
+            }
5964
+            // must accept <img src="http://example.com/aaa.png" />
5965
+            elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) {
5966
+                            return true;
5967
+            }
5968
+            // must accept <a href="http://example.com/aaa.png" />
5969
+            elseif (preg_match('/<h[0-9]>/i', $msg)) {
5970
+                            return true;
5971
+            } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) {
5972
+                            return true;
5973
+            }
5974
+            // Html entities names (http://www.w3schools.com/tags/ref_entities.asp)
5975
+            elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) {
5976
+                            return true;
5977
+            }
5978
+            // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp)
5723 5979
 
5724 5980
             return false;
5725 5981
         }
@@ -5871,12 +6127,14 @@  discard block
 block discarded – undo
5871 6127
                 $birthday = AlDolUtils::dol_print_date($object->birth, 'day');
5872 6128
 
5873 6129
                 $substitutionarray['__MEMBER_ID__'] = $object->id;
5874
-                if (method_exists($object, 'getCivilityLabel'))
5875
-                    $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6130
+                if (method_exists($object, 'getCivilityLabel')) {
6131
+                                    $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
6132
+                }
5876 6133
                 $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->firstname) : $object->firstname;
5877 6134
                 $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->lastname) : $object->lastname;
5878
-                if (method_exists($object, 'getFullName'))
5879
-                    $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6135
+                if (method_exists($object, 'getFullName')) {
6136
+                                    $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs);
6137
+                }
5880 6138
                 $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->societe) : $object->societe;
5881 6139
                 $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->address) : $object->address;
5882 6140
                 $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? AlDolUtils::dol_htmlentitiesbr($object->zip) : $object->zip;
@@ -5924,10 +6182,12 @@  discard block
 block discarded – undo
5924 6182
                     $dateplannedstart = '';
5925 6183
                     $datenextexpiration = '';
5926 6184
                     foreach ($object->lines as $line) {
5927
-                        if ($line->date_ouverture_prevue > $dateplannedstart)
5928
-                            $dateplannedstart = $line->date_ouverture_prevue;
5929
-                        if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration))
5930
-                            $datenextexpiration = $line->date_fin_prevue;
6185
+                        if ($line->date_ouverture_prevue > $dateplannedstart) {
6186
+                                                    $dateplannedstart = $line->date_ouverture_prevue;
6187
+                        }
6188
+                        if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) {
6189
+                                                    $datenextexpiration = $line->date_fin_prevue;
6190
+                        }
5931 6191
                     }
5932 6192
                     $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = AlDolUtils::dol_print_date($dateplannedstart, 'dayrfc');
5933 6193
                     $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = AlDolUtils::dol_print_date($dateplannedstart, 'standard');
@@ -5937,8 +6197,9 @@  discard block
 block discarded – undo
5937 6197
 
5938 6198
 // Create dynamic tags for __EXTRAFIELD_FIELD__
5939 6199
                 if ($object->table_element && $object->id > 0) {
5940
-                    if (!is_object($extrafields))
5941
-                        $extrafields = new ExtraFields($db);
6200
+                    if (!is_object($extrafields)) {
6201
+                                            $extrafields = new ExtraFields($db);
6202
+                    }
5942 6203
                     $extrafields->fetch_name_optionals_label($object->table_element, true);
5943 6204
 
5944 6205
                     if ($object->fetch_optionals() > 0) {
@@ -5959,12 +6220,15 @@  discard block
 block discarded – undo
5959 6220
                     require_once DOL_BASE_PATH . '/core/lib/payments.lib.php';
5960 6221
                     $outputlangs->loadLangs(array('paypal', 'other'));
5961 6222
                     $typeforonlinepayment = 'free';
5962
-                    if (is_object($object) && $object->element == 'commande')
5963
-                        $typeforonlinepayment = 'order';
5964
-                    if (is_object($object) && $object->element == 'facture')
5965
-                        $typeforonlinepayment = 'invoice';
5966
-                    if (is_object($object) && $object->element == 'member')
5967
-                        $typeforonlinepayment = 'member';
6223
+                    if (is_object($object) && $object->element == 'commande') {
6224
+                                            $typeforonlinepayment = 'order';
6225
+                    }
6226
+                    if (is_object($object) && $object->element == 'facture') {
6227
+                                            $typeforonlinepayment = 'invoice';
6228
+                    }
6229
+                    if (is_object($object) && $object->element == 'member') {
6230
+                                            $typeforonlinepayment = 'member';
6231
+                    }
5968 6232
                     $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']);
5969 6233
                     $paymenturl = $url;
5970 6234
                 }
@@ -5974,16 +6238,19 @@  discard block
 block discarded – undo
5974 6238
 
5975 6239
                 if (!empty(Globals::$conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') {
5976 6240
                     $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
5977
-                } else
5978
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6241
+                } else {
6242
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
6243
+                }
5979 6244
                 if (!empty(Globals::$conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') {
5980 6245
                     $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
5981
-                } else
5982
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6246
+                } else {
6247
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
6248
+                }
5983 6249
                 if (!empty(Globals::$conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') {
5984 6250
                     $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
5985
-                } else
5986
-                    $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6251
+                } else {
6252
+                                    $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
6253
+                }
5987 6254
             }
5988 6255
         }
5989 6256
         if (empty($exclude) || !in_array('objectamount', $exclude)) {
@@ -5993,18 +6260,22 @@  discard block
 block discarded – undo
5993 6260
             $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : '';
5994 6261
             $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : '';
5995 6262
             $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : '';
5996
-            if ($onlykey != 2 || $mysoc->useLocalTax(1))
5997
-                $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
5998
-            if ($onlykey != 2 || $mysoc->useLocalTax(2))
5999
-                $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6263
+            if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6264
+                            $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : '';
6265
+            }
6266
+            if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6267
+                            $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : '';
6268
+            }
6000 6269
 
6001 6270
             $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6002 6271
             $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6003 6272
             $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)) : '';
6004
-            if ($onlykey != 2 || $mysoc->useLocalTax(1))
6005
-                $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6006
-            if ($onlykey != 2 || $mysoc->useLocalTax(2))
6007
-                $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6273
+            if ($onlykey != 2 || $mysoc->useLocalTax(1)) {
6274
+                            $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6275
+            }
6276
+            if ($onlykey != 2 || $mysoc->useLocalTax(2)) {
6277
+                            $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, Globals::$conf->currency) : '';
6278
+            }
6008 6279
 
6009 6280
 // TODO Add keys for foreign multicurrency
6010 6281
 // For backward compatibility
@@ -6074,23 +6345,27 @@  discard block
 block discarded – undo
6074 6345
     {
6075 6346
         // global Globals::$conf, Globals::$langs;
6076 6347
 
6077
-        if (!is_array($substitutionarray))
6078
-            return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6348
+        if (!is_array($substitutionarray)) {
6349
+                    return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions';
6350
+        }
6079 6351
 
6080
-        if (empty($outputlangs))
6081
-            $outputlangs = Globals::$langs;
6352
+        if (empty($outputlangs)) {
6353
+                    $outputlangs = Globals::$langs;
6354
+        }
6082 6355
 
6083 6356
 // Make substitution for language keys
6084 6357
         if (is_object($outputlangs)) {
6085 6358
             while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) {
6086 6359
                 $msgishtml = 0;
6087
-                if (AlDolUtils::dol_textishtml($text, 1))
6088
-                    $msgishtml = 1;
6360
+                if (AlDolUtils::dol_textishtml($text, 1)) {
6361
+                                    $msgishtml = 1;
6362
+                }
6089 6363
 
6090 6364
 // If key is __(TranslationKey|langfile)__, then force load of langfile.lang
6091 6365
                 $tmp = explode('|', $reg[1]);
6092
-                if (!empty($tmp[1]))
6093
-                    $outputlangs->load($tmp[1]);
6366
+                if (!empty($tmp[1])) {
6367
+                                    $outputlangs->load($tmp[1]);
6368
+                }
6094 6369
 
6095 6370
                 $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? AlDolUtils::dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text);
6096 6371
             }
@@ -6100,23 +6375,29 @@  discard block
 block discarded – undo
6100 6375
 // it is also converted.
6101 6376
         while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) {
6102 6377
             $msgishtml = 0;
6103
-            if (AlDolUtils::dol_textishtml($text, 1))
6104
-                $msgishtml = 1;
6378
+            if (AlDolUtils::dol_textishtml($text, 1)) {
6379
+                            $msgishtml = 1;
6380
+            }
6105 6381
 
6106 6382
             $keyfound = $reg[1];
6107
-            if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound))
6108
-                $newval = '*****forbidden*****';
6109
-            else
6110
-                $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound;
6383
+            if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) {
6384
+                            $newval = '*****forbidden*****';
6385
+            } else {
6386
+                            $newval = empty(Globals::$conf->global->$keyfound) ? '' : Globals::$conf->global->$keyfound;
6387
+            }
6111 6388
             $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? AlDolUtils::dol_htmlentitiesbr($newval) : $newval, $text);
6112 6389
         }
6113 6390
 
6114 6391
 // Make substitition for array $substitutionarray
6115 6392
         foreach ($substitutionarray as $key => $value) {
6116
-            if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6117
-                $value = '';  // Protection
6118
-            if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)))
6119
-                $value = ''; // Protection
6393
+            if ($key == '__SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6394
+                            $value = '';
6395
+            }
6396
+            // Protection
6397
+            if ($key == '__USER_SIGNATURE__' && (!empty(Globals::$conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) {
6398
+                            $value = '';
6399
+            }
6400
+            // Protection
6120 6401
 
6121 6402
             $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
6122 6403
         }
@@ -6162,8 +6443,9 @@  discard block
 block discarded – undo
6162 6443
             $dir = dol_buildpath($reldir, 0);
6163 6444
 
6164 6445
 // Check if directory exists
6165
-            if (!dol_is_dir($dir))
6166
-                continue;
6446
+            if (!dol_is_dir($dir)) {
6447
+                            continue;
6448
+            }
6167 6449
 
6168 6450
             $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_');
6169 6451
             foreach ($substitfiles as $substitfile) {
@@ -6175,8 +6457,9 @@  discard block
 block discarded – undo
6175 6457
                     require_once $dir . $substitfile['name'];
6176 6458
                     // Call the user's function, and only if it is defined
6177 6459
                     $function_name = $module . "_" . $callfunc;
6178
-                    if (function_exists($function_name))
6179
-                        $function_name($substitutionarray, $outputlangs, $object, $parameters);
6460
+                    if (function_exists($function_name)) {
6461
+                                            $function_name($substitutionarray, $outputlangs, $object, $parameters);
6462
+                    }
6180 6463
                 }
6181 6464
             }
6182 6465
         }
@@ -6212,8 +6495,9 @@  discard block
 block discarded – undo
6212 6495
 
6213 6496
         $out = '';
6214 6497
 
6215
-        if (!is_object($outputlangs))
6216
-            $outputlangs = Globals::$langs;
6498
+        if (!is_object($outputlangs)) {
6499
+                    $outputlangs = Globals::$langs;
6500
+        }
6217 6501
 
6218 6502
         if ($date_start && $date_end) {
6219 6503
             $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', AlDolUtils::dol_print_date($date_start, $format, false, $outputlangs), AlDolUtils::dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : '');
@@ -6242,20 +6526,22 @@  discard block
 block discarded – undo
6242 6526
 
6243 6527
         $ret = '';
6244 6528
 // If order not defined, we use the setup
6245
-        if ($nameorder < 0)
6246
-            $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6529
+        if ($nameorder < 0) {
6530
+                    $nameorder = (empty(Globals::$conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0);
6531
+        }
6247 6532
         if ($nameorder && ((string) $nameorder != '2')) {
6248 6533
             $ret .= $firstname;
6249
-            if ($firstname && $lastname)
6250
-                $ret .= ' ';
6534
+            if ($firstname && $lastname) {
6535
+                            $ret .= ' ';
6536
+            }
6251 6537
             $ret .= $lastname;
6252
-        }
6253
-        else if ($nameorder == 2) {
6538
+        } else if ($nameorder == 2) {
6254 6539
             $ret .= $firstname;
6255 6540
         } else {
6256 6541
             $ret .= $lastname;
6257
-            if ($firstname && $lastname)
6258
-                $ret .= ' ';
6542
+            if ($firstname && $lastname) {
6543
+                            $ret .= ' ';
6544
+            }
6259 6545
             $ret .= $firstname;
6260 6546
         }
6261 6547
         return $ret;
@@ -6275,13 +6561,14 @@  discard block
 block discarded – undo
6275 6561
     {
6276 6562
 //DolUtils::dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);		This is not deprecated, it is used by setEventMessages function
6277 6563
         if (!is_array($mesgs)) {  // If mesgs is a string
6278
-            if ($mesgs)
6279
-                $_SESSION['dol_events'][$style][] = $mesgs;
6280
-        }
6281
-        else {      // If mesgs is an array
6564
+            if ($mesgs) {
6565
+                            $_SESSION['dol_events'][$style][] = $mesgs;
6566
+            }
6567
+        } else {      // If mesgs is an array
6282 6568
             foreach ($mesgs as $mesg) {
6283
-                if ($mesg)
6284
-                    $_SESSION['dol_events'][$style][] = $mesg;
6569
+                if ($mesg) {
6570
+                                    $_SESSION['dol_events'][$style][] = $mesg;
6571
+                }
6285 6572
             }
6286 6573
         }
6287 6574
     }
@@ -6301,13 +6588,16 @@  discard block
 block discarded – undo
6301 6588
         if (empty($mesg) && empty($mesgs)) {
6302 6589
             AlDolUtils::dol_syslog("Try to add a message in stack with empty message", LOG_WARNING);
6303 6590
         } else {
6304
-            if (!in_array((string) $style, array('mesgs', 'warnings', 'errors')))
6305
-                dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6306
-            if (empty($mesgs))
6307
-                setEventMessage($mesg, $style);
6308
-            else {
6309
-                if (!empty($mesg) && !in_array($mesg, $mesgs))
6310
-                    setEventMessage($mesg, $style); // Add message string if not already into array
6591
+            if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) {
6592
+                            dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages');
6593
+            }
6594
+            if (empty($mesgs)) {
6595
+                            setEventMessage($mesg, $style);
6596
+            } else {
6597
+                if (!empty($mesg) && !in_array($mesg, $mesgs)) {
6598
+                                    setEventMessage($mesg, $style);
6599
+                }
6600
+                // Add message string if not already into array
6311 6601
                 setEventMessage($mesgs, $style);
6312 6602
             }
6313 6603
         }
@@ -6326,22 +6616,25 @@  discard block
 block discarded – undo
6326 6616
     {
6327 6617
 // Show mesgs
6328 6618
         if (isset($_SESSION['dol_events']['mesgs'])) {
6329
-            if (empty($disabledoutputofmessages))
6330
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6619
+            if (empty($disabledoutputofmessages)) {
6620
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
6621
+            }
6331 6622
             unset($_SESSION['dol_events']['mesgs']);
6332 6623
         }
6333 6624
 
6334 6625
 // Show errors
6335 6626
         if (isset($_SESSION['dol_events']['errors'])) {
6336
-            if (empty($disabledoutputofmessages))
6337
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6627
+            if (empty($disabledoutputofmessages)) {
6628
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
6629
+            }
6338 6630
             unset($_SESSION['dol_events']['errors']);
6339 6631
         }
6340 6632
 
6341 6633
 // Show warnings
6342 6634
         if (isset($_SESSION['dol_events']['warnings'])) {
6343
-            if (empty($disabledoutputofmessages))
6344
-                dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6635
+            if (empty($disabledoutputofmessages)) {
6636
+                            dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
6637
+            }
6345 6638
             unset($_SESSION['dol_events']['warnings']);
6346 6639
         }
6347 6640
     }
@@ -6382,8 +6675,9 @@  discard block
 block discarded – undo
6382 6675
                 foreach ($mesgarray as $message) {
6383 6676
                     $ret++;
6384 6677
                     $out .= Globals::$langs->trans($message);
6385
-                    if ($ret < count($mesgarray))
6386
-                        $out .= "<br>\n";
6678
+                    if ($ret < count($mesgarray)) {
6679
+                                            $out .= "<br>\n";
6680
+                    }
6387 6681
                 }
6388 6682
             }
6389 6683
             if ($mesgstring) {
@@ -6449,8 +6743,9 @@  discard block
 block discarded – undo
6449 6743
      */
6450 6744
     static function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0)
6451 6745
     {
6452
-        if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0))
6453
-            return;
6746
+        if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) {
6747
+                    return;
6748
+        }
6454 6749
 
6455 6750
         $iserror = 0;
6456 6751
         $iswarning = 0;
@@ -6465,14 +6760,17 @@  discard block
 block discarded – undo
6465 6760
                     break;
6466 6761
                 }
6467 6762
             }
6468
-        } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring))
6469
-            $iserror++;
6470
-        else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring))
6471
-            $iswarning++;
6472
-        if ($style == 'error')
6473
-            $iserror++;
6474
-        if ($style == 'warning')
6475
-            $iswarning++;
6763
+        } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) {
6764
+                    $iserror++;
6765
+        } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) {
6766
+                    $iswarning++;
6767
+        }
6768
+        if ($style == 'error') {
6769
+                    $iserror++;
6770
+        }
6771
+        if ($style == 'warning') {
6772
+                    $iswarning++;
6773
+        }
6476 6774
 
6477 6775
         if ($iserror || $iswarning) {
6478 6776
 // Remove div from texts
@@ -6491,8 +6789,9 @@  discard block
 block discarded – undo
6491 6789
                 $mesgarray = $newmesgarray;
6492 6790
             }
6493 6791
             print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded);
6494
-        } else
6495
-            print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6792
+        } else {
6793
+                    print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded);
6794
+        }
6496 6795
     }
6497 6796
 
6498 6797
     /**
@@ -6533,15 +6832,17 @@  discard block
 block discarded – undo
6533 6832
             $sizearray = count($array);
6534 6833
             if ($sizearray > 0) {
6535 6834
                 $temp = array();
6536
-                foreach (array_keys($array) as $key)
6537
-                    $temp[$key] = $array[$key][$index];
6835
+                foreach (array_keys($array) as $key) {
6836
+                                    $temp[$key] = $array[$key][$index];
6837
+                }
6538 6838
 
6539
-                if (!$natsort)
6540
-                    ($order == 'asc') ? asort($temp) : arsort($temp);
6541
-                else {
6839
+                if (!$natsort) {
6840
+                                    ($order == 'asc') ? asort($temp) : arsort($temp);
6841
+                } else {
6542 6842
                     ($case_sensitive) ? natsort($temp) : natcasesort($temp);
6543
-                    if ($order != 'asc')
6544
-                        $temp = array_reverse($temp, true);
6843
+                    if ($order != 'asc') {
6844
+                                            $temp = array_reverse($temp, true);
6845
+                    }
6545 6846
                 }
6546 6847
 
6547 6848
                 $sorted = array();
@@ -6567,23 +6868,38 @@  discard block
 block discarded – undo
6567 6868
         // We must use here a binary strlen static function (so not AlDolUtils::dol_strlen)
6568 6869
         $strLength = AlDolUtils::dol_strlen($str);
6569 6870
         for ($i = 0; $i < $strLength; $i++) {
6570
-            if (ord($str[$i]) < 0x80)
6571
-                continue; // 0bbbbbbb
6572
-            elseif ((ord($str[$i]) & 0xE0) == 0xC0)
6573
-                $n = 1; // 110bbbbb
6574
-            elseif ((ord($str[$i]) & 0xF0) == 0xE0)
6575
-                $n = 2; // 1110bbbb
6576
-            elseif ((ord($str[$i]) & 0xF8) == 0xF0)
6577
-                $n = 3; // 11110bbb
6578
-            elseif ((ord($str[$i]) & 0xFC) == 0xF8)
6579
-                $n = 4; // 111110bb
6580
-            elseif ((ord($str[$i]) & 0xFE) == 0xFC)
6581
-                $n = 5; // 1111110b
6582
-            else
6583
-                return false; // Does not match any model
6871
+            if (ord($str[$i]) < 0x80) {
6872
+                            continue;
6873
+            }
6874
+            // 0bbbbbbb
6875
+            elseif ((ord($str[$i]) & 0xE0) == 0xC0) {
6876
+                            $n = 1;
6877
+            }
6878
+            // 110bbbbb
6879
+            elseif ((ord($str[$i]) & 0xF0) == 0xE0) {
6880
+                            $n = 2;
6881
+            }
6882
+            // 1110bbbb
6883
+            elseif ((ord($str[$i]) & 0xF8) == 0xF0) {
6884
+                            $n = 3;
6885
+            }
6886
+            // 11110bbb
6887
+            elseif ((ord($str[$i]) & 0xFC) == 0xF8) {
6888
+                            $n = 4;
6889
+            }
6890
+            // 111110bb
6891
+            elseif ((ord($str[$i]) & 0xFE) == 0xFC) {
6892
+                            $n = 5;
6893
+            }
6894
+            // 1111110b
6895
+            else {
6896
+                            return false;
6897
+            }
6898
+            // Does not match any model
6584 6899
             for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ?
6585
-                if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80))
6586
-                    return false;
6900
+                if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) {
6901
+                                    return false;
6902
+                }
6587 6903
             }
6588 6904
         }
6589 6905
         return true;
@@ -6601,15 +6917,21 @@  discard block
 block discarded – undo
6601 6917
         // global Globals::$conf;
6602 6918
 
6603 6919
         $tmp = ini_get("unicode.filesystem_encoding");      // Disponible avec PHP 6.0
6604
-        if (empty($tmp) && !empty($_SERVER["WINDIR"]))
6605
-            $tmp = 'iso-8859-1'; // By default for windows
6606
-        if (empty($tmp))
6607
-            $tmp = 'utf-8';          // By default for other
6608
-        if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING))
6609
-            $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING;
6610
-
6611
-        if ($tmp == 'iso-8859-1')
6612
-            return utf8_decode($str);
6920
+        if (empty($tmp) && !empty($_SERVER["WINDIR"])) {
6921
+                    $tmp = 'iso-8859-1';
6922
+        }
6923
+        // By default for windows
6924
+        if (empty($tmp)) {
6925
+                    $tmp = 'utf-8';
6926
+        }
6927
+        // By default for other
6928
+        if (!empty(Globals::$conf->global->MAIN_FILESYSTEM_ENCODING)) {
6929
+                    $tmp = Globals::$conf->global->MAIN_FILESYSTEM_ENCODING;
6930
+        }
6931
+
6932
+        if ($tmp == 'iso-8859-1') {
6933
+                    return utf8_decode($str);
6934
+        }
6613 6935
         return $str;
6614 6936
     }
6615 6937
 
@@ -6630,8 +6952,9 @@  discard block
 block discarded – undo
6630 6952
     {
6631 6953
         // global $cache_codes;
6632 6954
 // If key empty
6633
-        if ($key == '')
6634
-            return '';
6955
+        if ($key == '') {
6956
+                    return '';
6957
+        }
6635 6958
 
6636 6959
 // Check in cache
6637 6960
         if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or ''
@@ -6643,20 +6966,21 @@  discard block
 block discarded – undo
6643 6966
         $sql = "SELECT " . $fieldid . " as valuetoget";
6644 6967
         $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
6645 6968
         $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'";
6646
-        if (!empty($entityfilter))
6647
-            $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6969
+        if (!empty($entityfilter)) {
6970
+                    $sql .= " AND entity IN (" . getEntity($tablename) . ")";
6971
+        }
6648 6972
 
6649 6973
         $resql = $db->query($sql);
6650 6974
         if ($resql) {
6651 6975
             $obj = $db->fetch_object($resql);
6652
-            if ($obj)
6653
-                $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6654
-            else
6655
-                $cache_codes[$tablename][$key][$fieldid] = '';
6976
+            if ($obj) {
6977
+                            $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget;
6978
+            } else {
6979
+                            $cache_codes[$tablename][$key][$fieldid] = '';
6980
+            }
6656 6981
             $db->free($resql);
6657 6982
             return $cache_codes[$tablename][$key][$fieldid];
6658
-        }
6659
-        else {
6983
+        } else {
6660 6984
             return -1;
6661 6985
         }
6662 6986
     }
@@ -6702,16 +7026,17 @@  discard block
 block discarded – undo
6702 7026
         // global $soc;       // For backward compatibility
6703 7027
 //print $s."<br>\n";
6704 7028
         if ($returnvalue) {
6705
-            if ($hideerrors)
6706
-                return @eval('return ' . $s . ';');
6707
-            else
6708
-                return eval('return ' . $s . ';');
6709
-        }
6710
-        else {
6711
-            if ($hideerrors)
6712
-                @eval($s);
6713
-            else
6714
-                eval($s);
7029
+            if ($hideerrors) {
7030
+                            return @eval('return ' . $s . ';');
7031
+            } else {
7032
+                            return eval('return ' . $s . ';');
7033
+            }
7034
+        } else {
7035
+            if ($hideerrors) {
7036
+                            @eval($s);
7037
+            } else {
7038
+                            eval($s);
7039
+            }
6715 7040
         }
6716 7041
     }
6717 7042
 
@@ -6737,8 +7062,9 @@  discard block
 block discarded – undo
6737 7062
     {
6738 7063
         // global Globals::$langs;
6739 7064
 
6740
-        if (empty($codelang))
6741
-            return '';
7065
+        if (empty($codelang)) {
7066
+                    return '';
7067
+        }
6742 7068
 
6743 7069
         if ($codelang == 'auto') {
6744 7070
             return '<span class="fa fa-globe"></span>';
@@ -6752,9 +7078,9 @@  discard block
 block discarded – undo
6752 7078
             'sv_SV' => 'se'
6753 7079
         );
6754 7080
 
6755
-        if (isset($langtocountryflag[$codelang]))
6756
-            $flagImage = $langtocountryflag[$codelang];
6757
-        else {
7081
+        if (isset($langtocountryflag[$codelang])) {
7082
+                    $flagImage = $langtocountryflag[$codelang];
7083
+        } else {
6758 7084
             $tmparray = explode('_', $codelang);
6759 7085
             $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1];
6760 7086
         }
@@ -6772,15 +7098,20 @@  discard block
 block discarded – undo
6772 7098
     {
6773 7099
         // global $mysoc;
6774 7100
 
6775
-        if (strtoupper($countrycode) == 'MQ')
6776
-            return 'fr_CA';
6777
-        if (strtoupper($countrycode) == 'SE')
6778
-            return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
7101
+        if (strtoupper($countrycode) == 'MQ') {
7102
+                    return 'fr_CA';
7103
+        }
7104
+        if (strtoupper($countrycode) == 'SE') {
7105
+                    return 'sv_SE';
7106
+        }
7107
+        // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
6779 7108
         if (strtoupper($countrycode) == 'CH') {
6780
-            if ($mysoc->country_code == 'FR')
6781
-                return 'fr_CH';
6782
-            if ($mysoc->country_code == 'DE')
6783
-                return 'de_CH';
7109
+            if ($mysoc->country_code == 'FR') {
7110
+                            return 'fr_CH';
7111
+            }
7112
+            if ($mysoc->country_code == 'DE') {
7113
+                            return 'de_CH';
7114
+            }
6784 7115
         }
6785 7116
 
6786 7117
 // Locale list taken from:
@@ -6958,8 +7289,9 @@  discard block
 block discarded – undo
6958 7289
         );
6959 7290
 
6960 7291
         $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode);
6961
-        if (in_array($buildprimarykeytotest, $locales))
6962
-            return strtolower($countrycode) . '_' . strtoupper($countrycode);
7292
+        if (in_array($buildprimarykeytotest, $locales)) {
7293
+                    return strtolower($countrycode) . '_' . strtoupper($countrycode);
7294
+        }
6963 7295
 
6964 7296
         foreach ($locales as $locale) {
6965 7297
             $locale_language = locale_get_primary_language($locale);
@@ -7013,18 +7345,21 @@  discard block
 block discarded – undo
7013 7345
 
7014 7346
                 if ($mode == 'add' && !preg_match('/^\-/', $values[1])) {
7015 7347
                     if (count($values) == 6) {       // new declaration with permissions:  $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'
7016
-                        if ($values[0] != $type)
7017
-                            continue;
7348
+                        if ($values[0] != $type) {
7349
+                                                    continue;
7350
+                        }
7018 7351
 
7019 7352
                         if (verifCond($values[4])) {
7020
-                            if ($values[3])
7021
-                                Globals::$langs->load($values[3]);
7353
+                            if ($values[3]) {
7354
+                                                            Globals::$langs->load($values[3]);
7355
+                            }
7022 7356
                             if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
7023 7357
                                 $substitutionarray = array();
7024 7358
                                 complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
7025 7359
                                 $label = make_substitutions($reg[1], $substitutionarray);
7026
-                            } else
7027
-                                $label = Globals::$langs->trans($values[2]);
7360
+                            } else {
7361
+                                                            $label = Globals::$langs->trans($values[2]);
7362
+                            }
7028 7363
 
7029 7364
                             //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1);
7030 7365
                             $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]);
@@ -7032,30 +7367,32 @@  discard block
 block discarded – undo
7032 7367
                             $head[$h][2] = str_replace('+', '', $values[1]);
7033 7368
                             $h++;
7034 7369
                         }
7035
-                    }
7036
-                    else if (count($values) == 5) {       // deprecated
7370
+                    } else if (count($values) == 5) {       // deprecated
7037 7371
                         AlDolUtils::dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING);
7038 7372
 
7039
-                        if ($values[0] != $type)
7040
-                            continue;
7041
-                        if ($values[3])
7042
-                            Globals::$langs->load($values[3]);
7373
+                        if ($values[0] != $type) {
7374
+                                                    continue;
7375
+                        }
7376
+                        if ($values[3]) {
7377
+                                                    Globals::$langs->load($values[3]);
7378
+                        }
7043 7379
                         if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) {
7044 7380
                             $substitutionarray = array();
7045 7381
                             complete_substitutions_array($substitutionarray, Globals::$langs, $object, array('needforkey' => $values[2]));
7046 7382
                             $label = make_substitutions($reg[1], $substitutionarray);
7047
-                        } else
7048
-                            $label = Globals::$langs->trans($values[2]);
7383
+                        } else {
7384
+                                                    $label = Globals::$langs->trans($values[2]);
7385
+                        }
7049 7386
 
7050 7387
                         $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1);
7051 7388
                         $head[$h][1] = $label;
7052 7389
                         $head[$h][2] = str_replace('+', '', $values[1]);
7053 7390
                         $h++;
7054 7391
                     }
7055
-                }
7056
-                else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
7057
-                    if ($values[0] != $type)
7058
-                        continue;
7392
+                } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) {
7393
+                    if ($values[0] != $type) {
7394
+                                            continue;
7395
+                    }
7059 7396
                     $tabname = str_replace('-', '', $values[1]);
7060 7397
                     foreach ($head as $key => $val) {
7061 7398
                         $condition = (!empty($values[3]) ? verifCond($values[3]) : 1);
@@ -7097,10 +7434,11 @@  discard block
 block discarded – undo
7097 7434
         // global $action;
7098 7435
         // global $micro_start_time;
7099 7436
 
7100
-        if ($zone == 'private')
7101
-            print "\n" . '<!-- Common footer for private page -->' . "\n";
7102
-        else
7103
-            print "\n" . '<!-- Common footer for public page -->' . "\n";
7437
+        if ($zone == 'private') {
7438
+                    print "\n" . '<!-- Common footer for private page -->' . "\n";
7439
+        } else {
7440
+                    print "\n" . '<!-- Common footer for public page -->' . "\n";
7441
+        }
7104 7442
 
7105 7443
 // A div to store page_y POST parameter so we can read it using javascript
7106 7444
         print "\n<!-- A div to store page_y POST paramater -->\n";
@@ -7109,8 +7447,9 @@  discard block
 block discarded – undo
7109 7447
         $parameters = array();
7110 7448
         $reshook = Globals::$hookManager->executeHooks('printCommonFooter', $parameters);    // Note that $action and $object may have been modified by some hooks
7111 7449
         if (empty($reshook)) {
7112
-            if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER))
7113
-                print Globals::$conf->global->MAIN_HTML_FOOTER . "\n";
7450
+            if (!empty(Globals::$conf->global->MAIN_HTML_FOOTER)) {
7451
+                            print Globals::$conf->global->MAIN_HTML_FOOTER . "\n";
7452
+            }
7114 7453
 
7115 7454
             print "\n";
7116 7455
             if (!empty(Globals::$conf->use_javascript_ajax)) {
@@ -7133,8 +7472,9 @@  discard block
 block discarded – undo
7133 7472
                     print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n";
7134 7473
                     $relativepathstring = $_SERVER["PHP_SELF"];
7135 7474
                     // Clean $relativepathstring
7136
-                    if (constant('DOL_BASE_URI'))
7137
-                        $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
7475
+                    if (constant('DOL_BASE_URI')) {
7476
+                                            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
7477
+                    }
7138 7478
                     $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
7139 7479
                     $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
7140 7480
                     $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING']));
@@ -7145,14 +7485,17 @@  discard block
 block discarded – undo
7145 7485
                                 $tmpqueryarraytohave = explode('&', $defkey);
7146 7486
                                 $foundintru = 0;
7147 7487
                                 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7148
-                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7149
-                                        $foundintru = 1;
7488
+                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7489
+                                                                            $foundintru = 1;
7490
+                                    }
7150 7491
                                 }
7151
-                                if (!$foundintru)
7152
-                                    $qualified = 1;
7492
+                                if (!$foundintru) {
7493
+                                                                    $qualified = 1;
7494
+                                }
7153 7495
                                 //var_dump($defkey.'-'.$qualified);
7154
-                            } else
7155
-                                $qualified = 1;
7496
+                            } else {
7497
+                                                            $qualified = 1;
7498
+                            }
7156 7499
 
7157 7500
                             if ($qualified) {
7158 7501
                                 foreach ($defval as $paramkey => $paramval) {
@@ -7171,14 +7514,17 @@  discard block
 block discarded – undo
7171 7514
                                 $tmpqueryarraytohave = explode('&', $defkey);
7172 7515
                                 $foundintru = 0;
7173 7516
                                 foreach ($tmpqueryarraytohave as $tmpquerytohave) {
7174
-                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave))
7175
-                                        $foundintru = 1;
7517
+                                    if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) {
7518
+                                                                            $foundintru = 1;
7519
+                                    }
7176 7520
                                 }
7177
-                                if (!$foundintru)
7178
-                                    $qualified = 1;
7521
+                                if (!$foundintru) {
7522
+                                                                    $qualified = 1;
7523
+                                }
7179 7524
                                 //var_dump($defkey.'-'.$qualified);
7180
-                            } else
7181
-                                $qualified = 1;
7525
+                            } else {
7526
+                                                            $qualified = 1;
7527
+                            }
7182 7528
 
7183 7529
                             if ($qualified) {
7184 7530
                                 foreach ($defval as $paramkey => $paramval) {
@@ -7217,8 +7563,9 @@  discard block
 block discarded – undo
7217 7563
                     print "\n";
7218 7564
                     print "/* JS CODE TO ENABLE to add memory info */\n";
7219 7565
                     print 'window.console && console.log("';
7220
-                    if (!empty(Globals::$conf->global->MEMCACHED_SERVER))
7221
-                        print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - ';
7566
+                    if (!empty(Globals::$conf->global->MEMCACHED_SERVER)) {
7567
+                                            print 'MEMCACHED_SERVER=' . Globals::$conf->global->MEMCACHED_SERVER . ' - ';
7568
+                    }
7222 7569
                     print 'MAIN_OPTIMIZE_SPEED=' . (isset(Globals::$conf->global->MAIN_OPTIMIZE_SPEED) ? Globals::$conf->global->MAIN_OPTIMIZE_SPEED : 'off');
7223 7570
                     if (!empty($micro_start_time)) {   // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in// global variable.
7224 7571
                         $micro_end_time = microtime(true);
@@ -7348,8 +7695,9 @@  discard block
 block discarded – undo
7348 7695
 
7349 7696
         $crits = explode(' ', $value);
7350 7697
         $res = '';
7351
-        if (!is_array($fields))
7352
-            $fields = array($fields);
7698
+        if (!is_array($fields)) {
7699
+                    $fields = array($fields);
7700
+        }
7353 7701
 
7354 7702
         $nboffields = count($fields);
7355 7703
         $end2 = count($crits);
@@ -7412,8 +7760,9 @@  discard block
 block discarded – undo
7412 7760
                     $tmpcrits = explode('|', $crit);
7413 7761
                     $i3 = 0;
7414 7762
                     foreach ($tmpcrits as $tmpcrit) {
7415
-                        if (empty($tmpcrit))
7416
-                            continue;
7763
+                        if (empty($tmpcrit)) {
7764
+                                                    continue;
7765
+                        }
7417 7766
 
7418 7767
                         $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : '');
7419 7768
 
@@ -7449,8 +7798,9 @@  discard block
 block discarded – undo
7449 7798
                 }
7450 7799
                 $i++;
7451 7800
             }
7452
-            if ($newres)
7453
-                $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7801
+            if ($newres) {
7802
+                            $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : '');
7803
+            }
7454 7804
             $j++;
7455 7805
         }
7456 7806
         $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")";
@@ -7490,29 +7840,37 @@  discard block
 block discarded – undo
7490 7840
     static function getImageFileNameForSize($file, $extName, $extImgTarget = '')
7491 7841
     {
7492 7842
         $dirName = dirname($file);
7493
-        if ($dirName == '.')
7494
-            $dirName = '';
7843
+        if ($dirName == '.') {
7844
+                    $dirName = '';
7845
+        }
7495 7846
 
7496 7847
         $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case
7497 7848
         $fileName = basename($fileName);
7498 7849
 
7499
-        if (empty($extImgTarget))
7500
-            $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7501
-        if (empty($extImgTarget))
7502
-            $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7503
-        if (empty($extImgTarget))
7504
-            $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7505
-        if (empty($extImgTarget))
7506
-            $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7507
-        if (empty($extImgTarget))
7508
-            $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7509
-
7510
-        if (!$extImgTarget)
7511
-            return $file;
7850
+        if (empty($extImgTarget)) {
7851
+                    $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : '');
7852
+        }
7853
+        if (empty($extImgTarget)) {
7854
+                    $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '');
7855
+        }
7856
+        if (empty($extImgTarget)) {
7857
+                    $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : '');
7858
+        }
7859
+        if (empty($extImgTarget)) {
7860
+                    $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : '');
7861
+        }
7862
+        if (empty($extImgTarget)) {
7863
+                    $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : '');
7864
+        }
7865
+
7866
+        if (!$extImgTarget) {
7867
+                    return $file;
7868
+        }
7512 7869
 
7513 7870
         $subdir = '';
7514
-        if ($extName)
7515
-            $subdir = 'thumbs/';
7871
+        if ($extName) {
7872
+                    $subdir = 'thumbs/';
7873
+        }
7516 7874
 
7517 7875
         return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb
7518 7876
     }
@@ -7530,8 +7888,9 @@  discard block
 block discarded – undo
7530 7888
     {
7531 7889
         // global Globals::$conf, Globals::$langs;
7532 7890
 
7533
-        if (empty(Globals::$conf->use_javascript_ajax))
7534
-            return '';
7891
+        if (empty(Globals::$conf->use_javascript_ajax)) {
7892
+                    return '';
7893
+        }
7535 7894
 
7536 7895
         $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
7537 7896
 //$mime_preview[]='vnd.oasis.opendocument.presentation';
@@ -7539,17 +7898,19 @@  discard block
 block discarded – undo
7539 7898
         $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
7540 7899
 
7541 7900
         if ($alldata == 1) {
7542
-            if ($num_mime !== false)
7543
-                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),);
7544
-            else
7545
-                return array();
7901
+            if ($num_mime !== false) {
7902
+                            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),);
7903
+            } else {
7904
+                            return array();
7905
+            }
7546 7906
         }
7547 7907
 
7548 7908
 // old behavior
7549
-        if ($num_mime !== false)
7550
-            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(Globals::$langs->trans('Preview')) . '\')';
7551
-        else
7552
-            return '';
7909
+        if ($num_mime !== false) {
7910
+                    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(Globals::$langs->trans('Preview')) . '\')';
7911
+        } else {
7912
+                    return '';
7913
+        }
7553 7914
     }
7554 7915
 
7555 7916
     /**
@@ -7567,8 +7928,9 @@  discard block
 block discarded – undo
7567 7928
 				    jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } );
7568 7929
 				});
7569 7930
 		    </script>';
7570
-        if ($addlink)
7571
-            $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>';
7931
+        if ($addlink) {
7932
+                    $out .= ' <a href="' . $addlink . '" target="_blank">' . Globals::$langs->trans("Link") . '</a>';
7933
+        }
7572 7934
         return $out;
7573 7935
     }
7574 7936
 
@@ -7950,8 +8312,9 @@  discard block
 block discarded – undo
7950 8312
         if (!isset($dictvalues[$tablename])) {
7951 8313
             $dictvalues[$tablename] = array();
7952 8314
             $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1';
7953
-            if ($checkentity)
7954
-                $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8315
+            if ($checkentity) {
8316
+                            $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')';
8317
+            }
7955 8318
 
7956 8319
             $resql = $db->query($sql);
7957 8320
             if ($resql) {
@@ -7963,11 +8326,14 @@  discard block
 block discarded – undo
7963 8326
             }
7964 8327
         }
7965 8328
 
7966
-        if (!empty($dictvalues[$tablename][$id]))
7967
-            return $dictvalues[$tablename][$id]->{$field}; // Found
8329
+        if (!empty($dictvalues[$tablename][$id])) {
8330
+                    return $dictvalues[$tablename][$id]->{$field};
8331
+        }
8332
+        // Found
7968 8333
         else { // Not found
7969
-            if ($id > 0)
7970
-                return $id;
8334
+            if ($id > 0) {
8335
+                            return $id;
8336
+            }
7971 8337
             return '';
7972 8338
         }
7973 8339
     }
@@ -7997,8 +8363,9 @@  discard block
 block discarded – undo
7997 8363
                 $b = hexdec($hexb);
7998 8364
             }
7999 8365
             $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0;    // HSL algorithm
8000
-            if ($bright > 0.6)
8001
-                $res = 1;
8366
+            if ($bright > 0.6) {
8367
+                            $res = 1;
8368
+            }
8002 8369
         }
8003 8370
         return $res;
8004 8371
     }
@@ -8016,8 +8383,10 @@  discard block
 block discarded – undo
8016 8383
         // global Globals::$conf;
8017 8384
 //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms'];
8018 8385
 //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal);
8019
-        if (empty($menuentry['enabled']))
8020
-            return 0; // Entry disabled by condition
8386
+        if (empty($menuentry['enabled'])) {
8387
+                    return 0;
8388
+        }
8389
+        // Entry disabled by condition
8021 8390
         if ($type_user && $menuentry['module']) {
8022 8391
             $tmploops = explode('|', $menuentry['module']);
8023 8392
             $found = 0;
@@ -8027,15 +8396,23 @@  discard block
 block discarded – undo
8027 8396
                     break;
8028 8397
                 }
8029 8398
             }
8030
-            if (!$found)
8031
-                return 0; // Entry is for menus all excluded to external users
8032
-        }
8033
-        if (!$menuentry['perms'] && $type_user)
8034
-            return 0;            // No permissions and user is external
8035
-        if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED))
8036
-            return 0; // No permissions and option to hide when not allowed, even for internal user, is on
8037
-        if (!$menuentry['perms'])
8038
-            return 2;               // No permissions and user is external
8399
+            if (!$found) {
8400
+                            return 0;
8401
+            }
8402
+            // Entry is for menus all excluded to external users
8403
+        }
8404
+        if (!$menuentry['perms'] && $type_user) {
8405
+                    return 0;
8406
+        }
8407
+        // No permissions and user is external
8408
+        if (!$menuentry['perms'] && !empty(Globals::$conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) {
8409
+                    return 0;
8410
+        }
8411
+        // No permissions and option to hide when not allowed, even for internal user, is on
8412
+        if (!$menuentry['perms']) {
8413
+                    return 2;
8414
+        }
8415
+        // No permissions and user is external
8039 8416
         return 1;
8040 8417
     }
8041 8418
 
Please login to merge, or discard this patch.