@@ -214,16 +214,18 @@ discard block |
||
| 214 | 214 | foreach ($tmplist as $tmpkey) { |
| 215 | 215 | $postkey = $tmpautoset[0] . '_' . $tmpkey; |
| 216 | 216 | //var_dump('tmpkey='.$tmpkey.' postkey='.$postkey.' value='.$_POST[$postkey]); |
| 217 | - if (!empty($_POST[$postkey])) |
|
| 218 | - $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; |
|
| 217 | + if (!empty($_POST[$postkey])) { |
|
| 218 | + $cookiearrayvalue[$tmpkey] = $_POST[$postkey]; |
|
| 219 | + } |
|
| 219 | 220 | } |
| 220 | 221 | $cookiename = $tmpautoset[0]; |
| 221 | 222 | $cookievalue = json_encode($cookiearrayvalue); |
| 222 | 223 | //var_dump('setcookie cookiename='.$cookiename.' cookievalue='.$cookievalue); |
| 223 | 224 | setcookie($cookiename, empty($cookievalue) ? '' : $cookievalue, empty($cookievalue) ? 0 : (time() + (86400 * 354)), '/', null, false, true); // keep cookie 1 year and add tag httponly |
| 224 | - if (empty($cookievalue)) |
|
| 225 | - unset($_COOKIE[$cookiename]); |
|
| 226 | -} |
|
| 225 | + if (empty($cookievalue)) { |
|
| 226 | + unset($_COOKIE[$cookiename]); |
|
| 227 | + } |
|
| 228 | + } |
|
| 227 | 229 | |
| 228 | 230 | |
| 229 | 231 | // Init session. Name of session is specific to Dolibarr instance. |
@@ -232,8 +234,9 @@ discard block |
||
| 232 | 234 | |
| 233 | 235 | $sessionname = 'DOLSESSID_' . $prefix; |
| 234 | 236 | $sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix; |
| 235 | -if (!empty($_COOKIE[$sessiontimeout])) |
|
| 237 | +if (!empty($_COOKIE[$sessiontimeout])) { |
|
| 236 | 238 | ini_set('session.gc_maxlifetime', $_COOKIE[$sessiontimeout]); |
| 239 | +} |
|
| 237 | 240 | session_name($sessionname); |
| 238 | 241 | 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. |
| 239 | 242 | // This create lock, released when session_write_close() or end of page. |
@@ -264,11 +267,13 @@ discard block |
||
| 264 | 267 | $conf->browser->layout = $tmp['layout']; // 'classic', 'phone', 'tablet' |
| 265 | 268 | //var_dump($conf->browser); |
| 266 | 269 | |
| 267 | - if ($conf->browser->layout == 'phone') |
|
| 268 | - $conf->dol_no_mouse_hover = 1; |
|
| 269 | - if ($conf->browser->layout == 'phone') |
|
| 270 | - $conf->global->MAIN_TESTMENUHIDER = 1; |
|
| 271 | -} |
|
| 270 | + if ($conf->browser->layout == 'phone') { |
|
| 271 | + $conf->dol_no_mouse_hover = 1; |
|
| 272 | + } |
|
| 273 | + if ($conf->browser->layout == 'phone') { |
|
| 274 | + $conf->global->MAIN_TESTMENUHIDER = 1; |
|
| 275 | + } |
|
| 276 | + } |
|
| 272 | 277 | |
| 273 | 278 | // Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url) |
| 274 | 279 | // $_SERVER["HTTPS"] is 'on' when link is https, otherwise $_SERVER["HTTPS"] is empty or 'off' |
@@ -313,10 +318,14 @@ discard block |
||
| 313 | 318 | } |
| 314 | 319 | |
| 315 | 320 | // Loading of additional presentation includes |
| 316 | -if (!defined('NOREQUIREHTML')) |
|
| 317 | - require_once DOL_BASE_PATH . '/core/class/html.form.class.php'; // Need 660ko memory (800ko in 2.2) |
|
| 318 | -if (!defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) |
|
| 319 | - require_once DOL_BASE_PATH . '/core/lib/ajax.lib.php'; // Need 22ko memory |
|
| 321 | +if (!defined('NOREQUIREHTML')) { |
|
| 322 | + require_once DOL_BASE_PATH . '/core/class/html.form.class.php'; |
|
| 323 | +} |
|
| 324 | +// Need 660ko memory (800ko in 2.2) |
|
| 325 | +if (!defined('NOREQUIREAJAX') && $conf->use_javascript_ajax) { |
|
| 326 | + require_once DOL_BASE_PATH . '/core/lib/ajax.lib.php'; |
|
| 327 | +} |
|
| 328 | +// Need 22ko memory |
|
| 320 | 329 | |
| 321 | 330 | |
| 322 | 331 | |
@@ -353,8 +362,9 @@ discard block |
||
| 353 | 362 | // Creation of a token against CSRF vulnerabilities |
| 354 | 363 | if (!defined('NOTOKENRENEWAL')) { |
| 355 | 364 | // roulement des jetons car cree a chaque appel |
| 356 | - if (isset($_SESSION['newtoken'])) |
|
| 357 | - $_SESSION['token'] = $_SESSION['newtoken']; |
|
| 365 | + if (isset($_SESSION['newtoken'])) { |
|
| 366 | + $_SESSION['token'] = $_SESSION['newtoken']; |
|
| 367 | + } |
|
| 358 | 368 | |
| 359 | 369 | // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken'] |
| 360 | 370 | $token = dol_hash(uniqid(mt_rand(), true)); // Generates a hash of a random number |
@@ -376,14 +386,16 @@ discard block |
||
| 376 | 386 | } |
| 377 | 387 | |
| 378 | 388 | // Disable modules (this must be after session_start and after conf has been loaded) |
| 379 | -if (GETPOST('disablemodules', 'alpha')) |
|
| 389 | +if (GETPOST('disablemodules', 'alpha')) { |
|
| 380 | 390 | $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha'); |
| 391 | +} |
|
| 381 | 392 | if (!empty($_SESSION["disablemodules"])) { |
| 382 | 393 | $disabled_modules = explode(',', $_SESSION["disablemodules"]); |
| 383 | 394 | foreach ($disabled_modules as $module) { |
| 384 | 395 | if ($module) { |
| 385 | - if (empty($conf->$module)) |
|
| 386 | - $conf->$module = new stdClass(); |
|
| 396 | + if (empty($conf->$module)) { |
|
| 397 | + $conf->$module = new stdClass(); |
|
| 398 | + } |
|
| 387 | 399 | $conf->$module->enabled = false; |
| 388 | 400 | if ($module == 'fournisseur') { // Special case |
| 389 | 401 | $conf->supplier_order->enabled = 0; |
@@ -405,11 +417,13 @@ discard block |
||
| 405 | 417 | $dolibarr_main_authentication = constant('MAIN_AUTHENTICATION_MODE'); |
| 406 | 418 | } else { |
| 407 | 419 | // Authentication mode |
| 408 | - if (empty($dolibarr_main_authentication)) |
|
| 409 | - $dolibarr_main_authentication = 'http,dolibarr'; |
|
| 420 | + if (empty($dolibarr_main_authentication)) { |
|
| 421 | + $dolibarr_main_authentication = 'http,dolibarr'; |
|
| 422 | + } |
|
| 410 | 423 | // Authentication mode: forceuser |
| 411 | - if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) |
|
| 412 | - $dolibarr_auto_user = 'auto'; |
|
| 424 | + if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) { |
|
| 425 | + $dolibarr_auto_user = 'auto'; |
|
| 426 | + } |
|
| 413 | 427 | } |
| 414 | 428 | // Set authmode |
| 415 | 429 | $authmode = explode(',', $dolibarr_main_authentication); |
@@ -486,35 +500,41 @@ discard block |
||
| 486 | 500 | $hookmanager->initHooks(array('login')); |
| 487 | 501 | $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); |
| 488 | 502 | $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks |
| 489 | - if ($reshook < 0) |
|
| 490 | - $error++; |
|
| 503 | + if ($reshook < 0) { |
|
| 504 | + $error++; |
|
| 505 | + } |
|
| 491 | 506 | |
| 492 | 507 | // Note: exit is done later |
| 493 | 508 | } |
| 494 | 509 | } |
| 495 | 510 | |
| 496 | 511 | $allowedmethodtopostusername = 2; |
| 497 | - if (defined('MAIN_AUTHENTICATION_POST_METHOD')) |
|
| 498 | - $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); |
|
| 512 | + if (defined('MAIN_AUTHENTICATION_POST_METHOD')) { |
|
| 513 | + $allowedmethodtopostusername = constant('MAIN_AUTHENTICATION_POST_METHOD'); |
|
| 514 | + } |
|
| 499 | 515 | $usertotest = (!empty($_COOKIE['login_dolibarr']) ? $_COOKIE['login_dolibarr'] : GETPOST("username", "alpha", $allowedmethodtopostusername)); |
| 500 | 516 | $passwordtotest = GETPOST('password', 'none', $allowedmethodtopostusername); |
| 501 | 517 | $entitytotest = (GETPOST('entity', 'int') ? GETPOST('entity', 'int') : (!empty($conf->entity) ? $conf->entity : 1)); |
| 502 | 518 | |
| 503 | 519 | // Define if we received data to test the login. |
| 504 | 520 | $goontestloop = false; |
| 505 | - if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) |
|
| 506 | - $goontestloop = true; |
|
| 507 | - if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) |
|
| 508 | - $goontestloop = true; |
|
| 509 | - if (GETPOST("username", "alpha", $allowedmethodtopostusername) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) |
|
| 510 | - $goontestloop = true; |
|
| 521 | + if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) { |
|
| 522 | + $goontestloop = true; |
|
| 523 | + } |
|
| 524 | + if ($dolibarr_main_authentication == 'forceuser' && !empty($dolibarr_auto_user)) { |
|
| 525 | + $goontestloop = true; |
|
| 526 | + } |
|
| 527 | + if (GETPOST("username", "alpha", $allowedmethodtopostusername) || !empty($_COOKIE['login_dolibarr']) || GETPOST('openid_mode', 'alpha', 1)) { |
|
| 528 | + $goontestloop = true; |
|
| 529 | + } |
|
| 511 | 530 | |
| 512 | 531 | if (!is_object($langs)) { // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages. |
| 513 | 532 | include_once DOL_BASE_PATH . '/core/class/translate.class.php'; |
| 514 | 533 | $langs = new Translate("", $conf); |
| 515 | 534 | $langcode = (GETPOST('lang', 'aZ09', 1) ? GETPOST('lang', 'aZ09', 1) : (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT)); |
| 516 | - if (defined('MAIN_LANG_DEFAULT')) |
|
| 517 | - $langcode = constant('MAIN_LANG_DEFAULT'); |
|
| 535 | + if (defined('MAIN_LANG_DEFAULT')) { |
|
| 536 | + $langcode = constant('MAIN_LANG_DEFAULT'); |
|
| 537 | + } |
|
| 518 | 538 | $langs->setDefaultLang($langcode); |
| 519 | 539 | } |
| 520 | 540 | |
@@ -536,8 +556,9 @@ discard block |
||
| 536 | 556 | $datenow = dol_now(); |
| 537 | 557 | $datefirst = dol_stringtotime($_POST["dst_first"]); |
| 538 | 558 | $datesecond = dol_stringtotime($_POST["dst_second"]); |
| 539 | - if ($datenow >= $datefirst && $datenow < $datesecond) |
|
| 540 | - $dol_dst = 1; |
|
| 559 | + if ($datenow >= $datefirst && $datenow < $datesecond) { |
|
| 560 | + $dol_dst = 1; |
|
| 561 | + } |
|
| 541 | 562 | } |
| 542 | 563 | //print $datefirst.'-'.$datesecond.'-'.$datenow.'-'.$dol_tz.'-'.$dol_tzstring.'-'.$dol_dst; exit; |
| 543 | 564 | } |
@@ -549,8 +570,9 @@ discard block |
||
| 549 | 570 | |
| 550 | 571 | // Bad password. No authmode has found a good password. |
| 551 | 572 | // We set a generic message if not defined inside function checkLoginPassEntity or subfunctions |
| 552 | - if (empty($_SESSION["dol_loginmesg"])) |
|
| 553 | - $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword"); |
|
| 573 | + if (empty($_SESSION["dol_loginmesg"])) { |
|
| 574 | + $_SESSION["dol_loginmesg"] = $langs->trans("ErrorBadLoginPassword"); |
|
| 575 | + } |
|
| 554 | 576 | |
| 555 | 577 | // Call trigger for the "security events" log |
| 556 | 578 | $user->trigger_mesg = $langs->trans("ErrorBadLoginPassword") . ' - login=' . GETPOST("username", "alpha", 2); |
@@ -567,8 +589,9 @@ discard block |
||
| 567 | 589 | $hookmanager->initHooks(array('login')); |
| 568 | 590 | $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); |
| 569 | 591 | $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks |
| 570 | - if ($reshook < 0) |
|
| 571 | - $error++; |
|
| 592 | + if ($reshook < 0) { |
|
| 593 | + $error++; |
|
| 594 | + } |
|
| 572 | 595 | |
| 573 | 596 | // Note: exit is done in next chapter |
| 574 | 597 | } |
@@ -578,10 +601,11 @@ discard block |
||
| 578 | 601 | 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. |
| 579 | 602 | // No data to test login, so we show the login page |
| 580 | 603 | dol_syslog("--- Access to " . $_SERVER["PHP_SELF"] . " showing the login form and exit"); |
| 581 | - if (defined('NOREDIRECTBYMAINTOLOGIN')) |
|
| 582 | - return 'ERROR_NOT_LOGGED'; |
|
| 583 | - else |
|
| 584 | - dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); |
|
| 604 | + if (defined('NOREDIRECTBYMAINTOLOGIN')) { |
|
| 605 | + return 'ERROR_NOT_LOGGED'; |
|
| 606 | + } else { |
|
| 607 | + dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); |
|
| 608 | + } |
|
| 585 | 609 | exit; |
| 586 | 610 | } |
| 587 | 611 | |
@@ -620,21 +644,24 @@ discard block |
||
| 620 | 644 | $hookmanager->initHooks(array('login')); |
| 621 | 645 | $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); |
| 622 | 646 | $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks |
| 623 | - if ($reshook < 0) |
|
| 624 | - $error++; |
|
| 647 | + if ($reshook < 0) { |
|
| 648 | + $error++; |
|
| 649 | + } |
|
| 625 | 650 | |
| 626 | 651 | $paramsurl = array(); |
| 627 | - if (GETPOST('textbrowser', 'int')) |
|
| 628 | - $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int'); |
|
| 629 | - if (GETPOST('nojs', 'int')) |
|
| 630 | - $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int'); |
|
| 631 | - if (GETPOST('lang', 'aZ09')) |
|
| 632 | - $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09'); |
|
| 652 | + if (GETPOST('textbrowser', 'int')) { |
|
| 653 | + $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int'); |
|
| 654 | + } |
|
| 655 | + if (GETPOST('nojs', 'int')) { |
|
| 656 | + $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int'); |
|
| 657 | + } |
|
| 658 | + if (GETPOST('lang', 'aZ09')) { |
|
| 659 | + $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09'); |
|
| 660 | + } |
|
| 633 | 661 | header('Location: ' . DOL_BASE_URI . '/index.php' . (count($paramsurl) ? '?' . implode('&', $paramsurl) : '')); |
| 634 | 662 | exit; |
| 635 | 663 | } |
| 636 | - } |
|
| 637 | - else { |
|
| 664 | + } else { |
|
| 638 | 665 | // We are already into an authenticated session |
| 639 | 666 | $login = $_SESSION["dol_login"]; |
| 640 | 667 | $entity = $_SESSION["dol_entity"]; |
@@ -676,20 +703,23 @@ discard block |
||
| 676 | 703 | $hookmanager->initHooks(array('login')); |
| 677 | 704 | $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginmesg' => $_SESSION["dol_loginmesg"]); |
| 678 | 705 | $reshook = $hookmanager->executeHooks('afterLoginFailed', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks |
| 679 | - if ($reshook < 0) |
|
| 680 | - $error++; |
|
| 706 | + if ($reshook < 0) { |
|
| 707 | + $error++; |
|
| 708 | + } |
|
| 681 | 709 | |
| 682 | 710 | $paramsurl = array(); |
| 683 | - if (GETPOST('textbrowser', 'int')) |
|
| 684 | - $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int'); |
|
| 685 | - if (GETPOST('nojs', 'int')) |
|
| 686 | - $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int'); |
|
| 687 | - if (GETPOST('lang', 'aZ09')) |
|
| 688 | - $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09'); |
|
| 711 | + if (GETPOST('textbrowser', 'int')) { |
|
| 712 | + $paramsurl[] = 'textbrowser=' . GETPOST('textbrowser', 'int'); |
|
| 713 | + } |
|
| 714 | + if (GETPOST('nojs', 'int')) { |
|
| 715 | + $paramsurl[] = 'nojs=' . GETPOST('nojs', 'int'); |
|
| 716 | + } |
|
| 717 | + if (GETPOST('lang', 'aZ09')) { |
|
| 718 | + $paramsurl[] = 'lang=' . GETPOST('lang', 'aZ09'); |
|
| 719 | + } |
|
| 689 | 720 | header('Location: ' . DOL_BASE_URI . '/index.php' . (count($paramsurl) ? '?' . implode('&', $paramsurl) : '')); |
| 690 | 721 | exit; |
| 691 | - } |
|
| 692 | - else { |
|
| 722 | + } else { |
|
| 693 | 723 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
| 694 | 724 | $hookmanager->initHooks(array('main')); |
| 695 | 725 | |
@@ -698,8 +728,9 @@ discard block |
||
| 698 | 728 | $relativepathstring = preg_replace('/\?.*$/', '', $_SERVER["HTTP_REFERER"]); |
| 699 | 729 | $relativepathstring = preg_replace('/^https?:\/\/[^\/]*/', '', $relativepathstring); // Get full path except host server |
| 700 | 730 | // Clean $relativepathstring |
| 701 | - if (constant('DOL_BASE_URI')) |
|
| 702 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 731 | + if (constant('DOL_BASE_URI')) { |
|
| 732 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 733 | + } |
|
| 703 | 734 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
| 704 | 735 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
| 705 | 736 | //var_dump($relativepathstring); |
@@ -750,16 +781,21 @@ discard block |
||
| 750 | 781 | $_SESSION["dol_company"] = $conf->global->MAIN_INFO_SOCIETE_NOM; |
| 751 | 782 | $_SESSION["dol_entity"] = $conf->entity; |
| 752 | 783 | // Store value into session (values stored only if defined) |
| 753 | - if (!empty($dol_hide_topmenu)) |
|
| 754 | - $_SESSION['dol_hide_topmenu'] = $dol_hide_topmenu; |
|
| 755 | - if (!empty($dol_hide_leftmenu)) |
|
| 756 | - $_SESSION['dol_hide_leftmenu'] = $dol_hide_leftmenu; |
|
| 757 | - if (!empty($dol_optimize_smallscreen)) |
|
| 758 | - $_SESSION['dol_optimize_smallscreen'] = $dol_optimize_smallscreen; |
|
| 759 | - if (!empty($dol_no_mouse_hover)) |
|
| 760 | - $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover; |
|
| 761 | - if (!empty($dol_use_jmobile)) |
|
| 762 | - $_SESSION['dol_use_jmobile'] = $dol_use_jmobile; |
|
| 784 | + if (!empty($dol_hide_topmenu)) { |
|
| 785 | + $_SESSION['dol_hide_topmenu'] = $dol_hide_topmenu; |
|
| 786 | + } |
|
| 787 | + if (!empty($dol_hide_leftmenu)) { |
|
| 788 | + $_SESSION['dol_hide_leftmenu'] = $dol_hide_leftmenu; |
|
| 789 | + } |
|
| 790 | + if (!empty($dol_optimize_smallscreen)) { |
|
| 791 | + $_SESSION['dol_optimize_smallscreen'] = $dol_optimize_smallscreen; |
|
| 792 | + } |
|
| 793 | + if (!empty($dol_no_mouse_hover)) { |
|
| 794 | + $_SESSION['dol_no_mouse_hover'] = $dol_no_mouse_hover; |
|
| 795 | + } |
|
| 796 | + if (!empty($dol_use_jmobile)) { |
|
| 797 | + $_SESSION['dol_use_jmobile'] = $dol_use_jmobile; |
|
| 798 | + } |
|
| 763 | 799 | |
| 764 | 800 | dol_syslog("This is a new started user session. _SESSION['dol_login']=" . $_SESSION["dol_login"] . " Session id=" . session_id()); |
| 765 | 801 | |
@@ -784,8 +820,9 @@ discard block |
||
| 784 | 820 | $hookmanager->initHooks(array('login')); |
| 785 | 821 | $parameters = array('dol_authmode' => $dol_authmode, 'dol_loginfo' => $loginfo); |
| 786 | 822 | $reshook = $hookmanager->executeHooks('afterLogin', $parameters, $user, $action); // Note that $action and $object may have been modified by some hooks |
| 787 | - if ($reshook < 0) |
|
| 788 | - $error++; |
|
| 823 | + if ($reshook < 0) { |
|
| 824 | + $error++; |
|
| 825 | + } |
|
| 789 | 826 | |
| 790 | 827 | if ($error) { |
| 791 | 828 | $db->rollback(); |
@@ -823,10 +860,14 @@ discard block |
||
| 823 | 860 | */ |
| 824 | 861 | |
| 825 | 862 | // Set liste_limit |
| 826 | - if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) |
|
| 827 | - $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; // Can be 0 |
|
| 828 | - if (isset($user->conf->PRODUIT_LIMIT_SIZE)) |
|
| 829 | - $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; // Can be 0 |
|
| 863 | + if (isset($user->conf->MAIN_SIZE_LISTE_LIMIT)) { |
|
| 864 | + $conf->liste_limit = $user->conf->MAIN_SIZE_LISTE_LIMIT; |
|
| 865 | + } |
|
| 866 | + // Can be 0 |
|
| 867 | + if (isset($user->conf->PRODUIT_LIMIT_SIZE)) { |
|
| 868 | + $conf->product->limit_size = $user->conf->PRODUIT_LIMIT_SIZE; |
|
| 869 | + } |
|
| 870 | + // Can be 0 |
|
| 830 | 871 | |
| 831 | 872 | |
| 832 | 873 | |
@@ -861,8 +902,9 @@ discard block |
||
| 861 | 902 | if (!empty($user->conf->MAIN_DISABLE_JAVASCRIPT)) { |
| 862 | 903 | $conf->use_javascript_ajax = !$user->conf->MAIN_DISABLE_JAVASCRIPT; |
| 863 | 904 | } |
| 864 | -} else |
|
| 905 | +} else { |
|
| 865 | 906 | $conf->use_javascript_ajax = 0; |
| 907 | +} |
|
| 866 | 908 | // Set MAIN_OPTIMIZEFORTEXTBROWSER |
| 867 | 909 | if (GETPOST('textbrowser', 'int') || (!empty($conf->browser->name) && $conf->browser->name == 'lynxlinks') || !empty($user->conf->MAIN_OPTIMIZEFORTEXTBROWSER)) { // If we must enable text browser |
| 868 | 910 | $conf->global->MAIN_OPTIMIZEFORTEXTBROWSER = 1; |
@@ -871,25 +913,32 @@ discard block |
||
| 871 | 913 | } |
| 872 | 914 | |
| 873 | 915 | // Set terminal output option according to conf->browser. |
| 874 | -if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) |
|
| 916 | +if (GETPOST('dol_hide_leftmenu', 'int') || !empty($_SESSION['dol_hide_leftmenu'])) { |
|
| 875 | 917 | $conf->dol_hide_leftmenu = 1; |
| 876 | -if (GETPOST('dol_hide_topmenu', 'int') || !empty($_SESSION['dol_hide_topmenu'])) |
|
| 918 | +} |
|
| 919 | +if (GETPOST('dol_hide_topmenu', 'int') || !empty($_SESSION['dol_hide_topmenu'])) { |
|
| 877 | 920 | $conf->dol_hide_topmenu = 1; |
| 878 | -if (GETPOST('dol_optimize_smallscreen', 'int') || !empty($_SESSION['dol_optimize_smallscreen'])) |
|
| 921 | +} |
|
| 922 | +if (GETPOST('dol_optimize_smallscreen', 'int') || !empty($_SESSION['dol_optimize_smallscreen'])) { |
|
| 879 | 923 | $conf->dol_optimize_smallscreen = 1; |
| 880 | -if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover'])) |
|
| 924 | +} |
|
| 925 | +if (GETPOST('dol_no_mouse_hover', 'int') || !empty($_SESSION['dol_no_mouse_hover'])) { |
|
| 881 | 926 | $conf->dol_no_mouse_hover = 1; |
| 882 | -if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile'])) |
|
| 927 | +} |
|
| 928 | +if (GETPOST('dol_use_jmobile', 'int') || !empty($_SESSION['dol_use_jmobile'])) { |
|
| 883 | 929 | $conf->dol_use_jmobile = 1; |
| 884 | -if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') |
|
| 930 | +} |
|
| 931 | +if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') { |
|
| 885 | 932 | $conf->dol_no_mouse_hover = 1; |
| 933 | +} |
|
| 886 | 934 | 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) |
| 887 | 935 | ) { |
| 888 | 936 | $conf->dol_optimize_smallscreen = 1; |
| 889 | 937 | } |
| 890 | 938 | // If we force to use jmobile, then we reenable javascript |
| 891 | -if (!empty($conf->dol_use_jmobile)) |
|
| 939 | +if (!empty($conf->dol_use_jmobile)) { |
|
| 892 | 940 | $conf->use_javascript_ajax = 1; |
| 941 | +} |
|
| 893 | 942 | // Replace themes bugged with jmobile with eldy |
| 894 | 943 | if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok'))) { |
| 895 | 944 | $conf->theme = 'eldy'; |
@@ -913,8 +962,9 @@ discard block |
||
| 913 | 962 | if (!defined('NOLOGIN')) { |
| 914 | 963 | // If the login is not recovered, it is identified with an account that does not exist. |
| 915 | 964 | // Hacking attempt? |
| 916 | - if (!$user->login) |
|
| 917 | - accessforbidden(); |
|
| 965 | + if (!$user->login) { |
|
| 966 | + accessforbidden(); |
|
| 967 | + } |
|
| 918 | 968 | |
| 919 | 969 | // Check if user is active |
| 920 | 970 | if ($user->statut < 1) { |
@@ -989,15 +1039,18 @@ discard block |
||
| 989 | 1039 | |
| 990 | 1040 | // Load the menu manager (only if not already done) |
| 991 | 1041 | $file_menu = $conf->standard_menu; |
| 992 | - if (GETPOST('menu', 'alpha')) |
|
| 993 | - $file_menu = GETPOST('menu', 'alpha'); // example: menu=eldy_menu.php |
|
| 1042 | + if (GETPOST('menu', 'alpha')) { |
|
| 1043 | + $file_menu = GETPOST('menu', 'alpha'); |
|
| 1044 | + } |
|
| 1045 | + // example: menu=eldy_menu.php |
|
| 994 | 1046 | if (!class_exists('MenuManager')) { |
| 995 | 1047 | $menufound = 0; |
| 996 | 1048 | $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']); |
| 997 | 1049 | foreach ($dirmenus as $dirmenu) { |
| 998 | 1050 | $menufound = dol_include_once($dirmenu . "standard/" . $file_menu); |
| 999 | - if (class_exists('MenuManager')) |
|
| 1000 | - break; |
|
| 1051 | + if (class_exists('MenuManager')) { |
|
| 1052 | + break; |
|
| 1053 | + } |
|
| 1001 | 1054 | } |
| 1002 | 1055 | if (!class_exists('MenuManager')) { // If failed to include, we try with standard eldy_menu.php |
| 1003 | 1056 | dol_syslog("You define a menu manager '" . $file_menu . "' that can not be loaded.", LOG_WARNING); |
@@ -1147,18 +1200,20 @@ discard block |
||
| 1147 | 1200 | } |
| 1148 | 1201 | print '<!doctype html>' . "\n"; |
| 1149 | 1202 | |
| 1150 | - if (!empty($conf->global->MAIN_USE_CACHE_MANIFEST)) |
|
| 1151 | - print '<html lang="' . substr($langs->defaultlang, 0, 2) . '" manifest="' . DOL_BASE_URI . '/cache.manifest">' . "\n"; |
|
| 1152 | - else |
|
| 1153 | - print '<html lang="' . substr($langs->defaultlang, 0, 2) . '">' . "\n"; |
|
| 1203 | + if (!empty($conf->global->MAIN_USE_CACHE_MANIFEST)) { |
|
| 1204 | + print '<html lang="' . substr($langs->defaultlang, 0, 2) . '" manifest="' . DOL_BASE_URI . '/cache.manifest">' . "\n"; |
|
| 1205 | + } else { |
|
| 1206 | + print '<html lang="' . substr($langs->defaultlang, 0, 2) . '">' . "\n"; |
|
| 1207 | + } |
|
| 1154 | 1208 | //print '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">'."\n"; |
| 1155 | 1209 | if (empty($disablehead)) { |
| 1156 | 1210 | $ext = 'layout=' . $conf->browser->layout . '&version=' . urlencode(DOL_VERSION); |
| 1157 | 1211 | |
| 1158 | 1212 | print "<head>\n"; |
| 1159 | 1213 | |
| 1160 | - if (GETPOST('dol_basehref', 'alpha')) |
|
| 1161 | - print '<base href="' . dol_escape_htmltag(GETPOST('dol_basehref', 'alpha')) . '">' . "\n"; |
|
| 1214 | + if (GETPOST('dol_basehref', 'alpha')) { |
|
| 1215 | + print '<base href="' . dol_escape_htmltag(GETPOST('dol_basehref', 'alpha')) . '">' . "\n"; |
|
| 1216 | + } |
|
| 1162 | 1217 | |
| 1163 | 1218 | // Displays meta |
| 1164 | 1219 | print '<meta charset="UTF-8">' . "\n"; |
@@ -1168,10 +1223,13 @@ discard block |
||
| 1168 | 1223 | |
| 1169 | 1224 | // Favicon |
| 1170 | 1225 | $favicon = dol_buildpath('/theme/' . $conf->theme . '/img/favicon.ico', 1); |
| 1171 | - if (!empty($conf->global->MAIN_FAVICON_URL)) |
|
| 1172 | - $favicon = $conf->global->MAIN_FAVICON_URL; |
|
| 1173 | - if (empty($conf->dol_use_jmobile)) |
|
| 1174 | - print '<link rel="shortcut icon" type="image/x-icon" href="' . $favicon . '"/>' . "\n"; // Not required into an Android webview |
|
| 1226 | + if (!empty($conf->global->MAIN_FAVICON_URL)) { |
|
| 1227 | + $favicon = $conf->global->MAIN_FAVICON_URL; |
|
| 1228 | + } |
|
| 1229 | + if (empty($conf->dol_use_jmobile)) { |
|
| 1230 | + print '<link rel="shortcut icon" type="image/x-icon" href="' . $favicon . '"/>' . "\n"; |
|
| 1231 | + } |
|
| 1232 | + // Not required into an Android webview |
|
| 1175 | 1233 | |
| 1176 | 1234 | |
| 1177 | 1235 | |
@@ -1189,47 +1247,59 @@ discard block |
||
| 1189 | 1247 | //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"; |
| 1190 | 1248 | //if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print '<link rel="author" title="Dolibarr Development Team" href="https://www.dolibarr.org">'."\n"; |
| 1191 | 1249 | // Auto refresh page |
| 1192 | - if (GETPOST('autorefresh', 'int') > 0) |
|
| 1193 | - print '<meta http-equiv="refresh" content="' . GETPOST('autorefresh', 'int') . '">'; |
|
| 1250 | + if (GETPOST('autorefresh', 'int') > 0) { |
|
| 1251 | + print '<meta http-equiv="refresh" content="' . GETPOST('autorefresh', 'int') . '">'; |
|
| 1252 | + } |
|
| 1194 | 1253 | |
| 1195 | 1254 | // Displays title |
| 1196 | 1255 | $appli = constant('DOL_APPLICATION_TITLE'); |
| 1197 | - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) |
|
| 1198 | - $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 1256 | + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { |
|
| 1257 | + $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 1258 | + } |
|
| 1199 | 1259 | |
| 1200 | 1260 | print '<title>'; |
| 1201 | 1261 | $titletoshow = ''; |
| 1202 | - if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/', $conf->global->MAIN_HTML_TITLE)) |
|
| 1203 | - $titletoshow = dol_htmlentities($title); |
|
| 1204 | - else if ($title) |
|
| 1205 | - $titletoshow = dol_htmlentities($appli . ' - ' . $title); |
|
| 1206 | - else |
|
| 1207 | - $titletoshow = dol_htmlentities($appli); |
|
| 1208 | - |
|
| 1209 | - if (!is_object($hookmanager)) |
|
| 1210 | - $hookmanager = new HookManager($db); |
|
| 1262 | + if ($title && !empty($conf->global->MAIN_HTML_TITLE) && preg_match('/noapp/', $conf->global->MAIN_HTML_TITLE)) { |
|
| 1263 | + $titletoshow = dol_htmlentities($title); |
|
| 1264 | + } else if ($title) { |
|
| 1265 | + $titletoshow = dol_htmlentities($appli . ' - ' . $title); |
|
| 1266 | + } else { |
|
| 1267 | + $titletoshow = dol_htmlentities($appli); |
|
| 1268 | + } |
|
| 1269 | + |
|
| 1270 | + if (!is_object($hookmanager)) { |
|
| 1271 | + $hookmanager = new HookManager($db); |
|
| 1272 | + } |
|
| 1211 | 1273 | $hookmanager->initHooks("main"); |
| 1212 | 1274 | $parameters = array('title' => $titletoshow); |
| 1213 | 1275 | $result = $hookmanager->executeHooks('setHtmlTitle', $parameters); // Note that $action and $object may have been modified by some hooks |
| 1214 | - if ($result > 0) |
|
| 1215 | - $titletoshow = $hookmanager->resPrint; // Replace Title to show |
|
| 1216 | - else |
|
| 1217 | - $titletoshow .= $hookmanager->resPrint; // Concat to Title to show |
|
| 1276 | + if ($result > 0) { |
|
| 1277 | + $titletoshow = $hookmanager->resPrint; |
|
| 1278 | + } |
|
| 1279 | + // Replace Title to show |
|
| 1280 | + else { |
|
| 1281 | + $titletoshow .= $hookmanager->resPrint; |
|
| 1282 | + } |
|
| 1283 | + // Concat to Title to show |
|
| 1218 | 1284 | |
| 1219 | 1285 | print $titletoshow; |
| 1220 | 1286 | print '</title>'; |
| 1221 | 1287 | |
| 1222 | 1288 | print "\n"; |
| 1223 | 1289 | |
| 1224 | - if (GETPOST('version', 'int')) |
|
| 1225 | - $ext = 'version=' . GETPOST('version', 'int'); // usefull to force no cache on css/js |
|
| 1226 | - if (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)) |
|
| 1227 | - $ext .= '&testmenuhider=' . (GETPOST('testmenuhider', 'int') ? GETPOST('testmenuhider', 'int') : $conf->global->MAIN_TESTMENUHIDER); |
|
| 1290 | + if (GETPOST('version', 'int')) { |
|
| 1291 | + $ext = 'version=' . GETPOST('version', 'int'); |
|
| 1292 | + } |
|
| 1293 | + // usefull to force no cache on css/js |
|
| 1294 | + if (GETPOST('testmenuhider', 'int') || !empty($conf->global->MAIN_TESTMENUHIDER)) { |
|
| 1295 | + $ext .= '&testmenuhider=' . (GETPOST('testmenuhider', 'int') ? GETPOST('testmenuhider', 'int') : $conf->global->MAIN_TESTMENUHIDER); |
|
| 1296 | + } |
|
| 1228 | 1297 | |
| 1229 | 1298 | $themeparam = '&lang=' . $langs->defaultlang . '&theme=' . $conf->theme . (GETPOST('optioncss', 'aZ09') ? '&optioncss=' . GETPOST('optioncss', 'aZ09', 1) : '') . '&userid=' . $user->id . '&entity=' . $conf->entity; |
| 1230 | 1299 | $themeparam .= ($ext ? '&' . $ext : ''); |
| 1231 | - if (!empty($_SESSION['dol_resetcache'])) |
|
| 1232 | - $themeparam .= '&dol_resetcache=' . $_SESSION['dol_resetcache']; |
|
| 1300 | + if (!empty($_SESSION['dol_resetcache'])) { |
|
| 1301 | + $themeparam .= '&dol_resetcache=' . $_SESSION['dol_resetcache']; |
|
| 1302 | + } |
|
| 1233 | 1303 | if (GETPOST('dol_hide_topmenu', 'int')) { |
| 1234 | 1304 | $themeparam .= '&dol_hide_topmenu=' . GETPOST('dol_hide_topmenu', 'int'); |
| 1235 | 1305 | } |
@@ -1288,8 +1358,9 @@ discard block |
||
| 1288 | 1358 | |
| 1289 | 1359 | //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; |
| 1290 | 1360 | print '<link rel="stylesheet" type="text/css" href="' . $themepath . $themeparam . '">' . "\n"; |
| 1291 | - if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) |
|
| 1292 | - 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"; |
|
| 1361 | + if (!empty($conf->global->MAIN_FIX_FLASH_ON_CHROME)) { |
|
| 1362 | + 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"; |
|
| 1363 | + } |
|
| 1293 | 1364 | |
| 1294 | 1365 | // CSS forced by modules (relative url starting with /) |
| 1295 | 1366 | if (!empty($conf->modules_parts['css'])) { |
@@ -1297,13 +1368,15 @@ discard block |
||
| 1297 | 1368 | foreach ($arraycss as $modcss => $filescss) { |
| 1298 | 1369 | $filescss = (array) $filescss; // To be sure filecss is an array |
| 1299 | 1370 | foreach ($filescss as $cssfile) { |
| 1300 | - if (empty($cssfile)) |
|
| 1301 | - dol_syslog("Warning: module " . $modcss . " declared a css path file into its descriptor that is empty.", LOG_WARNING); |
|
| 1371 | + if (empty($cssfile)) { |
|
| 1372 | + dol_syslog("Warning: module " . $modcss . " declared a css path file into its descriptor that is empty.", LOG_WARNING); |
|
| 1373 | + } |
|
| 1302 | 1374 | // cssfile is a relative path |
| 1303 | 1375 | print '<!-- Includes CSS added by module ' . $modcss . ' -->' . "\n" . '<link rel="stylesheet" type="text/css" href="' . dol_buildpath($cssfile, 1); |
| 1304 | 1376 | // 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. |
| 1305 | - if (!preg_match('/\.css$/i', $cssfile)) |
|
| 1306 | - print $themeparam; |
|
| 1377 | + if (!preg_match('/\.css$/i', $cssfile)) { |
|
| 1378 | + print $themeparam; |
|
| 1379 | + } |
|
| 1307 | 1380 | print '">' . "\n"; |
| 1308 | 1381 | } |
| 1309 | 1382 | } |
@@ -1313,8 +1386,9 @@ discard block |
||
| 1313 | 1386 | foreach ($arrayofcss as $cssfile) { |
| 1314 | 1387 | print '<!-- Includes CSS added by page -->' . "\n" . '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath($cssfile, 1); |
| 1315 | 1388 | // 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. |
| 1316 | - if (!preg_match('/\.css$/i', $cssfile)) |
|
| 1317 | - print $themeparam; |
|
| 1389 | + if (!preg_match('/\.css$/i', $cssfile)) { |
|
| 1390 | + print $themeparam; |
|
| 1391 | + } |
|
| 1318 | 1392 | print '">' . "\n"; |
| 1319 | 1393 | } |
| 1320 | 1394 | } |
@@ -1418,10 +1492,12 @@ discard block |
||
| 1418 | 1492 | // Browser notifications |
| 1419 | 1493 | if (!defined('DISABLE_BROWSER_NOTIF')) { |
| 1420 | 1494 | $enablebrowsernotif = false; |
| 1421 | - if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) |
|
| 1422 | - $enablebrowsernotif = true; |
|
| 1423 | - if ($conf->browser->layout == 'phone') |
|
| 1424 | - $enablebrowsernotif = false; |
|
| 1495 | + if (!empty($conf->agenda->enabled) && !empty($conf->global->AGENDA_REMINDER_BROWSER)) { |
|
| 1496 | + $enablebrowsernotif = true; |
|
| 1497 | + } |
|
| 1498 | + if ($conf->browser->layout == 'phone') { |
|
| 1499 | + $enablebrowsernotif = false; |
|
| 1500 | + } |
|
| 1425 | 1501 | if ($enablebrowsernotif) { |
| 1426 | 1502 | print '<!-- Includes JS of Dolibarr (brwoser layout = ' . $conf->browser->layout . ')-->' . "\n"; |
| 1427 | 1503 | //print '<script type="text/javascript" src="' . DOL_BASE_URI . '/core/js/lib_notification.js.php' . ($ext ? '?' . $ext : '') . '"></script>' . "\n"; |
@@ -1458,10 +1534,12 @@ discard block |
||
| 1458 | 1534 | } |
| 1459 | 1535 | } |
| 1460 | 1536 | |
| 1461 | - if (!empty($head)) |
|
| 1462 | - print $head . "\n"; |
|
| 1463 | - if (!empty($conf->global->MAIN_HTML_HEADER)) |
|
| 1464 | - print $conf->global->MAIN_HTML_HEADER . "\n"; |
|
| 1537 | + if (!empty($head)) { |
|
| 1538 | + print $head . "\n"; |
|
| 1539 | + } |
|
| 1540 | + if (!empty($conf->global->MAIN_HTML_HEADER)) { |
|
| 1541 | + print $conf->global->MAIN_HTML_HEADER . "\n"; |
|
| 1542 | + } |
|
| 1465 | 1543 | |
| 1466 | 1544 | print "<!-- Alixar debugBar header -->"; |
| 1467 | 1545 | print Debug::getRenderHeader(); // Includes Alixar debugBar header |
@@ -1526,15 +1604,20 @@ discard block |
||
| 1526 | 1604 | if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { |
| 1527 | 1605 | $appli = $conf->global->MAIN_APPLICATION_TITLE; |
| 1528 | 1606 | if (preg_match('/\d\.\d/', $appli)) { |
| 1529 | - if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
|
| 1530 | - $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
|
| 1531 | - } else |
|
| 1532 | - $appli .= " " . DOL_VERSION; |
|
| 1533 | - } else |
|
| 1534 | - $appli .= " " . DOL_VERSION; |
|
| 1607 | + if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) { |
|
| 1608 | + $appli .= " (" . DOL_VERSION . ")"; |
|
| 1609 | + } |
|
| 1610 | + // If new title contains a version that is different than core |
|
| 1611 | + } else { |
|
| 1612 | + $appli .= " " . DOL_VERSION; |
|
| 1613 | + } |
|
| 1614 | + } else { |
|
| 1615 | + $appli .= " " . DOL_VERSION; |
|
| 1616 | + } |
|
| 1535 | 1617 | |
| 1536 | - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) |
|
| 1537 | - $appli .= "<br>" . $langs->trans("LevelOfFeature") . ': ' . $conf->global->MAIN_FEATURES_LEVEL; |
|
| 1618 | + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { |
|
| 1619 | + $appli .= "<br>" . $langs->trans("LevelOfFeature") . ': ' . $conf->global->MAIN_FEATURES_LEVEL; |
|
| 1620 | + } |
|
| 1538 | 1621 | |
| 1539 | 1622 | $logouttext = ''; |
| 1540 | 1623 | if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
@@ -1572,12 +1655,15 @@ discard block |
||
| 1572 | 1655 | $parameters = array(); |
| 1573 | 1656 | $result = $hookmanager->executeHooks('printTopRightMenu', $parameters); // Note that $action and $object may have been modified by some hooks |
| 1574 | 1657 | if (is_numeric($result)) { |
| 1575 | - if ($result == 0) |
|
| 1576 | - $toprightmenu .= $hookmanager->resPrint; // add |
|
| 1577 | - else |
|
| 1578 | - $toprightmenu = $hookmanager->resPrint; // replace |
|
| 1579 | - } |
|
| 1580 | - else { |
|
| 1658 | + if ($result == 0) { |
|
| 1659 | + $toprightmenu .= $hookmanager->resPrint; |
|
| 1660 | + } |
|
| 1661 | + // add |
|
| 1662 | + else { |
|
| 1663 | + $toprightmenu = $hookmanager->resPrint; |
|
| 1664 | + } |
|
| 1665 | + // replace |
|
| 1666 | + } else { |
|
| 1581 | 1667 | $toprightmenu .= $result; // For backward compatibility |
| 1582 | 1668 | } |
| 1583 | 1669 | |
@@ -1597,8 +1683,9 @@ discard block |
||
| 1597 | 1683 | |
| 1598 | 1684 | if (is_array($_POST)) { |
| 1599 | 1685 | foreach ($_POST as $key => $value) { |
| 1600 | - if ($key !== 'action' && $key !== 'password' && !is_array($value)) |
|
| 1601 | - $qs .= '&' . $key . '=' . urlencode($value); |
|
| 1686 | + if ($key !== 'action' && $key !== 'password' && !is_array($value)) { |
|
| 1687 | + $qs .= '&' . $key . '=' . urlencode($value); |
|
| 1688 | + } |
|
| 1602 | 1689 | } |
| 1603 | 1690 | } |
| 1604 | 1691 | $qs .= (($qs && $morequerystring) ? '&' : '') . $morequerystring; |
@@ -1617,8 +1704,9 @@ discard block |
||
| 1617 | 1704 | $helppage = ''; |
| 1618 | 1705 | $mode = ''; |
| 1619 | 1706 | |
| 1620 | - if (empty($helppagename)) |
|
| 1621 | - $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios'; |
|
| 1707 | + if (empty($helppagename)) { |
|
| 1708 | + $helppagename = 'EN:User_documentation|FR:Documentation_utilisateur|ES:Documentación_usuarios'; |
|
| 1709 | + } |
|
| 1622 | 1710 | |
| 1623 | 1711 | // Get helpbaseurl, helppage and mode from helppagename and langs |
| 1624 | 1712 | $arrayres = getHelpParamFor($helppagename, $langs); |
@@ -1635,13 +1723,15 @@ discard block |
||
| 1635 | 1723 | } |
| 1636 | 1724 | $title = $appli . '<br>'; |
| 1637 | 1725 | $title .= $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage'); |
| 1638 | - if ($mode == 'wiki') |
|
| 1639 | - $title .= ' - ' . $langs->trans("PageWiki") . ' "' . dol_escape_htmltag(strtr($helppage, '_', ' ')) . '"'; |
|
| 1726 | + if ($mode == 'wiki') { |
|
| 1727 | + $title .= ' - ' . $langs->trans("PageWiki") . ' "' . dol_escape_htmltag(strtr($helppage, '_', ' ')) . '"'; |
|
| 1728 | + } |
|
| 1640 | 1729 | $text .= '<a class="help" target="_blank" rel="noopener" href="'; |
| 1641 | - if ($mode == 'wiki') |
|
| 1642 | - $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage))); |
|
| 1643 | - else |
|
| 1644 | - $text .= sprintf($helpbaseurl, $helppage); |
|
| 1730 | + if ($mode == 'wiki') { |
|
| 1731 | + $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage))); |
|
| 1732 | + } else { |
|
| 1733 | + $text .= sprintf($helpbaseurl, $helppage); |
|
| 1734 | + } |
|
| 1645 | 1735 | $text .= '">'; |
| 1646 | 1736 | //$text.=img_picto('', 'helpdoc_top').' '; |
| 1647 | 1737 | $text .= '<span class="fa fa-question-circle atoplogin"></span>'; |
@@ -1668,9 +1758,10 @@ discard block |
||
| 1668 | 1758 | print "<!-- End top horizontal menu -->\n\n"; |
| 1669 | 1759 | } |
| 1670 | 1760 | |
| 1671 | - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) |
|
| 1672 | - print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 1673 | -} |
|
| 1761 | + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) { |
|
| 1762 | + print '<!-- Begin div id-container --><div id="id-container" class="id-container' . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 1763 | + } |
|
| 1764 | + } |
|
| 1674 | 1765 | |
| 1675 | 1766 | /** |
| 1676 | 1767 | * Show left menu bar |
@@ -1694,8 +1785,9 @@ discard block |
||
| 1694 | 1785 | $searchform = ''; |
| 1695 | 1786 | $bookmarks = ''; |
| 1696 | 1787 | |
| 1697 | - if (!empty($menu_array_before)) |
|
| 1698 | - 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); |
|
| 1788 | + if (!empty($menu_array_before)) { |
|
| 1789 | + 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); |
|
| 1790 | + } |
|
| 1699 | 1791 | |
| 1700 | 1792 | if (empty($conf->dol_hide_leftmenu) && (!defined('NOREQUIREMENU') || !constant('NOREQUIREMENU'))) { |
| 1701 | 1793 | // Instantiate hooks of thirdparty module |
@@ -1703,8 +1795,10 @@ discard block |
||
| 1703 | 1795 | |
| 1704 | 1796 | print "\n" . '<!-- Begin side-nav id-left -->' . "\n" . '<div class="side-nav"><div id="id-left">' . "\n"; |
| 1705 | 1797 | |
| 1706 | - if ($conf->browser->layout == 'phone') |
|
| 1707 | - $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? |
|
| 1798 | + if ($conf->browser->layout == 'phone') { |
|
| 1799 | + $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; |
|
| 1800 | + } |
|
| 1801 | + // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? |
|
| 1708 | 1802 | |
| 1709 | 1803 | print "\n"; |
| 1710 | 1804 | |
@@ -1731,8 +1825,9 @@ discard block |
||
| 1731 | 1825 | $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks |
| 1732 | 1826 | if (empty($reshook)) { |
| 1733 | 1827 | $searchform .= $hookmanager->resPrint; |
| 1734 | - } else |
|
| 1735 | - $searchform = $hookmanager->resPrint; |
|
| 1828 | + } else { |
|
| 1829 | + $searchform = $hookmanager->resPrint; |
|
| 1830 | + } |
|
| 1736 | 1831 | |
| 1737 | 1832 | // Force special value for $searchform |
| 1738 | 1833 | if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) { |
@@ -1776,38 +1871,49 @@ discard block |
||
| 1776 | 1871 | if (empty($conf->global->MAIN_HIDE_VERSION)) { // Version is already on help picto and on login page. |
| 1777 | 1872 | $doliurl = 'https://www.dolibarr.org'; |
| 1778 | 1873 | //local communities |
| 1779 | - if (preg_match('/fr/i', $langs->defaultlang)) |
|
| 1780 | - $doliurl = 'https://www.dolibarr.fr'; |
|
| 1781 | - if (preg_match('/es/i', $langs->defaultlang)) |
|
| 1782 | - $doliurl = 'https://www.dolibarr.es'; |
|
| 1783 | - if (preg_match('/de/i', $langs->defaultlang)) |
|
| 1784 | - $doliurl = 'https://www.dolibarr.de'; |
|
| 1785 | - if (preg_match('/it/i', $langs->defaultlang)) |
|
| 1786 | - $doliurl = 'https://www.dolibarr.it'; |
|
| 1787 | - if (preg_match('/gr/i', $langs->defaultlang)) |
|
| 1788 | - $doliurl = 'https://www.dolibarr.gr'; |
|
| 1874 | + if (preg_match('/fr/i', $langs->defaultlang)) { |
|
| 1875 | + $doliurl = 'https://www.dolibarr.fr'; |
|
| 1876 | + } |
|
| 1877 | + if (preg_match('/es/i', $langs->defaultlang)) { |
|
| 1878 | + $doliurl = 'https://www.dolibarr.es'; |
|
| 1879 | + } |
|
| 1880 | + if (preg_match('/de/i', $langs->defaultlang)) { |
|
| 1881 | + $doliurl = 'https://www.dolibarr.de'; |
|
| 1882 | + } |
|
| 1883 | + if (preg_match('/it/i', $langs->defaultlang)) { |
|
| 1884 | + $doliurl = 'https://www.dolibarr.it'; |
|
| 1885 | + } |
|
| 1886 | + if (preg_match('/gr/i', $langs->defaultlang)) { |
|
| 1887 | + $doliurl = 'https://www.dolibarr.gr'; |
|
| 1888 | + } |
|
| 1789 | 1889 | |
| 1790 | 1890 | $appli = constant('DOL_APPLICATION_TITLE'); |
| 1791 | 1891 | if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { |
| 1792 | 1892 | $appli = $conf->global->MAIN_APPLICATION_TITLE; |
| 1793 | 1893 | $doliurl = ''; |
| 1794 | 1894 | if (preg_match('/\d\.\d/', $appli)) { |
| 1795 | - if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) |
|
| 1796 | - $appli .= " (" . DOL_VERSION . ")"; // If new title contains a version that is different than core |
|
| 1797 | - } else |
|
| 1798 | - $appli .= " " . DOL_VERSION; |
|
| 1799 | - } else |
|
| 1800 | - $appli .= " " . DOL_VERSION; |
|
| 1895 | + if (!preg_match('/' . preg_quote(DOL_VERSION) . '/', $appli)) { |
|
| 1896 | + $appli .= " (" . DOL_VERSION . ")"; |
|
| 1897 | + } |
|
| 1898 | + // If new title contains a version that is different than core |
|
| 1899 | + } else { |
|
| 1900 | + $appli .= " " . DOL_VERSION; |
|
| 1901 | + } |
|
| 1902 | + } else { |
|
| 1903 | + $appli .= " " . DOL_VERSION; |
|
| 1904 | + } |
|
| 1801 | 1905 | print '<div id="blockvmenuhelpapp" class="blockvmenuhelp">'; |
| 1802 | - if ($doliurl) |
|
| 1803 | - print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">'; |
|
| 1804 | - else |
|
| 1805 | - print '<span class="help">'; |
|
| 1906 | + if ($doliurl) { |
|
| 1907 | + print '<a class="help" target="_blank" rel="noopener" href="' . $doliurl . '">'; |
|
| 1908 | + } else { |
|
| 1909 | + print '<span class="help">'; |
|
| 1910 | + } |
|
| 1806 | 1911 | print $appli; |
| 1807 | - if ($doliurl) |
|
| 1808 | - print '</a>'; |
|
| 1809 | - else |
|
| 1810 | - print '</span>'; |
|
| 1912 | + if ($doliurl) { |
|
| 1913 | + print '</a>'; |
|
| 1914 | + } else { |
|
| 1915 | + print '</span>'; |
|
| 1916 | + } |
|
| 1811 | 1917 | print '</div>' . "\n"; |
| 1812 | 1918 | } |
| 1813 | 1919 | |
@@ -1854,9 +1960,10 @@ discard block |
||
| 1854 | 1960 | print "\n"; |
| 1855 | 1961 | print '<!-- Begin right area -->' . "\n"; |
| 1856 | 1962 | |
| 1857 | - if (empty($leftmenuwithoutmainarea)) |
|
| 1858 | - main_area($title); |
|
| 1859 | -} |
|
| 1963 | + if (empty($leftmenuwithoutmainarea)) { |
|
| 1964 | + main_area($title); |
|
| 1965 | + } |
|
| 1966 | + } |
|
| 1860 | 1967 | |
| 1861 | 1968 | /** |
| 1862 | 1969 | * Begin main area |
@@ -1868,16 +1975,18 @@ discard block |
||
| 1868 | 1975 | { |
| 1869 | 1976 | global $conf, $langs; |
| 1870 | 1977 | |
| 1871 | - if (empty($conf->dol_hide_leftmenu)) |
|
| 1872 | - print '<div id="id-right">'; |
|
| 1978 | + if (empty($conf->dol_hide_leftmenu)) { |
|
| 1979 | + print '<div id="id-right">'; |
|
| 1980 | + } |
|
| 1873 | 1981 | |
| 1874 | 1982 | print "\n"; |
| 1875 | 1983 | |
| 1876 | 1984 | print '<!-- Begin div class="fiche" -->' . "\n" . '<div class="fiche">' . "\n"; |
| 1877 | 1985 | |
| 1878 | - if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) |
|
| 1879 | - print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED)); |
|
| 1880 | -} |
|
| 1986 | + if (!empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { |
|
| 1987 | + print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED)); |
|
| 1988 | + } |
|
| 1989 | + } |
|
| 1881 | 1990 | |
| 1882 | 1991 | /** |
| 1883 | 1992 | * Return helpbaseurl, helppage and mode |
@@ -1901,18 +2010,21 @@ discard block |
||
| 1901 | 2010 | // If WIKI URL |
| 1902 | 2011 | if (preg_match('/^es/i', $langs->defaultlang)) { |
| 1903 | 2012 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 1904 | - if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) |
|
| 1905 | - $helppage = $reg[1]; |
|
| 2013 | + if (preg_match('/ES:([^|]+)/i', $helppagename, $reg)) { |
|
| 2014 | + $helppage = $reg[1]; |
|
| 2015 | + } |
|
| 1906 | 2016 | } |
| 1907 | 2017 | if (preg_match('/^fr/i', $langs->defaultlang)) { |
| 1908 | 2018 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 1909 | - if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) |
|
| 1910 | - $helppage = $reg[1]; |
|
| 2019 | + if (preg_match('/FR:([^|]+)/i', $helppagename, $reg)) { |
|
| 2020 | + $helppage = $reg[1]; |
|
| 2021 | + } |
|
| 1911 | 2022 | } |
| 1912 | 2023 | if (empty($helppage)) { // If help page not already found |
| 1913 | 2024 | $helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s'; |
| 1914 | - if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) |
|
| 1915 | - $helppage = $reg[1]; |
|
| 2025 | + if (preg_match('/EN:([^|]+)/i', $helppagename, $reg)) { |
|
| 2026 | + $helppage = $reg[1]; |
|
| 2027 | + } |
|
| 1916 | 2028 | } |
| 1917 | 2029 | $mode = 'wiki'; |
| 1918 | 2030 | } |
@@ -1943,8 +2055,9 @@ discard block |
||
| 1943 | 2055 | $ret .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 1944 | 2056 | $ret .= '<input type="hidden" name="mode" value="search">'; |
| 1945 | 2057 | $ret .= '<input type="hidden" name="savelogin" value="' . dol_escape_htmltag($user->login) . '">'; |
| 1946 | - if ($showtitlebefore) |
|
| 1947 | - $ret .= $title . ' '; |
|
| 2058 | + if ($showtitlebefore) { |
|
| 2059 | + $ret .= $title . ' '; |
|
| 2060 | + } |
|
| 1948 | 2061 | $ret .= '<input type="text" class="flat ' . $htmlmorecss . '"'; |
| 1949 | 2062 | $ret .= ' style="text-indent: 22px; background-image: url(\'' . $img . '\'); background-repeat: no-repeat; background-position: 3px;"'; |
| 1950 | 2063 | $ret .= ($accesskey ? ' accesskey="' . $accesskey . '"' : ''); |
@@ -1987,10 +2100,12 @@ discard block |
||
| 1987 | 2100 | foreach ($user->lastsearch_values_tmp as $key => $val) { |
| 1988 | 2101 | unset($_SESSION['lastsearch_values_tmp_' . $key]); // Clean array to rebuild it just after |
| 1989 | 2102 | if (count($val) && empty($_POST['button_removefilter'])) { // If there is search criteria to save and we did not click on 'Clear filter' button |
| 1990 | - if (empty($val['sortfield'])) |
|
| 1991 | - unset($val['sortfield']); |
|
| 1992 | - if (empty($val['sortorder'])) |
|
| 1993 | - unset($val['sortorder']); |
|
| 2103 | + if (empty($val['sortfield'])) { |
|
| 2104 | + unset($val['sortfield']); |
|
| 2105 | + } |
|
| 2106 | + if (empty($val['sortorder'])) { |
|
| 2107 | + unset($val['sortorder']); |
|
| 2108 | + } |
|
| 1994 | 2109 | dol_syslog('Save lastsearch_values_tmp_' . $key . '=' . json_encode($val, 0) . " (systematic recording of last search criterias)"); |
| 1995 | 2110 | $_SESSION['lastsearch_values_tmp_' . $key] = json_encode($val); |
| 1996 | 2111 | unset($_SESSION['lastsearch_values_' . $key]); |
@@ -2001,8 +2116,9 @@ discard block |
||
| 2001 | 2116 | |
| 2002 | 2117 | $relativepathstring = $_SERVER["PHP_SELF"]; |
| 2003 | 2118 | // Clean $relativepathstring |
| 2004 | - if (constant('DOL_BASE_URI')) |
|
| 2005 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 2119 | + if (constant('DOL_BASE_URI')) { |
|
| 2120 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_BASE_URI'), '/') . '/', '', $relativepathstring); |
|
| 2121 | + } |
|
| 2006 | 2122 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
| 2007 | 2123 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
| 2008 | 2124 | if (preg_match('/list\.php$/', $relativepathstring)) { |
@@ -2010,12 +2126,15 @@ discard block |
||
| 2010 | 2126 | unset($_SESSION['lastsearch_page_tmp_' . $relativepathstring]); |
| 2011 | 2127 | unset($_SESSION['lastsearch_limit_tmp_' . $relativepathstring]); |
| 2012 | 2128 | |
| 2013 | - if (!empty($contextpage)) |
|
| 2014 | - $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage; |
|
| 2015 | - if (!empty($page) && $page > 1) |
|
| 2016 | - $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page; |
|
| 2017 | - if (!empty($limit) && $limit != $conf->limit) |
|
| 2018 | - $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit; |
|
| 2129 | + if (!empty($contextpage)) { |
|
| 2130 | + $_SESSION['lastsearch_contextpage_tmp_' . $relativepathstring] = $contextpage; |
|
| 2131 | + } |
|
| 2132 | + if (!empty($page) && $page > 1) { |
|
| 2133 | + $_SESSION['lastsearch_page_tmp_' . $relativepathstring] = $page; |
|
| 2134 | + } |
|
| 2135 | + if (!empty($limit) && $limit != $conf->limit) { |
|
| 2136 | + $_SESSION['lastsearch_limit_tmp_' . $relativepathstring] = $limit; |
|
| 2137 | + } |
|
| 2019 | 2138 | |
| 2020 | 2139 | unset($_SESSION['lastsearch_contextpage_' . $relativepathstring]); |
| 2021 | 2140 | unset($_SESSION['lastsearch_page_' . $relativepathstring]); |
@@ -2042,20 +2161,26 @@ discard block |
||
| 2042 | 2161 | |
| 2043 | 2162 | print '</div> <!-- End div class="fiche" -->' . "\n"; // End div fiche |
| 2044 | 2163 | |
| 2045 | - if (empty($conf->dol_hide_leftmenu)) |
|
| 2046 | - print '</div> <!-- End div id-right -->' . "\n"; // End div id-right |
|
| 2164 | + if (empty($conf->dol_hide_leftmenu)) { |
|
| 2165 | + print '</div> <!-- End div id-right -->' . "\n"; |
|
| 2166 | + } |
|
| 2167 | + // End div id-right |
|
| 2047 | 2168 | |
| 2048 | - if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) |
|
| 2049 | - print '</div> <!-- End div id-container -->' . "\n"; // End div container |
|
| 2169 | + if (empty($conf->dol_hide_leftmenu) && empty($conf->dol_use_jmobile)) { |
|
| 2170 | + print '</div> <!-- End div id-container -->' . "\n"; |
|
| 2171 | + } |
|
| 2172 | + // End div container |
|
| 2050 | 2173 | |
| 2051 | 2174 | print "\n"; |
| 2052 | - if ($comment) |
|
| 2053 | - print '<!-- ' . $comment . ' -->' . "\n"; |
|
| 2175 | + if ($comment) { |
|
| 2176 | + print '<!-- ' . $comment . ' -->' . "\n"; |
|
| 2177 | + } |
|
| 2054 | 2178 | |
| 2055 | 2179 | printCommonFooter($zone); |
| 2056 | 2180 | |
| 2057 | - if (!empty($delayedhtmlcontent)) |
|
| 2058 | - print $delayedhtmlcontent; |
|
| 2181 | + if (!empty($delayedhtmlcontent)) { |
|
| 2182 | + print $delayedhtmlcontent; |
|
| 2183 | + } |
|
| 2059 | 2184 | |
| 2060 | 2185 | if (!empty($conf->use_javascript_ajax)) { |
| 2061 | 2186 | print "\n" . '<!-- Includes JS Footer of Dolibarr -->' . "\n"; |
@@ -31,8 +31,9 @@ discard block |
||
| 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'; |
@@ -141,8 +142,9 @@ discard block |
||
| 141 | 142 | $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; |
| 142 | 143 | |
| 143 | 144 | // Define prefix |
| 144 | -if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) |
|
| 145 | +if (!isset($dolibarr_main_db_prefix) || !$dolibarr_main_db_prefix) { |
|
| 145 | 146 | $dolibarr_main_db_prefix = 'llx_'; |
| 147 | +} |
|
| 146 | 148 | define('MAIN_DB_PREFIX', (isset($dolibarr_main_db_prefix) ? $dolibarr_main_db_prefix : '')); |
| 147 | 149 | |
| 148 | 150 | define('DOL_CLASS_PATH', 'class/'); // Filsystem path to class dir |
@@ -150,23 +152,31 @@ discard block |
||
| 150 | 152 | define('DOL_MAIN_URL_ROOT', (isset($dolibarr_main_url_root) ? $dolibarr_main_url_root : '')); // URL relative root |
| 151 | 153 | $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http* |
| 152 | 154 | $suburi = strstr($uri, '/'); // $suburi contains url without domain |
| 153 | -if ($suburi == '/') |
|
| 154 | - $suburi = ''; // If $suburi is /, it is now '' |
|
| 155 | +if ($suburi == '/') { |
|
| 156 | + $suburi = ''; |
|
| 157 | +} |
|
| 158 | +// If $suburi is /, it is now '' |
|
| 155 | 159 | define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...) |
| 156 | 160 | |
| 157 | 161 | |
| 158 | -if (empty($conf->file->character_set_client)) |
|
| 162 | +if (empty($conf->file->character_set_client)) { |
|
| 159 | 163 | $conf->file->character_set_client = "utf-8"; |
| 160 | -if (empty($conf->db->character_set)) |
|
| 164 | +} |
|
| 165 | +if (empty($conf->db->character_set)) { |
|
| 161 | 166 | $conf->db->character_set = 'utf8'; |
| 162 | -if (empty($conf->db->dolibarr_main_db_collation)) |
|
| 167 | +} |
|
| 168 | +if (empty($conf->db->dolibarr_main_db_collation)) { |
|
| 163 | 169 | $conf->db->dolibarr_main_db_collation = 'utf8_unicode_ci'; |
| 164 | -if (empty($conf->db->dolibarr_main_db_encryption)) |
|
| 170 | +} |
|
| 171 | +if (empty($conf->db->dolibarr_main_db_encryption)) { |
|
| 165 | 172 | $conf->db->dolibarr_main_db_encryption = 0; |
| 166 | -if (empty($conf->db->dolibarr_main_db_cryptkey)) |
|
| 173 | +} |
|
| 174 | +if (empty($conf->db->dolibarr_main_db_cryptkey)) { |
|
| 167 | 175 | $conf->db->dolibarr_main_db_cryptkey = ''; |
| 168 | -if (empty($conf->db->user)) |
|
| 176 | +} |
|
| 177 | +if (empty($conf->db->user)) { |
|
| 169 | 178 | $conf->db->user = ''; |
| 179 | +} |
|
| 170 | 180 | |
| 171 | 181 | // Define array of document root directories |
| 172 | 182 | $conf->file->dol_document_root = array(DOL_DOCUMENT_ROOT); |
@@ -223,19 +233,24 @@ discard block |
||
| 223 | 233 | // Force usage of log file for install and upgrades |
| 224 | 234 | $conf->syslog->enabled = 1; |
| 225 | 235 | $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); |
| 226 | -if (!defined('SYSLOG_HANDLERS')) |
|
| 236 | +if (!defined('SYSLOG_HANDLERS')) { |
|
| 227 | 237 | define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); |
| 238 | +} |
|
| 228 | 239 | if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined |
| 229 | - if (@is_writable('/tmp')) |
|
| 230 | - define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); |
|
| 231 | - else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) |
|
| 232 | - define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log'); |
|
| 233 | - else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) |
|
| 234 | - define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log'); |
|
| 235 | - else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) |
|
| 236 | - define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp |
|
| 237 | - else if (@is_writable('../../')) |
|
| 238 | - 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 |
|
| 239 | 254 | |
| 240 | 255 | |
| 241 | 256 | |
@@ -248,10 +263,12 @@ discard block |
||
| 248 | 263 | |
| 249 | 264 | //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; |
| 250 | 265 | } |
| 251 | -if (defined('SYSLOG_FILE')) |
|
| 266 | +if (defined('SYSLOG_FILE')) { |
|
| 252 | 267 | $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); |
| 253 | -if (!defined('SYSLOG_FILE_NO_ERROR')) |
|
| 268 | +} |
|
| 269 | +if (!defined('SYSLOG_FILE_NO_ERROR')) { |
|
| 254 | 270 | define('SYSLOG_FILE_NO_ERROR', 1); |
| 271 | +} |
|
| 255 | 272 | // We init log handler for install |
| 256 | 273 | $handlers = array('mod_syslog_file'); |
| 257 | 274 | foreach ($handlers as $handler) { |
@@ -266,9 +283,10 @@ discard block |
||
| 266 | 283 | throw new Exception('Log handler does not extend LogHandlerInterface'); |
| 267 | 284 | } |
| 268 | 285 | |
| 269 | - if (empty($conf->loghandlers[$handler])) |
|
| 270 | - $conf->loghandlers[$handler] = $loghandlerinstance; |
|
| 271 | -} |
|
| 286 | + if (empty($conf->loghandlers[$handler])) { |
|
| 287 | + $conf->loghandlers[$handler] = $loghandlerinstance; |
|
| 288 | + } |
|
| 289 | + } |
|
| 272 | 290 | |
| 273 | 291 | // Removed magic_quotes |
| 274 | 292 | if (function_exists('get_magic_quotes_gpc')) { // magic_quotes_* removed in PHP 5.4 |
@@ -292,10 +310,11 @@ discard block |
||
| 292 | 310 | |
| 293 | 311 | // Defini objet langs |
| 294 | 312 | $langs = new Translate('..', $conf); |
| 295 | -if (GETPOST('lang', 'aZ09')) |
|
| 313 | +if (GETPOST('lang', 'aZ09')) { |
|
| 296 | 314 | $langs->setDefaultLang(GETPOST('lang', 'aZ09')); |
| 297 | -else |
|
| 315 | +} else { |
|
| 298 | 316 | $langs->setDefaultLang('auto'); |
| 317 | +} |
|
| 299 | 318 | |
| 300 | 319 | $bc[false] = ' class="bg1"'; |
| 301 | 320 | $bc[true] = ' class="bg2"'; |
@@ -318,8 +337,9 @@ discard block |
||
| 318 | 337 | global $character_set_client; |
| 319 | 338 | |
| 320 | 339 | $return = include_once $dolibarr_main_document_root . '/core/class/conf.class.php'; |
| 321 | - if (!$return) |
|
| 322 | - return -1; |
|
| 340 | + if (!$return) { |
|
| 341 | + return -1; |
|
| 342 | + } |
|
| 323 | 343 | |
| 324 | 344 | $conf = new Conf(); |
| 325 | 345 | $conf->db->type = trim($dolibarr_main_db_type); |
@@ -330,40 +350,51 @@ discard block |
||
| 330 | 350 | $conf->db->pass = trim($dolibarr_main_db_pass); |
| 331 | 351 | |
| 332 | 352 | // Mysql driver support has been removed in favor of mysqli |
| 333 | - if ($conf->db->type == 'mysql') |
|
| 334 | - $conf->db->type = 'mysqli'; |
|
| 335 | - if (empty($character_set_client)) |
|
| 336 | - $character_set_client = "UTF-8"; |
|
| 353 | + if ($conf->db->type == 'mysql') { |
|
| 354 | + $conf->db->type = 'mysqli'; |
|
| 355 | + } |
|
| 356 | + if (empty($character_set_client)) { |
|
| 357 | + $character_set_client = "UTF-8"; |
|
| 358 | + } |
|
| 337 | 359 | $conf->file->character_set_client = strtoupper($character_set_client); |
| 338 | - if (empty($dolibarr_main_db_character_set)) |
|
| 339 | - $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); |
|
| 360 | + if (empty($dolibarr_main_db_character_set)) { |
|
| 361 | + $dolibarr_main_db_character_set = ($conf->db->type == 'mysqli' ? 'utf8' : ''); |
|
| 362 | + } |
|
| 340 | 363 | $conf->db->character_set = $dolibarr_main_db_character_set; |
| 341 | - if (empty($dolibarr_main_db_collation)) |
|
| 342 | - $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); |
|
| 364 | + if (empty($dolibarr_main_db_collation)) { |
|
| 365 | + $dolibarr_main_db_collation = ($conf->db->type == 'mysqli' ? 'utf8_unicode_ci' : ''); |
|
| 366 | + } |
|
| 343 | 367 | $conf->db->dolibarr_main_db_collation = $dolibarr_main_db_collation; |
| 344 | - if (empty($dolibarr_main_db_encryption)) |
|
| 345 | - $dolibarr_main_db_encryption = 0; |
|
| 368 | + if (empty($dolibarr_main_db_encryption)) { |
|
| 369 | + $dolibarr_main_db_encryption = 0; |
|
| 370 | + } |
|
| 346 | 371 | $conf->db->dolibarr_main_db_encryption = $dolibarr_main_db_encryption; |
| 347 | - if (empty($dolibarr_main_db_cryptkey)) |
|
| 348 | - $dolibarr_main_db_cryptkey = ''; |
|
| 372 | + if (empty($dolibarr_main_db_cryptkey)) { |
|
| 373 | + $dolibarr_main_db_cryptkey = ''; |
|
| 374 | + } |
|
| 349 | 375 | $conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey; |
| 350 | 376 | |
| 351 | 377 | // Force usage of log file for install and upgrades |
| 352 | 378 | $conf->syslog->enabled = 1; |
| 353 | 379 | $conf->global->SYSLOG_LEVEL = constant('LOG_DEBUG'); |
| 354 | - if (!defined('SYSLOG_HANDLERS')) |
|
| 355 | - define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); |
|
| 380 | + if (!defined('SYSLOG_HANDLERS')) { |
|
| 381 | + define('SYSLOG_HANDLERS', '["mod_syslog_file"]'); |
|
| 382 | + } |
|
| 356 | 383 | if (!defined('SYSLOG_FILE')) { // To avoid warning on systems with constant already defined |
| 357 | - if (@is_writable('/tmp')) |
|
| 358 | - define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); |
|
| 359 | - else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) |
|
| 360 | - define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log'); |
|
| 361 | - else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) |
|
| 362 | - define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log'); |
|
| 363 | - else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) |
|
| 364 | - define('SYSLOG_FILE', '../../../../dolibarr_install.log'); // For DoliWamp |
|
| 365 | - else if (@is_writable('../../')) |
|
| 366 | - define('SYSLOG_FILE', '../../dolibarr_install.log'); // For others |
|
| 384 | + if (@is_writable('/tmp')) { |
|
| 385 | + define('SYSLOG_FILE', '/tmp/dolibarr_install.log'); |
|
| 386 | + } else if (!empty($_ENV["TMP"]) && @is_writable($_ENV["TMP"])) { |
|
| 387 | + define('SYSLOG_FILE', $_ENV["TMP"] . '/dolibarr_install.log'); |
|
| 388 | + } else if (!empty($_ENV["TEMP"]) && @is_writable($_ENV["TEMP"])) { |
|
| 389 | + define('SYSLOG_FILE', $_ENV["TEMP"] . '/dolibarr_install.log'); |
|
| 390 | + } else if (@is_writable('../../../../') && @file_exists('../../../../startdoliwamp.bat')) { |
|
| 391 | + define('SYSLOG_FILE', '../../../../dolibarr_install.log'); |
|
| 392 | + } |
|
| 393 | + // For DoliWamp |
|
| 394 | + else if (@is_writable('../../')) { |
|
| 395 | + define('SYSLOG_FILE', '../../dolibarr_install.log'); |
|
| 396 | + } |
|
| 397 | + // For others |
|
| 367 | 398 | |
| 368 | 399 | |
| 369 | 400 | |
@@ -376,10 +407,12 @@ discard block |
||
| 376 | 407 | |
| 377 | 408 | //print 'SYSLOG_FILE='.SYSLOG_FILE;exit; |
| 378 | 409 | } |
| 379 | - if (defined('SYSLOG_FILE')) |
|
| 380 | - $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); |
|
| 381 | - if (!defined('SYSLOG_FILE_NO_ERROR')) |
|
| 382 | - define('SYSLOG_FILE_NO_ERROR', 1); |
|
| 410 | + if (defined('SYSLOG_FILE')) { |
|
| 411 | + $conf->global->SYSLOG_FILE = constant('SYSLOG_FILE'); |
|
| 412 | + } |
|
| 413 | + if (!defined('SYSLOG_FILE_NO_ERROR')) { |
|
| 414 | + define('SYSLOG_FILE_NO_ERROR', 1); |
|
| 415 | + } |
|
| 383 | 416 | // We init log handler for install |
| 384 | 417 | $handlers = array('mod_syslog_file'); |
| 385 | 418 | foreach ($handlers as $handler) { |
@@ -394,8 +427,9 @@ discard block |
||
| 394 | 427 | throw new Exception('Log handler does not extend LogHandlerInterface'); |
| 395 | 428 | } |
| 396 | 429 | |
| 397 | - if (empty($conf->loghandlers[$handler])) |
|
| 398 | - $conf->loghandlers[$handler] = $loghandlerinstance; |
|
| 430 | + if (empty($conf->loghandlers[$handler])) { |
|
| 431 | + $conf->loghandlers[$handler] = $loghandlerinstance; |
|
| 432 | + } |
|
| 399 | 433 | } |
| 400 | 434 | |
| 401 | 435 | return 1; |
@@ -517,11 +551,13 @@ discard block |
||
| 517 | 551 | } |
| 518 | 552 | |
| 519 | 553 | print '<input type="submit" ' . ($nonext == '2' ? 'disabled="disabled" ' : '') . 'value="' . $langs->trans("NextStep") . ' ->"'; |
| 520 | - if ($jscheckfunction) |
|
| 521 | - print ' onClick="return ' . $jscheckfunction . '();"'; |
|
| 554 | + if ($jscheckfunction) { |
|
| 555 | + print ' onClick="return ' . $jscheckfunction . '();"'; |
|
| 556 | + } |
|
| 522 | 557 | print '></div>'; |
| 523 | - if ($withpleasewait) |
|
| 524 | - print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>' . $langs->trans("NextStepMightLastALongTime") . '<br><br><div class="blinkwait">' . $langs->trans("PleaseBePatient") . '</div></div>'; |
|
| 558 | + if ($withpleasewait) { |
|
| 559 | + print '<div style="visibility: hidden;" class="pleasewait" id="pleasewait"><br>' . $langs->trans("NextStepMightLastALongTime") . '<br><br><div class="blinkwait">' . $langs->trans("PleaseBePatient") . '</div></div>'; |
|
| 560 | + } |
|
| 525 | 561 | } |
| 526 | 562 | if ($setuplang) { |
| 527 | 563 | print '<input type="hidden" name="selectlang" value="' . $setuplang . '">'; |
@@ -557,8 +593,9 @@ discard block |
||
| 557 | 593 | */ |
| 558 | 594 | function dolibarr_install_syslog($message, $level = LOG_DEBUG) |
| 559 | 595 | { |
| 560 | - if (!defined('LOG_DEBUG')) |
|
| 561 | - define('LOG_DEBUG', 6); |
|
| 596 | + if (!defined('LOG_DEBUG')) { |
|
| 597 | + define('LOG_DEBUG', 6); |
|
| 598 | + } |
|
| 562 | 599 | dol_syslog($message, $level); |
| 563 | 600 | } |
| 564 | 601 | |