@@ -49,8 +49,7 @@ |
||
49 | 49 | if (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox','alpha')) |
50 | 50 | { |
51 | 51 | $stripearrayofkeys = $stripearrayofkeysbyenv[0]; // Test |
52 | -} |
|
53 | -else |
|
52 | +} else |
|
54 | 53 | { |
55 | 54 | $stripearrayofkeys = $stripearrayofkeysbyenv[1]; // Live |
56 | 55 | } |
@@ -75,8 +75,9 @@ discard block |
||
75 | 75 | if ($found) return $result; |
76 | 76 | } */ |
77 | 77 | |
78 | - if (isset($class::$member)) |
|
79 | - return $class::$member; |
|
78 | + if (isset($class::$member)) { |
|
79 | + return $class::$member; |
|
80 | + } |
|
80 | 81 | dol_print_error('', 'Try to get a static member "' . $member . '" in class "' . $class . '" that does not exists or is not static.'); |
81 | 82 | return null; |
82 | 83 | } |
@@ -127,8 +128,9 @@ discard block |
||
127 | 128 | } else { |
128 | 129 | $out = ''; |
129 | 130 | $addzero = array('user', 'usergroup', 'c_email_templates', 'email_template', 'default_values'); |
130 | - if (in_array($element, $addzero)) |
|
131 | - $out .= '0,'; |
|
131 | + if (in_array($element, $addzero)) { |
|
132 | + $out .= '0,'; |
|
133 | + } |
|
132 | 134 | $out .= $conf->entity; |
133 | 135 | return $out; |
134 | 136 | } |
@@ -307,32 +309,35 @@ discard block |
||
307 | 309 | { |
308 | 310 | global $mysoc, $user, $conf; |
309 | 311 | |
310 | - if (empty($paramname)) |
|
311 | - return 'BadFirstParameterForGETPOST'; |
|
312 | + if (empty($paramname)) { |
|
313 | + return 'BadFirstParameterForGETPOST'; |
|
314 | + } |
|
312 | 315 | if (empty($check)) { |
313 | 316 | dol_syslog("Deprecated use of GETPOST, called with 1st param = " . $paramname . " and 2nd param is '', when calling page " . $_SERVER["PHP_SELF"], LOG_WARNING); |
314 | 317 | // Enable this line to know who call the GETPOST with '' $check parameter. |
315 | 318 | //var_dump(debug_backtrace()[0]); |
316 | 319 | } |
317 | 320 | |
318 | - if (empty($method)) |
|
319 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
320 | - elseif ($method == 1) |
|
321 | - $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
322 | - elseif ($method == 2) |
|
323 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
324 | - elseif ($method == 3) |
|
325 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
326 | - elseif ($method == 4) |
|
327 | - $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
328 | - else |
|
329 | - return 'BadThirdParameterForGETPOST'; |
|
321 | + if (empty($method)) { |
|
322 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_POST[$paramname]) ? $_POST[$paramname] : ''); |
|
323 | + } elseif ($method == 1) { |
|
324 | + $out = isset($_GET[$paramname]) ? $_GET[$paramname] : ''; |
|
325 | + } elseif ($method == 2) { |
|
326 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : ''; |
|
327 | + } elseif ($method == 3) { |
|
328 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : ''); |
|
329 | + } elseif ($method == 4) { |
|
330 | + $out = isset($_POST[$paramname]) ? $_POST[$paramname] : (isset($_GET[$paramname]) ? $_GET[$paramname] : (isset($_COOKIE[$paramname]) ? $_COOKIE[$paramname] : '')); |
|
331 | + } else { |
|
332 | + return 'BadThirdParameterForGETPOST'; |
|
333 | + } |
|
330 | 334 | |
331 | 335 | if (empty($method) || $method == 3 || $method == 4) { |
332 | 336 | $relativepathstring = $_SERVER["PHP_SELF"]; |
333 | 337 | // Clean $relativepathstring |
334 | - if (constant('DOL_URL_ROOT')) |
|
335 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
338 | + if (constant('DOL_URL_ROOT')) { |
|
339 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
340 | + } |
|
336 | 341 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
337 | 342 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
338 | 343 | //var_dump($relativepathstring); |
@@ -381,14 +386,17 @@ discard block |
||
381 | 386 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
382 | 387 | $foundintru = 0; |
383 | 388 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
384 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
385 | - $foundintru = 1; |
|
389 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
390 | + $foundintru = 1; |
|
391 | + } |
|
386 | 392 | } |
387 | - if (!$foundintru) |
|
388 | - $qualified = 1; |
|
393 | + if (!$foundintru) { |
|
394 | + $qualified = 1; |
|
395 | + } |
|
389 | 396 | //var_dump($defkey.'-'.$qualified); |
390 | - } else |
|
391 | - $qualified = 1; |
|
397 | + } else { |
|
398 | + $qualified = 1; |
|
399 | + } |
|
392 | 400 | |
393 | 401 | if ($qualified) { |
394 | 402 | //var_dump($user->default_values[$relativepathstring][$defkey]['createform']); |
@@ -415,20 +423,24 @@ discard block |
||
415 | 423 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
416 | 424 | $foundintru = 0; |
417 | 425 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
418 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
419 | - $foundintru = 1; |
|
426 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
427 | + $foundintru = 1; |
|
428 | + } |
|
420 | 429 | } |
421 | - if (!$foundintru) |
|
422 | - $qualified = 1; |
|
430 | + if (!$foundintru) { |
|
431 | + $qualified = 1; |
|
432 | + } |
|
423 | 433 | //var_dump($defkey.'-'.$qualified); |
424 | - } else |
|
425 | - $qualified = 1; |
|
434 | + } else { |
|
435 | + $qualified = 1; |
|
436 | + } |
|
426 | 437 | |
427 | 438 | if ($qualified) { |
428 | 439 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ";", "="); // we accept _, -, . and , |
429 | 440 | foreach ($user->default_values[$relativepathstring]['sortorder'][$defkey] as $key => $val) { |
430 | - if ($out) |
|
431 | - $out .= ', '; |
|
441 | + if ($out) { |
|
442 | + $out .= ', '; |
|
443 | + } |
|
432 | 444 | if ($paramname == 'sortfield') { |
433 | 445 | $out .= dol_string_nospecial($key, '', $forbidden_chars_to_replace); |
434 | 446 | } |
@@ -448,14 +460,17 @@ discard block |
||
448 | 460 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
449 | 461 | $foundintru = 0; |
450 | 462 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
451 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
452 | - $foundintru = 1; |
|
463 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
464 | + $foundintru = 1; |
|
465 | + } |
|
453 | 466 | } |
454 | - if (!$foundintru) |
|
455 | - $qualified = 1; |
|
467 | + if (!$foundintru) { |
|
468 | + $qualified = 1; |
|
469 | + } |
|
456 | 470 | //var_dump($defkey.'-'.$qualified); |
457 | - } else |
|
458 | - $qualified = 1; |
|
471 | + } else { |
|
472 | + $qualified = 1; |
|
473 | + } |
|
459 | 474 | |
460 | 475 | if ($qualified) { |
461 | 476 | if (isset($_POST['sall']) || isset($_POST['search_all']) || isset($_GET['sall']) || isset($_GET['search_all'])) { |
@@ -527,8 +542,10 @@ discard block |
||
527 | 542 | $newout = $user->fk_user; |
528 | 543 | } elseif ($reg[1] == 'ENTITY_ID' || $reg[1] == 'ENTITYID') { |
529 | 544 | $newout = $conf->entity; |
530 | - } else |
|
531 | - $newout = ''; // Key not found, we replace with empty string |
|
545 | + } else { |
|
546 | + $newout = ''; |
|
547 | + } |
|
548 | + // Key not found, we replace with empty string |
|
532 | 549 | |
533 | 550 | |
534 | 551 | |
@@ -564,18 +581,20 @@ discard block |
||
564 | 581 | } |
565 | 582 | break; |
566 | 583 | case 'intcomma': |
567 | - if (preg_match('/[^0-9,-]+/i', $out)) |
|
568 | - $out = ''; |
|
584 | + if (preg_match('/[^0-9,-]+/i', $out)) { |
|
585 | + $out = ''; |
|
586 | + } |
|
569 | 587 | break; |
570 | 588 | case 'alpha': |
571 | 589 | if (!is_array($out)) { |
572 | 590 | $out = trim($out); |
573 | 591 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
574 | 592 | // '../' is dangerous because it allows dir transversals |
575 | - if (preg_match('/"/', $out)) |
|
576 | - $out = ''; |
|
577 | - else if (preg_match('/\.\.\//', $out)) |
|
578 | - $out = ''; |
|
593 | + if (preg_match('/"/', $out)) { |
|
594 | + $out = ''; |
|
595 | + } else if (preg_match('/\.\.\//', $out)) { |
|
596 | + $out = ''; |
|
597 | + } |
|
579 | 598 | } |
580 | 599 | break; |
581 | 600 | case 'san_alpha': |
@@ -584,27 +603,31 @@ discard block |
||
584 | 603 | case 'aZ': |
585 | 604 | if (!is_array($out)) { |
586 | 605 | $out = trim($out); |
587 | - if (preg_match('/[^a-z]+/i', $out)) |
|
588 | - $out = ''; |
|
606 | + if (preg_match('/[^a-z]+/i', $out)) { |
|
607 | + $out = ''; |
|
608 | + } |
|
589 | 609 | } |
590 | 610 | break; |
591 | 611 | case 'aZ09': |
592 | 612 | if (!is_array($out)) { |
593 | 613 | $out = trim($out); |
594 | - if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) |
|
595 | - $out = ''; |
|
614 | + if (preg_match('/[^a-z0-9_\-\.]+/i', $out)) { |
|
615 | + $out = ''; |
|
616 | + } |
|
596 | 617 | } |
597 | 618 | break; |
598 | 619 | case 'aZ09comma': // great to sanitize sortfield or sortorder params that can be t.abc,t.def_gh |
599 | 620 | if (!is_array($out)) { |
600 | 621 | $out = trim($out); |
601 | - if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) |
|
602 | - $out = ''; |
|
622 | + if (preg_match('/[^a-z0-9_\-\.,]+/i', $out)) { |
|
623 | + $out = ''; |
|
624 | + } |
|
603 | 625 | } |
604 | 626 | break; |
605 | 627 | case 'array': |
606 | - if (!is_array($out) || empty($out)) |
|
607 | - $out = array(); |
|
628 | + if (!is_array($out) || empty($out)) { |
|
629 | + $out = array(); |
|
630 | + } |
|
608 | 631 | break; |
609 | 632 | case 'nohtml': // Recommended for most scalar parameters |
610 | 633 | $out = dol_string_nohtmltag($out, 0); |
@@ -614,16 +637,18 @@ discard block |
||
614 | 637 | $out = trim($out); |
615 | 638 | // '"' is dangerous because param in url can close the href= or src= and add javascript functions. |
616 | 639 | // '../' is dangerous because it allows dir transversals |
617 | - if (preg_match('/"/', $out)) |
|
618 | - $out = ''; |
|
619 | - else if (preg_match('/\.\.\//', $out)) |
|
620 | - $out = ''; |
|
640 | + if (preg_match('/"/', $out)) { |
|
641 | + $out = ''; |
|
642 | + } else if (preg_match('/\.\.\//', $out)) { |
|
643 | + $out = ''; |
|
644 | + } |
|
621 | 645 | $out = dol_string_nohtmltag($out); |
622 | 646 | } |
623 | 647 | break; |
624 | 648 | case 'custom': |
625 | - if (empty($filter)) |
|
626 | - return 'BadFourthParameterForGETPOST'; |
|
649 | + if (empty($filter)) { |
|
650 | + return 'BadFourthParameterForGETPOST'; |
|
651 | + } |
|
627 | 652 | $out = filter_var($out, $filter, $options); |
628 | 653 | break; |
629 | 654 | } |
@@ -663,10 +688,11 @@ discard block |
||
663 | 688 | // If prefix is for email |
664 | 689 | if ($mode == 'email') { |
665 | 690 | if (!empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID)) { // If MAIL_PREFIX_FOR_EMAIL_ID is set (a value initialized with a random value is recommended) |
666 | - if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') |
|
667 | - return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
668 | - else if (isset($_SERVER["SERVER_NAME"])) |
|
669 | - return $_SERVER["SERVER_NAME"]; |
|
691 | + if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') { |
|
692 | + return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID; |
|
693 | + } else if (isset($_SERVER["SERVER_NAME"])) { |
|
694 | + return $_SERVER["SERVER_NAME"]; |
|
695 | + } |
|
670 | 696 | } |
671 | 697 | return dol_hash(DOL_DOCUMENT_ROOT . DOL_URL_ROOT); |
672 | 698 | } |
@@ -739,22 +765,27 @@ discard block |
||
739 | 765 | } |
740 | 766 | } |
741 | 767 | if ($returnemptyifnotfound) { // Not found into alternate dir |
742 | - if ($returnemptyifnotfound == 1 || !file_exists($res)) |
|
743 | - return ''; |
|
768 | + if ($returnemptyifnotfound == 1 || !file_exists($res)) { |
|
769 | + return ''; |
|
770 | + } |
|
744 | 771 | } |
745 | - } |
|
746 | - else { // For an url path |
|
772 | + } else { // For an url path |
|
747 | 773 | // We try to get local path of file on filesystem from url |
748 | 774 | // Note that trying to know if a file on disk exist by forging path on disk from url |
749 | 775 | // works only for some web server and some setup. This is bugged when |
750 | 776 | // using proxy, rewriting, virtual path, etc... |
751 | 777 | $res = ''; |
752 | - if ($type == 1) |
|
753 | - $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path; // Standard value |
|
754 | - if ($type == 2) |
|
755 | - $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path; // Standard value |
|
756 | - if ($type == 3) |
|
757 | - $res = DOL_URL_ROOT . '/' . $path; |
|
778 | + if ($type == 1) { |
|
779 | + $res = /* DOL_URL_ROOT */ DOL_BASE_URI . '/' . $path; |
|
780 | + } |
|
781 | + // Standard value |
|
782 | + if ($type == 2) { |
|
783 | + $res = /* DOL_MAIN_URL_ROOT */ DOL_BASE_PATH . '/' . $path; |
|
784 | + } |
|
785 | + // Standard value |
|
786 | + if ($type == 3) { |
|
787 | + $res = DOL_URL_ROOT . '/' . $path; |
|
788 | + } |
|
758 | 789 | |
759 | 790 | foreach ($conf->file->dol_document_root as $key => $dirroot) { // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...) |
760 | 791 | if ($key == 'main') { |
@@ -834,13 +865,15 @@ discard block |
||
834 | 865 | function dol_size($size, $type = '') |
835 | 866 | { |
836 | 867 | global $conf; |
837 | - if (empty($conf->dol_optimize_smallscreen)) |
|
838 | - return $size; |
|
839 | - if ($type == 'width' && $size > 250) |
|
840 | - return 250; |
|
841 | - else |
|
842 | - return 10; |
|
843 | -} |
|
868 | + if (empty($conf->dol_optimize_smallscreen)) { |
|
869 | + return $size; |
|
870 | + } |
|
871 | + if ($type == 'width' && $size > 250) { |
|
872 | + return 250; |
|
873 | + } else { |
|
874 | + return 10; |
|
875 | + } |
|
876 | + } |
|
844 | 877 | |
845 | 878 | /** |
846 | 879 | * Clean a string to use it as a file name |
@@ -939,8 +972,9 @@ discard block |
||
939 | 972 | { |
940 | 973 | $forbidden_chars_to_replace = array(" ", "'", "/", "\\", ":", "*", "?", "\"", "<", ">", "|", "[", "]", ",", ";", "=", '°'); // more complete than dol_sanitizeFileName |
941 | 974 | $forbidden_chars_to_remove = array(); |
942 | - if (is_array($badcharstoreplace)) |
|
943 | - $forbidden_chars_to_replace = $badcharstoreplace; |
|
975 | + if (is_array($badcharstoreplace)) { |
|
976 | + $forbidden_chars_to_replace = $badcharstoreplace; |
|
977 | + } |
|
944 | 978 | //$forbidden_chars_to_remove=array("(",")"); |
945 | 979 | |
946 | 980 | return str_replace($forbidden_chars_to_replace, $newstr, str_replace($forbidden_chars_to_remove, "", $str)); |
@@ -977,9 +1011,9 @@ discard block |
||
977 | 1011 | if (empty($mode)) { |
978 | 1012 | $substitjs["'"] = "\\'"; |
979 | 1013 | $substitjs['"'] = "\\'"; |
980 | - } else if ($mode == 1) |
|
981 | - $substitjs["'"] = "\\'"; |
|
982 | - else if ($mode == 2) { |
|
1014 | + } else if ($mode == 1) { |
|
1015 | + $substitjs["'"] = "\\'"; |
|
1016 | + } else if ($mode == 2) { |
|
983 | 1017 | $substitjs['"'] = '\\"'; |
984 | 1018 | } else if ($mode == 3) { |
985 | 1019 | $substitjs["'"] = "\\'"; |
@@ -1001,10 +1035,12 @@ discard block |
||
1001 | 1035 | { |
1002 | 1036 | // escape quotes and backslashes, newlines, etc. |
1003 | 1037 | $tmp = html_entity_decode($stringtoescape, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars_decode instead, that make only required change for html tags |
1004 | - if (!$keepb) |
|
1005 | - $tmp = strtr($tmp, array("<b>" => '', '</b>' => '')); |
|
1006 | - if (!$keepn) |
|
1007 | - $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n')); |
|
1038 | + if (!$keepb) { |
|
1039 | + $tmp = strtr($tmp, array("<b>" => '', '</b>' => '')); |
|
1040 | + } |
|
1041 | + if (!$keepn) { |
|
1042 | + $tmp = strtr($tmp, array("\r" => '\\r', "\n" => '\\n')); |
|
1043 | + } |
|
1008 | 1044 | return htmlentities($tmp, ENT_COMPAT, 'UTF-8'); // TODO Use htmlspecialchars instead, that make only required change for html tags |
1009 | 1045 | } |
1010 | 1046 | |
@@ -1055,8 +1091,9 @@ discard block |
||
1055 | 1091 | global $conf, $user; |
1056 | 1092 | |
1057 | 1093 | // If syslog module enabled |
1058 | - if (empty($conf->syslog->enabled)) |
|
1059 | - return; |
|
1094 | + if (empty($conf->syslog->enabled)) { |
|
1095 | + return; |
|
1096 | + } |
|
1060 | 1097 | |
1061 | 1098 | if ($ident < 0) { |
1062 | 1099 | foreach ($conf->loghandlers as $loghandlerinstance) { |
@@ -1070,8 +1107,9 @@ discard block |
||
1070 | 1107 | if (!in_array($level, $logLevels, true)) { |
1071 | 1108 | throw new Exception('Incorrect log level'); |
1072 | 1109 | } |
1073 | - if ($level > $conf->global->SYSLOG_LEVEL) |
|
1074 | - return; |
|
1110 | + if ($level > $conf->global->SYSLOG_LEVEL) { |
|
1111 | + return; |
|
1112 | + } |
|
1075 | 1113 | |
1076 | 1114 | $message = preg_replace('/password=\'[^\']*\'/', 'password=\'hidden\'', $message); // protection to avoid to have value of password in log |
1077 | 1115 | // If adding log inside HTML page is required |
@@ -1096,24 +1134,30 @@ discard block |
||
1096 | 1134 | ); |
1097 | 1135 | |
1098 | 1136 | // This is when server run behind a reverse proxy |
1099 | - if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) |
|
1100 | - $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
1137 | + if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
1138 | + $data['ip'] = $_SERVER['HTTP_X_FORWARDED_FOR'] . (empty($_SERVER["REMOTE_ADDR"]) ? '' : '->' . $_SERVER['REMOTE_ADDR']); |
|
1139 | + } |
|
1101 | 1140 | // This is when server run normally on a server |
1102 | - else if (!empty($_SERVER["REMOTE_ADDR"])) |
|
1103 | - $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
1141 | + else if (!empty($_SERVER["REMOTE_ADDR"])) { |
|
1142 | + $data['ip'] = $_SERVER['REMOTE_ADDR']; |
|
1143 | + } |
|
1104 | 1144 | // This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache) |
1105 | - else if (!empty($_SERVER['SERVER_ADDR'])) |
|
1106 | - $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
1145 | + else if (!empty($_SERVER['SERVER_ADDR'])) { |
|
1146 | + $data['ip'] = $_SERVER['SERVER_ADDR']; |
|
1147 | + } |
|
1107 | 1148 | // This is when PHP session is ran outside a web server, like from Windows command line (Not always defined, but useful if OS defined it). |
1108 | - else if (!empty($_SERVER['COMPUTERNAME'])) |
|
1109 | - $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
1149 | + else if (!empty($_SERVER['COMPUTERNAME'])) { |
|
1150 | + $data['ip'] = $_SERVER['COMPUTERNAME'] . (empty($_SERVER['USERNAME']) ? '' : '@' . $_SERVER['USERNAME']); |
|
1151 | + } |
|
1110 | 1152 | // This is when PHP session is ran outside a web server, like from Linux command line (Not always defined, but usefull if OS defined it). |
1111 | - else if (!empty($_SERVER['LOGNAME'])) |
|
1112 | - $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
1153 | + else if (!empty($_SERVER['LOGNAME'])) { |
|
1154 | + $data['ip'] = '???@' . $_SERVER['LOGNAME']; |
|
1155 | + } |
|
1113 | 1156 | // Loop on each log handler and send output |
1114 | 1157 | foreach ($conf->loghandlers as $loghandlerinstance) { |
1115 | - if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) |
|
1116 | - continue; |
|
1158 | + if ($restricttologhandler && $loghandlerinstance->code != $restricttologhandler) { |
|
1159 | + continue; |
|
1160 | + } |
|
1117 | 1161 | $loghandlerinstance->export($data, $suffixinfilename); |
1118 | 1162 | } |
1119 | 1163 | unset($data); |
@@ -1169,13 +1213,15 @@ discard block |
||
1169 | 1213 | |
1170 | 1214 | // Show title |
1171 | 1215 | $showtitle = 1; |
1172 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
1173 | - $showtitle = 0; |
|
1216 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
1217 | + $showtitle = 0; |
|
1218 | + } |
|
1174 | 1219 | if (!empty($title) && $showtitle) { |
1175 | 1220 | $limittitle = 30; |
1176 | 1221 | $out .= '<a class="tabTitle">'; |
1177 | - if ($picto) |
|
1178 | - $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
1222 | + if ($picto) { |
|
1223 | + $out .= img_picto($title, ($pictoisfullpath ? '' : 'object_') . $picto, '', $pictoisfullpath) . ' '; |
|
1224 | + } |
|
1179 | 1225 | $out .= '<span class="tabTitleText">' . dol_trunc($title, $limittitle) . '</span>'; |
1180 | 1226 | $out .= '</a>'; |
1181 | 1227 | } |
@@ -1184,12 +1230,14 @@ discard block |
||
1184 | 1230 | $maxkey = -1; |
1185 | 1231 | if (is_array($links) && !empty($links)) { |
1186 | 1232 | $keys = array_keys($links); |
1187 | - if (count($keys)) |
|
1188 | - $maxkey = max($keys); |
|
1233 | + if (count($keys)) { |
|
1234 | + $maxkey = max($keys); |
|
1235 | + } |
|
1189 | 1236 | } |
1190 | 1237 | |
1191 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
1192 | - $conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
1238 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
1239 | + $conf->global->MAIN_MAXTABS_IN_CARD = 2; |
|
1240 | + } |
|
1193 | 1241 | |
1194 | 1242 | // Show tabs |
1195 | 1243 | $bactive = false; |
@@ -1202,8 +1250,9 @@ discard block |
||
1202 | 1250 | for ($i = 0; $i <= $maxkey; $i++) { |
1203 | 1251 | if ((is_numeric($active) && $i == $active) || (!empty($links[$i][2]) && !is_numeric($active) && $active == $links[$i][2])) { |
1204 | 1252 | // If active tab is already present |
1205 | - if ($i >= $limittoshow) |
|
1206 | - $limittoshow--; |
|
1253 | + if ($i >= $limittoshow) { |
|
1254 | + $limittoshow--; |
|
1255 | + } |
|
1207 | 1256 | } |
1208 | 1257 | } |
1209 | 1258 | |
@@ -1244,12 +1293,12 @@ discard block |
||
1244 | 1293 | } |
1245 | 1294 | $outmore .= '<div class="popuptab wordwrap" style="display:inherit;">'; |
1246 | 1295 | if (isset($links[$i][2]) && $links[$i][2] == 'image') { |
1247 | - if (!empty($links[$i][0])) |
|
1248 | - $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
1249 | - else |
|
1250 | - $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
1251 | - } |
|
1252 | - else if (!empty($links[$i][1])) { |
|
1296 | + if (!empty($links[$i][0])) { |
|
1297 | + $outmore .= '<a class="tabimage' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">' . $links[$i][1] . '</a>' . "\n"; |
|
1298 | + } else { |
|
1299 | + $outmore .= '<span class="tabspan">' . $links[$i][1] . '</span>' . "\n"; |
|
1300 | + } |
|
1301 | + } else if (!empty($links[$i][1])) { |
|
1253 | 1302 | $outmore .= '<a' . (!empty($links[$i][2]) ? ' id="' . $links[$i][2] . '"' : '') . ' class="wordwrap inline-block' . ($morecss ? ' ' . $morecss : '') . '" href="' . $links[$i][0] . '">'; |
1254 | 1303 | $outmore .= preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. |
1255 | 1304 | $outmore .= '</a>' . "\n"; |
@@ -1260,8 +1309,9 @@ discard block |
||
1260 | 1309 | } |
1261 | 1310 | $displaytab = $i; |
1262 | 1311 | } |
1263 | - if ($popuptab) |
|
1264 | - $outmore .= '</div>'; |
|
1312 | + if ($popuptab) { |
|
1313 | + $outmore .= '</div>'; |
|
1314 | + } |
|
1265 | 1315 | |
1266 | 1316 | if ($displaytab > $limittoshow) { |
1267 | 1317 | $left = ($langs->trans("DIRECTION") == 'rtl' ? 'right' : 'left'); |
@@ -1284,8 +1334,9 @@ discard block |
||
1284 | 1334 | |
1285 | 1335 | $out .= "</div>\n"; |
1286 | 1336 | |
1287 | - if (!$notab || $notab == -1) |
|
1288 | - $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
1337 | + if (!$notab || $notab == -1) { |
|
1338 | + $out .= "\n" . '<div class="tabBar' . ($notab == -1 ? '' : ' tabBarWithBottom') . '">' . "\n"; |
|
1339 | + } |
|
1289 | 1340 | |
1290 | 1341 | $parameters = array('tabname' => $active, 'out' => $out); |
1291 | 1342 | $reshook = $hookmanager->executeHooks('printTabsHead', $parameters); // This hook usage is called just before output the head of tabs. Take also a look at "completeTabsHead" |
@@ -1315,11 +1366,12 @@ discard block |
||
1315 | 1366 | */ |
1316 | 1367 | function dol_get_fiche_end($notab = 0) |
1317 | 1368 | { |
1318 | - if (!$notab || $notab == -1) |
|
1319 | - return "\n</div>\n"; |
|
1320 | - else |
|
1321 | - return ''; |
|
1322 | -} |
|
1369 | + if (!$notab || $notab == -1) { |
|
1370 | + return "\n</div>\n"; |
|
1371 | + } else { |
|
1372 | + return ''; |
|
1373 | + } |
|
1374 | + } |
|
1323 | 1375 | |
1324 | 1376 | /** |
1325 | 1377 | * Show tab footer of a card. |
@@ -1350,40 +1402,55 @@ discard block |
||
1350 | 1402 | $showimage = 1; |
1351 | 1403 | $entity = (empty($object->entity) ? $conf->entity : $object->entity); |
1352 | 1404 | $showbarcode = empty($conf->barcode->enabled) ? 0 : ($object->barcode ? 1 : 0); |
1353 | - if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) |
|
1354 | - $showbarcode = 0; |
|
1405 | + if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) { |
|
1406 | + $showbarcode = 0; |
|
1407 | + } |
|
1355 | 1408 | $modulepart = 'unknown'; |
1356 | 1409 | |
1357 | - if ($object->element == 'societe') |
|
1358 | - $modulepart = 'societe'; |
|
1359 | - if ($object->element == 'contact') |
|
1360 | - $modulepart = 'contact'; |
|
1361 | - if ($object->element == 'member') |
|
1362 | - $modulepart = 'memberphoto'; |
|
1363 | - if ($object->element == 'user') |
|
1364 | - $modulepart = 'userphoto'; |
|
1365 | - if ($object->element == 'product') |
|
1366 | - $modulepart = 'product'; |
|
1410 | + if ($object->element == 'societe') { |
|
1411 | + $modulepart = 'societe'; |
|
1412 | + } |
|
1413 | + if ($object->element == 'contact') { |
|
1414 | + $modulepart = 'contact'; |
|
1415 | + } |
|
1416 | + if ($object->element == 'member') { |
|
1417 | + $modulepart = 'memberphoto'; |
|
1418 | + } |
|
1419 | + if ($object->element == 'user') { |
|
1420 | + $modulepart = 'userphoto'; |
|
1421 | + } |
|
1422 | + if ($object->element == 'product') { |
|
1423 | + $modulepart = 'product'; |
|
1424 | + } |
|
1367 | 1425 | |
1368 | 1426 | if (class_exists("Imagick")) { |
1369 | - if ($object->element == 'propal') |
|
1370 | - $modulepart = 'propal'; |
|
1371 | - if ($object->element == 'commande') |
|
1372 | - $modulepart = 'commande'; |
|
1373 | - if ($object->element == 'facture') |
|
1374 | - $modulepart = 'facture'; |
|
1375 | - if ($object->element == 'fichinter') |
|
1376 | - $modulepart = 'ficheinter'; |
|
1377 | - if ($object->element == 'contrat') |
|
1378 | - $modulepart = 'contract'; |
|
1379 | - if ($object->element == 'supplier_proposal') |
|
1380 | - $modulepart = 'supplier_proposal'; |
|
1381 | - if ($object->element == 'order_supplier') |
|
1382 | - $modulepart = 'supplier_order'; |
|
1383 | - if ($object->element == 'invoice_supplier') |
|
1384 | - $modulepart = 'supplier_invoice'; |
|
1385 | - if ($object->element == 'expensereport') |
|
1386 | - $modulepart = 'expensereport'; |
|
1427 | + if ($object->element == 'propal') { |
|
1428 | + $modulepart = 'propal'; |
|
1429 | + } |
|
1430 | + if ($object->element == 'commande') { |
|
1431 | + $modulepart = 'commande'; |
|
1432 | + } |
|
1433 | + if ($object->element == 'facture') { |
|
1434 | + $modulepart = 'facture'; |
|
1435 | + } |
|
1436 | + if ($object->element == 'fichinter') { |
|
1437 | + $modulepart = 'ficheinter'; |
|
1438 | + } |
|
1439 | + if ($object->element == 'contrat') { |
|
1440 | + $modulepart = 'contract'; |
|
1441 | + } |
|
1442 | + if ($object->element == 'supplier_proposal') { |
|
1443 | + $modulepart = 'supplier_proposal'; |
|
1444 | + } |
|
1445 | + if ($object->element == 'order_supplier') { |
|
1446 | + $modulepart = 'supplier_order'; |
|
1447 | + } |
|
1448 | + if ($object->element == 'invoice_supplier') { |
|
1449 | + $modulepart = 'supplier_invoice'; |
|
1450 | + } |
|
1451 | + if ($object->element == 'expensereport') { |
|
1452 | + $modulepart = 'expensereport'; |
|
1453 | + } |
|
1387 | 1454 | } |
1388 | 1455 | |
1389 | 1456 | if ($object->element == 'product') { |
@@ -1391,11 +1458,12 @@ discard block |
||
1391 | 1458 | $cssclass = 'photoref'; |
1392 | 1459 | $showimage = $object->is_photo_available($conf->product->multidir_output[$entity]); |
1393 | 1460 | $maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : 5); |
1394 | - if ($conf->browser->layout == 'phone') |
|
1395 | - $maxvisiblephotos = 1; |
|
1396 | - if ($showimage) |
|
1397 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
1398 | - else { |
|
1461 | + if ($conf->browser->layout == 'phone') { |
|
1462 | + $maxvisiblephotos = 1; |
|
1463 | + } |
|
1464 | + if ($showimage) { |
|
1465 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('product', $conf->product->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
1466 | + } else { |
|
1399 | 1467 | if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) { |
1400 | 1468 | $nophoto = ''; |
1401 | 1469 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1411,11 +1479,12 @@ discard block |
||
1411 | 1479 | $cssclass = 'photoref'; |
1412 | 1480 | $showimage = $object->is_photo_available($conf->ticket->multidir_output[$entity] . '/' . $object->track_id); |
1413 | 1481 | $maxvisiblephotos = (isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO) ? $conf->global->TICKETSUP_MAX_VISIBLE_PHOTO : 2); |
1414 | - if ($conf->browser->layout == 'phone') |
|
1415 | - $maxvisiblephotos = 1; |
|
1416 | - if ($showimage) |
|
1417 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
1418 | - else { |
|
1482 | + if ($conf->browser->layout == 'phone') { |
|
1483 | + $maxvisiblephotos = 1; |
|
1484 | + } |
|
1485 | + if ($showimage) { |
|
1486 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $object->show_photos('ticket', $conf->ticket->multidir_output[$entity], 'small', $maxvisiblephotos, 0, 0, 0, $width, 0) . '</div>'; |
|
1487 | + } else { |
|
1419 | 1488 | if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) { |
1420 | 1489 | $nophoto = ''; |
1421 | 1490 | $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"></div>'; |
@@ -1440,8 +1509,10 @@ discard block |
||
1440 | 1509 | } else { |
1441 | 1510 | $subdir = get_exdir($object->id, 0, 0, 1, $object, $modulepart); |
1442 | 1511 | } |
1443 | - if (empty($subdir)) |
|
1444 | - $subdir = 'errorgettingsubdirofobject'; // Protection to avoid to return empty path |
|
1512 | + if (empty($subdir)) { |
|
1513 | + $subdir = 'errorgettingsubdirofobject'; |
|
1514 | + } |
|
1515 | + // Protection to avoid to return empty path |
|
1445 | 1516 | |
1446 | 1517 | $filepath = $dir_output . $subdir . "/"; |
1447 | 1518 | |
@@ -1462,14 +1533,16 @@ discard block |
||
1462 | 1533 | if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) { // If you experienc trouble with pdf thumb generation and imagick, you can disable here. |
1463 | 1534 | include_once DOL_BASE_PATH . '/core/lib/files.lib.php'; |
1464 | 1535 | $ret = dol_convert_file($file, 'png', $fileimage); |
1465 | - if ($ret < 0) |
|
1466 | - $error++; |
|
1536 | + if ($ret < 0) { |
|
1537 | + $error++; |
|
1538 | + } |
|
1467 | 1539 | } |
1468 | 1540 | } |
1469 | 1541 | |
1470 | 1542 | $heightforphotref = 70; |
1471 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
1472 | - $heightforphotref = 60; |
|
1543 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
1544 | + $heightforphotref = 60; |
|
1545 | + } |
|
1473 | 1546 | // Si fichier png PDF d'1 page trouve |
1474 | 1547 | if (file_exists($fileimage)) { |
1475 | 1548 | $phototoshow = '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref">'; |
@@ -1505,8 +1578,10 @@ discard block |
||
1505 | 1578 | $width = 14; |
1506 | 1579 | $cssclass = 'photorefcenter'; |
1507 | 1580 | $picto = $object->picto; |
1508 | - if ($object->element == 'project' && !$object->public) |
|
1509 | - $picto = 'project'; // instead of projectpub |
|
1581 | + if ($object->element == 'project' && !$object->public) { |
|
1582 | + $picto = 'project'; |
|
1583 | + } |
|
1584 | + // instead of projectpub |
|
1510 | 1585 | $nophoto = img_picto('', 'object_' . $picto, '', false, 1); |
1511 | 1586 | } |
1512 | 1587 | $morehtmlleft .= '<!-- No photo to show -->'; |
@@ -1517,8 +1592,9 @@ discard block |
||
1517 | 1592 | } |
1518 | 1593 | } |
1519 | 1594 | |
1520 | - if ($showbarcode) |
|
1521 | - $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
1595 | + if ($showbarcode) { |
|
1596 | + $morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">' . $form->showbarcode($object) . '</div>'; |
|
1597 | + } |
|
1522 | 1598 | |
1523 | 1599 | if ($object->element == 'societe') { |
1524 | 1600 | if (!empty($conf->use_javascript_ajax) && $user->rights->societe->creer && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { |
@@ -1542,35 +1618,37 @@ discard block |
||
1542 | 1618 | } |
1543 | 1619 | } elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) { |
1544 | 1620 | $tmptxt = $object->getLibStatut(6, $object->totalpaye); |
1545 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') |
|
1546 | - $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
1621 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') { |
|
1622 | + $tmptxt = $object->getLibStatut(5, $object->totalpaye); |
|
1623 | + } |
|
1547 | 1624 | $morehtmlstatus .= $tmptxt; |
1548 | - } |
|
1549 | - elseif ($object->element == 'contrat' || $object->element == 'contract') { |
|
1550 | - if ($object->statut == 0) |
|
1551 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
1552 | - else |
|
1553 | - $morehtmlstatus .= $object->getLibStatut(4); |
|
1554 | - } |
|
1555 | - elseif ($object->element == 'facturerec') { |
|
1556 | - if ($object->frequency == 0) |
|
1557 | - $morehtmlstatus .= $object->getLibStatut(2); |
|
1558 | - else |
|
1559 | - $morehtmlstatus .= $object->getLibStatut(5); |
|
1560 | - } |
|
1561 | - elseif ($object->element == 'project_task') { |
|
1625 | + } elseif ($object->element == 'contrat' || $object->element == 'contract') { |
|
1626 | + if ($object->statut == 0) { |
|
1627 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
1628 | + } else { |
|
1629 | + $morehtmlstatus .= $object->getLibStatut(4); |
|
1630 | + } |
|
1631 | + } elseif ($object->element == 'facturerec') { |
|
1632 | + if ($object->frequency == 0) { |
|
1633 | + $morehtmlstatus .= $object->getLibStatut(2); |
|
1634 | + } else { |
|
1635 | + $morehtmlstatus .= $object->getLibStatut(5); |
|
1636 | + } |
|
1637 | + } elseif ($object->element == 'project_task') { |
|
1562 | 1638 | $object->fk_statut = 1; |
1563 | - if ($object->progress > 0) |
|
1564 | - $object->fk_statut = 2; |
|
1565 | - if ($object->progress >= 100) |
|
1566 | - $object->fk_statut = 3; |
|
1639 | + if ($object->progress > 0) { |
|
1640 | + $object->fk_statut = 2; |
|
1641 | + } |
|
1642 | + if ($object->progress >= 100) { |
|
1643 | + $object->fk_statut = 3; |
|
1644 | + } |
|
1567 | 1645 | $tmptxt = $object->getLibStatut(5); |
1568 | 1646 | $morehtmlstatus .= $tmptxt; // No status on task |
1569 | - } |
|
1570 | - else { // Generic case |
|
1647 | + } else { // Generic case |
|
1571 | 1648 | $tmptxt = $object->getLibStatut(6); |
1572 | - if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') |
|
1573 | - $tmptxt = $object->getLibStatut(5); |
|
1649 | + if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout == 'phone') { |
|
1650 | + $tmptxt = $object->getLibStatut(5); |
|
1651 | + } |
|
1574 | 1652 | $morehtmlstatus .= $tmptxt; |
1575 | 1653 | } |
1576 | 1654 | |
@@ -1584,13 +1662,15 @@ discard block |
||
1584 | 1662 | } |
1585 | 1663 | |
1586 | 1664 | // Add alias for thirdparty |
1587 | - if (!empty($object->name_alias)) |
|
1588 | - $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
1665 | + if (!empty($object->name_alias)) { |
|
1666 | + $morehtmlref .= '<div class="refidno">' . $object->name_alias . '</div>'; |
|
1667 | + } |
|
1589 | 1668 | |
1590 | 1669 | // Add label |
1591 | 1670 | if ($object->element == 'product' || $object->element == 'bank_account' || $object->element == 'project_task') { |
1592 | - if (!empty($object->label)) |
|
1593 | - $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
1671 | + if (!empty($object->label)) { |
|
1672 | + $morehtmlref .= '<div class="refidno">' . $object->label . '</div>'; |
|
1673 | + } |
|
1594 | 1674 | } |
1595 | 1675 | |
1596 | 1676 | if (method_exists($object, 'getBannerAddress') && $object->element != 'product' && $object->element != 'bookmark' && $object->element != 'ecm_directories' && $object->element != 'ecm_files') { |
@@ -1623,15 +1703,19 @@ discard block |
||
1623 | 1703 | { |
1624 | 1704 | global $conf, $langs; |
1625 | 1705 | $ret = ''; |
1626 | - if ($fieldrequired) |
|
1627 | - $ret .= '<span class="fieldrequired">'; |
|
1628 | - if (($conf->dol_use_jmobile != 4)) |
|
1629 | - $ret .= '<label for="' . $fieldkey . '">'; |
|
1706 | + if ($fieldrequired) { |
|
1707 | + $ret .= '<span class="fieldrequired">'; |
|
1708 | + } |
|
1709 | + if (($conf->dol_use_jmobile != 4)) { |
|
1710 | + $ret .= '<label for="' . $fieldkey . '">'; |
|
1711 | + } |
|
1630 | 1712 | $ret .= $langs->trans($langkey); |
1631 | - if (($conf->dol_use_jmobile != 4)) |
|
1632 | - $ret .= '</label>'; |
|
1633 | - if ($fieldrequired) |
|
1634 | - $ret .= '</span>'; |
|
1713 | + if (($conf->dol_use_jmobile != 4)) { |
|
1714 | + $ret .= '</label>'; |
|
1715 | + } |
|
1716 | + if ($fieldrequired) { |
|
1717 | + $ret .= '</span>'; |
|
1718 | + } |
|
1635 | 1719 | return $ret; |
1636 | 1720 | } |
1637 | 1721 | |
@@ -1646,8 +1730,9 @@ discard block |
||
1646 | 1730 | { |
1647 | 1731 | global $bc; |
1648 | 1732 | $ret = ' ' . $bc[$var]; |
1649 | - if ($moreclass) |
|
1650 | - $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret); |
|
1733 | + if ($moreclass) { |
|
1734 | + $ret = preg_replace('/class=\"/', 'class="' . $moreclass . ' ', $ret); |
|
1735 | + } |
|
1651 | 1736 | return $ret; |
1652 | 1737 | } |
1653 | 1738 | |
@@ -1678,18 +1763,18 @@ discard block |
||
1678 | 1763 | if ($object->state) { |
1679 | 1764 | $ret .= ($ret ? ", " : '') . $object->state; |
1680 | 1765 | } |
1681 | - if ($object->zip) |
|
1682 | - $ret .= ($ret ? ", " : '') . $object->zip; |
|
1683 | - } |
|
1684 | - else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country |
|
1766 | + if ($object->zip) { |
|
1767 | + $ret .= ($ret ? ", " : '') . $object->zip; |
|
1768 | + } |
|
1769 | + } else if (in_array($object->country_code, array('GB', 'UK'))) { // UK: title firstname name \n address lines \n town state \n zip \n country |
|
1685 | 1770 | $ret .= ($ret ? $sep : '' ) . $object->town; |
1686 | 1771 | if ($object->state) { |
1687 | 1772 | $ret .= ($ret ? ", " : '') . $object->state; |
1688 | 1773 | } |
1689 | - if ($object->zip) |
|
1690 | - $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
1691 | - } |
|
1692 | - else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country |
|
1774 | + if ($object->zip) { |
|
1775 | + $ret .= ($ret ? $sep : '' ) . $object->zip; |
|
1776 | + } |
|
1777 | + } else if (in_array($object->country_code, array('ES', 'TR'))) { // ES: title firstname name \n address lines \n zip town \n state \n country |
|
1693 | 1778 | $ret .= ($ret ? $sep : '' ) . $object->zip; |
1694 | 1779 | $ret .= ($object->town ? (($object->zip ? ' ' : '') . $object->town) : ''); |
1695 | 1780 | if ($object->state) { |
@@ -1706,8 +1791,9 @@ discard block |
||
1706 | 1791 | $ret .= ($ret ? ", " : '') . $object->state; |
1707 | 1792 | } |
1708 | 1793 | } |
1709 | - if (!is_object($outputlangs)) |
|
1710 | - $outputlangs = $langs; |
|
1794 | + if (!is_object($outputlangs)) { |
|
1795 | + $outputlangs = $langs; |
|
1796 | + } |
|
1711 | 1797 | if ($withcountry) { |
1712 | 1798 | $langs->load("dict"); |
1713 | 1799 | $ret .= ($object->country_code ? ($ret ? $sep : '') . $outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country" . $object->country_code)) : ''); |
@@ -1728,9 +1814,10 @@ discard block |
||
1728 | 1814 | { |
1729 | 1815 | if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range |
1730 | 1816 | return ($is_gmt) ? @gmstrftime($fmt, $ts) : @strftime($fmt, $ts); |
1731 | - } else |
|
1732 | - return 'Error date into a not supported range'; |
|
1733 | -} |
|
1817 | + } else { |
|
1818 | + return 'Error date into a not supported range'; |
|
1819 | + } |
|
1820 | + } |
|
1734 | 1821 | |
1735 | 1822 | /** |
1736 | 1823 | * Output date in a string format according to outputlangs (or langs if not defined). |
@@ -1776,10 +1863,12 @@ discard block |
||
1776 | 1863 | } |
1777 | 1864 | } |
1778 | 1865 | } |
1779 | - if (!is_object($outputlangs)) |
|
1780 | - $outputlangs = $langs; |
|
1781 | - if (!$format) |
|
1782 | - $format = 'daytextshort'; |
|
1866 | + if (!is_object($outputlangs)) { |
|
1867 | + $outputlangs = $langs; |
|
1868 | + } |
|
1869 | + if (!$format) { |
|
1870 | + $format = 'daytextshort'; |
|
1871 | + } |
|
1783 | 1872 | $reduceformat = (!empty($conf->dol_optimize_smallscreen) && in_array($format, array('day', 'dayhour'))) ? 1 : 0; |
1784 | 1873 | $formatwithoutreduce = preg_replace('/reduceformat/', '', $format); |
1785 | 1874 | if ($formatwithoutreduce != $format) { |
@@ -1788,40 +1877,46 @@ discard block |
||
1788 | 1877 | } // so format 'dayreduceformat' is processed like day |
1789 | 1878 | // Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default. |
1790 | 1879 | // TODO Add format daysmallyear and dayhoursmallyear |
1791 | - if ($format == 'day') |
|
1792 | - $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); |
|
1793 | - else if ($format == 'hour') |
|
1794 | - $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); |
|
1795 | - else if ($format == 'hourduration') |
|
1796 | - $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); |
|
1797 | - else if ($format == 'daytext') |
|
1798 | - $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); |
|
1799 | - else if ($format == 'daytextshort') |
|
1800 | - // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
1801 | - $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); |
|
1802 | - else if ($format == 'dayhour') |
|
1803 | - $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); |
|
1804 | - else if ($format == 'dayhoursec') |
|
1805 | - $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); |
|
1806 | - else if ($format == 'dayhourtext') |
|
1807 | - $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); |
|
1808 | - else if ($format == 'dayhourtextshort') |
|
1809 | - $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); |
|
1880 | + if ($format == 'day') { |
|
1881 | + $format = ($outputlangs->trans("FormatDateShort") != "FormatDateShort" ? $outputlangs->trans("FormatDateShort") : $conf->format_date_short); |
|
1882 | + } else if ($format == 'hour') { |
|
1883 | + $format = ($outputlangs->trans("FormatHourShort") != "FormatHourShort" ? $outputlangs->trans("FormatHourShort") : $conf->format_hour_short); |
|
1884 | + } else if ($format == 'hourduration') { |
|
1885 | + $format = ($outputlangs->trans("FormatHourShortDuration") != "FormatHourShortDuration" ? $outputlangs->trans("FormatHourShortDuration") : $conf->format_hour_short_duration); |
|
1886 | + } else if ($format == 'daytext') { |
|
1887 | + $format = ($outputlangs->trans("FormatDateText") != "FormatDateText" ? $outputlangs->trans("FormatDateText") : $conf->format_date_text); |
|
1888 | + } else if ($format == 'daytextshort') { |
|
1889 | + // Notice: Undefined property: stdClass::$format_date_text_short in \alixar\dolibarr\htdocs\core\lib\functions.lib.php on line 1781 |
|
1890 | + $format = ($outputlangs->trans("FormatDateTextShort") != "FormatDateTextShort" ? $outputlangs->trans("FormatDateTextShort") : $conf->format_date_text_short); |
|
1891 | + } else if ($format == 'dayhour') { |
|
1892 | + $format = ($outputlangs->trans("FormatDateHourShort") != "FormatDateHourShort" ? $outputlangs->trans("FormatDateHourShort") : $conf->format_date_hour_short); |
|
1893 | + } else if ($format == 'dayhoursec') { |
|
1894 | + $format = ($outputlangs->trans("FormatDateHourSecShort") != "FormatDateHourSecShort" ? $outputlangs->trans("FormatDateHourSecShort") : $conf->format_date_hour_sec_short); |
|
1895 | + } else if ($format == 'dayhourtext') { |
|
1896 | + $format = ($outputlangs->trans("FormatDateHourText") != "FormatDateHourText" ? $outputlangs->trans("FormatDateHourText") : $conf->format_date_hour_text); |
|
1897 | + } else if ($format == 'dayhourtextshort') { |
|
1898 | + $format = ($outputlangs->trans("FormatDateHourTextShort") != "FormatDateHourTextShort" ? $outputlangs->trans("FormatDateHourTextShort") : $conf->format_date_hour_text_short); |
|
1899 | + } |
|
1810 | 1900 | // Format not sensitive to language |
1811 | - else if ($format == 'dayhourlog') |
|
1812 | - $format = '%Y%m%d%H%M%S'; |
|
1813 | - else if ($format == 'dayhourldap') |
|
1814 | - $format = '%Y%m%d%H%M%SZ'; |
|
1815 | - else if ($format == 'dayhourxcard') |
|
1816 | - $format = '%Y%m%dT%H%M%SZ'; |
|
1817 | - else if ($format == 'dayxcard') |
|
1818 | - $format = '%Y%m%d'; |
|
1819 | - else if ($format == 'dayrfc') |
|
1820 | - $format = '%Y-%m-%d'; // DATE_RFC3339 |
|
1821 | - else if ($format == 'dayhourrfc') |
|
1822 | - $format = '%Y-%m-%dT%H:%M:%SZ'; // DATETIME RFC3339 |
|
1823 | - else if ($format == 'standard') |
|
1824 | - $format = '%Y-%m-%d %H:%M:%S'; |
|
1901 | + else if ($format == 'dayhourlog') { |
|
1902 | + $format = '%Y%m%d%H%M%S'; |
|
1903 | + } else if ($format == 'dayhourldap') { |
|
1904 | + $format = '%Y%m%d%H%M%SZ'; |
|
1905 | + } else if ($format == 'dayhourxcard') { |
|
1906 | + $format = '%Y%m%dT%H%M%SZ'; |
|
1907 | + } else if ($format == 'dayxcard') { |
|
1908 | + $format = '%Y%m%d'; |
|
1909 | + } else if ($format == 'dayrfc') { |
|
1910 | + $format = '%Y-%m-%d'; |
|
1911 | + } |
|
1912 | + // DATE_RFC3339 |
|
1913 | + else if ($format == 'dayhourrfc') { |
|
1914 | + $format = '%Y-%m-%dT%H:%M:%SZ'; |
|
1915 | + } |
|
1916 | + // DATETIME RFC3339 |
|
1917 | + else if ($format == 'standard') { |
|
1918 | + $format = '%Y-%m-%d %H:%M:%S'; |
|
1919 | + } |
|
1825 | 1920 | |
1826 | 1921 | if ($reduceformat) { |
1827 | 1922 | $format = str_replace('%Y', '%y', $format); |
@@ -1829,8 +1924,10 @@ discard block |
||
1829 | 1924 | } |
1830 | 1925 | |
1831 | 1926 | // If date undefined or "", we return "" |
1832 | - if (dol_strlen($time) == 0) |
|
1833 | - return ''; // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
1927 | + if (dol_strlen($time) == 0) { |
|
1928 | + return ''; |
|
1929 | + } |
|
1930 | + // $time=0 allowed (it means 01/01/1970 00:00:00) |
|
1834 | 1931 | |
1835 | 1932 | |
1836 | 1933 | |
@@ -1885,8 +1982,9 @@ discard block |
||
1885 | 1982 | $timetouse = $time + $offsettz + $offsetdst; // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring. |
1886 | 1983 | |
1887 | 1984 | $ret = adodb_strftime($format, $timetouse, $to_gmt); |
1888 | - } else |
|
1889 | - $ret = 'Bad value ' . $time . ' for date'; |
|
1985 | + } else { |
|
1986 | + $ret = 'Bad value ' . $time . ' for date'; |
|
1987 | + } |
|
1890 | 1988 | } |
1891 | 1989 | |
1892 | 1990 | if (preg_match('/__b__/i', $format)) { |
@@ -1957,10 +2055,14 @@ discard block |
||
1957 | 2055 | global $conf; |
1958 | 2056 | |
1959 | 2057 | $usealternatemethod = false; |
1960 | - if ($timestamp <= 0) |
|
1961 | - $usealternatemethod = true; // <= 1970 |
|
1962 | - if ($timestamp >= 2145913200) |
|
1963 | - $usealternatemethod = true; // >= 2038 |
|
2058 | + if ($timestamp <= 0) { |
|
2059 | + $usealternatemethod = true; |
|
2060 | + } |
|
2061 | + // <= 1970 |
|
2062 | + if ($timestamp >= 2145913200) { |
|
2063 | + $usealternatemethod = true; |
|
2064 | + } |
|
2065 | + // >= 2038 |
|
1964 | 2066 | |
1965 | 2067 | if ($usealternatemethod) { |
1966 | 2068 | $arrayinfo = adodb_getdate($timestamp, $fast); |
@@ -1995,27 +2097,36 @@ discard block |
||
1995 | 2097 | global $conf; |
1996 | 2098 | //print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -"; |
1997 | 2099 | // Clean parameters |
1998 | - if ($hour == -1 || empty($hour)) |
|
1999 | - $hour = 0; |
|
2000 | - if ($minute == -1 || empty($minute)) |
|
2001 | - $minute = 0; |
|
2002 | - if ($second == -1 || empty($second)) |
|
2003 | - $second = 0; |
|
2100 | + if ($hour == -1 || empty($hour)) { |
|
2101 | + $hour = 0; |
|
2102 | + } |
|
2103 | + if ($minute == -1 || empty($minute)) { |
|
2104 | + $minute = 0; |
|
2105 | + } |
|
2106 | + if ($second == -1 || empty($second)) { |
|
2107 | + $second = 0; |
|
2108 | + } |
|
2004 | 2109 | |
2005 | 2110 | // Check parameters |
2006 | 2111 | if ($check) { |
2007 | - if (!$month || !$day) |
|
2008 | - return ''; |
|
2009 | - if ($day > 31) |
|
2010 | - return ''; |
|
2011 | - if ($month > 12) |
|
2012 | - return ''; |
|
2013 | - if ($hour < 0 || $hour > 24) |
|
2014 | - return ''; |
|
2015 | - if ($minute < 0 || $minute > 60) |
|
2016 | - return ''; |
|
2017 | - if ($second < 0 || $second > 60) |
|
2018 | - return ''; |
|
2112 | + if (!$month || !$day) { |
|
2113 | + return ''; |
|
2114 | + } |
|
2115 | + if ($day > 31) { |
|
2116 | + return ''; |
|
2117 | + } |
|
2118 | + if ($month > 12) { |
|
2119 | + return ''; |
|
2120 | + } |
|
2121 | + if ($hour < 0 || $hour > 24) { |
|
2122 | + return ''; |
|
2123 | + } |
|
2124 | + if ($minute < 0 || $minute > 60) { |
|
2125 | + return ''; |
|
2126 | + } |
|
2127 | + if ($second < 0 || $second > 60) { |
|
2128 | + return ''; |
|
2129 | + } |
|
2019 | 2130 | } |
2020 | 2131 | |
2021 | 2132 | if (method_exists('DateTime', 'getTimestamp')) { |
@@ -2072,8 +2183,10 @@ discard block |
||
2072 | 2183 | |
2073 | 2184 | // Note that gmmktime and mktime return same value (GMT) when used without parameters |
2074 | 2185 | //if ($mode == 'gmt') $ret=gmmktime(); // Strict Standards: gmmktime(): You should be using the time() function instead |
2075 | - if ($mode == 'gmt') |
|
2076 | - $ret = time(); // Time for now at greenwich. |
|
2186 | + if ($mode == 'gmt') { |
|
2187 | + $ret = time(); |
|
2188 | + } |
|
2189 | + // Time for now at greenwich. |
|
2077 | 2190 | else if ($mode == 'tzserver') { // Time for now with PHP server timezone added |
2078 | 2191 | require_once DOL_BASE_PATH . '/core/lib/date.lib.php'; |
2079 | 2192 | $tzsecond = getServerTimeZoneInt('now'); // Contains tz+dayling saving time |
@@ -2107,8 +2220,9 @@ discard block |
||
2107 | 2220 | global $conf, $langs; |
2108 | 2221 | $level = 1024; |
2109 | 2222 | |
2110 | - if (!empty($conf->dol_optimize_smallscreen)) |
|
2111 | - $shortunit = 1; |
|
2223 | + if (!empty($conf->dol_optimize_smallscreen)) { |
|
2224 | + $shortunit = 1; |
|
2225 | + } |
|
2112 | 2226 | |
2113 | 2227 | // Set value text |
2114 | 2228 | if (empty($shortvalue) || $size < ($level * 10)) { |
@@ -2143,19 +2257,23 @@ discard block |
||
2143 | 2257 | { |
2144 | 2258 | global $langs; |
2145 | 2259 | |
2146 | - if (empty($url)) |
|
2147 | - return ''; |
|
2260 | + if (empty($url)) { |
|
2261 | + return ''; |
|
2262 | + } |
|
2148 | 2263 | |
2149 | 2264 | $link = '<a href="'; |
2150 | - if (!preg_match('/^http/i', $url)) |
|
2151 | - $link .= 'http://'; |
|
2265 | + if (!preg_match('/^http/i', $url)) { |
|
2266 | + $link .= 'http://'; |
|
2267 | + } |
|
2152 | 2268 | $link .= $url; |
2153 | 2269 | $link .= '"'; |
2154 | - if ($target) |
|
2155 | - $link .= ' target="' . $target . '"'; |
|
2270 | + if ($target) { |
|
2271 | + $link .= ' target="' . $target . '"'; |
|
2272 | + } |
|
2156 | 2273 | $link .= '>'; |
2157 | - if (!preg_match('/^http/i', $url)) |
|
2158 | - $link .= 'http://'; |
|
2274 | + if (!preg_match('/^http/i', $url)) { |
|
2275 | + $link .= 'http://'; |
|
2276 | + } |
|
2159 | 2277 | $link .= dol_trunc($url, $max); |
2160 | 2278 | $link .= '</a>'; |
2161 | 2279 | return '<div class="nospan float" style="margin-right: 10px">' . ($withpicto ? img_picto($langs->trans("Url"), 'object_globe.png') . ' ' : '') . $link . '</div>'; |
@@ -2179,13 +2297,15 @@ discard block |
||
2179 | 2297 | |
2180 | 2298 | $newemail = $email; |
2181 | 2299 | |
2182 | - if (empty($email)) |
|
2183 | - return ' '; |
|
2300 | + if (empty($email)) { |
|
2301 | + return ' '; |
|
2302 | + } |
|
2184 | 2303 | |
2185 | 2304 | if (!empty($addlink)) { |
2186 | 2305 | $newemail = '<a style="text-overflow: ellipsis;" href="'; |
2187 | - if (!preg_match('/^mailto:/i', $email)) |
|
2188 | - $newemail .= 'mailto:'; |
|
2306 | + if (!preg_match('/^mailto:/i', $email)) { |
|
2307 | + $newemail .= 'mailto:'; |
|
2308 | + } |
|
2189 | 2309 | $newemail .= $email; |
2190 | 2310 | $newemail .= '">'; |
2191 | 2311 | $newemail .= dol_trunc($email, $max); |
@@ -2198,13 +2318,14 @@ discard block |
||
2198 | 2318 | if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { |
2199 | 2319 | $type = 'AC_EMAIL'; |
2200 | 2320 | $link = ''; |
2201 | - if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) |
|
2202 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2203 | - if ($link) |
|
2204 | - $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
2321 | + if (!empty($conf->global->AGENDA_ADDACTIONFOREMAIL)) { |
|
2322 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2323 | + } |
|
2324 | + if ($link) { |
|
2325 | + $newemail = '<div>' . $newemail . ' ' . $link . '</div>'; |
|
2326 | + } |
|
2205 | 2327 | } |
2206 | - } |
|
2207 | - else { |
|
2328 | + } else { |
|
2208 | 2329 | if ($showinvalid && !isValidEmail($email)) { |
2209 | 2330 | $langs->load("errors"); |
2210 | 2331 | $newemail .= img_warning($langs->trans("ErrorBadEMail", $email)); |
@@ -2236,8 +2357,9 @@ discard block |
||
2236 | 2357 | |
2237 | 2358 | $newskype = $value; |
2238 | 2359 | |
2239 | - if (empty($value)) |
|
2240 | - return ' '; |
|
2360 | + if (empty($value)) { |
|
2361 | + return ' '; |
|
2362 | + } |
|
2241 | 2363 | |
2242 | 2364 | if (!empty($type)) { |
2243 | 2365 | $newskype = '<div class="divsocialnetwork inline-block valignmiddle">'; |
@@ -2258,13 +2380,13 @@ discard block |
||
2258 | 2380 | if (($cid || $socid) && !empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create && $type == 'skype') { |
2259 | 2381 | $addlink = 'AC_SKYPE'; |
2260 | 2382 | $link = ''; |
2261 | - if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) |
|
2262 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2383 | + if (!empty($conf->global->AGENDA_ADDACTIONFORSKYPE)) { |
|
2384 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $addlink . '&contactid=' . $cid . '&socid=' . $socid . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2385 | + } |
|
2263 | 2386 | $newskype .= ($link ? ' ' . $link : ''); |
2264 | 2387 | } |
2265 | 2388 | $newskype .= '</div>'; |
2266 | - } |
|
2267 | - else { |
|
2389 | + } else { |
|
2268 | 2390 | $langs->load("errors"); |
2269 | 2391 | $newskype .= img_warning($langs->trans("ErrorBadSocialNetworkValue", $value)); |
2270 | 2392 | } |
@@ -2294,12 +2416,14 @@ discard block |
||
2294 | 2416 | if (empty($phone)) { |
2295 | 2417 | return ''; |
2296 | 2418 | } |
2297 | - if (empty($countrycode)) |
|
2298 | - $countrycode = $mysoc->country_code; |
|
2419 | + if (empty($countrycode)) { |
|
2420 | + $countrycode = $mysoc->country_code; |
|
2421 | + } |
|
2299 | 2422 | |
2300 | 2423 | // Short format for small screens |
2301 | - if ($conf->dol_optimize_smallscreen) |
|
2302 | - $separ = ''; |
|
2424 | + if ($conf->dol_optimize_smallscreen) { |
|
2425 | + $separ = ''; |
|
2426 | + } |
|
2303 | 2427 | |
2304 | 2428 | $newphone = $phone; |
2305 | 2429 | if (strtoupper($countrycode) == "FR") { |
@@ -2465,15 +2589,18 @@ discard block |
||
2465 | 2589 | $newphone = '<a href="tel:' . $phone . '"'; |
2466 | 2590 | $newphone .= '>' . $phone . '</a>'; |
2467 | 2591 | } else if (!empty($conf->clicktodial->enabled) && $addlink == 'AC_TEL') { // If click to dial, we use click to dial url |
2468 | - if (empty($user->clicktodial_loaded)) |
|
2469 | - $user->fetch_clicktodial(); |
|
2592 | + if (empty($user->clicktodial_loaded)) { |
|
2593 | + $user->fetch_clicktodial(); |
|
2594 | + } |
|
2470 | 2595 | |
2471 | 2596 | // Define urlmask |
2472 | 2597 | $urlmask = 'ErrorClickToDialModuleNotConfigured'; |
2473 | - if (!empty($conf->global->CLICKTODIAL_URL)) |
|
2474 | - $urlmask = $conf->global->CLICKTODIAL_URL; |
|
2475 | - if (!empty($user->clicktodial_url)) |
|
2476 | - $urlmask = $user->clicktodial_url; |
|
2598 | + if (!empty($conf->global->CLICKTODIAL_URL)) { |
|
2599 | + $urlmask = $conf->global->CLICKTODIAL_URL; |
|
2600 | + } |
|
2601 | + if (!empty($user->clicktodial_url)) { |
|
2602 | + $urlmask = $user->clicktodial_url; |
|
2603 | + } |
|
2477 | 2604 | |
2478 | 2605 | $clicktodial_poste = (!empty($user->clicktodial_poste) ? urlencode($user->clicktodial_poste) : ''); |
2479 | 2606 | $clicktodial_login = (!empty($user->clicktodial_login) ? urlencode($user->clicktodial_login) : ''); |
@@ -2488,8 +2615,9 @@ discard block |
||
2488 | 2615 | $url = make_substitutions($url, $substitarray); |
2489 | 2616 | $newphonesav = $newphone; |
2490 | 2617 | $newphone = '<a href="' . $url . '"'; |
2491 | - if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) |
|
2492 | - $newphone .= ' target="_blank"'; |
|
2618 | + if (!empty($conf->global->CLICKTODIAL_FORCENEWTARGET)) { |
|
2619 | + $newphone .= ' target="_blank"'; |
|
2620 | + } |
|
2493 | 2621 | $newphone .= '>' . $newphonesav . '</a>'; |
2494 | 2622 | } |
2495 | 2623 | |
@@ -2497,12 +2625,15 @@ discard block |
||
2497 | 2625 | if (!empty($conf->agenda->enabled) && $user->rights->agenda->myactions->create) { |
2498 | 2626 | $type = 'AC_TEL'; |
2499 | 2627 | $link = ''; |
2500 | - if ($addlink == 'AC_FAX') |
|
2501 | - $type = 'AC_FAX'; |
|
2502 | - if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) |
|
2503 | - $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2504 | - if ($link) |
|
2505 | - $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
2628 | + if ($addlink == 'AC_FAX') { |
|
2629 | + $type = 'AC_FAX'; |
|
2630 | + } |
|
2631 | + if (!empty($conf->global->AGENDA_ADDACTIONFORPHONE)) { |
|
2632 | + $link = '<a href="' . DOL_URL_ROOT . '/comm/action/card.php?action=create&backtopage=1&actioncode=' . $type . ($cid ? '&contactid=' . $cid : '') . ($socid ? '&socid=' . $socid : '') . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>'; |
|
2633 | + } |
|
2634 | + if ($link) { |
|
2635 | + $newphone = '<div>' . $newphone . ' ' . $link . '</div>'; |
|
2636 | + } |
|
2506 | 2637 | } |
2507 | 2638 | } |
2508 | 2639 | |
@@ -2529,15 +2660,17 @@ discard block |
||
2529 | 2660 | $picto = ''; |
2530 | 2661 | } |
2531 | 2662 | } |
2532 | - if ($adddivfloat) |
|
2533 | - $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
2534 | - else |
|
2535 | - $rep .= '<span style="margin-right: 10px;">'; |
|
2663 | + if ($adddivfloat) { |
|
2664 | + $rep .= '<div class="nospan float" style="margin-right: 10px">'; |
|
2665 | + } else { |
|
2666 | + $rep .= '<span style="margin-right: 10px;">'; |
|
2667 | + } |
|
2536 | 2668 | $rep .= ($withpicto ? img_picto($titlealt, 'object_' . $picto . '.png') . ' ' : '') . $newphone; |
2537 | - if ($adddivfloat) |
|
2538 | - $rep .= '</div>'; |
|
2539 | - else |
|
2540 | - $rep .= '</span>'; |
|
2669 | + if ($adddivfloat) { |
|
2670 | + $rep .= '</div>'; |
|
2671 | + } else { |
|
2672 | + $rep .= '</span>'; |
|
2673 | + } |
|
2541 | 2674 | } |
2542 | 2675 | |
2543 | 2676 | return $rep; |
@@ -2568,8 +2701,9 @@ discard block |
||
2568 | 2701 | if ($countrycode) { // If success, countrycode is us, fr, ... |
2569 | 2702 | if (file_exists(DOL_BASE_PATH . '/theme/common/flags/' . $countrycode . '.png')) { |
2570 | 2703 | $ret .= ' ' . img_picto($countrycode . ' ' . $langs->trans("AccordingToGeoIPDatabase"), DOL_BASE_URI . '/theme/common/flags/' . $countrycode . '.png', '', 1); |
2571 | - } else |
|
2572 | - $ret .= ' (' . $countrycode . ')'; |
|
2704 | + } else { |
|
2705 | + $ret .= ' (' . $countrycode . ')'; |
|
2706 | + } |
|
2573 | 2707 | } |
2574 | 2708 | } |
2575 | 2709 | |
@@ -2667,26 +2801,33 @@ discard block |
||
2667 | 2801 | $out .= $hookmanager->resPrint; |
2668 | 2802 | } |
2669 | 2803 | if (empty($reshook)) { |
2670 | - if (empty($charfornl)) |
|
2671 | - $out .= nl2br($address); |
|
2672 | - else |
|
2673 | - $out .= preg_replace('/[\r\n]+/', $charfornl, $address); |
|
2804 | + if (empty($charfornl)) { |
|
2805 | + $out .= nl2br($address); |
|
2806 | + } else { |
|
2807 | + $out .= preg_replace('/[\r\n]+/', $charfornl, $address); |
|
2808 | + } |
|
2674 | 2809 | |
2675 | 2810 | $showgmap = $showomap = 0; |
2676 | 2811 | |
2677 | 2812 | // TODO Add a hook here |
2678 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) |
|
2679 | - $showgmap = 1; |
|
2680 | - if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) |
|
2681 | - $showgmap = 1; |
|
2682 | - if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) |
|
2683 | - $showgmap = 1; |
|
2684 | - if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) |
|
2685 | - $showomap = 1; |
|
2686 | - if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) |
|
2687 | - $showomap = 1; |
|
2688 | - if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) |
|
2689 | - $showomap = 1; |
|
2813 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS)) { |
|
2814 | + $showgmap = 1; |
|
2815 | + } |
|
2816 | + if ($mode == 'contact' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) { |
|
2817 | + $showgmap = 1; |
|
2818 | + } |
|
2819 | + if ($mode == 'member' && !empty($conf->google->enabled) && !empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) { |
|
2820 | + $showgmap = 1; |
|
2821 | + } |
|
2822 | + if (($mode == 'thirdparty' || $mode == 'societe') && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) { |
|
2823 | + $showomap = 1; |
|
2824 | + } |
|
2825 | + if ($mode == 'contact' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) { |
|
2826 | + $showomap = 1; |
|
2827 | + } |
|
2828 | + if ($mode == 'member' && !empty($conf->openstreetmap->enabled) && !empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) { |
|
2829 | + $showomap = 1; |
|
2830 | + } |
|
2690 | 2831 | |
2691 | 2832 | if ($showgmap) { |
2692 | 2833 | $url = dol_buildpath('/google/gmaps.php?mode=' . $mode . '&id=' . $id, 1); |
@@ -2698,11 +2839,12 @@ discard block |
||
2698 | 2839 | } |
2699 | 2840 | } |
2700 | 2841 | } |
2701 | - if ($noprint) |
|
2702 | - return $out; |
|
2703 | - else |
|
2704 | - print $out; |
|
2705 | -} |
|
2842 | + if ($noprint) { |
|
2843 | + return $out; |
|
2844 | + } else { |
|
2845 | + print $out; |
|
2846 | + } |
|
2847 | + } |
|
2706 | 2848 | |
2707 | 2849 | /** |
2708 | 2850 | * Return true if email syntax is ok |
@@ -2713,10 +2855,12 @@ discard block |
||
2713 | 2855 | */ |
2714 | 2856 | function isValidEmail($address, $acceptsupervisorkey = 0) |
2715 | 2857 | { |
2716 | - if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') |
|
2717 | - return true; |
|
2718 | - if (filter_var($address, FILTER_VALIDATE_EMAIL)) |
|
2719 | - return true; |
|
2858 | + if ($acceptsupervisorkey && $address == '__SUPERVISOREMAIL__') { |
|
2859 | + return true; |
|
2860 | + } |
|
2861 | + if (filter_var($address, FILTER_VALIDATE_EMAIL)) { |
|
2862 | + return true; |
|
2863 | + } |
|
2720 | 2864 | |
2721 | 2865 | return false; |
2722 | 2866 | } |
@@ -2738,10 +2882,12 @@ discard block |
||
2738 | 2882 | $mxhosts = array(); |
2739 | 2883 | $weight = array(); |
2740 | 2884 | getmxrr(idn_to_ascii($domain), $mxhosts, $weight); |
2741 | - if (count($mxhosts) > 1) |
|
2742 | - return 1; |
|
2743 | - if (count($mxhosts) == 1 && !empty($mxhosts[0])) |
|
2744 | - return 1; |
|
2885 | + if (count($mxhosts) > 1) { |
|
2886 | + return 1; |
|
2887 | + } |
|
2888 | + if (count($mxhosts) == 1 && !empty($mxhosts[0])) { |
|
2889 | + return 1; |
|
2890 | + } |
|
2745 | 2891 | |
2746 | 2892 | return 0; |
2747 | 2893 | } |
@@ -2770,11 +2916,12 @@ discard block |
||
2770 | 2916 | */ |
2771 | 2917 | function dol_strlen($string, $stringencoding = 'UTF-8') |
2772 | 2918 | { |
2773 | - if (function_exists('mb_strlen')) |
|
2774 | - return mb_strlen($string, $stringencoding); |
|
2775 | - else |
|
2776 | - return strlen($string); |
|
2777 | -} |
|
2919 | + if (function_exists('mb_strlen')) { |
|
2920 | + return mb_strlen($string, $stringencoding); |
|
2921 | + } else { |
|
2922 | + return strlen($string); |
|
2923 | + } |
|
2924 | + } |
|
2778 | 2925 | |
2779 | 2926 | /** |
2780 | 2927 | * Make a substring. Works even if mbstring module is not enabled for better compatibility. |
@@ -2790,8 +2937,9 @@ discard block |
||
2790 | 2937 | { |
2791 | 2938 | global $langs; |
2792 | 2939 | |
2793 | - if (empty($stringencoding)) |
|
2794 | - $stringencoding = $langs->charset_output; |
|
2940 | + if (empty($stringencoding)) { |
|
2941 | + $stringencoding = $langs->charset_output; |
|
2942 | + } |
|
2795 | 2943 | |
2796 | 2944 | $ret = ''; |
2797 | 2945 | if (empty($trunconbytes)) { |
@@ -2827,49 +2975,56 @@ discard block |
||
2827 | 2975 | { |
2828 | 2976 | global $conf; |
2829 | 2977 | |
2830 | - if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) |
|
2831 | - return $string; |
|
2978 | + if ($size == 0 || !empty($conf->global->MAIN_DISABLE_TRUNC)) { |
|
2979 | + return $string; |
|
2980 | + } |
|
2832 | 2981 | |
2833 | - if (empty($stringencoding)) |
|
2834 | - $stringencoding = 'UTF-8'; |
|
2982 | + if (empty($stringencoding)) { |
|
2983 | + $stringencoding = 'UTF-8'; |
|
2984 | + } |
|
2835 | 2985 | // reduce for small screen |
2836 | - if ($conf->dol_optimize_smallscreen == 1 && $display == 1) |
|
2837 | - $size = round($size / 3); |
|
2986 | + if ($conf->dol_optimize_smallscreen == 1 && $display == 1) { |
|
2987 | + $size = round($size / 3); |
|
2988 | + } |
|
2838 | 2989 | |
2839 | 2990 | // We go always here |
2840 | 2991 | if ($trunc == 'right') { |
2841 | 2992 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
2842 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
2843 | - return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
2844 | - else |
|
2845 | - //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
2846 | - return $string; |
|
2847 | - } |
|
2848 | - elseif ($trunc == 'middle') { |
|
2993 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
2994 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
2995 | + return dol_substr($newstring, 0, $size, $stringencoding) . ($nodot ? '' : '...'); |
|
2996 | + } else { |
|
2997 | + //return 'u'.$size.'-'.$newstring.'-'.dol_strlen($newstring,$stringencoding).'-'.$string; |
|
2998 | + return $string; |
|
2999 | + } |
|
3000 | + } elseif ($trunc == 'middle') { |
|
2849 | 3001 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
2850 | 3002 | if (dol_strlen($newstring, $stringencoding) > 2 && dol_strlen($newstring, $stringencoding) > ($size + 1)) { |
2851 | 3003 | $size1 = round($size / 2); |
2852 | 3004 | $size2 = round($size / 2); |
2853 | 3005 | return dol_substr($newstring, 0, $size1, $stringencoding) . '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size2, $size2, $stringencoding); |
2854 | - } else |
|
2855 | - return $string; |
|
2856 | - } |
|
2857 | - elseif ($trunc == 'left') { |
|
3006 | + } else { |
|
3007 | + return $string; |
|
3008 | + } |
|
3009 | + } elseif ($trunc == 'left') { |
|
2858 | 3010 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
2859 | - if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
2860 | - return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
2861 | - else |
|
2862 | - return $string; |
|
2863 | - } |
|
2864 | - elseif ($trunc == 'wrap') { |
|
3011 | + if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) { |
|
3012 | + // If nodot is 0 and size is 1,2 or 3 chars more, we don't trunc and don't add ... |
|
3013 | + return '...' . dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding); |
|
3014 | + } else { |
|
3015 | + return $string; |
|
3016 | + } |
|
3017 | + } elseif ($trunc == 'wrap') { |
|
2865 | 3018 | $newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string; |
2866 | - if (dol_strlen($newstring, $stringencoding) > ($size + 1)) |
|
2867 | - return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
2868 | - else |
|
2869 | - return $string; |
|
2870 | - } else |
|
2871 | - return 'BadParam3CallingDolTrunc'; |
|
2872 | -} |
|
3019 | + if (dol_strlen($newstring, $stringencoding) > ($size + 1)) { |
|
3020 | + return dol_substr($newstring, 0, $size, $stringencoding) . "\n" . dol_trunc(dol_substr($newstring, $size, dol_strlen($newstring, $stringencoding) - $size, $stringencoding), $size, $trunc); |
|
3021 | + } else { |
|
3022 | + return $string; |
|
3023 | + } |
|
3024 | + } else { |
|
3025 | + return 'BadParam3CallingDolTrunc'; |
|
3026 | + } |
|
3027 | + } |
|
2873 | 3028 | |
2874 | 3029 | /** |
2875 | 3030 | * Show picto whatever it's its name (generic function) |
@@ -3079,8 +3234,9 @@ discard block |
||
3079 | 3234 | { |
3080 | 3235 | global $conf; |
3081 | 3236 | |
3082 | - if (!preg_match('/(\.png|\.gif)$/i', $picto)) |
|
3083 | - $picto .= '.png'; |
|
3237 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
3238 | + $picto .= '.png'; |
|
3239 | + } |
|
3084 | 3240 | |
3085 | 3241 | //$path = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/weather/' . $picto; |
3086 | 3242 | $path = DOL_BASE_URI . '/theme/' . $conf->theme . '/img/weather/' . $picto; |
@@ -3102,20 +3258,22 @@ discard block |
||
3102 | 3258 | { |
3103 | 3259 | global $conf; |
3104 | 3260 | |
3105 | - if (!preg_match('/(\.png|\.gif)$/i', $picto)) |
|
3106 | - $picto .= '.png'; |
|
3261 | + if (!preg_match('/(\.png|\.gif)$/i', $picto)) { |
|
3262 | + $picto .= '.png'; |
|
3263 | + } |
|
3107 | 3264 | |
3108 | - if ($pictoisfullpath) |
|
3109 | - $path = $picto; |
|
3110 | - else { |
|
3265 | + if ($pictoisfullpath) { |
|
3266 | + $path = $picto; |
|
3267 | + } else { |
|
3111 | 3268 | //$path = DOL_URL_ROOT . '/theme/common/' . $picto; |
3112 | 3269 | $path = DOL_BASE_URI . '/theme/common/' . $picto; |
3113 | 3270 | |
3114 | 3271 | if (!empty($conf->global->MAIN_MODULE_CAN_OVERWRITE_COMMONICONS)) { |
3115 | 3272 | $themepath = DOL_BASE_PATH . 'theme/' . $conf->theme . '/img/' . $picto; |
3116 | 3273 | |
3117 | - if (file_exists($themepath)) |
|
3118 | - $path = $themepath; |
|
3274 | + if (file_exists($themepath)) { |
|
3275 | + $path = $themepath; |
|
3276 | + } |
|
3119 | 3277 | } |
3120 | 3278 | } |
3121 | 3279 | |
@@ -3154,8 +3312,9 @@ discard block |
||
3154 | 3312 | $numaction = 0; |
3155 | 3313 | } |
3156 | 3314 | } |
3157 | - if (!is_numeric($numaction)) |
|
3158 | - $numaction = 0; |
|
3315 | + if (!is_numeric($numaction)) { |
|
3316 | + $numaction = 0; |
|
3317 | + } |
|
3159 | 3318 | |
3160 | 3319 | return img_picto($titlealt, 'stcomm' . $numaction . '.png'); |
3161 | 3320 | } |
@@ -3171,8 +3330,9 @@ discard block |
||
3171 | 3330 | { |
3172 | 3331 | global $conf, $langs; |
3173 | 3332 | |
3174 | - if ($titlealt == 'default') |
|
3175 | - $titlealt = $langs->trans('Show'); |
|
3333 | + if ($titlealt == 'default') { |
|
3334 | + $titlealt = $langs->trans('Show'); |
|
3335 | + } |
|
3176 | 3336 | |
3177 | 3337 | return img_picto($titlealt, 'pdf' . $size . '.png'); |
3178 | 3338 | } |
@@ -3188,8 +3348,9 @@ discard block |
||
3188 | 3348 | { |
3189 | 3349 | global $conf, $langs; |
3190 | 3350 | |
3191 | - if ($titlealt == 'default') |
|
3192 | - $titlealt = $langs->trans('Add'); |
|
3351 | + if ($titlealt == 'default') { |
|
3352 | + $titlealt = $langs->trans('Add'); |
|
3353 | + } |
|
3193 | 3354 | |
3194 | 3355 | return img_picto($titlealt, 'edit_add.png', $other); |
3195 | 3356 | } |
@@ -3205,8 +3366,9 @@ discard block |
||
3205 | 3366 | { |
3206 | 3367 | global $conf, $langs; |
3207 | 3368 | |
3208 | - if ($titlealt == 'default') |
|
3209 | - $titlealt = $langs->trans('Remove'); |
|
3369 | + if ($titlealt == 'default') { |
|
3370 | + $titlealt = $langs->trans('Remove'); |
|
3371 | + } |
|
3210 | 3372 | |
3211 | 3373 | return img_picto($titlealt, 'edit_remove.png', $other); |
3212 | 3374 | } |
@@ -3223,8 +3385,9 @@ discard block |
||
3223 | 3385 | { |
3224 | 3386 | global $conf, $langs; |
3225 | 3387 | |
3226 | - if ($titlealt == 'default') |
|
3227 | - $titlealt = $langs->trans('Modify'); |
|
3388 | + if ($titlealt == 'default') { |
|
3389 | + $titlealt = $langs->trans('Modify'); |
|
3390 | + } |
|
3228 | 3391 | |
3229 | 3392 | return img_picto($titlealt, 'edit.png', ($float ? 'style="float: ' . ($langs->tab_translate["DIRECTION"] == 'rtl' ? 'left' : 'right') . '"' : "") . ($other ? ' ' . $other : '')); |
3230 | 3393 | } |
@@ -3241,8 +3404,9 @@ discard block |
||
3241 | 3404 | { |
3242 | 3405 | global $conf, $langs; |
3243 | 3406 | |
3244 | - if ($titlealt == 'default') |
|
3245 | - $titlealt = $langs->trans('View'); |
|
3407 | + if ($titlealt == 'default') { |
|
3408 | + $titlealt = $langs->trans('View'); |
|
3409 | + } |
|
3246 | 3410 | |
3247 | 3411 | $moreatt = ($float ? 'style="float: right" ' : '') . $other; |
3248 | 3412 | |
@@ -3260,8 +3424,9 @@ discard block |
||
3260 | 3424 | { |
3261 | 3425 | global $conf, $langs; |
3262 | 3426 | |
3263 | - if ($titlealt == 'default') |
|
3264 | - $titlealt = $langs->trans('Delete'); |
|
3427 | + if ($titlealt == 'default') { |
|
3428 | + $titlealt = $langs->trans('Delete'); |
|
3429 | + } |
|
3265 | 3430 | |
3266 | 3431 | return img_picto($titlealt, 'delete.png', $other); |
3267 | 3432 | //return '<span class="fa fa-trash fa-2x fa-fw" style="font-size: 1.7em;" title="'.$titlealt.'"></span>'; |
@@ -3277,8 +3442,9 @@ discard block |
||
3277 | 3442 | function img_printer($titlealt = "default", $other = '') |
3278 | 3443 | { |
3279 | 3444 | global $conf, $langs; |
3280 | - if ($titlealt == "default") |
|
3281 | - $titlealt = $langs->trans("Print"); |
|
3445 | + if ($titlealt == "default") { |
|
3446 | + $titlealt = $langs->trans("Print"); |
|
3447 | + } |
|
3282 | 3448 | return img_picto($titlealt, 'printer.png', $other); |
3283 | 3449 | } |
3284 | 3450 | |
@@ -3293,8 +3459,9 @@ discard block |
||
3293 | 3459 | { |
3294 | 3460 | global $conf, $langs; |
3295 | 3461 | |
3296 | - if ($titlealt == 'default') |
|
3297 | - $titlealt = $langs->trans('Split'); |
|
3462 | + if ($titlealt == 'default') { |
|
3463 | + $titlealt = $langs->trans('Split'); |
|
3464 | + } |
|
3298 | 3465 | |
3299 | 3466 | return img_picto($titlealt, 'split.png', $other); |
3300 | 3467 | } |
@@ -3311,10 +3478,11 @@ discard block |
||
3311 | 3478 | global $conf, $langs; |
3312 | 3479 | |
3313 | 3480 | if ($usealttitle) { |
3314 | - if (is_string($usealttitle)) |
|
3315 | - $usealttitle = dol_escape_htmltag($usealttitle); |
|
3316 | - else |
|
3317 | - $usealttitle = $langs->trans('Info'); |
|
3481 | + if (is_string($usealttitle)) { |
|
3482 | + $usealttitle = dol_escape_htmltag($usealttitle); |
|
3483 | + } else { |
|
3484 | + $usealttitle = $langs->trans('Info'); |
|
3485 | + } |
|
3318 | 3486 | } |
3319 | 3487 | |
3320 | 3488 | return img_picto($usealttitle, 'info.png', 'style="vertical-align: middle;' . ($usehelpcursor == 1 ? ' cursor: help' : ($usehelpcursor == 2 ? ' cursor: pointer' : '')) . '"'); |
@@ -3330,8 +3498,9 @@ discard block |
||
3330 | 3498 | { |
3331 | 3499 | global $conf, $langs; |
3332 | 3500 | |
3333 | - if ($titlealt == 'default') |
|
3334 | - $titlealt = $langs->trans('Informations'); |
|
3501 | + if ($titlealt == 'default') { |
|
3502 | + $titlealt = $langs->trans('Informations'); |
|
3503 | + } |
|
3335 | 3504 | |
3336 | 3505 | return img_picto($titlealt, 'info.png', 'style="vertical-align: middle;"'); |
3337 | 3506 | } |
@@ -3347,8 +3516,9 @@ discard block |
||
3347 | 3516 | { |
3348 | 3517 | global $conf, $langs; |
3349 | 3518 | |
3350 | - if ($titlealt == 'default') |
|
3351 | - $titlealt = $langs->trans('Warning'); |
|
3519 | + if ($titlealt == 'default') { |
|
3520 | + $titlealt = $langs->trans('Warning'); |
|
3521 | + } |
|
3352 | 3522 | |
3353 | 3523 | //return '<div class="imglatecoin">'.img_picto($titlealt, 'warning_white.png', 'class="pictowarning valignmiddle"'.($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' '.$moreatt): '')).'</div>'; |
3354 | 3524 | return img_picto($titlealt, 'warning.png', 'class="pictowarning valignmiddle"' . ($moreatt ? ($moreatt == '1' ? ' style="float: right"' : ' ' . $moreatt) : '')); |
@@ -3364,8 +3534,9 @@ discard block |
||
3364 | 3534 | { |
3365 | 3535 | global $conf, $langs; |
3366 | 3536 | |
3367 | - if ($titlealt == 'default') |
|
3368 | - $titlealt = $langs->trans('Error'); |
|
3537 | + if ($titlealt == 'default') { |
|
3538 | + $titlealt = $langs->trans('Error'); |
|
3539 | + } |
|
3369 | 3540 | |
3370 | 3541 | return img_picto($titlealt, 'error.png', 'class="valigntextbottom"'); |
3371 | 3542 | } |
@@ -3381,8 +3552,9 @@ discard block |
||
3381 | 3552 | { |
3382 | 3553 | global $conf, $langs; |
3383 | 3554 | |
3384 | - if ($titlealt == 'default') |
|
3385 | - $titlealt = $langs->trans('Next'); |
|
3555 | + if ($titlealt == 'default') { |
|
3556 | + $titlealt = $langs->trans('Next'); |
|
3557 | + } |
|
3386 | 3558 | |
3387 | 3559 | //return img_picto($titlealt, 'next.png', $moreatt); |
3388 | 3560 | return '<span class="fa fa-chevron-right paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3399,8 +3571,9 @@ discard block |
||
3399 | 3571 | { |
3400 | 3572 | global $conf, $langs; |
3401 | 3573 | |
3402 | - if ($titlealt == 'default') |
|
3403 | - $titlealt = $langs->trans('Previous'); |
|
3574 | + if ($titlealt == 'default') { |
|
3575 | + $titlealt = $langs->trans('Previous'); |
|
3576 | + } |
|
3404 | 3577 | |
3405 | 3578 | //return img_picto($titlealt, 'previous.png', $moreatt); |
3406 | 3579 | return '<span class="fa fa-chevron-left paddingright paddingleft" title="' . dol_escape_htmltag($titlealt) . '"></span>'; |
@@ -3418,8 +3591,9 @@ discard block |
||
3418 | 3591 | { |
3419 | 3592 | global $conf, $langs; |
3420 | 3593 | |
3421 | - if ($titlealt == 'default') |
|
3422 | - $titlealt = $langs->trans('Down'); |
|
3594 | + if ($titlealt == 'default') { |
|
3595 | + $titlealt = $langs->trans('Down'); |
|
3596 | + } |
|
3423 | 3597 | |
3424 | 3598 | return img_picto($titlealt, ($selected ? '1downarrow_selected.png' : '1downarrow.png'), 'class="imgdown' . ($moreclass ? " " . $moreclass : "") . '"'); |
3425 | 3599 | } |
@@ -3436,8 +3610,9 @@ discard block |
||
3436 | 3610 | { |
3437 | 3611 | global $conf, $langs; |
3438 | 3612 | |
3439 | - if ($titlealt == 'default') |
|
3440 | - $titlealt = $langs->trans('Up'); |
|
3613 | + if ($titlealt == 'default') { |
|
3614 | + $titlealt = $langs->trans('Up'); |
|
3615 | + } |
|
3441 | 3616 | |
3442 | 3617 | return img_picto($titlealt, ($selected ? '1uparrow_selected.png' : '1uparrow.png'), 'class="imgup' . ($moreclass ? " " . $moreclass : "") . '"'); |
3443 | 3618 | } |
@@ -3454,8 +3629,9 @@ discard block |
||
3454 | 3629 | { |
3455 | 3630 | global $conf, $langs; |
3456 | 3631 | |
3457 | - if ($titlealt == 'default') |
|
3458 | - $titlealt = $langs->trans('Left'); |
|
3632 | + if ($titlealt == 'default') { |
|
3633 | + $titlealt = $langs->trans('Left'); |
|
3634 | + } |
|
3459 | 3635 | |
3460 | 3636 | return img_picto($titlealt, ($selected ? '1leftarrow_selected.png' : '1leftarrow.png'), $moreatt); |
3461 | 3637 | } |
@@ -3472,8 +3648,9 @@ discard block |
||
3472 | 3648 | { |
3473 | 3649 | global $conf, $langs; |
3474 | 3650 | |
3475 | - if ($titlealt == 'default') |
|
3476 | - $titlealt = $langs->trans('Right'); |
|
3651 | + if ($titlealt == 'default') { |
|
3652 | + $titlealt = $langs->trans('Right'); |
|
3653 | + } |
|
3477 | 3654 | |
3478 | 3655 | return img_picto($titlealt, ($selected ? '1rightarrow_selected.png' : '1rightarrow.png'), $moreatt); |
3479 | 3656 | } |
@@ -3489,11 +3666,13 @@ discard block |
||
3489 | 3666 | { |
3490 | 3667 | global $conf, $langs; |
3491 | 3668 | |
3492 | - if ($titlealt == 'default') |
|
3493 | - $titlealt = $langs->trans('Active'); |
|
3669 | + if ($titlealt == 'default') { |
|
3670 | + $titlealt = $langs->trans('Active'); |
|
3671 | + } |
|
3494 | 3672 | |
3495 | - if ($allow == 1) |
|
3496 | - return img_picto($titlealt, 'tick.png'); |
|
3673 | + if ($allow == 1) { |
|
3674 | + return img_picto($titlealt, 'tick.png'); |
|
3675 | + } |
|
3497 | 3676 | |
3498 | 3677 | return '-'; |
3499 | 3678 | } |
@@ -3541,8 +3720,9 @@ discard block |
||
3541 | 3720 | $mimeimg = dol_mimetype($file, '', 2); |
3542 | 3721 | $mimefa = dol_mimetype($file, '', 4); |
3543 | 3722 | |
3544 | - if (empty($titlealt)) |
|
3545 | - $titlealt = 'Mime type: ' . $mimetype; |
|
3723 | + if (empty($titlealt)) { |
|
3724 | + $titlealt = 'Mime type: ' . $mimetype; |
|
3725 | + } |
|
3546 | 3726 | |
3547 | 3727 | //return img_picto_common($titlealt, 'mime/'.$mimeimg, 'class="'.$morecss.'"'); |
3548 | 3728 | return '<i class="fa fa-' . $mimefa . ' paddingright"></i>'; |
@@ -3564,13 +3744,15 @@ discard block |
||
3564 | 3744 | |
3565 | 3745 | global $conf, $langs; |
3566 | 3746 | |
3567 | - if ($titlealt == 'default') |
|
3568 | - $titlealt = $langs->trans('Call'); |
|
3747 | + if ($titlealt == 'default') { |
|
3748 | + $titlealt = $langs->trans('Call'); |
|
3749 | + } |
|
3569 | 3750 | |
3570 | - if ($option == 1) |
|
3571 | - $img = 'call'; |
|
3572 | - else |
|
3573 | - $img = 'call_out'; |
|
3751 | + if ($option == 1) { |
|
3752 | + $img = 'call'; |
|
3753 | + } else { |
|
3754 | + $img = 'call_out'; |
|
3755 | + } |
|
3574 | 3756 | |
3575 | 3757 | return img_picto($titlealt, $img); |
3576 | 3758 | } |
@@ -3586,8 +3768,9 @@ discard block |
||
3586 | 3768 | { |
3587 | 3769 | global $conf, $langs; |
3588 | 3770 | |
3589 | - if ($titlealt == 'default') |
|
3590 | - $titlealt = $langs->trans('Search'); |
|
3771 | + if ($titlealt == 'default') { |
|
3772 | + $titlealt = $langs->trans('Search'); |
|
3773 | + } |
|
3591 | 3774 | |
3592 | 3775 | $img = img_picto($titlealt, 'search.png', $other, false, 1); |
3593 | 3776 | |
@@ -3608,8 +3791,9 @@ discard block |
||
3608 | 3791 | { |
3609 | 3792 | global $conf, $langs; |
3610 | 3793 | |
3611 | - if ($titlealt == 'default') |
|
3612 | - $titlealt = $langs->trans('Search'); |
|
3794 | + if ($titlealt == 'default') { |
|
3795 | + $titlealt = $langs->trans('Search'); |
|
3796 | + } |
|
3613 | 3797 | |
3614 | 3798 | $img = img_picto($titlealt, 'searchclear.png', $other, false, 1); |
3615 | 3799 | |
@@ -3671,14 +3855,16 @@ discard block |
||
3671 | 3855 | |
3672 | 3856 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web |
3673 | 3857 | $out .= $langs->trans("DolibarrHasDetectedError") . ".<br>\n"; |
3674 | - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) |
|
3675 | - $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
3858 | + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { |
|
3859 | + $out .= "You use an experimental or develop level of features, so please do NOT report any bugs, except if problem is confirmed moving option MAIN_FEATURES_LEVEL back to 0.<br>\n"; |
|
3860 | + } |
|
3676 | 3861 | $out .= $langs->trans("InformationToHelpDiagnose") . ":<br>\n"; |
3677 | 3862 | |
3678 | 3863 | $out .= "<b>" . $langs->trans("Date") . ":</b> " . dol_print_date(time(), 'dayhourlog') . "<br>\n"; |
3679 | 3864 | $out .= "<b>" . $langs->trans("Dolibarr") . ":</b> " . DOL_VERSION . "<br>\n"; |
3680 | - if (isset($conf->global->MAIN_FEATURES_LEVEL)) |
|
3681 | - $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; |
|
3865 | + if (isset($conf->global->MAIN_FEATURES_LEVEL)) { |
|
3866 | + $out .= "<b>" . $langs->trans("LevelOfFeature") . ":</b> " . $conf->global->MAIN_FEATURES_LEVEL . "<br>\n"; |
|
3867 | + } |
|
3682 | 3868 | if (function_exists("phpversion")) { |
3683 | 3869 | $out .= "<b>" . $langs->trans("PHP") . ":</b> " . phpversion() . "<br>\n"; |
3684 | 3870 | } |
@@ -3721,18 +3907,20 @@ discard block |
||
3721 | 3907 | $langs->load("errors"); |
3722 | 3908 | |
3723 | 3909 | // Merge all into $errors array |
3724 | - if (is_array($error) && is_array($errors)) |
|
3725 | - $errors = array_merge($error, $errors); |
|
3726 | - elseif (is_array($error)) |
|
3727 | - $errors = $error; |
|
3728 | - elseif (is_array($errors)) |
|
3729 | - $errors = array_merge(array($error), $errors); |
|
3730 | - else |
|
3731 | - $errors = array_merge(array($error)); |
|
3910 | + if (is_array($error) && is_array($errors)) { |
|
3911 | + $errors = array_merge($error, $errors); |
|
3912 | + } elseif (is_array($error)) { |
|
3913 | + $errors = $error; |
|
3914 | + } elseif (is_array($errors)) { |
|
3915 | + $errors = array_merge(array($error), $errors); |
|
3916 | + } else { |
|
3917 | + $errors = array_merge(array($error)); |
|
3918 | + } |
|
3732 | 3919 | |
3733 | 3920 | foreach ($errors as $msg) { |
3734 | - if (empty($msg)) |
|
3735 | - continue; |
|
3921 | + if (empty($msg)) { |
|
3922 | + continue; |
|
3923 | + } |
|
3736 | 3924 | if ($_SERVER['DOCUMENT_ROOT']) { // Mode web |
3737 | 3925 | $out .= "<b>" . $langs->trans("Message") . ":</b> " . dol_escape_htmltag($msg) . "<br>\n"; |
3738 | 3926 | } else { // Mode CLI |
@@ -3750,9 +3938,9 @@ discard block |
||
3750 | 3938 | $out .= "<br>\n"; |
3751 | 3939 | } |
3752 | 3940 | |
3753 | - if (empty($dolibarr_main_prod)) |
|
3754 | - print $out; |
|
3755 | - else { |
|
3941 | + if (empty($dolibarr_main_prod)) { |
|
3942 | + print $out; |
|
3943 | + } else { |
|
3756 | 3944 | print $langs->trans("DolibarrHasDetectedError") . '. '; |
3757 | 3945 | print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); |
3758 | 3946 | define("MAIN_CORE_ERROR", 1); |
@@ -3775,16 +3963,18 @@ discard block |
||
3775 | 3963 | { |
3776 | 3964 | global $langs, $conf; |
3777 | 3965 | |
3778 | - if (empty($email)) |
|
3779 | - $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
3966 | + if (empty($email)) { |
|
3967 | + $email = $conf->global->MAIN_INFO_SOCIETE_MAIL; |
|
3968 | + } |
|
3780 | 3969 | |
3781 | 3970 | $langs->load("errors"); |
3782 | 3971 | $now = dol_now(); |
3783 | 3972 | |
3784 | 3973 | print '<br><div class="center login_main_message"><div class="' . $morecss . '">'; |
3785 | 3974 | print $langs->trans("ErrorContactEMail", $email, $prefixcode . dol_print_date($now, '%Y%m%d')); |
3786 | - if ($errormessage) |
|
3787 | - print '<br><br>' . $errormessage; |
|
3975 | + if ($errormessage) { |
|
3976 | + print '<br><br>' . $errormessage; |
|
3977 | + } |
|
3788 | 3978 | if (is_array($errormessages) && count($errormessages)) { |
3789 | 3979 | foreach ($errormessages as $mesgtoshow) { |
3790 | 3980 | print '<br><br>' . $mesgtoshow; |
@@ -4027,12 +4217,15 @@ discard block |
||
4027 | 4217 | $savtotalnboflines = $totalnboflines; |
4028 | 4218 | $totalnboflines = abs($totalnboflines); |
4029 | 4219 | |
4030 | - if ($picto == 'setup') |
|
4031 | - $picto = 'title_setup.png'; |
|
4032 | - if (($conf->browser->name == 'ie') && $picto == 'title_generic.png') |
|
4033 | - $picto = 'title.gif'; |
|
4034 | - if ($limit < 0) |
|
4035 | - $limit = $conf->liste_limit; |
|
4220 | + if ($picto == 'setup') { |
|
4221 | + $picto = 'title_setup.png'; |
|
4222 | + } |
|
4223 | + if (($conf->browser->name == 'ie') && $picto == 'title_generic.png') { |
|
4224 | + $picto = 'title.gif'; |
|
4225 | + } |
|
4226 | + if ($limit < 0) { |
|
4227 | + $limit = $conf->liste_limit; |
|
4228 | + } |
|
4036 | 4229 | if ($savlimit != 0 && (($num > $limit) || ($num == -1) || ($limit == 0))) { |
4037 | 4230 | $nextpage = 1; |
4038 | 4231 | } else { |
@@ -4046,11 +4239,13 @@ discard block |
||
4046 | 4239 | // Left |
4047 | 4240 | //if ($picto && $titre) print '<td class="nobordernopadding hideonsmartphone" width="40" align="left" valign="middle">'.img_picto('', $picto, 'id="pictotitle"', $pictoisfullpath).'</td>'; |
4048 | 4241 | print '<td class="nobordernopadding valignmiddle">'; |
4049 | - if ($picto && $titre) |
|
4050 | - print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); |
|
4242 | + if ($picto && $titre) { |
|
4243 | + print img_picto('', $picto, 'class="hideonsmartphone valignmiddle opacityhigh pictotitle widthpictotitle"', $pictoisfullpath); |
|
4244 | + } |
|
4051 | 4245 | print '<div class="titre inline-block">' . $titre; |
4052 | - if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') |
|
4053 | - print ' (' . $totalnboflines . ')'; |
|
4246 | + if (!empty($titre) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') { |
|
4247 | + print ' (' . $totalnboflines . ')'; |
|
4248 | + } |
|
4054 | 4249 | print '</div></td>'; |
4055 | 4250 | |
4056 | 4251 | // Center |
@@ -4060,10 +4255,12 @@ discard block |
||
4060 | 4255 | |
4061 | 4256 | // Right |
4062 | 4257 | print '<td class="nobordernopadding valignmiddle" align="right">'; |
4063 | - if ($sortfield) |
|
4064 | - $options .= "&sortfield=" . urlencode($sortfield); |
|
4065 | - if ($sortorder) |
|
4066 | - $options .= "&sortorder=" . urlencode($sortorder); |
|
4258 | + if ($sortfield) { |
|
4259 | + $options .= "&sortfield=" . urlencode($sortfield); |
|
4260 | + } |
|
4261 | + if ($sortorder) { |
|
4262 | + $options .= "&sortorder=" . urlencode($sortorder); |
|
4263 | + } |
|
4067 | 4264 | // Show navigation bar |
4068 | 4265 | $pagelist = ''; |
4069 | 4266 | if ($savlimit != 0 && ($page > 0 || $num > $limit)) { |
@@ -4071,10 +4268,11 @@ discard block |
||
4071 | 4268 | // Define nb of extra page links before and after selected page + ... + first or last |
4072 | 4269 | $maxnbofpage = (empty($conf->dol_optimize_smallscreen) ? 4 : 1); |
4073 | 4270 | |
4074 | - if ($limit > 0) |
|
4075 | - $nbpages = ceil($totalnboflines / $limit); |
|
4076 | - else |
|
4077 | - $nbpages = 1; |
|
4271 | + if ($limit > 0) { |
|
4272 | + $nbpages = ceil($totalnboflines / $limit); |
|
4273 | + } else { |
|
4274 | + $nbpages = 1; |
|
4275 | + } |
|
4078 | 4276 | $cpt = ($page - $maxnbofpage); |
4079 | 4277 | if ($cpt < 0) { |
4080 | 4278 | $cpt = 0; |
@@ -4082,10 +4280,11 @@ discard block |
||
4082 | 4280 | |
4083 | 4281 | if ($cpt >= 1) { |
4084 | 4282 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=0' . $options . '">1</a></li>'; |
4085 | - if ($cpt > 2) |
|
4086 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
4087 | - else if ($cpt == 2) |
|
4088 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
4283 | + if ($cpt > 2) { |
|
4284 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
4285 | + } else if ($cpt == 2) { |
|
4286 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=1' . $options . '">2</a></li>'; |
|
4287 | + } |
|
4089 | 4288 | } |
4090 | 4289 | |
4091 | 4290 | do { |
@@ -4098,14 +4297,14 @@ discard block |
||
4098 | 4297 | } while ($cpt < $nbpages && $cpt <= $page + $maxnbofpage); |
4099 | 4298 | |
4100 | 4299 | if ($cpt < $nbpages) { |
4101 | - if ($cpt < $nbpages - 2) |
|
4102 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
4103 | - else if ($cpt == $nbpages - 2) |
|
4104 | - $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
4300 | + if ($cpt < $nbpages - 2) { |
|
4301 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="inactive"' : '') . '>...</span></li>'; |
|
4302 | + } else if ($cpt == $nbpages - 2) { |
|
4303 | + $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 2) . $options . '">' . ($nbpages - 1) . '</a></li>'; |
|
4304 | + } |
|
4105 | 4305 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><a href="' . $file . '?page=' . ($nbpages - 1) . $options . '">' . $nbpages . '</a></li>'; |
4106 | 4306 | } |
4107 | - } |
|
4108 | - else { |
|
4307 | + } else { |
|
4109 | 4308 | $pagelist .= '<li' . (($conf->dol_use_jmobile != 4) ? ' class="pagination"' : '') . '><span ' . (($conf->dol_use_jmobile != 4) ? 'class="active"' : '') . '>' . ($page + 1) . "</li>"; |
4110 | 4309 | } |
4111 | 4310 | } |
@@ -4141,18 +4340,21 @@ discard block |
||
4141 | 4340 | $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; |
4142 | 4341 | //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported |
4143 | 4342 | //$pagesizechoices.=',2:2'; |
4144 | - if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) |
|
4145 | - $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; |
|
4343 | + if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) { |
|
4344 | + $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; |
|
4345 | + } |
|
4146 | 4346 | |
4147 | 4347 | print '<li class="pagination">'; |
4148 | 4348 | print '<select class="flat selectlimit" name="limit" title="' . dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")) . '">'; |
4149 | 4349 | $tmpchoice = explode(',', $pagesizechoices); |
4150 | 4350 | $tmpkey = $limit . ':' . $limit; |
4151 | - if (!in_array($tmpkey, $tmpchoice)) |
|
4152 | - $tmpchoice[] = $tmpkey; |
|
4351 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
4352 | + $tmpchoice[] = $tmpkey; |
|
4353 | + } |
|
4153 | 4354 | $tmpkey = $conf->liste_limit . ':' . $conf->liste_limit; |
4154 | - if (!in_array($tmpkey, $tmpchoice)) |
|
4155 | - $tmpchoice[] = $tmpkey; |
|
4355 | + if (!in_array($tmpkey, $tmpchoice)) { |
|
4356 | + $tmpchoice[] = $tmpkey; |
|
4357 | + } |
|
4156 | 4358 | asort($tmpchoice, SORT_NUMERIC); |
4157 | 4359 | $found = false; |
4158 | 4360 | foreach ($tmpchoice as $val) { |
@@ -4228,14 +4430,15 @@ discard block |
||
4228 | 4430 | } |
4229 | 4431 | |
4230 | 4432 | // If rate is '9/9/9' we don't change it. If rate is '9.000' we apply price() |
4231 | - if (!preg_match('/\//', $rate)) |
|
4232 | - $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
4233 | - else { |
|
4433 | + if (!preg_match('/\//', $rate)) { |
|
4434 | + $ret = price($rate, 0, '', 0, 0) . ($addpercent ? '%' : ''); |
|
4435 | + } else { |
|
4234 | 4436 | // TODO Split on / and output with a price2num to have clean numbers without ton of 000. |
4235 | 4437 | $ret = $rate . ($addpercent ? '%' : ''); |
4236 | 4438 | } |
4237 | - if (($info_bits & 1) && $usestarfornpr >= 0) |
|
4238 | - $ret .= ' *'; |
|
4439 | + if (($info_bits & 1) && $usestarfornpr >= 0) { |
|
4440 | + $ret .= ' *'; |
|
4441 | + } |
|
4239 | 4442 | $ret .= $morelabel; |
4240 | 4443 | return $ret; |
4241 | 4444 | } |
@@ -4260,11 +4463,14 @@ discard block |
||
4260 | 4463 | global $langs, $conf; |
4261 | 4464 | |
4262 | 4465 | // Clean parameters |
4263 | - if (empty($amount)) |
|
4264 | - $amount = 0; // To have a numeric value if amount not defined or = '' |
|
4466 | + if (empty($amount)) { |
|
4467 | + $amount = 0; |
|
4468 | + } |
|
4469 | + // To have a numeric value if amount not defined or = '' |
|
4265 | 4470 | $amount = (is_numeric($amount) ? $amount : 0); // Check if amount is numeric, for example, an error occured when amount value = o (letter) instead 0 (number) |
4266 | - if ($rounding < 0) |
|
4267 | - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); |
|
4471 | + if ($rounding < 0) { |
|
4472 | + $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); |
|
4473 | + } |
|
4268 | 4474 | $nbdecimal = $rounding; |
4269 | 4475 | |
4270 | 4476 | // Output separators by default (french) |
@@ -4272,17 +4478,21 @@ discard block |
||
4272 | 4478 | $thousand = ' '; |
4273 | 4479 | |
4274 | 4480 | // If $outlangs not forced, we use use language |
4275 | - if (!is_object($outlangs)) |
|
4276 | - $outlangs = $langs; |
|
4277 | - |
|
4278 | - if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") |
|
4279 | - $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4280 | - if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") |
|
4281 | - $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
4282 | - if ($thousand == 'None') |
|
4283 | - $thousand = ''; |
|
4284 | - else if ($thousand == 'Space') |
|
4285 | - $thousand = ' '; |
|
4481 | + if (!is_object($outlangs)) { |
|
4482 | + $outlangs = $langs; |
|
4483 | + } |
|
4484 | + |
|
4485 | + if ($outlangs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
4486 | + $dec = $outlangs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4487 | + } |
|
4488 | + if ($outlangs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
4489 | + $thousand = $outlangs->transnoentitiesnoconv("SeparatorThousand"); |
|
4490 | + } |
|
4491 | + if ($thousand == 'None') { |
|
4492 | + $thousand = ''; |
|
4493 | + } else if ($thousand == 'Space') { |
|
4494 | + $thousand = ' '; |
|
4495 | + } |
|
4286 | 4496 | //print "outlangs=".$outlangs->defaultlang." amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
4287 | 4497 | //print "amount=".$amount."-"; |
4288 | 4498 | $amount = str_replace(',', '.', $amount); // should be useless |
@@ -4294,8 +4504,9 @@ discard block |
||
4294 | 4504 | $end = ''; |
4295 | 4505 | |
4296 | 4506 | // We increase nbdecimal if there is more decimal than asked (to not loose information) |
4297 | - if (dol_strlen($decpart) > $nbdecimal) |
|
4298 | - $nbdecimal = dol_strlen($decpart); |
|
4507 | + if (dol_strlen($decpart) > $nbdecimal) { |
|
4508 | + $nbdecimal = dol_strlen($decpart); |
|
4509 | + } |
|
4299 | 4510 | // Si on depasse max |
4300 | 4511 | if ($trunc && $nbdecimal > $conf->global->MAIN_MAX_DECIMALS_SHOWN) { |
4301 | 4512 | $nbdecimal = $conf->global->MAIN_MAX_DECIMALS_SHOWN; |
@@ -4306,8 +4517,9 @@ discard block |
||
4306 | 4517 | } |
4307 | 4518 | |
4308 | 4519 | // If force rounding |
4309 | - if ($forcerounding >= 0) |
|
4310 | - $nbdecimal = $forcerounding; |
|
4520 | + if ($forcerounding >= 0) { |
|
4521 | + $nbdecimal = $forcerounding; |
|
4522 | + } |
|
4311 | 4523 | |
4312 | 4524 | // Format number |
4313 | 4525 | $output = number_format($amount, $nbdecimal, $dec, $thousand); |
@@ -4318,13 +4530,14 @@ discard block |
||
4318 | 4530 | // Add symbol of currency if requested |
4319 | 4531 | $cursymbolbefore = $cursymbolafter = ''; |
4320 | 4532 | if ($currency_code) { |
4321 | - if ($currency_code == 'auto') |
|
4322 | - $currency_code = $conf->currency; |
|
4533 | + if ($currency_code == 'auto') { |
|
4534 | + $currency_code = $conf->currency; |
|
4535 | + } |
|
4323 | 4536 | |
4324 | 4537 | $listofcurrenciesbefore = array('USD', 'GBP', 'AUD', 'MXN', 'PEN', 'CNY'); |
4325 | - if (in_array($currency_code, $listofcurrenciesbefore)) |
|
4326 | - $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
4327 | - else { |
|
4538 | + if (in_array($currency_code, $listofcurrenciesbefore)) { |
|
4539 | + $cursymbolbefore .= $outlangs->getCurrencySymbol($currency_code); |
|
4540 | + } else { |
|
4328 | 4541 | $tmpcur = $outlangs->getCurrencySymbol($currency_code); |
4329 | 4542 | $cursymbolafter .= ($tmpcur == $currency_code ? ' ' . $tmpcur : $tmpcur); |
4330 | 4543 | } |
@@ -4358,14 +4571,17 @@ discard block |
||
4358 | 4571 | // Decimal delimiter for PHP and database SQL requests must be '.' |
4359 | 4572 | $dec = ','; |
4360 | 4573 | $thousand = ' '; |
4361 | - if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") |
|
4362 | - $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4363 | - if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") |
|
4364 | - $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); |
|
4365 | - if ($thousand == 'None') |
|
4366 | - $thousand = ''; |
|
4367 | - elseif ($thousand == 'Space') |
|
4368 | - $thousand = ' '; |
|
4574 | + if ($langs->transnoentitiesnoconv("SeparatorDecimal") != "SeparatorDecimal") { |
|
4575 | + $dec = $langs->transnoentitiesnoconv("SeparatorDecimal"); |
|
4576 | + } |
|
4577 | + if ($langs->transnoentitiesnoconv("SeparatorThousand") != "SeparatorThousand") { |
|
4578 | + $thousand = $langs->transnoentitiesnoconv("SeparatorThousand"); |
|
4579 | + } |
|
4580 | + if ($thousand == 'None') { |
|
4581 | + $thousand = ''; |
|
4582 | + } elseif ($thousand == 'Space') { |
|
4583 | + $thousand = ' '; |
|
4584 | + } |
|
4369 | 4585 | //print "amount=".$amount." html=".$form." trunc=".$trunc." nbdecimal=".$nbdecimal." dec='".$dec."' thousand='".$thousand."'<br>"; |
4370 | 4586 | // Convert value to universal number format (no thousand separator, '.' as decimal separator) |
4371 | 4587 | if ($alreadysqlnb != 1) { // If not a PHP number or unknown, we change format |
@@ -4381,8 +4597,10 @@ discard block |
||
4381 | 4597 | } |
4382 | 4598 | //print "QQ".$amount.'<br>'; |
4383 | 4599 | // Now make replace (the main goal of function) |
4384 | - if ($thousand != ',' && $thousand != '.') |
|
4385 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users |
|
4600 | + if ($thousand != ',' && $thousand != '.') { |
|
4601 | + $amount = str_replace(',', '.', $amount); |
|
4602 | + } |
|
4603 | + // To accept 2 notations for french users |
|
4386 | 4604 | $amount = str_replace(' ', '', $amount); // To avoid spaces |
4387 | 4605 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
4388 | 4606 | $amount = str_replace($dec, '.', $amount); |
@@ -4391,19 +4609,23 @@ discard block |
||
4391 | 4609 | // Now, make a rounding if required |
4392 | 4610 | if ($rounding) { |
4393 | 4611 | $nbofdectoround = ''; |
4394 | - if ($rounding == 'MU') |
|
4395 | - $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
4396 | - elseif ($rounding == 'MT') |
|
4397 | - $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; |
|
4398 | - elseif ($rounding == 'MS') |
|
4399 | - $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
4400 | - elseif (is_numeric($rounding)) |
|
4401 | - $nbofdectoround = $rounding; |
|
4612 | + if ($rounding == 'MU') { |
|
4613 | + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT; |
|
4614 | + } elseif ($rounding == 'MT') { |
|
4615 | + $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT; |
|
4616 | + } elseif ($rounding == 'MS') { |
|
4617 | + $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK; |
|
4618 | + } elseif (is_numeric($rounding)) { |
|
4619 | + $nbofdectoround = $rounding; |
|
4620 | + } |
|
4402 | 4621 | //print "RR".$amount.' - '.$nbofdectoround.'<br>'; |
4403 | - if (dol_strlen($nbofdectoround)) |
|
4404 | - $amount = round($amount, $nbofdectoround); // $nbofdectoround can be 0. |
|
4405 | - else |
|
4406 | - return 'ErrorBadParameterProvidedToFunction'; |
|
4622 | + if (dol_strlen($nbofdectoround)) { |
|
4623 | + $amount = round($amount, $nbofdectoround); |
|
4624 | + } |
|
4625 | + // $nbofdectoround can be 0. |
|
4626 | + else { |
|
4627 | + return 'ErrorBadParameterProvidedToFunction'; |
|
4628 | + } |
|
4407 | 4629 | //print 'SS'.$amount.' - '.$nbofdec.' - '.$dec.' - '.$thousand.' - '.$nbofdectoround.'<br>'; |
4408 | 4630 | // Convert amount to format with dolibarr dec and thousand (this is because PHP convert a number |
4409 | 4631 | // to format defined by LC_NUMERIC after a calculation and we want source format to be defined by Dolibarr setup. |
@@ -4417,8 +4639,10 @@ discard block |
||
4417 | 4639 | //print "TT".$amount.'<br>'; |
4418 | 4640 | // Always make replace because each math function (like round) replace |
4419 | 4641 | // with local values and we want a number that has a SQL string format x.y |
4420 | - if ($thousand != ',' && $thousand != '.') |
|
4421 | - $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users |
|
4642 | + if ($thousand != ',' && $thousand != '.') { |
|
4643 | + $amount = str_replace(',', '.', $amount); |
|
4644 | + } |
|
4645 | + // To accept 2 notations for french users |
|
4422 | 4646 | $amount = str_replace(' ', '', $amount); // To avoid spaces |
4423 | 4647 | $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . |
4424 | 4648 | $amount = str_replace($dec, '.', $amount); |
@@ -4477,8 +4701,9 @@ discard block |
||
4477 | 4701 | { |
4478 | 4702 | global $db, $conf, $mysoc; |
4479 | 4703 | |
4480 | - if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) |
|
4481 | - $thirdparty_seller = $mysoc; |
|
4704 | + if (empty($thirdparty_seller) || !is_object($thirdparty_seller)) { |
|
4705 | + $thirdparty_seller = $mysoc; |
|
4706 | + } |
|
4482 | 4707 | |
4483 | 4708 | dol_syslog("get_localtax tva=" . $vatrate . " local=" . $local . " thirdparty_buyer id=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->id : '') . "/country_code=" . (is_object($thirdparty_buyer) ? $thirdparty_buyer->country_code : '') . " thirdparty_seller id=" . $thirdparty_seller->id . "/country_code=" . $thirdparty_seller->country_code . " thirdparty_seller localtax1_assuj=" . $thirdparty_seller->localtax1_assuj . " thirdparty_seller localtax2_assuj=" . $thirdparty_seller->localtax2_assuj); |
4484 | 4709 | |
@@ -4496,37 +4721,43 @@ discard block |
||
4496 | 4721 | // Some test to guess with no need to make database access |
4497 | 4722 | if ($mysoc->country_code == 'ES') { // For spain localtaxes 1 and 2, tax is qualified if buyer use local tax |
4498 | 4723 | if ($local == 1) { |
4499 | - if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") |
|
4500 | - return 0; |
|
4724 | + if (!$mysoc->localtax1_assuj || (string) $vatratecleaned == "0") { |
|
4725 | + return 0; |
|
4726 | + } |
|
4501 | 4727 | if ($thirdparty_seller->id == $mysoc->id) { |
4502 | - if (!$thirdparty_buyer->localtax1_assuj) |
|
4503 | - return 0; |
|
4504 | - } |
|
4505 | - else { |
|
4506 | - if (!$thirdparty_seller->localtax1_assuj) |
|
4507 | - return 0; |
|
4728 | + if (!$thirdparty_buyer->localtax1_assuj) { |
|
4729 | + return 0; |
|
4730 | + } |
|
4731 | + } else { |
|
4732 | + if (!$thirdparty_seller->localtax1_assuj) { |
|
4733 | + return 0; |
|
4734 | + } |
|
4508 | 4735 | } |
4509 | 4736 | } |
4510 | 4737 | |
4511 | 4738 | if ($local == 2) { |
4512 | 4739 | //if (! $mysoc->localtax2_assuj || (string) $vatratecleaned == "0") return 0; |
4513 | - if (!$mysoc->localtax2_assuj) |
|
4514 | - return 0; // If main vat is 0, IRPF may be different than 0. |
|
4740 | + if (!$mysoc->localtax2_assuj) { |
|
4741 | + return 0; |
|
4742 | + } |
|
4743 | + // If main vat is 0, IRPF may be different than 0. |
|
4515 | 4744 | if ($thirdparty_seller->id == $mysoc->id) { |
4516 | - if (!$thirdparty_buyer->localtax2_assuj) |
|
4517 | - return 0; |
|
4518 | - } |
|
4519 | - else { |
|
4520 | - if (!$thirdparty_seller->localtax2_assuj) |
|
4521 | - return 0; |
|
4745 | + if (!$thirdparty_buyer->localtax2_assuj) { |
|
4746 | + return 0; |
|
4747 | + } |
|
4748 | + } else { |
|
4749 | + if (!$thirdparty_seller->localtax2_assuj) { |
|
4750 | + return 0; |
|
4751 | + } |
|
4522 | 4752 | } |
4523 | 4753 | } |
4524 | - } |
|
4525 | - else { |
|
4526 | - if ($local == 1 && !$thirdparty_seller->localtax1_assuj) |
|
4527 | - return 0; |
|
4528 | - if ($local == 2 && !$thirdparty_seller->localtax2_assuj) |
|
4529 | - return 0; |
|
4754 | + } else { |
|
4755 | + if ($local == 1 && !$thirdparty_seller->localtax1_assuj) { |
|
4756 | + return 0; |
|
4757 | + } |
|
4758 | + if ($local == 2 && !$thirdparty_seller->localtax2_assuj) { |
|
4759 | + return 0; |
|
4760 | + } |
|
4530 | 4761 | } |
4531 | 4762 | |
4532 | 4763 | // For some country MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY is forced to on. |
@@ -4568,19 +4799,23 @@ discard block |
||
4568 | 4799 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t, " . MAIN_DB_PREFIX . "c_country as c"; |
4569 | 4800 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $thirdparty_seller->country_code . "'"; |
4570 | 4801 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
4571 | - if ($vatratecode) |
|
4572 | - $sql .= " AND t.code ='" . $vatratecode . "'"; // If we have the code, we use it in priority |
|
4573 | - else |
|
4574 | - $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
4802 | + if ($vatratecode) { |
|
4803 | + $sql .= " AND t.code ='" . $vatratecode . "'"; |
|
4804 | + } |
|
4805 | + // If we have the code, we use it in priority |
|
4806 | + else { |
|
4807 | + $sql .= " AND t.recuperableonly ='" . $vatnpr . "'"; |
|
4808 | + } |
|
4575 | 4809 | dol_syslog("get_localtax", LOG_DEBUG); |
4576 | 4810 | $resql = $db->query($sql); |
4577 | 4811 | |
4578 | 4812 | if ($resql) { |
4579 | 4813 | $obj = $db->fetch_object($resql); |
4580 | - if ($local == 1) |
|
4581 | - return $obj->localtax1; |
|
4582 | - elseif ($local == 2) |
|
4583 | - return $obj->localtax2; |
|
4814 | + if ($local == 1) { |
|
4815 | + return $obj->localtax1; |
|
4816 | + } elseif ($local == 2) { |
|
4817 | + return $obj->localtax2; |
|
4818 | + } |
|
4584 | 4819 | } |
4585 | 4820 | |
4586 | 4821 | return 0; |
@@ -4626,10 +4861,11 @@ discard block |
||
4626 | 4861 | $resql = $db->query($sql); |
4627 | 4862 | if ($resql) { |
4628 | 4863 | $obj = $db->fetch_object($resql); |
4629 | - if ($local == 1) |
|
4630 | - return $obj->localtax1; |
|
4631 | - elseif ($local == 2) |
|
4632 | - return $obj->localtax2; |
|
4864 | + if ($local == 1) { |
|
4865 | + return $obj->localtax1; |
|
4866 | + } elseif ($local == 2) { |
|
4867 | + return $obj->localtax2; |
|
4868 | + } |
|
4633 | 4869 | } |
4634 | 4870 | |
4635 | 4871 | return 0; |
@@ -4655,9 +4891,9 @@ discard block |
||
4655 | 4891 | // Search local taxes |
4656 | 4892 | $sql = "SELECT t.rowid, t.code, t.taux as rate, t.recuperableonly as npr, t.accountancy_code_sell, t.accountancy_code_buy"; |
4657 | 4893 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
4658 | - if ($firstparamisid) |
|
4659 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
4660 | - else { |
|
4894 | + if ($firstparamisid) { |
|
4895 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
4896 | + } else { |
|
4661 | 4897 | $vatratecleaned = $vatrate; |
4662 | 4898 | $vatratecode = ''; |
4663 | 4899 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "xx (yy)" |
@@ -4670,19 +4906,22 @@ discard block |
||
4670 | 4906 | else $sql.= " WHERE t.fk_pays = c.rowid AND c.code = '".$seller->country_code."'"; */ |
4671 | 4907 | $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
4672 | 4908 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
4673 | - if ($vatratecode) |
|
4674 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
4909 | + if ($vatratecode) { |
|
4910 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
4911 | + } |
|
4675 | 4912 | } |
4676 | 4913 | |
4677 | 4914 | $resql = $db->query($sql); |
4678 | 4915 | if ($resql) { |
4679 | 4916 | $obj = $db->fetch_object($resql); |
4680 | - if ($obj) |
|
4681 | - return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy); |
|
4682 | - else |
|
4683 | - return array(); |
|
4684 | - } else |
|
4685 | - dol_print_error($db); |
|
4917 | + if ($obj) { |
|
4918 | + return array('rowid' => $obj->rowid, 'code' => $obj->code, 'rate' => $obj->rate, 'npr' => $obj->npr, 'accountancy_code_sell' => $obj->accountancy_code_sell, 'accountancy_code_buy' => $obj->accountancy_code_buy); |
|
4919 | + } else { |
|
4920 | + return array(); |
|
4921 | + } |
|
4922 | + } else { |
|
4923 | + dol_print_error($db); |
|
4924 | + } |
|
4686 | 4925 | |
4687 | 4926 | return array(); |
4688 | 4927 | } |
@@ -4712,9 +4951,9 @@ discard block |
||
4712 | 4951 | // Search local taxes |
4713 | 4952 | $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; |
4714 | 4953 | $sql .= " FROM " . MAIN_DB_PREFIX . "c_tva as t"; |
4715 | - if ($firstparamisid) |
|
4716 | - $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
4717 | - else { |
|
4954 | + if ($firstparamisid) { |
|
4955 | + $sql .= " WHERE t.rowid = " . (int) $vatrate; |
|
4956 | + } else { |
|
4718 | 4957 | $vatratecleaned = $vatrate; |
4719 | 4958 | $vatratecode = ''; |
4720 | 4959 | if (preg_match('/^(.*)\s*\((.*)\)$/', $vatrate, $reg)) { // If vat is "x.x (yy)" |
@@ -4723,13 +4962,17 @@ discard block |
||
4723 | 4962 | } |
4724 | 4963 | |
4725 | 4964 | $sql .= ", " . MAIN_DB_PREFIX . "c_country as c"; |
4726 | - if ($mysoc->country_code == 'ES') |
|
4727 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; // local tax in spain use the buyer country ?? |
|
4728 | - else |
|
4729 | - $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
4965 | + if ($mysoc->country_code == 'ES') { |
|
4966 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $buyer->country_code . "'"; |
|
4967 | + } |
|
4968 | + // local tax in spain use the buyer country ?? |
|
4969 | + else { |
|
4970 | + $sql .= " WHERE t.fk_pays = c.rowid AND c.code = '" . $seller->country_code . "'"; |
|
4971 | + } |
|
4730 | 4972 | $sql .= " AND t.taux = " . ((float) $vatratecleaned) . " AND t.active = 1"; |
4731 | - if ($vatratecode) |
|
4732 | - $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
4973 | + if ($vatratecode) { |
|
4974 | + $sql .= " AND t.code = '" . $vatratecode . "'"; |
|
4975 | + } |
|
4733 | 4976 | } |
4734 | 4977 | |
4735 | 4978 | $resql = $db->query($sql); |
@@ -4775,17 +5018,17 @@ discard block |
||
4775 | 5018 | if ($idprodfournprice > 0) { // We want vat for product for a "supplier" object |
4776 | 5019 | $product->get_buyprice($idprodfournprice, 0, 0, 0); |
4777 | 5020 | $ret = $product->vatrate_supplier; |
4778 | - if ($product->default_vat_code) |
|
4779 | - $ret .= ' (' . $product->default_vat_code . ')'; |
|
4780 | - } |
|
4781 | - else { |
|
5021 | + if ($product->default_vat_code) { |
|
5022 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
5023 | + } |
|
5024 | + } else { |
|
4782 | 5025 | $ret = $product->tva_tx; // Default vat of product we defined |
4783 | - if ($product->default_vat_code) |
|
4784 | - $ret .= ' (' . $product->default_vat_code . ')'; |
|
5026 | + if ($product->default_vat_code) { |
|
5027 | + $ret .= ' (' . $product->default_vat_code . ')'; |
|
5028 | + } |
|
4785 | 5029 | } |
4786 | 5030 | $found = 1; |
4787 | - } |
|
4788 | - else { |
|
5031 | + } else { |
|
4789 | 5032 | // TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet. |
4790 | 5033 | // May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on |
4791 | 5034 | } |
@@ -4805,14 +5048,18 @@ discard block |
||
4805 | 5048 | $obj = $db->fetch_object($resql); |
4806 | 5049 | if ($obj) { |
4807 | 5050 | $ret = $obj->vat_rate; |
4808 | - if ($obj->default_vat_code) |
|
4809 | - $ret .= ' (' . $obj->default_vat_code . ')'; |
|
5051 | + if ($obj->default_vat_code) { |
|
5052 | + $ret .= ' (' . $obj->default_vat_code . ')'; |
|
5053 | + } |
|
4810 | 5054 | } |
4811 | 5055 | $db->free($sql); |
4812 | - } else |
|
4813 | - dol_print_error($db); |
|
4814 | - } else |
|
4815 | - $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; // Forced value if autodetect fails |
|
5056 | + } else { |
|
5057 | + dol_print_error($db); |
|
5058 | + } |
|
5059 | + } else { |
|
5060 | + $ret = $conf->global->MAIN_VAT_DEFAULT_IF_AUTODETECT_FAILS; |
|
5061 | + } |
|
5062 | + // Forced value if autodetect fails |
|
4816 | 5063 | } |
4817 | 5064 | |
4818 | 5065 | dol_syslog("get_product_vat_for_country: ret=" . $ret); |
@@ -4867,13 +5114,15 @@ discard block |
||
4867 | 5114 | if ($resql) { |
4868 | 5115 | $obj = $db->fetch_object($resql); |
4869 | 5116 | if ($obj) { |
4870 | - if ($local == 1) |
|
4871 | - $ret = $obj->localtax1; |
|
4872 | - elseif ($local == 2) |
|
4873 | - $ret = $obj->localtax2; |
|
5117 | + if ($local == 1) { |
|
5118 | + $ret = $obj->localtax1; |
|
5119 | + } elseif ($local == 2) { |
|
5120 | + $ret = $obj->localtax2; |
|
5121 | + } |
|
4874 | 5122 | } |
4875 | - } else |
|
4876 | - dol_print_error($db); |
|
5123 | + } else { |
|
5124 | + dol_print_error($db); |
|
5125 | + } |
|
4877 | 5126 | } |
4878 | 5127 | |
4879 | 5128 | dol_syslog("get_product_localtax_for_country: ret=" . $ret); |
@@ -4976,15 +5225,16 @@ discard block |
||
4976 | 5225 | global $db; |
4977 | 5226 | |
4978 | 5227 | if ($idprodfournprice > 0) { |
4979 | - if (!class_exists('ProductFournisseur')) |
|
4980 | - require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
5228 | + if (!class_exists('ProductFournisseur')) { |
|
5229 | + require_once DOL_BASE_PATH . '/fourn/class/fournisseur.product.class.php'; |
|
5230 | + } |
|
4981 | 5231 | $prodprice = new ProductFournisseur($db); |
4982 | 5232 | $prodprice->fetch_product_fournisseur_price($idprodfournprice); |
4983 | 5233 | return $prodprice->fourn_tva_npr; |
4984 | - } |
|
4985 | - elseif ($idprod > 0) { |
|
4986 | - if (!class_exists('Product')) |
|
4987 | - require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
5234 | + } elseif ($idprod > 0) { |
|
5235 | + if (!class_exists('Product')) { |
|
5236 | + require_once DOL_BASE_PATH . 'product/class/product.class.php'; |
|
5237 | + } |
|
4988 | 5238 | $prod = new Product($db); |
4989 | 5239 | $prod->fetch($idprod); |
4990 | 5240 | return $prod->tva_npr; |
@@ -5010,30 +5260,35 @@ discard block |
||
5010 | 5260 | { |
5011 | 5261 | global $mysoc; |
5012 | 5262 | |
5013 | - if (!is_object($thirdparty_seller)) |
|
5014 | - return -1; |
|
5015 | - if (!is_object($thirdparty_buyer)) |
|
5016 | - return -1; |
|
5263 | + if (!is_object($thirdparty_seller)) { |
|
5264 | + return -1; |
|
5265 | + } |
|
5266 | + if (!is_object($thirdparty_buyer)) { |
|
5267 | + return -1; |
|
5268 | + } |
|
5017 | 5269 | |
5018 | 5270 | if ($local == 1) { // Localtax 1 |
5019 | 5271 | if ($mysoc->country_code == 'ES') { |
5020 | - if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) |
|
5021 | - return 0; |
|
5022 | - } |
|
5023 | - else { |
|
5272 | + if (is_numeric($thirdparty_buyer->localtax1_assuj) && !$thirdparty_buyer->localtax1_assuj) { |
|
5273 | + return 0; |
|
5274 | + } |
|
5275 | + } else { |
|
5024 | 5276 | // Si vendeur non assujeti a Localtax1, localtax1 par default=0 |
5025 | - if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) |
|
5026 | - return 0; |
|
5027 | - if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') |
|
5028 | - return 0; |
|
5029 | - } |
|
5030 | - } |
|
5031 | - elseif ($local == 2) { //I Localtax 2 |
|
5277 | + if (is_numeric($thirdparty_seller->localtax1_assuj) && !$thirdparty_seller->localtax1_assuj) { |
|
5278 | + return 0; |
|
5279 | + } |
|
5280 | + if (!is_numeric($thirdparty_seller->localtax1_assuj) && $thirdparty_seller->localtax1_assuj == 'localtax1off') { |
|
5281 | + return 0; |
|
5282 | + } |
|
5283 | + } |
|
5284 | + } elseif ($local == 2) { //I Localtax 2 |
|
5032 | 5285 | // Si vendeur non assujeti a Localtax2, localtax2 par default=0 |
5033 | - if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) |
|
5034 | - return 0; |
|
5035 | - if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') |
|
5036 | - return 0; |
|
5286 | + if (is_numeric($thirdparty_seller->localtax2_assuj) && !$thirdparty_seller->localtax2_assuj) { |
|
5287 | + return 0; |
|
5288 | + } |
|
5289 | + if (!is_numeric($thirdparty_seller->localtax2_assuj) && $thirdparty_seller->localtax2_assuj == 'localtax2off') { |
|
5290 | + return 0; |
|
5291 | + } |
|
5037 | 5292 | } |
5038 | 5293 | |
5039 | 5294 | if ($thirdparty_seller->country_code == $thirdparty_buyer->country_code) { |
@@ -5058,31 +5313,38 @@ discard block |
||
5058 | 5313 | $classname = ''; |
5059 | 5314 | if ($yesno == 1 || strtolower($yesno) == 'yes' || strtolower($yesno) == 'true') { // A mettre avant test sur no a cause du == 0 |
5060 | 5315 | $result = $langs->trans('yes'); |
5061 | - if ($case == 1 || $case == 3) |
|
5062 | - $result = $langs->trans("Yes"); |
|
5063 | - if ($case == 2) |
|
5064 | - $result = '<input type="checkbox" value="1" checked disabled>'; |
|
5065 | - if ($case == 3) |
|
5066 | - $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
5316 | + if ($case == 1 || $case == 3) { |
|
5317 | + $result = $langs->trans("Yes"); |
|
5318 | + } |
|
5319 | + if ($case == 2) { |
|
5320 | + $result = '<input type="checkbox" value="1" checked disabled>'; |
|
5321 | + } |
|
5322 | + if ($case == 3) { |
|
5323 | + $result = '<input type="checkbox" value="1" checked disabled> ' . $result; |
|
5324 | + } |
|
5067 | 5325 | |
5068 | 5326 | $classname = 'ok'; |
5069 | - } |
|
5070 | - elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') { |
|
5327 | + } elseif ($yesno == 0 || strtolower($yesno) == 'no' || strtolower($yesno) == 'false') { |
|
5071 | 5328 | $result = $langs->trans("no"); |
5072 | - if ($case == 1 || $case == 3) |
|
5073 | - $result = $langs->trans("No"); |
|
5074 | - if ($case == 2) |
|
5075 | - $result = '<input type="checkbox" value="0" disabled>'; |
|
5076 | - if ($case == 3) |
|
5077 | - $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
5078 | - |
|
5079 | - if ($color == 2) |
|
5080 | - $classname = 'ok'; |
|
5081 | - else |
|
5082 | - $classname = 'error'; |
|
5083 | - } |
|
5084 | - if ($color) |
|
5085 | - return '<font class="' . $classname . '">' . $result . '</font>'; |
|
5329 | + if ($case == 1 || $case == 3) { |
|
5330 | + $result = $langs->trans("No"); |
|
5331 | + } |
|
5332 | + if ($case == 2) { |
|
5333 | + $result = '<input type="checkbox" value="0" disabled>'; |
|
5334 | + } |
|
5335 | + if ($case == 3) { |
|
5336 | + $result = '<input type="checkbox" value="0" disabled> ' . $result; |
|
5337 | + } |
|
5338 | + |
|
5339 | + if ($color == 2) { |
|
5340 | + $classname = 'ok'; |
|
5341 | + } else { |
|
5342 | + $classname = 'error'; |
|
5343 | + } |
|
5344 | + } |
|
5345 | + if ($color) { |
|
5346 | + return '<font class="' . $classname . '">' . $result . '</font>'; |
|
5347 | + } |
|
5086 | 5348 | return $result; |
5087 | 5349 | } |
5088 | 5350 | |
@@ -5108,23 +5370,27 @@ discard block |
||
5108 | 5370 | $path = ''; |
5109 | 5371 | |
5110 | 5372 | $arrayforoldpath = array('cheque', 'user', 'category', 'holiday', 'supplier_invoice', 'invoice_supplier', 'mailing', 'supplier_payment'); |
5111 | - if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) |
|
5112 | - $arrayforoldpath[] = 'product'; |
|
5373 | + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { |
|
5374 | + $arrayforoldpath[] = 'product'; |
|
5375 | + } |
|
5113 | 5376 | if (!empty($level) && in_array($modulepart, $arrayforoldpath)) { |
5114 | 5377 | // This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided. |
5115 | - if (empty($alpha)) |
|
5116 | - $num = preg_replace('/([^0-9])/i', '', $num); |
|
5117 | - else |
|
5118 | - $num = preg_replace('/^.*\-/i', '', $num); |
|
5378 | + if (empty($alpha)) { |
|
5379 | + $num = preg_replace('/([^0-9])/i', '', $num); |
|
5380 | + } else { |
|
5381 | + $num = preg_replace('/^.*\-/i', '', $num); |
|
5382 | + } |
|
5119 | 5383 | $num = substr("000" . $num, -$level); |
5120 | - if ($level == 1) |
|
5121 | - $path = substr($num, 0, 1); |
|
5122 | - if ($level == 2) |
|
5123 | - $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
5124 | - if ($level == 3) |
|
5125 | - $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
5126 | - } |
|
5127 | - else { |
|
5384 | + if ($level == 1) { |
|
5385 | + $path = substr($num, 0, 1); |
|
5386 | + } |
|
5387 | + if ($level == 2) { |
|
5388 | + $path = substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
5389 | + } |
|
5390 | + if ($level == 3) { |
|
5391 | + $path = substr($num, 2, 1) . '/' . substr($num, 1, 1) . '/' . substr($num, 0, 1); |
|
5392 | + } |
|
5393 | + } else { |
|
5128 | 5394 | // TODO |
5129 | 5395 | // We will enhance here a common way of forging path for document storage |
5130 | 5396 | // Here, object->id, object->ref and modulepart are required. |
@@ -5135,8 +5401,9 @@ discard block |
||
5135 | 5401 | } |
5136 | 5402 | } |
5137 | 5403 | |
5138 | - if (empty($withoutslash) && !empty($path)) |
|
5139 | - $path .= '/'; |
|
5404 | + if (empty($withoutslash) && !empty($path)) { |
|
5405 | + $path .= '/'; |
|
5406 | + } |
|
5140 | 5407 | |
5141 | 5408 | return $path; |
5142 | 5409 | } |
@@ -5156,8 +5423,9 @@ discard block |
||
5156 | 5423 | dol_syslog("functions.lib::dol_mkdir: dir=" . $dir, LOG_INFO); |
5157 | 5424 | |
5158 | 5425 | $dir_osencoded = dol_osencode($dir); |
5159 | - if (@is_dir($dir_osencoded)) |
|
5160 | - return 0; |
|
5426 | + if (@is_dir($dir_osencoded)) { |
|
5427 | + return 0; |
|
5428 | + } |
|
5161 | 5429 | |
5162 | 5430 | $nberr = 0; |
5163 | 5431 | $nbcreated = 0; |
@@ -5172,12 +5440,15 @@ discard block |
||
5172 | 5440 | $cdir = explode("/", $dir); |
5173 | 5441 | $num = count($cdir); |
5174 | 5442 | for ($i = 0; $i < $num; $i++) { |
5175 | - if ($i > 0) |
|
5176 | - $ccdir .= '/' . $cdir[$i]; |
|
5177 | - else |
|
5178 | - $ccdir .= $cdir[$i]; |
|
5179 | - if (preg_match("/^.:$/", $ccdir, $regs)) |
|
5180 | - continue; // Si chemin Windows incomplet, on poursuit par rep suivant |
|
5443 | + if ($i > 0) { |
|
5444 | + $ccdir .= '/' . $cdir[$i]; |
|
5445 | + } else { |
|
5446 | + $ccdir .= $cdir[$i]; |
|
5447 | + } |
|
5448 | + if (preg_match("/^.:$/", $ccdir, $regs)) { |
|
5449 | + continue; |
|
5450 | + } |
|
5451 | + // Si chemin Windows incomplet, on poursuit par rep suivant |
|
5181 | 5452 | |
5182 | 5453 | |
5183 | 5454 | |
@@ -5256,8 +5527,9 @@ discard block |
||
5256 | 5527 | */ |
5257 | 5528 | function dol_string_nohtmltag($stringtoclean, $removelinefeed = 1, $pagecodeto = 'UTF-8', $strip_tags = 0) |
5258 | 5529 | { |
5259 | - if ($removelinefeed == 2) |
|
5260 | - $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean); |
|
5530 | + if ($removelinefeed == 2) { |
|
5531 | + $stringtoclean = preg_replace('/<br[^>]*>\n+/ims', '<br>', $stringtoclean); |
|
5532 | + } |
|
5261 | 5533 | $temp = preg_replace('/<br[^>]*>/i', "\n", $stringtoclean); |
5262 | 5534 | |
5263 | 5535 | if ($strip_tags) { |
@@ -5274,8 +5546,9 @@ discard block |
||
5274 | 5546 | $temp = dol_html_entity_decode($temp, ENT_COMPAT, $pagecodeto); |
5275 | 5547 | |
5276 | 5548 | // Supprime aussi les retours |
5277 | - if ($removelinefeed == 1) |
|
5278 | - $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); |
|
5549 | + if ($removelinefeed == 1) { |
|
5550 | + $temp = str_replace(array("\r\n", "\r", "\n"), " ", $temp); |
|
5551 | + } |
|
5279 | 5552 | |
5280 | 5553 | // et les espaces doubles |
5281 | 5554 | while (strpos($temp, " ")) { |
@@ -5361,18 +5634,21 @@ discard block |
||
5361 | 5634 | if ($charset == 'UTF-8') { |
5362 | 5635 | $pattern = '/(<br[^>]*>)/Uu'; |
5363 | 5636 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
5364 | - else |
|
5365 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
5637 | + else { |
|
5638 | + $pattern = '/(<br[^>]*>)/U'; |
|
5639 | + } |
|
5640 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
5366 | 5641 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
5367 | 5642 | |
5368 | 5643 | $firstline = ''; |
5369 | 5644 | $i = 0; |
5370 | 5645 | $nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator |
5371 | 5646 | while (($i < $nba) && ($i < ($nboflines * 2))) { |
5372 | - if ($i % 2 == 0) |
|
5373 | - $firstline .= $a[$i]; |
|
5374 | - elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) |
|
5375 | - $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
5647 | + if ($i % 2 == 0) { |
|
5648 | + $firstline .= $a[$i]; |
|
5649 | + } elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) { |
|
5650 | + $firstline .= ($ishtml ? "<br>\n" : "\n"); |
|
5651 | + } |
|
5376 | 5652 | $i++; |
5377 | 5653 | } |
5378 | 5654 | unset($a); |
@@ -5421,15 +5697,18 @@ discard block |
||
5421 | 5697 | $newstring = $stringtoencode; |
5422 | 5698 | if (dol_textishtml($stringtoencode)) { // Check if text is already HTML or not |
5423 | 5699 | $newstring = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. |
5424 | - if ($removelasteolbr) |
|
5425 | - $newstring = preg_replace('/<br>$/i', '', $newstring); // Remove last <br> (remove only last one) |
|
5700 | + if ($removelasteolbr) { |
|
5701 | + $newstring = preg_replace('/<br>$/i', '', $newstring); |
|
5702 | + } |
|
5703 | + // Remove last <br> (remove only last one) |
|
5426 | 5704 | $newstring = strtr($newstring, array('&' => '__and__', '<' => '__lt__', '>' => '__gt__', '"' => '__dquot__')); |
5427 | 5705 | $newstring = dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom); // Make entity encoding |
5428 | 5706 | $newstring = strtr($newstring, array('__and__' => '&', '__lt__' => '<', '__gt__' => '>', '__dquot__' => '"')); |
5429 | - } |
|
5430 | - else { |
|
5431 | - if ($removelasteolbr) |
|
5432 | - $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); // Remove last \n (may remove several) |
|
5707 | + } else { |
|
5708 | + if ($removelasteolbr) { |
|
5709 | + $newstring = preg_replace('/(\r\n|\r|\n)$/i', '', $newstring); |
|
5710 | + } |
|
5711 | + // Remove last \n (may remove several) |
|
5433 | 5712 | $newstring = dol_nl2br(dol_htmlentities($newstring, ENT_COMPAT, $pagecodefrom), $nl2brmode); |
5434 | 5713 | } |
5435 | 5714 | // Other substitutions that htmlentities does not do |
@@ -5531,8 +5810,9 @@ discard block |
||
5531 | 5810 | */ |
5532 | 5811 | function dol_nboflines($s, $maxchar = 0) |
5533 | 5812 | { |
5534 | - if ($s == '') |
|
5535 | - return 0; |
|
5813 | + if ($s == '') { |
|
5814 | + return 0; |
|
5815 | + } |
|
5536 | 5816 | $arraystring = explode("\n", $s); |
5537 | 5817 | $nb = count($arraystring); |
5538 | 5818 | |
@@ -5551,15 +5831,18 @@ discard block |
||
5551 | 5831 | function dol_nboflines_bis($text, $maxlinesize = 0, $charset = 'UTF-8') |
5552 | 5832 | { |
5553 | 5833 | $repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " "); |
5554 | - if (dol_textishtml($text)) |
|
5555 | - $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
5834 | + if (dol_textishtml($text)) { |
|
5835 | + $repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " "); |
|
5836 | + } |
|
5556 | 5837 | |
5557 | 5838 | $text = strtr($text, $repTable); |
5558 | 5839 | if ($charset == 'UTF-8') { |
5559 | 5840 | $pattern = '/(<br[^>]*>)/Uu'; |
5560 | 5841 | } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support |
5561 | - else |
|
5562 | - $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag. |
|
5842 | + else { |
|
5843 | + $pattern = '/(<br[^>]*>)/U'; |
|
5844 | + } |
|
5845 | + // /U is to have UNGREEDY regex to limit to one html tag. |
|
5563 | 5846 | $a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); |
5564 | 5847 | |
5565 | 5848 | $nblines = (int) floor((count($a) + 1) / 2); |
@@ -5606,39 +5889,47 @@ discard block |
||
5606 | 5889 | function dol_textishtml($msg, $option = 0) |
5607 | 5890 | { |
5608 | 5891 | if ($option == 1) { |
5609 | - if (preg_match('/<html/i', $msg)) |
|
5610 | - return true; |
|
5611 | - elseif (preg_match('/<body/i', $msg)) |
|
5612 | - return true; |
|
5613 | - elseif (preg_match('/<br/i', $msg)) |
|
5614 | - return true; |
|
5892 | + if (preg_match('/<html/i', $msg)) { |
|
5893 | + return true; |
|
5894 | + } elseif (preg_match('/<body/i', $msg)) { |
|
5895 | + return true; |
|
5896 | + } elseif (preg_match('/<br/i', $msg)) { |
|
5897 | + return true; |
|
5898 | + } |
|
5615 | 5899 | return false; |
5616 | - } |
|
5617 | - else { |
|
5618 | - if (preg_match('/<html/i', $msg)) |
|
5619 | - return true; |
|
5620 | - elseif (preg_match('/<body/i', $msg)) |
|
5621 | - return true; |
|
5622 | - elseif (preg_match('/<(b|em|i|u)>/i', $msg)) |
|
5623 | - return true; |
|
5624 | - elseif (preg_match('/<br\/>/i', $msg)) |
|
5625 | - return true; |
|
5626 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) |
|
5627 | - return true; |
|
5628 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) |
|
5629 | - return true; |
|
5630 | - elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) |
|
5631 | - return true; |
|
5632 | - elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) |
|
5633 | - return true; // must accept <img src="http://example.com/aaa.png" /> |
|
5634 | - elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) |
|
5635 | - return true; // must accept <a href="http://example.com/aaa.png" /> |
|
5636 | - elseif (preg_match('/<h[0-9]>/i', $msg)) |
|
5637 | - return true; |
|
5638 | - elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) |
|
5639 | - return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
5640 | - elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) |
|
5641 | - return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
5900 | + } else { |
|
5901 | + if (preg_match('/<html/i', $msg)) { |
|
5902 | + return true; |
|
5903 | + } elseif (preg_match('/<body/i', $msg)) { |
|
5904 | + return true; |
|
5905 | + } elseif (preg_match('/<(b|em|i|u)>/i', $msg)) { |
|
5906 | + return true; |
|
5907 | + } elseif (preg_match('/<br\/>/i', $msg)) { |
|
5908 | + return true; |
|
5909 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)>/i', $msg)) { |
|
5910 | + return true; |
|
5911 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*>/i', $msg)) { |
|
5912 | + return true; |
|
5913 | + } elseif (preg_match('/<(br|div|font|li|p|span|strong|table)\s+[^<>\/]*\/>/i', $msg)) { |
|
5914 | + return true; |
|
5915 | + } elseif (preg_match('/<img\s+[^<>]*src[^<>]*>/i', $msg)) { |
|
5916 | + return true; |
|
5917 | + } |
|
5918 | + // must accept <img src="http://example.com/aaa.png" /> |
|
5919 | + elseif (preg_match('/<a\s+[^<>]*href[^<>]*>/i', $msg)) { |
|
5920 | + return true; |
|
5921 | + } |
|
5922 | + // must accept <a href="http://example.com/aaa.png" /> |
|
5923 | + elseif (preg_match('/<h[0-9]>/i', $msg)) { |
|
5924 | + return true; |
|
5925 | + } elseif (preg_match('/&[A-Z0-9]{1,6};/i', $msg)) { |
|
5926 | + return true; |
|
5927 | + } |
|
5928 | + // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) |
|
5929 | + elseif (preg_match('/&#[0-9]{2,3};/i', $msg)) { |
|
5930 | + return true; |
|
5931 | + } |
|
5932 | + // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) |
|
5642 | 5933 | |
5643 | 5934 | return false; |
5644 | 5935 | } |
@@ -5790,12 +6081,14 @@ discard block |
||
5790 | 6081 | $birthday = dol_print_date($object->birth, 'day'); |
5791 | 6082 | |
5792 | 6083 | $substitutionarray['__MEMBER_ID__'] = $object->id; |
5793 | - if (method_exists($object, 'getCivilityLabel')) |
|
5794 | - $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
6084 | + if (method_exists($object, 'getCivilityLabel')) { |
|
6085 | + $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel(); |
|
6086 | + } |
|
5795 | 6087 | $substitutionarray['__MEMBER_FIRSTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->firstname) : $object->firstname; |
5796 | 6088 | $substitutionarray['__MEMBER_LASTNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->lastname) : $object->lastname; |
5797 | - if (method_exists($object, 'getFullName')) |
|
5798 | - $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
6089 | + if (method_exists($object, 'getFullName')) { |
|
6090 | + $substitutionarray['__MEMBER_FULLNAME__'] = $msgishtml ? dol_htmlentitiesbr($object->getFullName($outputlangs)) : $object->getFullName($outputlangs); |
|
6091 | + } |
|
5799 | 6092 | $substitutionarray['__MEMBER_COMPANY__'] = $msgishtml ? dol_htmlentitiesbr($object->societe) : $object->societe; |
5800 | 6093 | $substitutionarray['__MEMBER_ADDRESS__'] = $msgishtml ? dol_htmlentitiesbr($object->address) : $object->address; |
5801 | 6094 | $substitutionarray['__MEMBER_ZIP__'] = $msgishtml ? dol_htmlentitiesbr($object->zip) : $object->zip; |
@@ -5843,10 +6136,12 @@ discard block |
||
5843 | 6136 | $dateplannedstart = ''; |
5844 | 6137 | $datenextexpiration = ''; |
5845 | 6138 | foreach ($object->lines as $line) { |
5846 | - if ($line->date_ouverture_prevue > $dateplannedstart) |
|
5847 | - $dateplannedstart = $line->date_ouverture_prevue; |
|
5848 | - if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) |
|
5849 | - $datenextexpiration = $line->date_fin_prevue; |
|
6139 | + if ($line->date_ouverture_prevue > $dateplannedstart) { |
|
6140 | + $dateplannedstart = $line->date_ouverture_prevue; |
|
6141 | + } |
|
6142 | + if ($line->statut == 4 && $line->date_fin_prevue && (!$datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) { |
|
6143 | + $datenextexpiration = $line->date_fin_prevue; |
|
6144 | + } |
|
5850 | 6145 | } |
5851 | 6146 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc'); |
5852 | 6147 | $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard'); |
@@ -5856,8 +6151,9 @@ discard block |
||
5856 | 6151 | |
5857 | 6152 | // Create dynamic tags for __EXTRAFIELD_FIELD__ |
5858 | 6153 | if ($object->table_element && $object->id > 0) { |
5859 | - if (!is_object($extrafields)) |
|
5860 | - $extrafields = new ExtraFields($db); |
|
6154 | + if (!is_object($extrafields)) { |
|
6155 | + $extrafields = new ExtraFields($db); |
|
6156 | + } |
|
5861 | 6157 | $extrafields->fetch_name_optionals_label($object->table_element, true); |
5862 | 6158 | |
5863 | 6159 | if ($object->fetch_optionals() > 0) { |
@@ -5878,12 +6174,15 @@ discard block |
||
5878 | 6174 | require_once DOL_BASE_PATH . '/core/lib/payments.lib.php'; |
5879 | 6175 | $outputlangs->loadLangs(array('paypal', 'other')); |
5880 | 6176 | $typeforonlinepayment = 'free'; |
5881 | - if (is_object($object) && $object->element == 'commande') |
|
5882 | - $typeforonlinepayment = 'order'; |
|
5883 | - if (is_object($object) && $object->element == 'facture') |
|
5884 | - $typeforonlinepayment = 'invoice'; |
|
5885 | - if (is_object($object) && $object->element == 'member') |
|
5886 | - $typeforonlinepayment = 'member'; |
|
6177 | + if (is_object($object) && $object->element == 'commande') { |
|
6178 | + $typeforonlinepayment = 'order'; |
|
6179 | + } |
|
6180 | + if (is_object($object) && $object->element == 'facture') { |
|
6181 | + $typeforonlinepayment = 'invoice'; |
|
6182 | + } |
|
6183 | + if (is_object($object) && $object->element == 'member') { |
|
6184 | + $typeforonlinepayment = 'member'; |
|
6185 | + } |
|
5887 | 6186 | $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $substitutionarray['__REF__']); |
5888 | 6187 | $paymenturl = $url; |
5889 | 6188 | } |
@@ -5893,16 +6192,19 @@ discard block |
||
5893 | 6192 | |
5894 | 6193 | if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') { |
5895 | 6194 | $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); |
5896 | - } else |
|
5897 | - $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
6195 | + } else { |
|
6196 | + $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = ''; |
|
6197 | + } |
|
5898 | 6198 | if (!empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande') { |
5899 | 6199 | $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element); |
5900 | - } else |
|
5901 | - $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
6200 | + } else { |
|
6201 | + $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = ''; |
|
6202 | + } |
|
5902 | 6203 | if (!empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture') { |
5903 | 6204 | $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element); |
5904 | - } else |
|
5905 | - $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
6205 | + } else { |
|
6206 | + $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = ''; |
|
6207 | + } |
|
5906 | 6208 | } |
5907 | 6209 | } |
5908 | 6210 | if (empty($exclude) || !in_array('objectamount', $exclude)) { |
@@ -5912,18 +6214,22 @@ discard block |
||
5912 | 6214 | $substitutionarray['__AMOUNT__'] = is_object($object) ? $object->total_ttc : ''; |
5913 | 6215 | $substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object) ? $object->total_ht : ''; |
5914 | 6216 | $substitutionarray['__AMOUNT_VAT__'] = is_object($object) ? ($object->total_vat ? $object->total_vat : $object->total_tva) : ''; |
5915 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
5916 | - $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
5917 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
5918 | - $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
6217 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
6218 | + $substitutionarray['__AMOUNT_TAX2__'] = is_object($object) ? $object->total_localtax1 : ''; |
|
6219 | + } |
|
6220 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
6221 | + $substitutionarray['__AMOUNT_TAX3__'] = is_object($object) ? $object->total_localtax2 : ''; |
|
6222 | + } |
|
5919 | 6223 | |
5920 | 6224 | $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object) ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
5921 | 6225 | $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object) ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
5922 | 6226 | $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object) ? ($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency) : price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency)) : ''; |
5923 | - if ($onlykey != 2 || $mysoc->useLocalTax(1)) |
|
5924 | - $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
5925 | - if ($onlykey != 2 || $mysoc->useLocalTax(2)) |
|
5926 | - $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
6227 | + if ($onlykey != 2 || $mysoc->useLocalTax(1)) { |
|
6228 | + $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object) ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
6229 | + } |
|
6230 | + if ($onlykey != 2 || $mysoc->useLocalTax(2)) { |
|
6231 | + $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object) ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : ''; |
|
6232 | + } |
|
5927 | 6233 | |
5928 | 6234 | // TODO Add keys for foreign multicurrency |
5929 | 6235 | // For backward compatibility |
@@ -5993,23 +6299,27 @@ discard block |
||
5993 | 6299 | { |
5994 | 6300 | global $conf, $langs; |
5995 | 6301 | |
5996 | - if (!is_array($substitutionarray)) |
|
5997 | - return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
6302 | + if (!is_array($substitutionarray)) { |
|
6303 | + return 'ErrorBadParameterSubstitutionArrayWhenCalling_make_substitutions'; |
|
6304 | + } |
|
5998 | 6305 | |
5999 | - if (empty($outputlangs)) |
|
6000 | - $outputlangs = $langs; |
|
6306 | + if (empty($outputlangs)) { |
|
6307 | + $outputlangs = $langs; |
|
6308 | + } |
|
6001 | 6309 | |
6002 | 6310 | // Make substitution for language keys |
6003 | 6311 | if (is_object($outputlangs)) { |
6004 | 6312 | while (preg_match('/__\(([^\)]+)\)__/', $text, $reg)) { |
6005 | 6313 | $msgishtml = 0; |
6006 | - if (dol_textishtml($text, 1)) |
|
6007 | - $msgishtml = 1; |
|
6314 | + if (dol_textishtml($text, 1)) { |
|
6315 | + $msgishtml = 1; |
|
6316 | + } |
|
6008 | 6317 | |
6009 | 6318 | // If key is __(TranslationKey|langfile)__, then force load of langfile.lang |
6010 | 6319 | $tmp = explode('|', $reg[1]); |
6011 | - if (!empty($tmp[1])) |
|
6012 | - $outputlangs->load($tmp[1]); |
|
6320 | + if (!empty($tmp[1])) { |
|
6321 | + $outputlangs->load($tmp[1]); |
|
6322 | + } |
|
6013 | 6323 | |
6014 | 6324 | $text = preg_replace('/__\(' . preg_quote($reg[1], '/') . '\)__/', $msgishtml ? dol_htmlentitiesbr($outputlangs->transnoentitiesnoconv($reg[1])) : $outputlangs->transnoentitiesnoconv($reg[1]), $text); |
6015 | 6325 | } |
@@ -6019,23 +6329,29 @@ discard block |
||
6019 | 6329 | // it is also converted. |
6020 | 6330 | while (preg_match('/__\[([^\]]+)\]__/', $text, $reg)) { |
6021 | 6331 | $msgishtml = 0; |
6022 | - if (dol_textishtml($text, 1)) |
|
6023 | - $msgishtml = 1; |
|
6332 | + if (dol_textishtml($text, 1)) { |
|
6333 | + $msgishtml = 1; |
|
6334 | + } |
|
6024 | 6335 | |
6025 | 6336 | $keyfound = $reg[1]; |
6026 | - if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) |
|
6027 | - $newval = '*****forbidden*****'; |
|
6028 | - else |
|
6029 | - $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound; |
|
6337 | + if (preg_match('/(_pass|password|secret|_key|key$)/i', $keyfound)) { |
|
6338 | + $newval = '*****forbidden*****'; |
|
6339 | + } else { |
|
6340 | + $newval = empty($conf->global->$keyfound) ? '' : $conf->global->$keyfound; |
|
6341 | + } |
|
6030 | 6342 | $text = preg_replace('/__\[' . preg_quote($keyfound, '/') . '\]__/', $msgishtml ? dol_htmlentitiesbr($newval) : $newval, $text); |
6031 | 6343 | } |
6032 | 6344 | |
6033 | 6345 | // Make substitition for array $substitutionarray |
6034 | 6346 | foreach ($substitutionarray as $key => $value) { |
6035 | - if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
6036 | - $value = ''; // Protection |
|
6037 | - if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) |
|
6038 | - $value = ''; // Protection |
|
6347 | + if ($key == '__SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
6348 | + $value = ''; |
|
6349 | + } |
|
6350 | + // Protection |
|
6351 | + if ($key == '__USER_SIGNATURE__' && (!empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) { |
|
6352 | + $value = ''; |
|
6353 | + } |
|
6354 | + // Protection |
|
6039 | 6355 | |
6040 | 6356 | $text = str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example |
6041 | 6357 | } |
@@ -6081,8 +6397,9 @@ discard block |
||
6081 | 6397 | $dir = dol_buildpath($reldir, 0); |
6082 | 6398 | |
6083 | 6399 | // Check if directory exists |
6084 | - if (!dol_is_dir($dir)) |
|
6085 | - continue; |
|
6400 | + if (!dol_is_dir($dir)) { |
|
6401 | + continue; |
|
6402 | + } |
|
6086 | 6403 | |
6087 | 6404 | $substitfiles = dol_dir_list($dir, 'files', 0, 'functions_'); |
6088 | 6405 | foreach ($substitfiles as $substitfile) { |
@@ -6094,8 +6411,9 @@ discard block |
||
6094 | 6411 | require_once $dir . $substitfile['name']; |
6095 | 6412 | // Call the user's function, and only if it is defined |
6096 | 6413 | $function_name = $module . "_" . $callfunc; |
6097 | - if (function_exists($function_name)) |
|
6098 | - $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
6414 | + if (function_exists($function_name)) { |
|
6415 | + $function_name($substitutionarray, $outputlangs, $object, $parameters); |
|
6416 | + } |
|
6099 | 6417 | } |
6100 | 6418 | } |
6101 | 6419 | } |
@@ -6131,8 +6449,9 @@ discard block |
||
6131 | 6449 | |
6132 | 6450 | $out = ''; |
6133 | 6451 | |
6134 | - if (!is_object($outputlangs)) |
|
6135 | - $outputlangs = $langs; |
|
6452 | + if (!is_object($outputlangs)) { |
|
6453 | + $outputlangs = $langs; |
|
6454 | + } |
|
6136 | 6455 | |
6137 | 6456 | if ($date_start && $date_end) { |
6138 | 6457 | $out .= ($withparenthesis ? ' (' : '') . $outputlangs->transnoentitiesnoconv('DateFromTo', dol_print_date($date_start, $format, false, $outputlangs), dol_print_date($date_end, $format, false, $outputlangs)) . ($withparenthesis ? ')' : ''); |
@@ -6161,20 +6480,22 @@ discard block |
||
6161 | 6480 | |
6162 | 6481 | $ret = ''; |
6163 | 6482 | // If order not defined, we use the setup |
6164 | - if ($nameorder < 0) |
|
6165 | - $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
6483 | + if ($nameorder < 0) { |
|
6484 | + $nameorder = (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION) ? 1 : 0); |
|
6485 | + } |
|
6166 | 6486 | if ($nameorder && ((string) $nameorder != '2')) { |
6167 | 6487 | $ret .= $firstname; |
6168 | - if ($firstname && $lastname) |
|
6169 | - $ret .= ' '; |
|
6488 | + if ($firstname && $lastname) { |
|
6489 | + $ret .= ' '; |
|
6490 | + } |
|
6170 | 6491 | $ret .= $lastname; |
6171 | - } |
|
6172 | - else if ($nameorder == 2) { |
|
6492 | + } else if ($nameorder == 2) { |
|
6173 | 6493 | $ret .= $firstname; |
6174 | 6494 | } else { |
6175 | 6495 | $ret .= $lastname; |
6176 | - if ($firstname && $lastname) |
|
6177 | - $ret .= ' '; |
|
6496 | + if ($firstname && $lastname) { |
|
6497 | + $ret .= ' '; |
|
6498 | + } |
|
6178 | 6499 | $ret .= $firstname; |
6179 | 6500 | } |
6180 | 6501 | return $ret; |
@@ -6194,13 +6515,14 @@ discard block |
||
6194 | 6515 | { |
6195 | 6516 | //dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); This is not deprecated, it is used by setEventMessages function |
6196 | 6517 | if (!is_array($mesgs)) { // If mesgs is a string |
6197 | - if ($mesgs) |
|
6198 | - $_SESSION['dol_events'][$style][] = $mesgs; |
|
6199 | - } |
|
6200 | - else { // If mesgs is an array |
|
6518 | + if ($mesgs) { |
|
6519 | + $_SESSION['dol_events'][$style][] = $mesgs; |
|
6520 | + } |
|
6521 | + } else { // If mesgs is an array |
|
6201 | 6522 | foreach ($mesgs as $mesg) { |
6202 | - if ($mesg) |
|
6203 | - $_SESSION['dol_events'][$style][] = $mesg; |
|
6523 | + if ($mesg) { |
|
6524 | + $_SESSION['dol_events'][$style][] = $mesg; |
|
6525 | + } |
|
6204 | 6526 | } |
6205 | 6527 | } |
6206 | 6528 | } |
@@ -6220,13 +6542,16 @@ discard block |
||
6220 | 6542 | if (empty($mesg) && empty($mesgs)) { |
6221 | 6543 | dol_syslog("Try to add a message in stack with empty message", LOG_WARNING); |
6222 | 6544 | } else { |
6223 | - if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) |
|
6224 | - dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages'); |
|
6225 | - if (empty($mesgs)) |
|
6226 | - setEventMessage($mesg, $style); |
|
6227 | - else { |
|
6228 | - if (!empty($mesg) && !in_array($mesg, $mesgs)) |
|
6229 | - setEventMessage($mesg, $style); // Add message string if not already into array |
|
6545 | + if (!in_array((string) $style, array('mesgs', 'warnings', 'errors'))) { |
|
6546 | + dol_print_error('', 'Bad parameter style=' . $style . ' for setEventMessages'); |
|
6547 | + } |
|
6548 | + if (empty($mesgs)) { |
|
6549 | + setEventMessage($mesg, $style); |
|
6550 | + } else { |
|
6551 | + if (!empty($mesg) && !in_array($mesg, $mesgs)) { |
|
6552 | + setEventMessage($mesg, $style); |
|
6553 | + } |
|
6554 | + // Add message string if not already into array |
|
6230 | 6555 | setEventMessage($mesgs, $style); |
6231 | 6556 | } |
6232 | 6557 | } |
@@ -6245,22 +6570,25 @@ discard block |
||
6245 | 6570 | { |
6246 | 6571 | // Show mesgs |
6247 | 6572 | if (isset($_SESSION['dol_events']['mesgs'])) { |
6248 | - if (empty($disabledoutputofmessages)) |
|
6249 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
6573 | + if (empty($disabledoutputofmessages)) { |
|
6574 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']); |
|
6575 | + } |
|
6250 | 6576 | unset($_SESSION['dol_events']['mesgs']); |
6251 | 6577 | } |
6252 | 6578 | |
6253 | 6579 | // Show errors |
6254 | 6580 | if (isset($_SESSION['dol_events']['errors'])) { |
6255 | - if (empty($disabledoutputofmessages)) |
|
6256 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
6581 | + if (empty($disabledoutputofmessages)) { |
|
6582 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error'); |
|
6583 | + } |
|
6257 | 6584 | unset($_SESSION['dol_events']['errors']); |
6258 | 6585 | } |
6259 | 6586 | |
6260 | 6587 | // Show warnings |
6261 | 6588 | if (isset($_SESSION['dol_events']['warnings'])) { |
6262 | - if (empty($disabledoutputofmessages)) |
|
6263 | - dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
6589 | + if (empty($disabledoutputofmessages)) { |
|
6590 | + dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning'); |
|
6591 | + } |
|
6264 | 6592 | unset($_SESSION['dol_events']['warnings']); |
6265 | 6593 | } |
6266 | 6594 | } |
@@ -6301,8 +6629,9 @@ discard block |
||
6301 | 6629 | foreach ($mesgarray as $message) { |
6302 | 6630 | $ret++; |
6303 | 6631 | $out .= $langs->trans($message); |
6304 | - if ($ret < count($mesgarray)) |
|
6305 | - $out .= "<br>\n"; |
|
6632 | + if ($ret < count($mesgarray)) { |
|
6633 | + $out .= "<br>\n"; |
|
6634 | + } |
|
6306 | 6635 | } |
6307 | 6636 | } |
6308 | 6637 | if ($mesgstring) { |
@@ -6368,8 +6697,9 @@ discard block |
||
6368 | 6697 | */ |
6369 | 6698 | function dol_htmloutput_mesg($mesgstring = '', $mesgarray = array(), $style = 'ok', $keepembedded = 0) |
6370 | 6699 | { |
6371 | - if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) |
|
6372 | - return; |
|
6700 | + if (empty($mesgstring) && (!is_array($mesgarray) || count($mesgarray) == 0)) { |
|
6701 | + return; |
|
6702 | + } |
|
6373 | 6703 | |
6374 | 6704 | $iserror = 0; |
6375 | 6705 | $iswarning = 0; |
@@ -6384,14 +6714,17 @@ discard block |
||
6384 | 6714 | break; |
6385 | 6715 | } |
6386 | 6716 | } |
6387 | - } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) |
|
6388 | - $iserror++; |
|
6389 | - else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) |
|
6390 | - $iswarning++; |
|
6391 | - if ($style == 'error') |
|
6392 | - $iserror++; |
|
6393 | - if ($style == 'warning') |
|
6394 | - $iswarning++; |
|
6717 | + } else if ($mesgstring && preg_match('/class="error"/i', $mesgstring)) { |
|
6718 | + $iserror++; |
|
6719 | + } else if ($mesgstring && preg_match('/class="warning"/i', $mesgstring)) { |
|
6720 | + $iswarning++; |
|
6721 | + } |
|
6722 | + if ($style == 'error') { |
|
6723 | + $iserror++; |
|
6724 | + } |
|
6725 | + if ($style == 'warning') { |
|
6726 | + $iswarning++; |
|
6727 | + } |
|
6395 | 6728 | |
6396 | 6729 | if ($iserror || $iswarning) { |
6397 | 6730 | // Remove div from texts |
@@ -6410,9 +6743,10 @@ discard block |
||
6410 | 6743 | $mesgarray = $newmesgarray; |
6411 | 6744 | } |
6412 | 6745 | print get_htmloutput_mesg($mesgstring, $mesgarray, ($iserror ? 'error' : 'warning'), $keepembedded); |
6413 | - } else |
|
6414 | - print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
6415 | -} |
|
6746 | + } else { |
|
6747 | + print get_htmloutput_mesg($mesgstring, $mesgarray, 'ok', $keepembedded); |
|
6748 | + } |
|
6749 | + } |
|
6416 | 6750 | |
6417 | 6751 | /** |
6418 | 6752 | * Print formated error messages to output (Used to show messages on html output). |
@@ -6452,15 +6786,17 @@ discard block |
||
6452 | 6786 | $sizearray = count($array); |
6453 | 6787 | if ($sizearray > 0) { |
6454 | 6788 | $temp = array(); |
6455 | - foreach (array_keys($array) as $key) |
|
6456 | - $temp[$key] = $array[$key][$index]; |
|
6789 | + foreach (array_keys($array) as $key) { |
|
6790 | + $temp[$key] = $array[$key][$index]; |
|
6791 | + } |
|
6457 | 6792 | |
6458 | - if (!$natsort) |
|
6459 | - ($order == 'asc') ? asort($temp) : arsort($temp); |
|
6460 | - else { |
|
6793 | + if (!$natsort) { |
|
6794 | + ($order == 'asc') ? asort($temp) : arsort($temp); |
|
6795 | + } else { |
|
6461 | 6796 | ($case_sensitive) ? natsort($temp) : natcasesort($temp); |
6462 | - if ($order != 'asc') |
|
6463 | - $temp = array_reverse($temp, true); |
|
6797 | + if ($order != 'asc') { |
|
6798 | + $temp = array_reverse($temp, true); |
|
6799 | + } |
|
6464 | 6800 | } |
6465 | 6801 | |
6466 | 6802 | $sorted = array(); |
@@ -6486,23 +6822,38 @@ discard block |
||
6486 | 6822 | // We must use here a binary strlen function (so not dol_strlen) |
6487 | 6823 | $strLength = dol_strlen($str); |
6488 | 6824 | for ($i = 0; $i < $strLength; $i++) { |
6489 | - if (ord($str[$i]) < 0x80) |
|
6490 | - continue; // 0bbbbbbb |
|
6491 | - elseif ((ord($str[$i]) & 0xE0) == 0xC0) |
|
6492 | - $n = 1; // 110bbbbb |
|
6493 | - elseif ((ord($str[$i]) & 0xF0) == 0xE0) |
|
6494 | - $n = 2; // 1110bbbb |
|
6495 | - elseif ((ord($str[$i]) & 0xF8) == 0xF0) |
|
6496 | - $n = 3; // 11110bbb |
|
6497 | - elseif ((ord($str[$i]) & 0xFC) == 0xF8) |
|
6498 | - $n = 4; // 111110bb |
|
6499 | - elseif ((ord($str[$i]) & 0xFE) == 0xFC) |
|
6500 | - $n = 5; // 1111110b |
|
6501 | - else |
|
6502 | - return false; // Does not match any model |
|
6825 | + if (ord($str[$i]) < 0x80) { |
|
6826 | + continue; |
|
6827 | + } |
|
6828 | + // 0bbbbbbb |
|
6829 | + elseif ((ord($str[$i]) & 0xE0) == 0xC0) { |
|
6830 | + $n = 1; |
|
6831 | + } |
|
6832 | + // 110bbbbb |
|
6833 | + elseif ((ord($str[$i]) & 0xF0) == 0xE0) { |
|
6834 | + $n = 2; |
|
6835 | + } |
|
6836 | + // 1110bbbb |
|
6837 | + elseif ((ord($str[$i]) & 0xF8) == 0xF0) { |
|
6838 | + $n = 3; |
|
6839 | + } |
|
6840 | + // 11110bbb |
|
6841 | + elseif ((ord($str[$i]) & 0xFC) == 0xF8) { |
|
6842 | + $n = 4; |
|
6843 | + } |
|
6844 | + // 111110bb |
|
6845 | + elseif ((ord($str[$i]) & 0xFE) == 0xFC) { |
|
6846 | + $n = 5; |
|
6847 | + } |
|
6848 | + // 1111110b |
|
6849 | + else { |
|
6850 | + return false; |
|
6851 | + } |
|
6852 | + // Does not match any model |
|
6503 | 6853 | for ($j = 0; $j < $n; $j++) { // n bytes matching 10bbbbbb follow ? |
6504 | - if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) |
|
6505 | - return false; |
|
6854 | + if (( ++$i == strlen($str)) || ((ord($str[$i]) & 0xC0) != 0x80)) { |
|
6855 | + return false; |
|
6856 | + } |
|
6506 | 6857 | } |
6507 | 6858 | } |
6508 | 6859 | return true; |
@@ -6520,15 +6871,21 @@ discard block |
||
6520 | 6871 | global $conf; |
6521 | 6872 | |
6522 | 6873 | $tmp = ini_get("unicode.filesystem_encoding"); // Disponible avec PHP 6.0 |
6523 | - if (empty($tmp) && !empty($_SERVER["WINDIR"])) |
|
6524 | - $tmp = 'iso-8859-1'; // By default for windows |
|
6525 | - if (empty($tmp)) |
|
6526 | - $tmp = 'utf-8'; // By default for other |
|
6527 | - if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) |
|
6528 | - $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; |
|
6529 | - |
|
6530 | - if ($tmp == 'iso-8859-1') |
|
6531 | - return utf8_decode($str); |
|
6874 | + if (empty($tmp) && !empty($_SERVER["WINDIR"])) { |
|
6875 | + $tmp = 'iso-8859-1'; |
|
6876 | + } |
|
6877 | + // By default for windows |
|
6878 | + if (empty($tmp)) { |
|
6879 | + $tmp = 'utf-8'; |
|
6880 | + } |
|
6881 | + // By default for other |
|
6882 | + if (!empty($conf->global->MAIN_FILESYSTEM_ENCODING)) { |
|
6883 | + $tmp = $conf->global->MAIN_FILESYSTEM_ENCODING; |
|
6884 | + } |
|
6885 | + |
|
6886 | + if ($tmp == 'iso-8859-1') { |
|
6887 | + return utf8_decode($str); |
|
6888 | + } |
|
6532 | 6889 | return $str; |
6533 | 6890 | } |
6534 | 6891 | |
@@ -6550,8 +6907,9 @@ discard block |
||
6550 | 6907 | global $cache_codes; |
6551 | 6908 | |
6552 | 6909 | // If key empty |
6553 | - if ($key == '') |
|
6554 | - return ''; |
|
6910 | + if ($key == '') { |
|
6911 | + return ''; |
|
6912 | + } |
|
6555 | 6913 | |
6556 | 6914 | // Check in cache |
6557 | 6915 | if (isset($cache_codes[$tablename][$key][$fieldid])) { // Can be defined to 0 or '' |
@@ -6563,20 +6921,21 @@ discard block |
||
6563 | 6921 | $sql = "SELECT " . $fieldid . " as valuetoget"; |
6564 | 6922 | $sql .= " FROM " . MAIN_DB_PREFIX . $tablename; |
6565 | 6923 | $sql .= " WHERE " . $fieldkey . " = '" . $db->escape($key) . "'"; |
6566 | - if (!empty($entityfilter)) |
|
6567 | - $sql .= " AND entity IN (" . getEntity($tablename) . ")"; |
|
6924 | + if (!empty($entityfilter)) { |
|
6925 | + $sql .= " AND entity IN (" . getEntity($tablename) . ")"; |
|
6926 | + } |
|
6568 | 6927 | |
6569 | 6928 | $resql = $db->query($sql); |
6570 | 6929 | if ($resql) { |
6571 | 6930 | $obj = $db->fetch_object($resql); |
6572 | - if ($obj) |
|
6573 | - $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
6574 | - else |
|
6575 | - $cache_codes[$tablename][$key][$fieldid] = ''; |
|
6931 | + if ($obj) { |
|
6932 | + $cache_codes[$tablename][$key][$fieldid] = $obj->valuetoget; |
|
6933 | + } else { |
|
6934 | + $cache_codes[$tablename][$key][$fieldid] = ''; |
|
6935 | + } |
|
6576 | 6936 | $db->free($resql); |
6577 | 6937 | return $cache_codes[$tablename][$key][$fieldid]; |
6578 | - } |
|
6579 | - else { |
|
6938 | + } else { |
|
6580 | 6939 | return -1; |
6581 | 6940 | } |
6582 | 6941 | } |
@@ -6623,16 +6982,17 @@ discard block |
||
6623 | 6982 | global $soc; // For backward compatibility |
6624 | 6983 | //print $s."<br>\n"; |
6625 | 6984 | if ($returnvalue) { |
6626 | - if ($hideerrors) |
|
6627 | - return @eval('return ' . $s . ';'); |
|
6628 | - else |
|
6629 | - return eval('return ' . $s . ';'); |
|
6630 | - } |
|
6631 | - else { |
|
6632 | - if ($hideerrors) |
|
6633 | - @eval($s); |
|
6634 | - else |
|
6635 | - eval($s); |
|
6985 | + if ($hideerrors) { |
|
6986 | + return @eval('return ' . $s . ';'); |
|
6987 | + } else { |
|
6988 | + return eval('return ' . $s . ';'); |
|
6989 | + } |
|
6990 | + } else { |
|
6991 | + if ($hideerrors) { |
|
6992 | + @eval($s); |
|
6993 | + } else { |
|
6994 | + eval($s); |
|
6995 | + } |
|
6636 | 6996 | } |
6637 | 6997 | } |
6638 | 6998 | |
@@ -6658,8 +7018,9 @@ discard block |
||
6658 | 7018 | { |
6659 | 7019 | global $langs; |
6660 | 7020 | |
6661 | - if (empty($codelang)) |
|
6662 | - return ''; |
|
7021 | + if (empty($codelang)) { |
|
7022 | + return ''; |
|
7023 | + } |
|
6663 | 7024 | |
6664 | 7025 | if ($codelang == 'auto') { |
6665 | 7026 | return '<span class="fa fa-globe"></span>'; |
@@ -6673,9 +7034,9 @@ discard block |
||
6673 | 7034 | 'sv_SV' => 'se' |
6674 | 7035 | ); |
6675 | 7036 | |
6676 | - if (isset($langtocountryflag[$codelang])) |
|
6677 | - $flagImage = $langtocountryflag[$codelang]; |
|
6678 | - else { |
|
7037 | + if (isset($langtocountryflag[$codelang])) { |
|
7038 | + $flagImage = $langtocountryflag[$codelang]; |
|
7039 | + } else { |
|
6679 | 7040 | $tmparray = explode('_', $codelang); |
6680 | 7041 | $flagImage = empty($tmparray[1]) ? $tmparray[0] : $tmparray[1]; |
6681 | 7042 | } |
@@ -6693,15 +7054,20 @@ discard block |
||
6693 | 7054 | { |
6694 | 7055 | global $mysoc; |
6695 | 7056 | |
6696 | - if (strtoupper($countrycode) == 'MQ') |
|
6697 | - return 'fr_CA'; |
|
6698 | - if (strtoupper($countrycode) == 'SE') |
|
6699 | - return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
7057 | + if (strtoupper($countrycode) == 'MQ') { |
|
7058 | + return 'fr_CA'; |
|
7059 | + } |
|
7060 | + if (strtoupper($countrycode) == 'SE') { |
|
7061 | + return 'sv_SE'; |
|
7062 | + } |
|
7063 | + // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country |
|
6700 | 7064 | if (strtoupper($countrycode) == 'CH') { |
6701 | - if ($mysoc->country_code == 'FR') |
|
6702 | - return 'fr_CH'; |
|
6703 | - if ($mysoc->country_code == 'DE') |
|
6704 | - return 'de_CH'; |
|
7065 | + if ($mysoc->country_code == 'FR') { |
|
7066 | + return 'fr_CH'; |
|
7067 | + } |
|
7068 | + if ($mysoc->country_code == 'DE') { |
|
7069 | + return 'de_CH'; |
|
7070 | + } |
|
6705 | 7071 | } |
6706 | 7072 | |
6707 | 7073 | // Locale list taken from: |
@@ -6879,8 +7245,9 @@ discard block |
||
6879 | 7245 | ); |
6880 | 7246 | |
6881 | 7247 | $buildprimarykeytotest = strtolower($countrycode) . '-' . strtoupper($countrycode); |
6882 | - if (in_array($buildprimarykeytotest, $locales)) |
|
6883 | - return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
7248 | + if (in_array($buildprimarykeytotest, $locales)) { |
|
7249 | + return strtolower($countrycode) . '_' . strtoupper($countrycode); |
|
7250 | + } |
|
6884 | 7251 | |
6885 | 7252 | foreach ($locales as $locale) { |
6886 | 7253 | $locale_language = locale_get_primary_language($locale); |
@@ -6934,18 +7301,21 @@ discard block |
||
6934 | 7301 | |
6935 | 7302 | if ($mode == 'add' && !preg_match('/^\-/', $values[1])) { |
6936 | 7303 | if (count($values) == 6) { // new declaration with permissions: $value='objecttype:+tabname1:Title1:langfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__' |
6937 | - if ($values[0] != $type) |
|
6938 | - continue; |
|
7304 | + if ($values[0] != $type) { |
|
7305 | + continue; |
|
7306 | + } |
|
6939 | 7307 | |
6940 | 7308 | if (verifCond($values[4])) { |
6941 | - if ($values[3]) |
|
6942 | - $langs->load($values[3]); |
|
7309 | + if ($values[3]) { |
|
7310 | + $langs->load($values[3]); |
|
7311 | + } |
|
6943 | 7312 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) { |
6944 | 7313 | $substitutionarray = array(); |
6945 | 7314 | complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2])); |
6946 | 7315 | $label = make_substitutions($reg[1], $substitutionarray); |
6947 | - } else |
|
6948 | - $label = $langs->trans($values[2]); |
|
7316 | + } else { |
|
7317 | + $label = $langs->trans($values[2]); |
|
7318 | + } |
|
6949 | 7319 | |
6950 | 7320 | //$head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]), 1); |
6951 | 7321 | $head[$h][0] = BASE_URI . preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[5]); |
@@ -6953,30 +7323,32 @@ discard block |
||
6953 | 7323 | $head[$h][2] = str_replace('+', '', $values[1]); |
6954 | 7324 | $h++; |
6955 | 7325 | } |
6956 | - } |
|
6957 | - else if (count($values) == 5) { // deprecated |
|
7326 | + } else if (count($values) == 5) { // deprecated |
|
6958 | 7327 | dol_syslog('Passing 5 values in tabs module_parts is deprecated. Please update to 6 with permissions.', LOG_WARNING); |
6959 | 7328 | |
6960 | - if ($values[0] != $type) |
|
6961 | - continue; |
|
6962 | - if ($values[3]) |
|
6963 | - $langs->load($values[3]); |
|
7329 | + if ($values[0] != $type) { |
|
7330 | + continue; |
|
7331 | + } |
|
7332 | + if ($values[3]) { |
|
7333 | + $langs->load($values[3]); |
|
7334 | + } |
|
6964 | 7335 | if (preg_match('/SUBSTITUTION_([^_]+)/i', $values[2], $reg)) { |
6965 | 7336 | $substitutionarray = array(); |
6966 | 7337 | complete_substitutions_array($substitutionarray, $langs, $object, array('needforkey' => $values[2])); |
6967 | 7338 | $label = make_substitutions($reg[1], $substitutionarray); |
6968 | - } else |
|
6969 | - $label = $langs->trans($values[2]); |
|
7339 | + } else { |
|
7340 | + $label = $langs->trans($values[2]); |
|
7341 | + } |
|
6970 | 7342 | |
6971 | 7343 | $head[$h][0] = dol_buildpath(preg_replace('/__ID__/i', ((is_object($object) && !empty($object->id)) ? $object->id : ''), $values[4]), 1); |
6972 | 7344 | $head[$h][1] = $label; |
6973 | 7345 | $head[$h][2] = str_replace('+', '', $values[1]); |
6974 | 7346 | $h++; |
6975 | 7347 | } |
6976 | - } |
|
6977 | - else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) { |
|
6978 | - if ($values[0] != $type) |
|
6979 | - continue; |
|
7348 | + } else if ($mode == 'remove' && preg_match('/^\-/', $values[1])) { |
|
7349 | + if ($values[0] != $type) { |
|
7350 | + continue; |
|
7351 | + } |
|
6980 | 7352 | $tabname = str_replace('-', '', $values[1]); |
6981 | 7353 | foreach ($head as $key => $val) { |
6982 | 7354 | $condition = (!empty($values[3]) ? verifCond($values[3]) : 1); |
@@ -7018,10 +7390,11 @@ discard block |
||
7018 | 7390 | global $action; |
7019 | 7391 | global $micro_start_time; |
7020 | 7392 | |
7021 | - if ($zone == 'private') |
|
7022 | - print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
7023 | - else |
|
7024 | - print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
7393 | + if ($zone == 'private') { |
|
7394 | + print "\n" . '<!-- Common footer for private page -->' . "\n"; |
|
7395 | + } else { |
|
7396 | + print "\n" . '<!-- Common footer for public page -->' . "\n"; |
|
7397 | + } |
|
7025 | 7398 | |
7026 | 7399 | // A div to store page_y POST parameter so we can read it using javascript |
7027 | 7400 | print "\n<!-- A div to store page_y POST paramater -->\n"; |
@@ -7030,8 +7403,9 @@ discard block |
||
7030 | 7403 | $parameters = array(); |
7031 | 7404 | $reshook = $hookmanager->executeHooks('printCommonFooter', $parameters); // Note that $action and $object may have been modified by some hooks |
7032 | 7405 | if (empty($reshook)) { |
7033 | - if (!empty($conf->global->MAIN_HTML_FOOTER)) |
|
7034 | - print $conf->global->MAIN_HTML_FOOTER . "\n"; |
|
7406 | + if (!empty($conf->global->MAIN_HTML_FOOTER)) { |
|
7407 | + print $conf->global->MAIN_HTML_FOOTER . "\n"; |
|
7408 | + } |
|
7035 | 7409 | |
7036 | 7410 | print "\n"; |
7037 | 7411 | if (!empty($conf->use_javascript_ajax)) { |
@@ -7054,8 +7428,9 @@ discard block |
||
7054 | 7428 | print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */' . "\n"; |
7055 | 7429 | $relativepathstring = $_SERVER["PHP_SELF"]; |
7056 | 7430 | // Clean $relativepathstring |
7057 | - if (constant('DOL_URL_ROOT')) |
|
7058 | - $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
7431 | + if (constant('DOL_URL_ROOT')) { |
|
7432 | + $relativepathstring = preg_replace('/^' . preg_quote(constant('DOL_URL_ROOT'), '/') . '/', '', $relativepathstring); |
|
7433 | + } |
|
7059 | 7434 | $relativepathstring = preg_replace('/^\//', '', $relativepathstring); |
7060 | 7435 | $relativepathstring = preg_replace('/^custom\//', '', $relativepathstring); |
7061 | 7436 | $tmpqueryarraywehave = explode('&', dol_string_nohtmltag($_SERVER['QUERY_STRING'])); |
@@ -7066,14 +7441,17 @@ discard block |
||
7066 | 7441 | $tmpqueryarraytohave = explode('&', $defkey); |
7067 | 7442 | $foundintru = 0; |
7068 | 7443 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
7069 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
7070 | - $foundintru = 1; |
|
7444 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
7445 | + $foundintru = 1; |
|
7446 | + } |
|
7071 | 7447 | } |
7072 | - if (!$foundintru) |
|
7073 | - $qualified = 1; |
|
7448 | + if (!$foundintru) { |
|
7449 | + $qualified = 1; |
|
7450 | + } |
|
7074 | 7451 | //var_dump($defkey.'-'.$qualified); |
7075 | - } else |
|
7076 | - $qualified = 1; |
|
7452 | + } else { |
|
7453 | + $qualified = 1; |
|
7454 | + } |
|
7077 | 7455 | |
7078 | 7456 | if ($qualified) { |
7079 | 7457 | foreach ($defval as $paramkey => $paramval) { |
@@ -7092,14 +7470,17 @@ discard block |
||
7092 | 7470 | $tmpqueryarraytohave = explode('&', $defkey); |
7093 | 7471 | $foundintru = 0; |
7094 | 7472 | foreach ($tmpqueryarraytohave as $tmpquerytohave) { |
7095 | - if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) |
|
7096 | - $foundintru = 1; |
|
7473 | + if (!in_array($tmpquerytohave, $tmpqueryarraywehave)) { |
|
7474 | + $foundintru = 1; |
|
7475 | + } |
|
7097 | 7476 | } |
7098 | - if (!$foundintru) |
|
7099 | - $qualified = 1; |
|
7477 | + if (!$foundintru) { |
|
7478 | + $qualified = 1; |
|
7479 | + } |
|
7100 | 7480 | //var_dump($defkey.'-'.$qualified); |
7101 | - } else |
|
7102 | - $qualified = 1; |
|
7481 | + } else { |
|
7482 | + $qualified = 1; |
|
7483 | + } |
|
7103 | 7484 | |
7104 | 7485 | if ($qualified) { |
7105 | 7486 | foreach ($defval as $paramkey => $paramval) { |
@@ -7138,8 +7519,9 @@ discard block |
||
7138 | 7519 | print "\n"; |
7139 | 7520 | print "/* JS CODE TO ENABLE to add memory info */\n"; |
7140 | 7521 | print 'window.console && console.log("'; |
7141 | - if (!empty($conf->global->MEMCACHED_SERVER)) |
|
7142 | - print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - '; |
|
7522 | + if (!empty($conf->global->MEMCACHED_SERVER)) { |
|
7523 | + print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - '; |
|
7524 | + } |
|
7143 | 7525 | print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off'); |
7144 | 7526 | if (!empty($micro_start_time)) { // Works only if MAIN_SHOW_TUNING_INFO is defined at $_SERVER level. Not in global variable. |
7145 | 7527 | $micro_end_time = microtime(true); |
@@ -7269,8 +7651,9 @@ discard block |
||
7269 | 7651 | |
7270 | 7652 | $crits = explode(' ', $value); |
7271 | 7653 | $res = ''; |
7272 | - if (!is_array($fields)) |
|
7273 | - $fields = array($fields); |
|
7654 | + if (!is_array($fields)) { |
|
7655 | + $fields = array($fields); |
|
7656 | + } |
|
7274 | 7657 | |
7275 | 7658 | $nboffields = count($fields); |
7276 | 7659 | $end2 = count($crits); |
@@ -7333,8 +7716,9 @@ discard block |
||
7333 | 7716 | $tmpcrits = explode('|', $crit); |
7334 | 7717 | $i3 = 0; |
7335 | 7718 | foreach ($tmpcrits as $tmpcrit) { |
7336 | - if (empty($tmpcrit)) |
|
7337 | - continue; |
|
7719 | + if (empty($tmpcrit)) { |
|
7720 | + continue; |
|
7721 | + } |
|
7338 | 7722 | |
7339 | 7723 | $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); |
7340 | 7724 | |
@@ -7370,8 +7754,9 @@ discard block |
||
7370 | 7754 | } |
7371 | 7755 | $i++; |
7372 | 7756 | } |
7373 | - if ($newres) |
|
7374 | - $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : ''); |
|
7757 | + if ($newres) { |
|
7758 | + $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') . $newres . ($i2 > 1 ? ')' : ''); |
|
7759 | + } |
|
7375 | 7760 | $j++; |
7376 | 7761 | } |
7377 | 7762 | $res = ($nofirstand ? "" : " AND ") . "(" . $res . ")"; |
@@ -7411,29 +7796,37 @@ discard block |
||
7411 | 7796 | function getImageFileNameForSize($file, $extName, $extImgTarget = '') |
7412 | 7797 | { |
7413 | 7798 | $dirName = dirname($file); |
7414 | - if ($dirName == '.') |
|
7415 | - $dirName = ''; |
|
7799 | + if ($dirName == '.') { |
|
7800 | + $dirName = ''; |
|
7801 | + } |
|
7416 | 7802 | |
7417 | 7803 | $fileName = preg_replace('/(\.gif|\.jpeg|\.jpg|\.png|\.bmp)$/i', '', $file); // We remove extension, whatever is its case |
7418 | 7804 | $fileName = basename($fileName); |
7419 | 7805 | |
7420 | - if (empty($extImgTarget)) |
|
7421 | - $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : ''); |
|
7422 | - if (empty($extImgTarget)) |
|
7423 | - $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : ''); |
|
7424 | - if (empty($extImgTarget)) |
|
7425 | - $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : ''); |
|
7426 | - if (empty($extImgTarget)) |
|
7427 | - $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : ''); |
|
7428 | - if (empty($extImgTarget)) |
|
7429 | - $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : ''); |
|
7430 | - |
|
7431 | - if (!$extImgTarget) |
|
7432 | - return $file; |
|
7806 | + if (empty($extImgTarget)) { |
|
7807 | + $extImgTarget = (preg_match('/\.jpg$/i', $file) ? '.jpg' : ''); |
|
7808 | + } |
|
7809 | + if (empty($extImgTarget)) { |
|
7810 | + $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : ''); |
|
7811 | + } |
|
7812 | + if (empty($extImgTarget)) { |
|
7813 | + $extImgTarget = (preg_match('/\.gif$/i', $file) ? '.gif' : ''); |
|
7814 | + } |
|
7815 | + if (empty($extImgTarget)) { |
|
7816 | + $extImgTarget = (preg_match('/\.png$/i', $file) ? '.png' : ''); |
|
7817 | + } |
|
7818 | + if (empty($extImgTarget)) { |
|
7819 | + $extImgTarget = (preg_match('/\.bmp$/i', $file) ? '.bmp' : ''); |
|
7820 | + } |
|
7821 | + |
|
7822 | + if (!$extImgTarget) { |
|
7823 | + return $file; |
|
7824 | + } |
|
7433 | 7825 | |
7434 | 7826 | $subdir = ''; |
7435 | - if ($extName) |
|
7436 | - $subdir = 'thumbs/'; |
|
7827 | + if ($extName) { |
|
7828 | + $subdir = 'thumbs/'; |
|
7829 | + } |
|
7437 | 7830 | |
7438 | 7831 | return ($dirName ? $dirName . '/' : '') . $subdir . $fileName . $extName . $extImgTarget; // New filename for thumb |
7439 | 7832 | } |
@@ -7451,8 +7844,9 @@ discard block |
||
7451 | 7844 | { |
7452 | 7845 | global $conf, $langs; |
7453 | 7846 | |
7454 | - if (empty($conf->use_javascript_ajax)) |
|
7455 | - return ''; |
|
7847 | + if (empty($conf->use_javascript_ajax)) { |
|
7848 | + return ''; |
|
7849 | + } |
|
7456 | 7850 | |
7457 | 7851 | $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml'); |
7458 | 7852 | //$mime_preview[]='vnd.oasis.opendocument.presentation'; |
@@ -7460,18 +7854,20 @@ discard block |
||
7460 | 7854 | $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview); |
7461 | 7855 | |
7462 | 7856 | if ($alldata == 1) { |
7463 | - if ($num_mime !== false) |
|
7464 | - return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),); |
|
7465 | - else |
|
7466 | - return array(); |
|
7857 | + if ($num_mime !== false) { |
|
7858 | + return array('target' => '_blank', 'css' => 'documentpreview', 'url' => DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : ''), 'mime' => dol_mimetype($relativepath),); |
|
7859 | + } else { |
|
7860 | + return array(); |
|
7861 | + } |
|
7467 | 7862 | } |
7468 | 7863 | |
7469 | 7864 | // old behavior |
7470 | - if ($num_mime !== false) |
|
7471 | - return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')'; |
|
7472 | - else |
|
7473 | - return ''; |
|
7474 | -} |
|
7865 | + if ($num_mime !== false) { |
|
7866 | + return 'javascript:document_preview(\'' . dol_escape_js(DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&attachment=0&file=' . urlencode($relativepath) . ($param ? '&' . $param : '')) . '\', \'' . dol_mimetype($relativepath) . '\', \'' . dol_escape_js($langs->trans('Preview')) . '\')'; |
|
7867 | + } else { |
|
7868 | + return ''; |
|
7869 | + } |
|
7870 | + } |
|
7475 | 7871 | |
7476 | 7872 | /** |
7477 | 7873 | * Make content of an input box selected when we click into input field. |
@@ -7488,8 +7884,9 @@ discard block |
||
7488 | 7884 | jQuery("#' . $htmlname . '").click(function() { jQuery(this).select(); } ); |
7489 | 7885 | }); |
7490 | 7886 | </script>'; |
7491 | - if ($addlink) |
|
7492 | - $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>'; |
|
7887 | + if ($addlink) { |
|
7888 | + $out .= ' <a href="' . $addlink . '" target="_blank">' . $langs->trans("Link") . '</a>'; |
|
7889 | + } |
|
7493 | 7890 | return $out; |
7494 | 7891 | } |
7495 | 7892 | |
@@ -7871,8 +8268,9 @@ discard block |
||
7871 | 8268 | if (!isset($dictvalues[$tablename])) { |
7872 | 8269 | $dictvalues[$tablename] = array(); |
7873 | 8270 | $sql = 'SELECT * FROM ' . $tablename . ' WHERE 1'; |
7874 | - if ($checkentity) |
|
7875 | - $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
8271 | + if ($checkentity) { |
|
8272 | + $sql .= ' AND entity IN (0,' . getEntity($tablename) . ')'; |
|
8273 | + } |
|
7876 | 8274 | |
7877 | 8275 | $resql = $db->query($sql); |
7878 | 8276 | if ($resql) { |
@@ -7884,11 +8282,14 @@ discard block |
||
7884 | 8282 | } |
7885 | 8283 | } |
7886 | 8284 | |
7887 | - if (!empty($dictvalues[$tablename][$id])) |
|
7888 | - return $dictvalues[$tablename][$id]->{$field}; // Found |
|
8285 | + if (!empty($dictvalues[$tablename][$id])) { |
|
8286 | + return $dictvalues[$tablename][$id]->{$field}; |
|
8287 | + } |
|
8288 | + // Found |
|
7889 | 8289 | else { // Not found |
7890 | - if ($id > 0) |
|
7891 | - return $id; |
|
8290 | + if ($id > 0) { |
|
8291 | + return $id; |
|
8292 | + } |
|
7892 | 8293 | return ''; |
7893 | 8294 | } |
7894 | 8295 | } |
@@ -7918,8 +8319,9 @@ discard block |
||
7918 | 8319 | $b = hexdec($hexb); |
7919 | 8320 | } |
7920 | 8321 | $bright = (max($r, $g, $b) + min($r, $g, $b)) / 510.0; // HSL algorithm |
7921 | - if ($bright > 0.6) |
|
7922 | - $res = 1; |
|
8322 | + if ($bright > 0.6) { |
|
8323 | + $res = 1; |
|
8324 | + } |
|
7923 | 8325 | } |
7924 | 8326 | return $res; |
7925 | 8327 | } |
@@ -7938,8 +8340,10 @@ discard block |
||
7938 | 8340 | |
7939 | 8341 | //print 'type_user='.$type_user.' module='.$menuentry['module'].' enabled='.$menuentry['enabled'].' perms='.$menuentry['perms']; |
7940 | 8342 | //print 'ok='.in_array($menuentry['module'], $listofmodulesforexternal); |
7941 | - if (empty($menuentry['enabled'])) |
|
7942 | - return 0; // Entry disabled by condition |
|
8343 | + if (empty($menuentry['enabled'])) { |
|
8344 | + return 0; |
|
8345 | + } |
|
8346 | + // Entry disabled by condition |
|
7943 | 8347 | if ($type_user && $menuentry['module']) { |
7944 | 8348 | $tmploops = explode('|', $menuentry['module']); |
7945 | 8349 | $found = 0; |
@@ -7949,15 +8353,23 @@ discard block |
||
7949 | 8353 | break; |
7950 | 8354 | } |
7951 | 8355 | } |
7952 | - if (!$found) |
|
7953 | - return 0; // Entry is for menus all excluded to external users |
|
7954 | - } |
|
7955 | - if (!$menuentry['perms'] && $type_user) |
|
7956 | - return 0; // No permissions and user is external |
|
7957 | - if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) |
|
7958 | - return 0; // No permissions and option to hide when not allowed, even for internal user, is on |
|
7959 | - if (!$menuentry['perms']) |
|
7960 | - return 2; // No permissions and user is external |
|
8356 | + if (!$found) { |
|
8357 | + return 0; |
|
8358 | + } |
|
8359 | + // Entry is for menus all excluded to external users |
|
8360 | + } |
|
8361 | + if (!$menuentry['perms'] && $type_user) { |
|
8362 | + return 0; |
|
8363 | + } |
|
8364 | + // No permissions and user is external |
|
8365 | + if (!$menuentry['perms'] && !empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED)) { |
|
8366 | + return 0; |
|
8367 | + } |
|
8368 | + // No permissions and option to hide when not allowed, even for internal user, is on |
|
8369 | + if (!$menuentry['perms']) { |
|
8370 | + return 2; |
|
8371 | + } |
|
8372 | + // No permissions and user is external |
|
7961 | 8373 | return 1; |
7962 | 8374 | } |
7963 | 8375 |