Test Failed
Push — master ( ed0f4f...3aebc2 )
by Alxarafe
43:14
created
dolibarr/htdocs/filefunc.inc.php 1 patch
Braces   +16 added lines, -12 removed lines patch added patch discarded remove patch
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
     if (!empty($_SERVER["CONTEXT_PREFIX"])) {    // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
85 85
         $path = $_SERVER["CONTEXT_PREFIX"];       // example '/dolibarr/' when using an apache alias.
86
-        if (!preg_match('/\/$/', $path))
87
-            $path .= '/';
88
-    }
89
-    else if (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
86
+        if (!preg_match('/\/$/', $path)) {
87
+                    $path .= '/';
88
+        }
89
+    } else if (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
90 90
         // When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process
91 91
         // when using apache alias like '/dolibarr/' that point to htdocs.
92 92
         // Note: If calling page was an index.php not into htdocs (ie comm/index.php, ...), then this redirect will fails,
@@ -100,12 +100,15 @@  discard block
 block discarded – undo
100 100
         $path = '';
101 101
         $i = count($TDir);
102 102
         while ($i--) {
103
-            if (empty($TDir[$i]) || $TDir[$i] == 'htdocs')
104
-                break;
105
-            if ($TDir[$i] == 'dolibarr')
106
-                break;
107
-            if (substr($TDir[$i], -4, 4) == '.php')
108
-                continue;
103
+            if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
104
+                            break;
105
+            }
106
+            if ($TDir[$i] == 'dolibarr') {
107
+                            break;
108
+            }
109
+            if (substr($TDir[$i], -4, 4) == '.php') {
110
+                            continue;
111
+            }
109 112
 
110 113
             $path .= '../';
111 114
         }
@@ -186,8 +189,9 @@  discard block
 block discarded – undo
186 189
         } else {
187 190
             $tmpa = parse_url($_SERVER['HTTP_HOST']);
188 191
             $tmpb = parse_url($_SERVER['HTTP_REFERER']);
189
-            if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host']))
190
-                $csrfattack = true;
192
+            if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) {
193
+                            $csrfattack = true;
194
+            }
191 195
         }
192 196
         if ($csrfattack) {
193 197
             //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
Please login to merge, or discard this patch.
dolibarr/htdocs/core/class/hookmanager.class.php 1 patch
Braces   +27 added lines, -18 removed lines patch added patch discarded remove patch
@@ -138,8 +138,9 @@  discard block
 block discarded – undo
138 138
      */
139 139
     function executeHooks($method, $parameters = array(), &$object = '', &$action = '')
140 140
     {
141
-        if (!is_array($this->hooks) || empty($this->hooks))
142
-            return '';
141
+        if (!is_array($this->hooks) || empty($this->hooks)) {
142
+                    return '';
143
+        }
143 144
 
144 145
         $parameters['context'] = join(':', $this->contextarray);
145 146
         //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']);
@@ -199,8 +200,9 @@  discard block
 block discarded – undo
199 200
                 'setContentSecurityPolicy',
200 201
                 'setHtmlTitle'
201 202
                 )
202
-            ))
203
-            $hooktype = 'addreplace';
203
+            )) {
204
+                    $hooktype = 'addreplace';
205
+        }
204 206
 
205 207
         if ($method == 'insertExtraFields') {
206 208
             $hooktype = 'returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available.
@@ -222,12 +224,14 @@  discard block
 block discarded – undo
222 224
                 foreach ($modules as $module => $actionclassinstance) {
223 225
                     //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."<br>\n";
224 226
                     // test to avoid running twice a hook, when a module implements several active contexts
225
-                    if (in_array($module, $modulealreadyexecuted))
226
-                        continue;
227
+                    if (in_array($module, $modulealreadyexecuted)) {
228
+                                            continue;
229
+                    }
227 230
 
228 231
                     // jump to next module/class if method does not exist
229
-                    if (!method_exists($actionclassinstance, $method))
230
-                        continue;
232
+                    if (!method_exists($actionclassinstance, $method)) {
233
+                                            continue;
234
+                    }
231 235
 
232 236
                     $this->resNbOfHooks++;
233 237
 
@@ -250,24 +254,29 @@  discard block
 block discarded – undo
250 254
                             dol_syslog("Error on hook module=" . $module . ", method " . $method . ", class " . get_class($actionclassinstance) . ", hooktype=" . $hooktype . (empty($this->error) ? '' : " " . $this->error) . (empty($this->errors) ? '' : " " . join(",", $this->errors)), LOG_ERR);
251 255
                         }
252 256
 
253
-                        if (isset($actionclassinstance->results) && is_array($actionclassinstance->results))
254
-                            $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
255
-                        if (!empty($actionclassinstance->resprints))
256
-                            $this->resPrint .= $actionclassinstance->resprints;
257
+                        if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) {
258
+                                                    $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
259
+                        }
260
+                        if (!empty($actionclassinstance->resprints)) {
261
+                                                    $this->resPrint .= $actionclassinstance->resprints;
262
+                        }
257 263
                     }
258 264
                     // Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
259 265
                     else {
260 266
                         // TODO. this test should be done into the method of hook by returning nothing
261
-                        if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number)
262
-                            continue;
267
+                        if (is_array($parameters) && !empty($parameters['special_code']) && $parameters['special_code'] > 3 && $parameters['special_code'] != $actionclassinstance->module_number) {
268
+                                                    continue;
269
+                        }
263 270
 
264 271
                         //dol_syslog("Call method ".$method." of class ".get_class($actionclassinstance).", module=".$module.", hooktype=".$hooktype, LOG_DEBUG);
265 272
                         $resaction = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
266 273
 
267
-                        if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results))
268
-                            $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
269
-                        if (!empty($actionclassinstance->resprints))
270
-                            $this->resPrint .= $actionclassinstance->resprints;
274
+                        if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) {
275
+                                                    $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
276
+                        }
277
+                        if (!empty($actionclassinstance->resprints)) {
278
+                                                    $this->resPrint .= $actionclassinstance->resprints;
279
+                        }
271 280
                         // TODO dead code to remove (do not enable this, but fix hook instead): result must not be a string but an int. you must use $actionclassinstance->resprints to return a string
272 281
                         if (!is_array($resaction) && !is_numeric($resaction)) {
273 282
                             dol_syslog('Error: Bug into hook ' . $method . ' of module class ' . get_class($actionclassinstance) . '. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR);
Please login to merge, or discard this patch.
dolibarr/htdocs/main.inc.php 1 patch
Braces   +415 added lines, -273 removed lines patch added patch discarded remove patch
@@ -213,16 +213,18 @@  discard block
 block discarded – undo
213 213
     foreach ($tmplist as $tmpkey) {
214 214
         $postkey = $tmpautoset[0] . '_' . $tmpkey;
215 215
         //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]);
216
-        if (!empty($_POST[$postkey]))
217
-            $cookiearrayvalue[$tmpkey] = $_POST[$postkey];
216
+        if (!empty($_POST[$postkey])) {
217
+                    $cookiearrayvalue[$tmpkey] = $_POST[$postkey];
218
+        }
218 219
     }
219 220
     $cookiename = $tmpautoset[0];
220 221
     $cookievalue = json_encode($cookiearrayvalue);
221 222
     //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue);
222 223
     setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, false, true); // keep cookie 1 year and add tag httponly
223
-    if (empty($cookievalue))
224
-        unset($_COOKIE[$cookiename]);
225
-}
224
+    if (empty($cookievalue)) {
225
+            unset($_COOKIE[$cookiename]);
226
+    }
227
+    }
226 228
 
227 229
 
228 230
 // Init session. Name of session is specific to Dolibarr instance.
@@ -231,8 +233,9 @@  discard block
 block discarded – undo
231 233
 
232 234
 $sessionname = 'DOLSESSID_' . $prefix;
233 235
 $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix;
234
-if (!empty($_COOKIE[$sessiontimeout]))
236
+if (!empty($_COOKIE[$sessiontimeout])) {
235 237
     ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]);
238
+}
236 239
 session_name($sessionname);
237 240
 session_set_cookie_params(0, '/', null, false, true);   // Add tag httponly on session cookie (same as setting session.cookie_httponly into php.ini). Must be called before the session_start.
238 241
 // This create lock, released when session_write_close() or end of page.
@@ -263,11 +266,13 @@  discard block
 block discarded – undo
263 266
     $conf->browser->layout = $tmp['layout'];     // 'classic', 'phone', 'tablet'
264 267
     //var_dump($conf->browser);
265 268
 
266
-    if ($conf->browser->layout == 'phone')
267
-        $conf->dol_no_mouse_hover = 1;
268
-    if ($conf->browser->layout == 'phone')
269
-        $conf->global->MAIN_TESTMENUHIDER = 1;
270
-}
269
+    if ($conf->browser->layout == 'phone') {
270
+            $conf->dol_no_mouse_hover = 1;
271
+    }
272
+    if ($conf->browser->layout == 'phone') {
273
+            $conf->global->MAIN_TESTMENUHIDER = 1;
274
+    }
275
+    }
271 276
 
272 277
 // Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url)
273 278
 // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off'
@@ -312,10 +317,14 @@  discard block
 block discarded – undo
312 317
 }
313 318
 
314 319
 // Loading of additional presentation includes
315
-if (!defined('NOREQUIREHTML'))
316
-    require_once DOL_BASE_PATH . '/core/class/html.form.class.php';     // Need 660ko memory (800ko in 2.2)
317
-if (!defined('NOREQUIREAJAX') && $conf->use_javascript_ajax)
318
-    require_once DOL_BASE_PATH . '/core/lib/ajax.lib.php'; // Need 22ko memory
320
+if (!defined('NOREQUIREHTML')) {
321
+    require_once DOL_BASE_PATH . '/core/class/html.form.class.php';
322
+}
323
+// Need 660ko memory (800ko in 2.2)
324
+if (!defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) {
325
+    require_once DOL_BASE_PATH . '/core/lib/ajax.lib.php';
326
+}
327
+// Need 22ko memory
319 328
 
320 329
 
321 330
 
@@ -344,8 +353,9 @@  discard block
 block discarded – undo
344 353
 // Creation of a token against CSRF vulnerabilities
345 354
 if (!defined('NOTOKENRENEWAL')) {
346 355
     // roulement des jetons car cree a chaque appel
347
-    if (isset($_SESSION['newtoken']))
348
-        $_SESSION['token'] = $_SESSION['newtoken'];
356
+    if (isset($_SESSION['newtoken'])) {
357
+            $_SESSION['token'] = $_SESSION['newtoken'];
358
+    }
349 359
 
350 360
     // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken']
351 361
     $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number
@@ -367,14 +377,16 @@  discard block
 block discarded – undo
367 377
 }
368 378
 
369 379
 // Disable modules (this must be after session_start and after conf has been loaded)
370
-if (GETPOST('disablemodules', 'alpha'))
380
+if (GETPOST('disablemodules', 'alpha')) {
371 381
     $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha');
382
+}
372 383
 if (!empty($_SESSION["disablemodules"])) {
373 384
     $disabled_modules = explode(',', $_SESSION["disablemodules"]);
374 385
     foreach ($disabled_modules as $module) {
375 386
         if ($module) {
376
-            if (empty($conf->$module))
377
-                $conf->$module = new stdClass();
387
+            if (empty($conf->$module)) {
388
+                            $conf->$module = new stdClass();
389
+            }
378 390
             $conf->$module->enabled = false;
379 391
             if ($module == 'fournisseur') {  // Special case
380 392
                 $conf->supplier_order->enabled = 0;
@@ -396,11 +408,13 @@  discard block
 block discarded – undo
396 408
         $dolibarr_main_authentication = constant('MAIN_AUTHENTICATION_MODE');
397 409
     } else {
398 410
         // Authentication mode
399
-        if (empty($dolibarr_main_authentication))
400
-            $dolibarr_main_authentication = 'http,dolibarr';
411
+        if (empty($dolibarr_main_authentication)) {
412
+                    $dolibarr_main_authentication = 'http,dolibarr';
413
+        }
401 414
         // Authentication mode: forceuser
402
-        if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user))
403
-            $dolibarr_auto_user = 'auto';
415
+        if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
416
+                    $dolibarr_auto_user = 'auto';
417
+        }
404 418
     }
405 419
     // Set authmode
406 420
     $authmode = explode(',', $dolibarr_main_authentication);
@@ -477,35 +491,41 @@  discard block
 block discarded – undo
477 491
                 $hookmanager->initHooks(array('login'));
478 492
                 $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]);
479 493
                 $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action);    // Note that $action and $object may have been modified by some hooks
480
-                if ($reshook < 0)
481
-                    $error++;
494
+                if ($reshook < 0) {
495
+                                    $error++;
496
+                }
482 497
 
483 498
                 // Note: exit is done later
484 499
             }
485 500
         }
486 501
 
487 502
         $allowedmethodtopostusername = 2;
488
-        if (defined('MAIN_AUTHENTICATION_POST_METHOD'))
489
-            $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD');
503
+        if (defined('MAIN_AUTHENTICATION_POST_METHOD')) {
504
+                    $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD');
505
+        }
490 506
         $usertotest = (!empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username", "alpha", $allowedmethodtopostusername));
491 507
         $passwordtotest = GETPOST('password', 'none', $allowedmethodtopostusername);
492 508
         $entitytotest = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1));
493 509
 
494 510
         // Define if we received data to test the login.
495 511
         $goontestloop = false;
496
-        if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode))
497
-            $goontestloop = true;
498
-        if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user))
499
-            $goontestloop = true;
500
-        if (GETPOST("username", "alpha", $allowedmethodtopostusername) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1))
501
-            $goontestloop = true;
512
+        if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
513
+                    $goontestloop = true;
514
+        }
515
+        if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) {
516
+                    $goontestloop = true;
517
+        }
518
+        if (GETPOST("username", "alpha", $allowedmethodtopostusername) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) {
519
+                    $goontestloop = true;
520
+        }
502 521
 
503 522
         if (!is_object($langs)) { // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages.
504 523
             include_once DOL_BASE_PATH . '/core/class/translate.class.php';
505 524
             $langs = new Translate("", $conf);
506 525
             $langcode = (GETPOST('lang', 'aZ09', 1) ? GETPOST('lang', 'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT));
507
-            if (defined('MAIN_LANG_DEFAULT'))
508
-                $langcode = constant('MAIN_LANG_DEFAULT');
526
+            if (defined('MAIN_LANG_DEFAULT')) {
527
+                            $langcode = constant('MAIN_LANG_DEFAULT');
528
+            }
509 529
             $langs->setDefaultLang($langcode);
510 530
         }
511 531
 
@@ -527,8 +547,9 @@  discard block
 block discarded – undo
527 547
                     $datenow = dol_now();
528 548
                     $datefirst = dol_stringtotime($_POST["dst_first"]);
529 549
                     $datesecond = dol_stringtotime($_POST["dst_second"]);
530
-                    if ($datenow >= $datefirst && $datenow < $datesecond)
531
-                        $dol_dst = 1;
550
+                    if ($datenow >= $datefirst && $datenow < $datesecond) {
551
+                                            $dol_dst = 1;
552
+                    }
532 553
                 }
533 554
                 //print $datefirst.'-'.$datesecond.'-'.$datenow.'-'.$dol_tz.'-'.$dol_tzstring.'-'.$dol_dst; exit;
534 555
             }
@@ -540,8 +561,9 @@  discard block
 block discarded – undo
540 561
 
541 562
                 // Bad password. No authmode has found a good password.
542 563
                 // We set a generic message if not defined inside function checkLoginPassEntity or subfunctions
543
-                if (empty($_SESSION["dol_loginmesg"]))
544
-                    $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword");
564
+                if (empty($_SESSION["dol_loginmesg"])) {
565
+                                    $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword");
566
+                }
545 567
 
546 568
                 // Call trigger for the "security events" log
547 569
                 $user->trigger_mesg = $langs->trans("ErrorBadLoginPassword") . ' - login=' . GETPOST("username", "alpha", 2);
@@ -558,8 +580,9 @@  discard block
 block discarded – undo
558 580
                 $hookmanager->initHooks(array('login'));
559 581
                 $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]);
560 582
                 $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action);    // Note that $action and $object may have been modified by some hooks
561
-                if ($reshook < 0)
562
-                    $error++;
583
+                if ($reshook < 0) {
584
+                                    $error++;
585
+                }
563 586
 
564 587
                 // Note: exit is done in next chapter
565 588
             }
@@ -569,10 +592,11 @@  discard block
 block discarded – undo
569 592
         if (!$login || (in_array('ldap', $authmode) && empty($passwordtotest))) { // With LDAP we refused empty password because some LDAP are "opened" for anonymous access so connexion is a success.
570 593
             // No data to test login, so we show the login page
571 594
             dol_syslog("--- Access to " . $_SERVER["PHP_SELF"] . " showing the login form and exit");
572
-            if (defined('NOREDIRECTBYMAINTOLOGIN'))
573
-                return 'ERROR_NOT_LOGGED';
574
-            else
575
-                dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : ''));
595
+            if (defined('NOREDIRECTBYMAINTOLOGIN')) {
596
+                            return 'ERROR_NOT_LOGGED';
597
+            } else {
598
+                            dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : ''));
599
+            }
576 600
             exit;
577 601
         }
578 602
 
@@ -611,21 +635,24 @@  discard block
 block discarded – undo
611 635
             $hookmanager->initHooks(array('login'));
612 636
             $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]);
613 637
             $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action);    // Note that $action and $object may have been modified by some hooks
614
-            if ($reshook < 0)
615
-                $error++;
638
+            if ($reshook < 0) {
639
+                            $error++;
640
+            }
616 641
 
617 642
             $paramsurl = array();
618
-            if (GETPOST('textbrowser', 'int'))
619
-                $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int');
620
-            if (GETPOST('nojs', 'int'))
621
-                $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int');
622
-            if (GETPOST('lang', 'aZ09'))
623
-                $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09');
643
+            if (GETPOST('textbrowser', 'int')) {
644
+                            $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int');
645
+            }
646
+            if (GETPOST('nojs', 'int')) {
647
+                            $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int');
648
+            }
649
+            if (GETPOST('lang', 'aZ09')) {
650
+                            $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09');
651
+            }
624 652
             header('Location: ' . DOL_BASE_URI . '/index.php' . (count($paramsurl) ? '?' . implode('&', $paramsurl) : ''));
625 653
             exit;
626 654
         }
627
-    }
628
-    else {
655
+    } else {
629 656
         // We are already into an authenticated session
630 657
         $login = $_SESSION["dol_login"];
631 658
         $entity = $_SESSION["dol_entity"];
@@ -667,20 +694,23 @@  discard block
 block discarded – undo
667 694
             $hookmanager->initHooks(array('login'));
668 695
             $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]);
669 696
             $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action);    // Note that $action and $object may have been modified by some hooks
670
-            if ($reshook < 0)
671
-                $error++;
697
+            if ($reshook < 0) {
698
+                            $error++;
699
+            }
672 700
 
673 701
             $paramsurl = array();
674
-            if (GETPOST('textbrowser', 'int'))
675
-                $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int');
676
-            if (GETPOST('nojs', 'int'))
677
-                $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int');
678
-            if (GETPOST('lang', 'aZ09'))
679
-                $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09');
702
+            if (GETPOST('textbrowser', 'int')) {
703
+                            $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int');
704
+            }
705
+            if (GETPOST('nojs', 'int')) {
706
+                            $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int');
707
+            }
708
+            if (GETPOST('lang', 'aZ09')) {
709
+                            $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09');
710
+            }
680 711
             header('Location: ' . DOL_BASE_URI . '/index.php' . (count($paramsurl) ? '?' . implode('&', $paramsurl) : ''));
681 712
             exit;
682
-        }
683
-        else {
713
+        } else {
684 714
             // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
685 715
             $hookmanager->initHooks(array('main'));
686 716
 
@@ -689,8 +719,9 @@  discard block
 block discarded – undo
689 719
                 $relativepathstring = preg_replace('/\?.*$/', '', $_SERVER["HTTP_REFERER"]);
690 720
                 $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/', '', $relativepathstring);     // Get full path except host server
691 721
                 // Clean $relativepathstring
692
-                if (constant('DOL_BASE_URI'))
693
-                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
722
+                if (constant('DOL_BASE_URI')) {
723
+                                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
724
+                }
694 725
                 $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
695 726
                 $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
696 727
                 //var_dump($relativepathstring);
@@ -741,16 +772,21 @@  discard block
 block discarded – undo
741 772
         $_SESSION["dol_company"] = $conf->global->MAIN_INFO_SOCIETE_NOM;
742 773
         $_SESSION["dol_entity"] = $conf->entity;
743 774
         // Store value into session (values stored only if defined)
744
-        if (!empty($dol_hide_topmenu))
745
-            $_SESSION['dol_hide_topmenu'] = $dol_hide_topmenu;
746
-        if (!empty($dol_hide_leftmenu))
747
-            $_SESSION['dol_hide_leftmenu'] = $dol_hide_leftmenu;
748
-        if (!empty($dol_optimize_smallscreen))
749
-            $_SESSION['dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
750
-        if (!empty($dol_no_mouse_hover))
751
-            $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover;
752
-        if (!empty($dol_use_jmobile))
753
-            $_SESSION['dol_use_jmobile'] = $dol_use_jmobile;
775
+        if (!empty($dol_hide_topmenu)) {
776
+                    $_SESSION['dol_hide_topmenu'] = $dol_hide_topmenu;
777
+        }
778
+        if (!empty($dol_hide_leftmenu)) {
779
+                    $_SESSION['dol_hide_leftmenu'] = $dol_hide_leftmenu;
780
+        }
781
+        if (!empty($dol_optimize_smallscreen)) {
782
+                    $_SESSION['dol_optimize_smallscreen'] = $dol_optimize_smallscreen;
783
+        }
784
+        if (!empty($dol_no_mouse_hover)) {
785
+                    $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover;
786
+        }
787
+        if (!empty($dol_use_jmobile)) {
788
+                    $_SESSION['dol_use_jmobile'] = $dol_use_jmobile;
789
+        }
754 790
 
755 791
         dol_syslog("This is a new started user session. _SESSION['dol_login']=" . $_SESSION["dol_login"] . " Session id=" . session_id());
756 792
 
@@ -775,8 +811,9 @@  discard block
 block discarded – undo
775 811
         $hookmanager->initHooks(array('login'));
776 812
         $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginfo' => $loginfo);
777 813
         $reshook = $hookmanager->executeHooks('afterLogin', $parameters, $user, $action);    // Note that $action and $object may have been modified by some hooks
778
-        if ($reshook < 0)
779
-            $error++;
814
+        if ($reshook < 0) {
815
+                    $error++;
816
+        }
780 817
 
781 818
         if ($error) {
782 819
             $db->rollback();
@@ -814,10 +851,14 @@  discard block
 block discarded – undo
814 851
      */
815 852
 
816 853
     // Set liste_limit
817
-    if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT))
818
-        $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; // Can be 0
819
-    if (isset($user->conf->PRODUIT_LIMIT_SIZE))
820
-        $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; // Can be 0
854
+    if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) {
855
+            $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT;
856
+    }
857
+    // Can be 0
858
+    if (isset($user->conf->PRODUIT_LIMIT_SIZE)) {
859
+            $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE;
860
+    }
861
+    // Can be 0
821 862
 
822 863
 
823 864
 
@@ -844,8 +885,9 @@  discard block
 block discarded – undo
844 885
     if (!empty($user->conf->MAIN_DISABLE_JAVASCRIPT)) {
845 886
         $conf->use_javascript_ajax = !$user->conf->MAIN_DISABLE_JAVASCRIPT;
846 887
     }
847
-} else
888
+} else {
848 889
     $conf->use_javascript_ajax = 0;
890
+}
849 891
 // Set MAIN_OPTIMIZEFORTEXTBROWSER
850 892
 if (GETPOST('textbrowser', 'int') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || !empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) {   // If we must enable text browser
851 893
     $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 1;
@@ -854,25 +896,32 @@  discard block
 block discarded – undo
854 896
 }
855 897
 
856 898
 // Set terminal output option according to conf->browser.
857
-if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu']))
899
+if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) {
858 900
     $conf->dol_hide_leftmenu = 1;
859
-if (GETPOST('dol_hide_topmenu', 'int') || !empty($_SESSION['dol_hide_topmenu']))
901
+}
902
+if (GETPOST('dol_hide_topmenu', 'int') || !empty($_SESSION['dol_hide_topmenu'])) {
860 903
     $conf->dol_hide_topmenu = 1;
861
-if (GETPOST('dol_optimize_smallscreen', 'int') || !empty($_SESSION['dol_optimize_smallscreen']))
904
+}
905
+if (GETPOST('dol_optimize_smallscreen', 'int') || !empty($_SESSION['dol_optimize_smallscreen'])) {
862 906
     $conf->dol_optimize_smallscreen = 1;
863
-if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover']))
907
+}
908
+if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover'])) {
864 909
     $conf->dol_no_mouse_hover = 1;
865
-if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile']))
910
+}
911
+if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile'])) {
866 912
     $conf->dol_use_jmobile = 1;
867
-if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic')
913
+}
914
+if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') {
868 915
     $conf->dol_no_mouse_hover = 1;
916
+}
869 917
 if ((!empty($conf->browser->layout) && $conf->browser->layout == 'phone') || (!empty($_SESSION['dol_screenwidth']) && $_SESSION['dol_screenwidth'] < 400) || (!empty($_SESSION['dol_screenheight']) && $_SESSION['dol_screenheight'] < 400)
870 918
 ) {
871 919
     $conf->dol_optimize_smallscreen = 1;
872 920
 }
873 921
 // If we force to use jmobile, then we reenable javascript
874
-if (!empty($conf->dol_use_jmobile))
922
+if (!empty($conf->dol_use_jmobile)) {
875 923
     $conf->use_javascript_ajax = 1;
924
+}
876 925
 // Replace themes bugged with jmobile with eldy
877 926
 if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok'))) {
878 927
     $conf->theme = 'eldy';
@@ -896,8 +945,9 @@  discard block
 block discarded – undo
896 945
 if (!defined('NOLOGIN')) {
897 946
     // If the login is not recovered, it is identified with an account that does not exist.
898 947
     // Hacking attempt?
899
-    if (!$user->login)
900
-        accessforbidden();
948
+    if (!$user->login) {
949
+            accessforbidden();
950
+    }
901 951
 
902 952
     // Check if user is active
903 953
     if ($user->statut < 1) {
@@ -972,15 +1022,18 @@  discard block
 block discarded – undo
972 1022
 
973 1023
     // Load the menu manager (only if not already done)
974 1024
     $file_menu = $conf->standard_menu;
975
-    if (GETPOST('menu', 'alpha'))
976
-        $file_menu = GETPOST('menu', 'alpha');     // example: menu=eldy_menu.php
1025
+    if (GETPOST('menu', 'alpha')) {
1026
+            $file_menu = GETPOST('menu', 'alpha');
1027
+    }
1028
+    // example: menu=eldy_menu.php
977 1029
     if (!class_exists('MenuManager')) {
978 1030
         $menufound = 0;
979 1031
         $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
980 1032
         foreach ($dirmenus as $dirmenu) {
981 1033
             $menufound = dol_include_once($dirmenu . "standard/" . $file_menu);
982
-            if (class_exists('MenuManager'))
983
-                break;
1034
+            if (class_exists('MenuManager')) {
1035
+                            break;
1036
+            }
984 1037
         }
985 1038
         if (!class_exists('MenuManager')) { // If failed to include, we try with standard eldy_menu.php
986 1039
             dol_syslog("You define a menu manager '" . $file_menu . "' that can not be loaded.", LOG_WARNING);
@@ -1054,10 +1107,11 @@  discard block
 block discarded – undo
1054 1107
 {
1055 1108
     global $db, $conf, $hookmanager;
1056 1109
 
1057
-    if ($contenttype == 'text/html')
1058
-        header("Content-Type: text/html; charset=" . $conf->file->character_set_client);
1059
-    else
1060
-        header("Content-Type: " . $contenttype);
1110
+    if ($contenttype == 'text/html') {
1111
+            header("Content-Type: text/html; charset=" . $conf->file->character_set_client);
1112
+    } else {
1113
+            header("Content-Type: " . $contenttype);
1114
+    }
1061 1115
     // Security options
1062 1116
     header("X-Content-Type-Options: nosniff");  // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
1063 1117
     header("X-Frame-Options: SAMEORIGIN");      // Frames allowed only if on same domain (stop some XSS attacks)
@@ -1071,16 +1125,21 @@  discard block
 block discarded – undo
1071 1125
         //else $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
1072 1126
         $contentsecuritypolicy = $conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY;
1073 1127
 
1074
-        if (!is_object($hookmanager))
1075
-            $hookmanager = new HookManager($db);
1128
+        if (!is_object($hookmanager)) {
1129
+                    $hookmanager = new HookManager($db);
1130
+        }
1076 1131
         $hookmanager->initHooks("main");
1077 1132
 
1078 1133
         $parameters = array('contentsecuritypolicy' => $contentsecuritypolicy);
1079 1134
         $result = $hookmanager->executeHooks('setContentSecurityPolicy', $parameters);    // Note that $action and $object may have been modified by some hooks
1080
-        if ($result > 0)
1081
-            $contentsecuritypolicy = $hookmanager->resPrint; // Replace CSP
1082
-        else
1083
-            $contentsecuritypolicy .= $hookmanager->resPrint;    // Concat CSP
1135
+        if ($result > 0) {
1136
+                    $contentsecuritypolicy = $hookmanager->resPrint;
1137
+        }
1138
+        // Replace CSP
1139
+        else {
1140
+                    $contentsecuritypolicy .= $hookmanager->resPrint;
1141
+        }
1142
+        // Concat CSP
1084 1143
 
1085 1144
         if (!empty($contentsecuritypolicy)) {
1086 1145
             // For example, to restrict 'script', 'object', 'frames' or 'img' to some domains:
@@ -1127,18 +1186,20 @@  discard block
 block discarded – undo
1127 1186
     }
1128 1187
     print '<!doctype html>' . "\n";
1129 1188
 
1130
-    if (!empty($conf->global->MAIN_USE_CACHE_MANIFEST))
1131
-        print '<html lang="' . substr($langs->defaultlang, 0, 2) . '" manifest="' . DOL_BASE_URI . '/cache.manifest">' . "\n";
1132
-    else
1133
-        print '<html lang="' . substr($langs->defaultlang, 0, 2) . '">' . "\n";
1189
+    if (!empty($conf->global->MAIN_USE_CACHE_MANIFEST)) {
1190
+            print '<html lang="' . substr($langs->defaultlang, 0, 2) . '" manifest="' . DOL_BASE_URI . '/cache.manifest">' . "\n";
1191
+    } else {
1192
+            print '<html lang="' . substr($langs->defaultlang, 0, 2) . '">' . "\n";
1193
+    }
1134 1194
     //print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n";
1135 1195
     if (empty($disablehead)) {
1136 1196
         $ext = 'layout=' . $conf->browser->layout . '&version=' . urlencode(DOL_VERSION);
1137 1197
 
1138 1198
         print "<head>\n";
1139 1199
 
1140
-        if (GETPOST('dol_basehref', 'alpha'))
1141
-            print '<base href="' . dol_escape_htmltag(GETPOST('dol_basehref', 'alpha')) . '">' . "\n";
1200
+        if (GETPOST('dol_basehref', 'alpha')) {
1201
+                    print '<base href="' . dol_escape_htmltag(GETPOST('dol_basehref', 'alpha')) . '">' . "\n";
1202
+        }
1142 1203
 
1143 1204
         // Displays meta
1144 1205
         print '<meta charset="UTF-8">' . "\n";
@@ -1148,10 +1209,13 @@  discard block
 block discarded – undo
1148 1209
 
1149 1210
         // Favicon
1150 1211
         $favicon = dol_buildpath('/theme/' . $conf->theme . '/img/favicon.ico', 1);
1151
-        if (!empty($conf->global->MAIN_FAVICON_URL))
1152
-            $favicon = $conf->global->MAIN_FAVICON_URL;
1153
-        if (empty($conf->dol_use_jmobile))
1154
-            print '<link rel="shortcut icon" type="image/x-icon" href="' . $favicon . '"/>' . "\n"; // Not required into an Android webview
1212
+        if (!empty($conf->global->MAIN_FAVICON_URL)) {
1213
+                    $favicon = $conf->global->MAIN_FAVICON_URL;
1214
+        }
1215
+        if (empty($conf->dol_use_jmobile)) {
1216
+                    print '<link rel="shortcut icon" type="image/x-icon" href="' . $favicon . '"/>' . "\n";
1217
+        }
1218
+        // Not required into an Android webview
1155 1219
 
1156 1220
 
1157 1221
 
@@ -1161,47 +1225,59 @@  discard block
 block discarded – undo
1161 1225
         //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1">'."\n";
1162 1226
         //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="author" title="Dolibarr Development Team" href="https://www.dolibarr.org">'."\n";
1163 1227
         // Auto refresh page
1164
-        if (GETPOST('autorefresh', 'int') > 0)
1165
-            print '<meta http-equiv="refresh" content="' . GETPOST('autorefresh', 'int') . '">';
1228
+        if (GETPOST('autorefresh', 'int') > 0) {
1229
+                    print '<meta http-equiv="refresh" content="' . GETPOST('autorefresh', 'int') . '">';
1230
+        }
1166 1231
 
1167 1232
         // Displays title
1168 1233
         $appli = constant('DOL_APPLICATION_TITLE');
1169
-        if (!empty($conf->global->MAIN_APPLICATION_TITLE))
1170
-            $appli = $conf->global->MAIN_APPLICATION_TITLE;
1234
+        if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1235
+                    $appli = $conf->global->MAIN_APPLICATION_TITLE;
1236
+        }
1171 1237
 
1172 1238
         print '<title>';
1173 1239
         $titletoshow = '';
1174
-        if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/', $conf->global->MAIN_HTML_TITLE))
1175
-            $titletoshow = dol_htmlentities($title);
1176
-        else if ($title)
1177
-            $titletoshow = dol_htmlentities($appli . ' - ' . $title);
1178
-        else
1179
-            $titletoshow = dol_htmlentities($appli);
1180
-
1181
-        if (!is_object($hookmanager))
1182
-            $hookmanager = new HookManager($db);
1240
+        if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/', $conf->global->MAIN_HTML_TITLE)) {
1241
+                    $titletoshow = dol_htmlentities($title);
1242
+        } else if ($title) {
1243
+                    $titletoshow = dol_htmlentities($appli . ' - ' . $title);
1244
+        } else {
1245
+                    $titletoshow = dol_htmlentities($appli);
1246
+        }
1247
+
1248
+        if (!is_object($hookmanager)) {
1249
+                    $hookmanager = new HookManager($db);
1250
+        }
1183 1251
         $hookmanager->initHooks("main");
1184 1252
         $parameters = array('title' => $titletoshow);
1185 1253
         $result = $hookmanager->executeHooks('setHtmlTitle', $parameters);  // Note that $action and $object may have been modified by some hooks
1186
-        if ($result > 0)
1187
-            $titletoshow = $hookmanager->resPrint;    // Replace Title to show
1188
-        else
1189
-            $titletoshow .= $hookmanager->resPrint;      // Concat to Title to show
1254
+        if ($result > 0) {
1255
+                    $titletoshow = $hookmanager->resPrint;
1256
+        }
1257
+        // Replace Title to show
1258
+        else {
1259
+                    $titletoshow .= $hookmanager->resPrint;
1260
+        }
1261
+        // Concat to Title to show
1190 1262
 
1191 1263
         print $titletoshow;
1192 1264
         print '</title>';
1193 1265
 
1194 1266
         print "\n";
1195 1267
 
1196
-        if (GETPOST('version', 'int'))
1197
-            $ext = 'version=' . GETPOST('version', 'int'); // usefull to force no cache on css/js
1198
-        if (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER))
1199
-            $ext .= '&testmenuhider=' . (GETPOST('testmenuhider', 'int') ? GETPOST('testmenuhider', 'int') : $conf->global->MAIN_TESTMENUHIDER);
1268
+        if (GETPOST('version', 'int')) {
1269
+                    $ext = 'version=' . GETPOST('version', 'int');
1270
+        }
1271
+        // usefull to force no cache on css/js
1272
+        if (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)) {
1273
+                    $ext .= '&testmenuhider=' . (GETPOST('testmenuhider', 'int') ? GETPOST('testmenuhider', 'int') : $conf->global->MAIN_TESTMENUHIDER);
1274
+        }
1200 1275
 
1201 1276
         $themeparam = '&lang=' . $langs->defaultlang . '&amp;theme=' . $conf->theme . (GETPOST('optioncss', 'aZ09') ? '&amp;optioncss=' . GETPOST('optioncss', 'aZ09', 1) : '') . '&amp;userid=' . $user->id . '&amp;entity=' . $conf->entity;
1202 1277
         $themeparam .= ($ext ? '&amp;' . $ext : '');
1203
-        if (!empty($_SESSION['dol_resetcache']))
1204
-            $themeparam .= '&amp;dol_resetcache=' . $_SESSION['dol_resetcache'];
1278
+        if (!empty($_SESSION['dol_resetcache'])) {
1279
+                    $themeparam .= '&amp;dol_resetcache=' . $_SESSION['dol_resetcache'];
1280
+        }
1205 1281
         if (GETPOST('dol_hide_topmenu', 'int')) {
1206 1282
             $themeparam .= '&amp;dol_hide_topmenu=' . GETPOST('dol_hide_topmenu', 'int');
1207 1283
         }
@@ -1222,14 +1298,21 @@  discard block
 block discarded – undo
1222 1298
         if (!defined('DISABLE_JQUERY') && !$disablejs && $conf->use_javascript_ajax) {
1223 1299
             print '<!-- Includes CSS for JQuery (Ajax library) -->' . "\n";
1224 1300
             $jquerytheme = 'base';
1225
-            if (!empty($conf->global->MAIN_USE_JQUERY_THEME))
1226
-                $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1227
-            if (constant('JS_JQUERY_UI'))
1228
-                print '<link rel="stylesheet" type="text/css" href="' . JS_JQUERY_UI . 'css/' . $jquerytheme . '/jquery-ui.min.css' . ($ext ? '?' . $ext : '') . '">' . "\n";  // JQuery
1229
-            else
1230
-                print '<link rel="stylesheet" type="text/css" href="' . DOL_BASE_URI . '/includes/jquery/css/' . $jquerytheme . '/jquery-ui.css' . ($ext ? '?' . $ext : '') . '">' . "\n";    // JQuery
1231
-            if (!defined('DISABLE_JQUERY_JNOTIFY'))
1232
-                print '<link rel="stylesheet" type="text/css" href="' . DOL_BASE_URI . '/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css' . ($ext ? '?' . $ext : '') . '">' . "\n";          // JNotify
1301
+            if (!empty($conf->global->MAIN_USE_JQUERY_THEME)) {
1302
+                            $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME;
1303
+            }
1304
+            if (constant('JS_JQUERY_UI')) {
1305
+                            print '<link rel="stylesheet" type="text/css" href="' . JS_JQUERY_UI . 'css/' . $jquerytheme . '/jquery-ui.min.css' . ($ext ? '?' . $ext : '') . '">' . "\n";
1306
+            }
1307
+            // JQuery
1308
+            else {
1309
+                            print '<link rel="stylesheet" type="text/css" href="' . DOL_BASE_URI . '/includes/jquery/css/' . $jquerytheme . '/jquery-ui.css' . ($ext ? '?' . $ext : '') . '">' . "\n";
1310
+            }
1311
+            // JQuery
1312
+            if (!defined('DISABLE_JQUERY_JNOTIFY')) {
1313
+                            print '<link rel="stylesheet" type="text/css" href="' . DOL_BASE_URI . '/includes/jquery/plugins/jnotify/jquery.jnotify-alt.min.css' . ($ext ? '?' . $ext : '') . '">' . "\n";
1314
+            }
1315
+            // JNotify
1233 1316
             if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))) {     // jQuery plugin "mutiselect", "multiple-select", "select2"...
1234 1317
                 $tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ? constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
1235 1318
                 print '<link rel="stylesheet" type="text/css" href="' . DOL_BASE_URI . '/includes/jquery/plugins/' . $tmpplugin . '/dist/css/' . $tmpplugin . '.css' . ($ext ? '?' . $ext : '') . '">' . "\n";
@@ -1257,8 +1340,9 @@  discard block
 block discarded – undo
1257 1340
 
1258 1341
         //print 'themepath='.$themepath.' themeparam='.$themeparam;exit;
1259 1342
         print '<link rel="stylesheet" type="text/css" href="' . $themepath . $themeparam . '">' . "\n";
1260
-        if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME))
1261
-            print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->' . "\n" . '<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">' . "\n";
1343
+        if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) {
1344
+                    print '<!-- Includes CSS that does not exists as a workaround of flash bug of chrome -->' . "\n" . '<link rel="stylesheet" type="text/css" href="filethatdoesnotexiststosolvechromeflashbug">' . "\n";
1345
+        }
1262 1346
 
1263 1347
         // CSS forced by modules (relative url starting with /)
1264 1348
         if (!empty($conf->modules_parts['css'])) {
@@ -1266,13 +1350,15 @@  discard block
 block discarded – undo
1266 1350
             foreach ($arraycss as $modcss => $filescss) {
1267 1351
                 $filescss = (array) $filescss; // To be sure filecss is an array
1268 1352
                 foreach ($filescss as $cssfile) {
1269
-                    if (empty($cssfile))
1270
-                        dol_syslog("Warning: module " . $modcss . " declared a css path file into its descriptor that is empty.", LOG_WARNING);
1353
+                    if (empty($cssfile)) {
1354
+                                            dol_syslog("Warning: module " . $modcss . " declared a css path file into its descriptor that is empty.", LOG_WARNING);
1355
+                    }
1271 1356
                     // cssfile is a relative path
1272 1357
                     print '<!-- Includes CSS added by module ' . $modcss . ' -->' . "\n" . '<link rel="stylesheet" type="text/css" href="' . dol_buildpath($cssfile, 1);
1273 1358
                     // We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters, so browser cache is not used.
1274
-                    if (!preg_match('/\.css$/i', $cssfile))
1275
-                        print $themeparam;
1359
+                    if (!preg_match('/\.css$/i', $cssfile)) {
1360
+                                            print $themeparam;
1361
+                    }
1276 1362
                     print '">' . "\n";
1277 1363
                 }
1278 1364
             }
@@ -1282,8 +1368,9 @@  discard block
 block discarded – undo
1282 1368
             foreach ($arrayofcss as $cssfile) {
1283 1369
                 print '<!-- Includes CSS added by page -->' . "\n" . '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath($cssfile, 1);
1284 1370
                 // We add params only if page is not static, because some web server setup does not return content type text/css if url has parameters and browser cache is not used.
1285
-                if (!preg_match('/\.css$/i', $cssfile))
1286
-                    print $themeparam;
1371
+                if (!preg_match('/\.css$/i', $cssfile)) {
1372
+                                    print $themeparam;
1373
+                }
1287 1374
                 print '">' . "\n";
1288 1375
             }
1289 1376
         }
@@ -1292,22 +1379,26 @@  discard block
 block discarded – undo
1292 1379
         if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) {
1293 1380
             // JQuery. Must be before other includes
1294 1381
             print '<!-- Includes JS for JQuery -->' . "\n";
1295
-            if (defined('JS_JQUERY') && constant('JS_JQUERY'))
1296
-                print '<script type="text/javascript" src="' . JS_JQUERY . 'jquery.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1297
-            else
1298
-                print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1382
+            if (defined('JS_JQUERY') && constant('JS_JQUERY')) {
1383
+                            print '<script type="text/javascript" src="' . JS_JQUERY . 'jquery.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1384
+            } else {
1385
+                            print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1386
+            }
1299 1387
             if (!empty($conf->global->MAIN_FEATURES_LEVEL) && !defined('JS_JQUERY_MIGRATE_DISABLED')) {
1300
-                if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE'))
1301
-                    print '<script type="text/javascript" src="' . JS_JQUERY_MIGRATE . 'jquery-migrate.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1302
-                else
1303
-                    print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery-migrate.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1304
-            }
1305
-            if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI'))
1306
-                print '<script type="text/javascript" src="' . JS_JQUERY_UI . 'jquery-ui.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1307
-            else
1308
-                print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery-ui.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1309
-            if (!defined('DISABLE_JQUERY_TABLEDND'))
1310
-                print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/plugins/tablednd/jquery.tablednd.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1388
+                if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) {
1389
+                                    print '<script type="text/javascript" src="' . JS_JQUERY_MIGRATE . 'jquery-migrate.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1390
+                } else {
1391
+                                    print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery-migrate.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1392
+                }
1393
+            }
1394
+            if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) {
1395
+                            print '<script type="text/javascript" src="' . JS_JQUERY_UI . 'jquery-ui.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1396
+            } else {
1397
+                            print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/js/jquery-ui.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1398
+            }
1399
+            if (!defined('DISABLE_JQUERY_TABLEDND')) {
1400
+                            print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/plugins/tablednd/jquery.tablednd.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
1401
+            }
1311 1402
             // jQuery jnotify
1312 1403
             if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY')) {
1313 1404
                 print '<script type="text/javascript" src="' . DOL_BASE_URI . '/includes/jquery/plugins/jnotify/jquery.jnotify.min.js' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
@@ -1378,10 +1469,12 @@  discard block
 block discarded – undo
1378 1469
             // Browser notifications
1379 1470
             if (!defined('DISABLE_BROWSER_NOTIF')) {
1380 1471
                 $enablebrowsernotif = false;
1381
-                if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER))
1382
-                    $enablebrowsernotif = true;
1383
-                if ($conf->browser->layout == 'phone')
1384
-                    $enablebrowsernotif = false;
1472
+                if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) {
1473
+                                    $enablebrowsernotif = true;
1474
+                }
1475
+                if ($conf->browser->layout == 'phone') {
1476
+                                    $enablebrowsernotif = false;
1477
+                }
1385 1478
                 if ($enablebrowsernotif) {
1386 1479
                     print '<!-- Includes JS of Dolibarr (brwoser layout = ' . $conf->browser->layout . ')-->' . "\n";
1387 1480
                     //print '<script type="text/javascript" src="' . DOL_BASE_URI . '/core/js/lib_notification.js.php' . ($ext ? '?' . $ext : '') . '"></script>' . "\n";
@@ -1418,10 +1511,12 @@  discard block
 block discarded – undo
1418 1511
             }
1419 1512
         }
1420 1513
 
1421
-        if (!empty($head))
1422
-            print $head . "\n";
1423
-        if (!empty($conf->global->MAIN_HTML_HEADER))
1424
-            print $conf->global->MAIN_HTML_HEADER . "\n";
1514
+        if (!empty($head)) {
1515
+                    print $head . "\n";
1516
+        }
1517
+        if (!empty($conf->global->MAIN_HTML_HEADER)) {
1518
+                    print $conf->global->MAIN_HTML_HEADER . "\n";
1519
+        }
1425 1520
 
1426 1521
         print "<!-- Alixar debugBar header -->";
1427 1522
         print Debug::getRenderHeader(); // Includes Alixar debugBar header
@@ -1486,15 +1581,20 @@  discard block
 block discarded – undo
1486 1581
         if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1487 1582
             $appli = $conf->global->MAIN_APPLICATION_TITLE;
1488 1583
             if (preg_match('/\d\.\d/', $appli)) {
1489
-                if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli))
1490
-                    $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core
1491
-            } else
1492
-                $appli .= " " . DOL_VERSION;
1493
-        } else
1494
-            $appli .= " " . DOL_VERSION;
1584
+                if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) {
1585
+                                    $appli .= " (" . DOL_VERSION . ")";
1586
+                }
1587
+                // If new title contains a version that is different than core
1588
+            } else {
1589
+                            $appli .= " " . DOL_VERSION;
1590
+            }
1591
+        } else {
1592
+                    $appli .= " " . DOL_VERSION;
1593
+        }
1495 1594
 
1496
-        if (!empty($conf->global->MAIN_FEATURES_LEVEL))
1497
-            $appli .= "<br>" . $langs->trans("LevelOfFeature") . ': ' . $conf->global->MAIN_FEATURES_LEVEL;
1595
+        if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
1596
+                    $appli .= "<br>" . $langs->trans("LevelOfFeature") . ': ' . $conf->global->MAIN_FEATURES_LEVEL;
1597
+        }
1498 1598
 
1499 1599
         $logouttext = '';
1500 1600
         if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
@@ -1532,12 +1632,15 @@  discard block
 block discarded – undo
1532 1632
         $parameters = array();
1533 1633
         $result = $hookmanager->executeHooks('printTopRightMenu', $parameters);    // Note that $action and $object may have been modified by some hooks
1534 1634
         if (is_numeric($result)) {
1535
-            if ($result == 0)
1536
-                $toprightmenu .= $hookmanager->resPrint;  // add
1537
-            else
1538
-                $toprightmenu = $hookmanager->resPrint;      // replace
1539
-        }
1540
-        else {
1635
+            if ($result == 0) {
1636
+                            $toprightmenu .= $hookmanager->resPrint;
1637
+            }
1638
+            // add
1639
+            else {
1640
+                            $toprightmenu = $hookmanager->resPrint;
1641
+            }
1642
+            // replace
1643
+        } else {
1541 1644
             $toprightmenu .= $result; // For backward compatibility
1542 1645
         }
1543 1646
 
@@ -1557,8 +1660,9 @@  discard block
 block discarded – undo
1557 1660
 
1558 1661
             if (is_array($_POST)) {
1559 1662
                 foreach ($_POST as $key => $value) {
1560
-                    if ($key !== 'action' && $key !== 'password' && !is_array($value))
1561
-                        $qs .= '&' . $key . '=' . urlencode($value);
1663
+                    if ($key !== 'action' && $key !== 'password' && !is_array($value)) {
1664
+                                            $qs .= '&' . $key . '=' . urlencode($value);
1665
+                    }
1562 1666
                 }
1563 1667
             }
1564 1668
             $qs .= (($qs && $morequerystring) ? '&' : '') . $morequerystring;
@@ -1577,8 +1681,9 @@  discard block
 block discarded – undo
1577 1681
             $helppage = '';
1578 1682
             $mode = '';
1579 1683
 
1580
-            if (empty($helppagename))
1581
-                $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1684
+            if (empty($helppagename)) {
1685
+                            $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios';
1686
+            }
1582 1687
 
1583 1688
             // Get helpbaseurl, helppage and mode from helppagename and langs
1584 1689
             $arrayres = getHelpParamFor($helppagename, $langs);
@@ -1595,13 +1700,15 @@  discard block
 block discarded – undo
1595 1700
                 }
1596 1701
                 $title = $appli . '<br>';
1597 1702
                 $title .= $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage');
1598
-                if ($mode == 'wiki')
1599
-                    $title .= ' - ' . $langs->trans("PageWiki") . ' &quot;' . dol_escape_htmltag(strtr($helppage, '_', ' ')) . '&quot;';
1703
+                if ($mode == 'wiki') {
1704
+                                    $title .= ' - ' . $langs->trans("PageWiki") . ' &quot;' . dol_escape_htmltag(strtr($helppage, '_', ' ')) . '&quot;';
1705
+                }
1600 1706
                 $text .= '<a class="help" target="_blank" rel="noopener" href="';
1601
-                if ($mode == 'wiki')
1602
-                    $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage)));
1603
-                else
1604
-                    $text .= sprintf($helpbaseurl, $helppage);
1707
+                if ($mode == 'wiki') {
1708
+                                    $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage)));
1709
+                } else {
1710
+                                    $text .= sprintf($helpbaseurl, $helppage);
1711
+                }
1605 1712
                 $text .= '">';
1606 1713
                 //$text.=img_picto('', 'helpdoc_top').' ';
1607 1714
                 $text .= '<span class="fa fa-question-circle atoplogin"></span>';
@@ -1628,9 +1735,10 @@  discard block
 block discarded – undo
1628 1735
         print "<!-- End top horizontal menu -->\n\n";
1629 1736
     }
1630 1737
 
1631
-    if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile))
1632
-        print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">';
1633
-}
1738
+    if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) {
1739
+            print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">';
1740
+    }
1741
+    }
1634 1742
 
1635 1743
 /**
1636 1744
  *  Show left menu bar
@@ -1654,8 +1762,9 @@  discard block
 block discarded – undo
1654 1762
     $searchform = '';
1655 1763
     $bookmarks = '';
1656 1764
 
1657
-    if (!empty($menu_array_before))
1658
-        dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1765
+    if (!empty($menu_array_before)) {
1766
+            dol_syslog("Deprecated parameter menu_array_before was used when calling main::left_menu function. Menu entries of module should now be defined into module descriptor and not provided when calling left_menu.", LOG_WARNING);
1767
+    }
1659 1768
 
1660 1769
     if (empty($conf->dol_hide_leftmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) {
1661 1770
         // Instantiate hooks of thirdparty module
@@ -1663,8 +1772,10 @@  discard block
 block discarded – undo
1663 1772
 
1664 1773
         print "\n" . '<!-- Begin side-nav id-left -->' . "\n" . '<div class="side-nav"><div id="id-left">' . "\n";
1665 1774
 
1666
-        if ($conf->browser->layout == 'phone')
1667
-            $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ?
1775
+        if ($conf->browser->layout == 'phone') {
1776
+                    $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1;
1777
+        }
1778
+        // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ?
1668 1779
 
1669 1780
         print "\n";
1670 1781
 
@@ -1691,8 +1802,9 @@  discard block
 block discarded – undo
1691 1802
         $reshook = $hookmanager->executeHooks('printSearchForm', $parameters);    // Note that $action and $object may have been modified by some hooks
1692 1803
         if (empty($reshook)) {
1693 1804
             $searchform .= $hookmanager->resPrint;
1694
-        } else
1695
-            $searchform = $hookmanager->resPrint;
1805
+        } else {
1806
+                    $searchform = $hookmanager->resPrint;
1807
+        }
1696 1808
 
1697 1809
         // Force special value for $searchform
1698 1810
         if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) {
@@ -1736,38 +1848,49 @@  discard block
 block discarded – undo
1736 1848
         if (empty($conf->global->MAIN_HIDE_VERSION)) {    // Version is already on help picto and on login page.
1737 1849
             $doliurl = 'https://www.dolibarr.org';
1738 1850
             //local communities
1739
-            if (preg_match('/fr/i', $langs->defaultlang))
1740
-                $doliurl = 'https://www.dolibarr.fr';
1741
-            if (preg_match('/es/i', $langs->defaultlang))
1742
-                $doliurl = 'https://www.dolibarr.es';
1743
-            if (preg_match('/de/i', $langs->defaultlang))
1744
-                $doliurl = 'https://www.dolibarr.de';
1745
-            if (preg_match('/it/i', $langs->defaultlang))
1746
-                $doliurl = 'https://www.dolibarr.it';
1747
-            if (preg_match('/gr/i', $langs->defaultlang))
1748
-                $doliurl = 'https://www.dolibarr.gr';
1851
+            if (preg_match('/fr/i', $langs->defaultlang)) {
1852
+                            $doliurl = 'https://www.dolibarr.fr';
1853
+            }
1854
+            if (preg_match('/es/i', $langs->defaultlang)) {
1855
+                            $doliurl = 'https://www.dolibarr.es';
1856
+            }
1857
+            if (preg_match('/de/i', $langs->defaultlang)) {
1858
+                            $doliurl = 'https://www.dolibarr.de';
1859
+            }
1860
+            if (preg_match('/it/i', $langs->defaultlang)) {
1861
+                            $doliurl = 'https://www.dolibarr.it';
1862
+            }
1863
+            if (preg_match('/gr/i', $langs->defaultlang)) {
1864
+                            $doliurl = 'https://www.dolibarr.gr';
1865
+            }
1749 1866
 
1750 1867
             $appli = constant('DOL_APPLICATION_TITLE');
1751 1868
             if (!empty($conf->global->MAIN_APPLICATION_TITLE)) {
1752 1869
                 $appli = $conf->global->MAIN_APPLICATION_TITLE;
1753 1870
                 $doliurl = '';
1754 1871
                 if (preg_match('/\d\.\d/', $appli)) {
1755
-                    if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli))
1756
-                        $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core
1757
-                } else
1758
-                    $appli .= " " . DOL_VERSION;
1759
-            } else
1760
-                $appli .= " " . DOL_VERSION;
1872
+                    if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) {
1873
+                                            $appli .= " (" . DOL_VERSION . ")";
1874
+                    }
1875
+                    // If new title contains a version that is different than core
1876
+                } else {
1877
+                                    $appli .= " " . DOL_VERSION;
1878
+                }
1879
+            } else {
1880
+                            $appli .= " " . DOL_VERSION;
1881
+            }
1761 1882
             print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">';
1762
-            if ($doliurl)
1763
-                print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">';
1764
-            else
1765
-                print '<span class="help">';
1883
+            if ($doliurl) {
1884
+                            print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">';
1885
+            } else {
1886
+                            print '<span class="help">';
1887
+            }
1766 1888
             print $appli;
1767
-            if ($doliurl)
1768
-                print '</a>';
1769
-            else
1770
-                print '</span>';
1889
+            if ($doliurl) {
1890
+                            print '</a>';
1891
+            } else {
1892
+                            print '</span>';
1893
+            }
1771 1894
             print '</div>' . "\n";
1772 1895
         }
1773 1896
 
@@ -1814,9 +1937,10 @@  discard block
 block discarded – undo
1814 1937
     print "\n";
1815 1938
     print '<!-- Begin right area -->' . "\n";
1816 1939
 
1817
-    if (empty($leftmenuwithoutmainarea))
1818
-        main_area($title);
1819
-}
1940
+    if (empty($leftmenuwithoutmainarea)) {
1941
+            main_area($title);
1942
+    }
1943
+    }
1820 1944
 
1821 1945
 /**
1822 1946
  *  Begin main area
@@ -1828,16 +1952,18 @@  discard block
 block discarded – undo
1828 1952
 {
1829 1953
     global $conf, $langs;
1830 1954
 
1831
-    if (empty($conf->dol_hide_leftmenu))
1832
-        print '<div id="id-right">';
1955
+    if (empty($conf->dol_hide_leftmenu)) {
1956
+            print '<div id="id-right">';
1957
+    }
1833 1958
 
1834 1959
     print "\n";
1835 1960
 
1836 1961
     print '<!-- Begin div class="fiche" -->' . "\n" . '<div class="fiche">' . "\n";
1837 1962
 
1838
-    if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED))
1839
-        print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED));
1840
-}
1963
+    if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
1964
+            print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED));
1965
+    }
1966
+    }
1841 1967
 
1842 1968
 /**
1843 1969
  *  Return helpbaseurl, helppage and mode
@@ -1861,18 +1987,21 @@  discard block
 block discarded – undo
1861 1987
         // If WIKI URL
1862 1988
         if (preg_match('/^es/i', $langs->defaultlang)) {
1863 1989
             $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1864
-            if (preg_match('/ES:([^|]+)/i', $helppagename, $reg))
1865
-                $helppage = $reg[1];
1990
+            if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) {
1991
+                            $helppage = $reg[1];
1992
+            }
1866 1993
         }
1867 1994
         if (preg_match('/^fr/i', $langs->defaultlang)) {
1868 1995
             $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1869
-            if (preg_match('/FR:([^|]+)/i', $helppagename, $reg))
1870
-                $helppage = $reg[1];
1996
+            if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) {
1997
+                            $helppage = $reg[1];
1998
+            }
1871 1999
         }
1872 2000
         if (empty($helppage)) { // If help page not already found
1873 2001
             $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s';
1874
-            if (preg_match('/EN:([^|]+)/i', $helppagename, $reg))
1875
-                $helppage = $reg[1];
2002
+            if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) {
2003
+                            $helppage = $reg[1];
2004
+            }
1876 2005
         }
1877 2006
         $mode = 'wiki';
1878 2007
     }
@@ -1903,8 +2032,9 @@  discard block
 block discarded – undo
1903 2032
     $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
1904 2033
     $ret .= '<input type="hidden" name="mode" value="search">';
1905 2034
     $ret .= '<input type="hidden" name="savelogin" value="' . dol_escape_htmltag($user->login) . '">';
1906
-    if ($showtitlebefore)
1907
-        $ret .= $title . ' ';
2035
+    if ($showtitlebefore) {
2036
+            $ret .= $title . ' ';
2037
+    }
1908 2038
     $ret .= '<input type="text" class="flat ' . $htmlmorecss . '"';
1909 2039
     $ret .= ' style="text-indent: 22px; background-image: url(\'' . $img . '\'); background-repeat: no-repeat; background-position: 3px;"';
1910 2040
     $ret .= ($accesskey ? ' accesskey="' . $accesskey . '"' : '');
@@ -1947,10 +2077,12 @@  discard block
 block discarded – undo
1947 2077
             foreach ($user->lastsearch_values_tmp as $key => $val) {
1948 2078
                 unset($_SESSION['lastsearch_values_tmp_' . $key]);   // Clean array to rebuild it just after
1949 2079
                 if (count($val) && empty($_POST['button_removefilter'])) { // If there is search criteria to save and we did not click on 'Clear filter' button
1950
-                    if (empty($val['sortfield']))
1951
-                        unset($val['sortfield']);
1952
-                    if (empty($val['sortorder']))
1953
-                        unset($val['sortorder']);
2080
+                    if (empty($val['sortfield'])) {
2081
+                                            unset($val['sortfield']);
2082
+                    }
2083
+                    if (empty($val['sortorder'])) {
2084
+                                            unset($val['sortorder']);
2085
+                    }
1954 2086
                     dol_syslog('Save lastsearch_values_tmp_' . $key . '=' . json_encode($val, 0) . " (systematic recording of last search criterias)");
1955 2087
                     $_SESSION['lastsearch_values_tmp_' . $key] = json_encode($val);
1956 2088
                     unset($_SESSION['lastsearch_values_' . $key]);
@@ -1961,8 +2093,9 @@  discard block
 block discarded – undo
1961 2093
 
1962 2094
         $relativepathstring = $_SERVER["PHP_SELF"];
1963 2095
         // Clean $relativepathstring
1964
-        if (constant('DOL_BASE_URI'))
1965
-            $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
2096
+        if (constant('DOL_BASE_URI')) {
2097
+                    $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring);
2098
+        }
1966 2099
         $relativepathstring = preg_replace('/^\//', '', $relativepathstring);
1967 2100
         $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring);
1968 2101
         if (preg_match('/list\.php$/', $relativepathstring)) {
@@ -1970,12 +2103,15 @@  discard block
 block discarded – undo
1970 2103
             unset($_SESSION['lastsearch_page_tmp_' . $relativepathstring]);
1971 2104
             unset($_SESSION['lastsearch_limit_tmp_' . $relativepathstring]);
1972 2105
 
1973
-            if (!empty($contextpage))
1974
-                $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage;
1975
-            if (!empty($page) && $page > 1)
1976
-                $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page;
1977
-            if (!empty($limit) && $limit != $conf->limit)
1978
-                $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit;
2106
+            if (!empty($contextpage)) {
2107
+                            $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage;
2108
+            }
2109
+            if (!empty($page) && $page > 1) {
2110
+                            $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page;
2111
+            }
2112
+            if (!empty($limit) && $limit != $conf->limit) {
2113
+                            $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit;
2114
+            }
1979 2115
 
1980 2116
             unset($_SESSION['lastsearch_contextpage_' . $relativepathstring]);
1981 2117
             unset($_SESSION['lastsearch_page_' . $relativepathstring]);
@@ -2002,20 +2138,26 @@  discard block
 block discarded – undo
2002 2138
 
2003 2139
         print '</div> <!-- End div class="fiche" -->' . "\n"; // End div fiche
2004 2140
 
2005
-        if (empty($conf->dol_hide_leftmenu))
2006
-            print '</div> <!-- End div id-right -->' . "\n"; // End div id-right
2141
+        if (empty($conf->dol_hide_leftmenu)) {
2142
+                    print '</div> <!-- End div id-right -->' . "\n";
2143
+        }
2144
+        // End div id-right
2007 2145
 
2008
-        if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile))
2009
-            print '</div> <!-- End div id-container -->' . "\n"; // End div container
2146
+        if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) {
2147
+                    print '</div> <!-- End div id-container -->' . "\n";
2148
+        }
2149
+        // End div container
2010 2150
 
2011 2151
         print "\n";
2012
-        if ($comment)
2013
-            print '<!-- ' . $comment . ' -->' . "\n";
2152
+        if ($comment) {
2153
+                    print '<!-- ' . $comment . ' -->' . "\n";
2154
+        }
2014 2155
 
2015 2156
         printCommonFooter($zone);
2016 2157
 
2017
-        if (!empty($delayedhtmlcontent))
2018
-            print $delayedhtmlcontent;
2158
+        if (!empty($delayedhtmlcontent)) {
2159
+                    print $delayedhtmlcontent;
2160
+        }
2019 2161
 
2020 2162
         if (!empty($conf->use_javascript_ajax)) {
2021 2163
             print "\n" . '<!-- Includes JS Footer of Dolibarr -->' . "\n";
Please login to merge, or discard this patch.