Test Setup Failed
Push — dev ( 608138...99eb65 )
by Rafael
61:41 queued 16s
created
Dolibarr/Lib/Filters.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
     private static function getEmojis()
67 67
     {
68 68
         $arrayofcommonemoji = array(
69
-            'misc' => array('2600', '26FF'),        // Miscellaneous Symbols
70
-            'ding' => array('2700', '27BF'),        // Dingbats
71
-            '????' => array('9989', '9989'),        // Variation Selectors
72
-            'vars' => array('FE00', 'FE0F'),        // Variation Selectors
73
-            'pict' => array('1F300', '1F5FF'),      // Miscellaneous Symbols and Pictographs
74
-            'emot' => array('1F600', '1F64F'),      // Emoticons
75
-            'tran' => array('1F680', '1F6FF'),      // Transport and Map Symbols
76
-            'flag' => array('1F1E0', '1F1FF'),      // Flags (note: may be 1F1E6 instead of 1F1E0)
77
-            'supp' => array('1F900', '1F9FF'),      // Supplemental Symbols and Pictographs
69
+            'misc' => array('2600', '26FF'), // Miscellaneous Symbols
70
+            'ding' => array('2700', '27BF'), // Dingbats
71
+            '????' => array('9989', '9989'), // Variation Selectors
72
+            'vars' => array('FE00', 'FE0F'), // Variation Selectors
73
+            'pict' => array('1F300', '1F5FF'), // Miscellaneous Symbols and Pictographs
74
+            'emot' => array('1F600', '1F64F'), // Emoticons
75
+            'tran' => array('1F680', '1F6FF'), // Transport and Map Symbols
76
+            'flag' => array('1F1E0', '1F1FF'), // Flags (note: may be 1F1E6 instead of 1F1E0)
77
+            'supp' => array('1F900', '1F9FF'), // Supplemental Symbols and Pictographs
78 78
         );
79 79
 
80 80
         return $arrayofcommonemoji;
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
                 $ip = (empty($_SERVER['REMOTE_ADDR']) ? 'unknown' : $_SERVER['REMOTE_ADDR']);
110 110
 
111 111
                 if ($stopcode) {
112
-                    $errormessage = 'Access refused to ' . htmlentities($ip, ENT_COMPAT, 'UTF-8') . ' by SQL or Script injection protection in main.inc.php:analyseVarsForSqlAndScriptsInjection type=' . htmlentities((string)$type, ENT_COMPAT, 'UTF-8');
112
+                    $errormessage = 'Access refused to ' . htmlentities($ip, ENT_COMPAT, 'UTF-8') . ' by SQL or Script injection protection in main.inc.php:analyseVarsForSqlAndScriptsInjection type=' . htmlentities((string) $type, ENT_COMPAT, 'UTF-8');
113 113
                     //$errormessage .= ' paramkey='.htmlentities($key, ENT_COMPAT, 'UTF-8');    // Disabled to avoid text injection
114 114
 
115 115
                     $errormessage2 = 'page=' . htmlentities((empty($_SERVER["REQUEST_URI"]) ? '' : $_SERVER["REQUEST_URI"]), ENT_COMPAT, 'UTF-8');
116
-                    $errormessage2 .= ' paramtype=' . htmlentities((string)$type, ENT_COMPAT, 'UTF-8');
116
+                    $errormessage2 .= ' paramtype=' . htmlentities((string) $type, ENT_COMPAT, 'UTF-8');
117 117
                     $errormessage2 .= ' paramkey=' . htmlentities($key, ENT_COMPAT, 'UTF-8');
118 118
                     $errormessage2 .= ' paramvalue=' . htmlentities($value, ENT_COMPAT, 'UTF-8');
119 119
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
         //print "before decoding $val\n";
169 169
         do {
170 170
             $oldval = $val;
171
-            $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5);    // Decode ':', ''', '	', '&NewLine', ...
171
+            $val = html_entity_decode($val, ENT_QUOTES | ENT_HTML5); // Decode ':', ''', '	', '&NewLine', ...
172 172
             // Sometimes we have entities without the ; at end so html_entity_decode does not work but entities is still interpreted by browser.
173 173
             $val = preg_replace_callback(
174 174
                 '/&#(x?[0-9][0-9a-f]+;?)/i',
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
                  * @param string[] $m
177 177
                  * @return string
178 178
                  */
179
-                static function ($m) {
179
+                static function($m) {
180 180
                     // Decode 'n', ...
181 181
                     return Filters::realCharForNumericEntities($m);
182 182
                 },
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             $inj += preg_match('/user\s*\(/i', $val); // avoid to use function user() or mysql_user() that return current database login
218 218
             $inj += preg_match('/information_schema/i', $val); // avoid to use request that read information_schema database
219 219
             $inj += preg_match('/<svg/i', $val); // <svg can be allowed in POST
220
-            $inj += preg_match('/update[^&=\w].*set.+=/i', $val);   // the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set...
220
+            $inj += preg_match('/update[^&=\w].*set.+=/i', $val); // the [^&=\w] test is to avoid error when request is like action=update&...set... or &updatemodule=...set...
221 221
             $inj += preg_match('/union.+select/i', $val);
222 222
         }
223 223
         if ($type == 3) {
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
         if (preg_match('/^x/i', $newstringnumentity)) {     // if numeric is hexadecimal
302 302
             $newstringnumentity = hexdec(preg_replace('/^x/i', '', $newstringnumentity));
303 303
         } else {
304
-            $newstringnumentity = (int)$newstringnumentity;
304
+            $newstringnumentity = (int) $newstringnumentity;
305 305
         }
306 306
 
307 307
         // The numeric values we don't want as entities because they encode ascii char, and why using html entities on ascii except for haking ?
308 308
         if (($newstringnumentity >= 65 && $newstringnumentity <= 90) || ($newstringnumentity >= 97 && $newstringnumentity <= 122)) {
309
-            return chr((int)$newstringnumentity);
309
+            return chr((int) $newstringnumentity);
310 310
         }
311 311
 
312 312
         // The numeric values we want in UTF8 instead of entities because it is emoji
Please login to merge, or discard this patch.
public/htdocs/main.inc.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 $micro_start_time = 0;
55 55
 if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {
56 56
     list($usec, $sec) = explode(" ", microtime());
57
-    $micro_start_time = ((float)$usec + (float)$sec);
57
+    $micro_start_time = ((float) $usec + (float) $sec);
58 58
     // Add Xdebug code coverage
59 59
     //define('XDEBUGCOVERAGE',1);
60 60
     if (defined('XDEBUGCOVERAGE')) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         session_set_cookie_params($sessioncookieparams);
178 178
     }
179 179
     session_name($sessionname);
180
-    dol_session_start();    // This call the open and read of session handler
180
+    dol_session_start(); // This call the open and read of session handler
181 181
     //exit; // this exist generates a call to write and close
182 182
 }
183 183
 
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
             // Note: Using MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL is not recommended: if a user succeed in entering a data from
359 359
             // a public page with a link that make a token regeneration, it can make use of the backoffice no more possible !
360 360
             // Save in $_SESSION['newtoken'] what will be next token. Into forms, we will add param token = $_SESSION['newtoken']
361
-            $token = dol_hash(uniqid((string)mt_rand(), false), 'md5'); // Generates a hash of a random number. We don't need a secured hash, just a changing random value.
361
+            $token = dol_hash(uniqid((string) mt_rand(), false), 'md5'); // Generates a hash of a random number. We don't need a secured hash, just a changing random value.
362 362
             $_SESSION['newtoken'] = $token;
363 363
             dol_syslog("NEW TOKEN generated by : " . $_SERVER['PHP_SELF'], LOG_DEBUG);
364 364
         }
@@ -441,16 +441,16 @@  discard block
 block discarded – undo
441 441
         }
442 442
         $savid = null;
443 443
         if (isset($_POST['id'])) {
444
-            $savid = ((int)$_POST['id']);
444
+            $savid = ((int) $_POST['id']);
445 445
         }
446 446
         unset($_POST);
447 447
         unset($_GET['confirm']);
448 448
         unset($_GET['action']);
449 449
         unset($_GET['confirmmassaction']);
450 450
         unset($_GET['massaction']);
451
-        unset($_GET['token']);          // TODO Make a redirect if we have a token in url to remove it ?
451
+        unset($_GET['token']); // TODO Make a redirect if we have a token in url to remove it ?
452 452
         if (isset($savid)) {
453
-            $_POST['id'] = ((int)$savid);
453
+            $_POST['id'] = ((int) $savid);
454 454
         }
455 455
         // So rest of code can know something was wrong here
456 456
         $_GET['errorcode'] = 'InvalidToken';
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
                 if (!empty($_SERVER["HTTP_USER_AGENT"]) && $_SERVER["HTTP_USER_AGENT"] == 'securitytest') {
759 759
                     http_response_code(401); // It makes easier to understand if session was broken during security tests
760 760
                 }
761
-                dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : ''));   // This include http headers
761
+                dol_loginfunction($langs, $conf, (!empty($mysoc) ? $mysoc : '')); // This include http headers
762 762
             }
763 763
             exit;
764 764
         }
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 } else {
1107 1107
     // We may have NOLOGIN set, but NOREQUIREUSER not
1108 1108
     if (!empty($user) && method_exists($user, 'loadDefaultValues') && !defined('NODEFAULTVALUES')) {
1109
-        $user->loadDefaultValues();     // Load default values for everybody (works even if $user->id = 0
1109
+        $user->loadDefaultValues(); // Load default values for everybody (works even if $user->id = 0
1110 1110
     }
1111 1111
 }
1112 1112
 
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
     }
1278 1278
     if (!class_exists('MenuManager')) {
1279 1279
         $menufound = 0;
1280
-        $dirmenus = array_merge(array("/core/menus/"), (array)$conf->modules_parts['menus']);
1280
+        $dirmenus = array_merge(array("/core/menus/"), (array) $conf->modules_parts['menus']);
1281 1281
         foreach ($dirmenus as $dirmenu) {
1282 1282
             $menufound = dol_include_once($dirmenu . "standard/" . $file_menu);
1283 1283
             if (class_exists('MenuManager')) {
@@ -1729,9 +1729,9 @@  discard block
 block discarded – undo
1729 1729
 
1730 1730
         // CSS forced by modules (relative url starting with /)
1731 1731
         if (!empty($conf->modules_parts['css'])) {
1732
-            $arraycss = (array)$conf->modules_parts['css'];
1732
+            $arraycss = (array) $conf->modules_parts['css'];
1733 1733
             foreach ($arraycss as $modcss => $filescss) {
1734
-                $filescss = (array)$filescss; // To be sure filecss is an array
1734
+                $filescss = (array) $filescss; // To be sure filecss is an array
1735 1735
                 foreach ($filescss as $cssfile) {
1736 1736
                     if (empty($cssfile)) {
1737 1737
                         dol_syslog("Warning: module " . $modcss . " declared a css path file into its descriptor that is empty.", LOG_WARNING);
@@ -1890,9 +1890,9 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
             // JS forced by modules (relative url starting with /)
1892 1892
             if (!empty($conf->modules_parts['js'])) {       // $conf->modules_parts['js'] is array('module'=>array('file1','file2'))
1893
-                $arrayjs = (array)$conf->modules_parts['js'];
1893
+                $arrayjs = (array) $conf->modules_parts['js'];
1894 1894
                 foreach ($arrayjs as $modjs => $filesjs) {
1895
-                    $filesjs = (array)$filesjs; // To be sure filejs is an array
1895
+                    $filesjs = (array) $filesjs; // To be sure filejs is an array
1896 1896
                     foreach ($filesjs as $jsfile) {
1897 1897
                         // jsfile is a relative path
1898 1898
                         $urlforjs = dol_buildpath($jsfile, 3);
@@ -2307,7 +2307,7 @@  discard block
 block discarded – undo
2307 2307
     $langFlag = picto_from_langcode($langs->getDefaultLang());
2308 2308
     $dropdownBody .= '<br><b>' . $langs->trans("CurrentUserLanguage") . ':</b> ' . ($langFlag ? $langFlag . ' ' : '') . $langs->getDefaultLang();
2309 2309
 
2310
-    $tz = (int)$_SESSION['dol_tz'] + (int)$_SESSION['dol_dst'];
2310
+    $tz = (int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst'];
2311 2311
     $dropdownBody .= '<br><b>' . $langs->trans("ClientTZ") . ':</b> ' . ($tz ? ($tz >= 0 ? '+' : '') . $tz : '');
2312 2312
     $dropdownBody .= ' (' . $_SESSION['dol_tz_string'] . ')';
2313 2313
     //$dropdownBody .= ' &nbsp; &nbsp; &nbsp; '.$langs->trans("DaylingSavingTime").': ';
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
 
2354 2354
     // Defined the links for bottom of card
2355 2355
     $profilLink = '<a accesskey="u" href="' . BASE_URL . '/user/card.php?id=' . $user->id . '" class="button-top-menu-dropdown" title="' . dol_escape_htmltag($langs->trans("YourUserFile") . ' (' . $stringforfirstkey . ' u)') . '"><i class="fa fa-user"></i>  ' . $langs->trans("Card") . '</a>';
2356
-    $urltovirtualcard = '/user/virtualcard.php?id=' . ((int)$user->id);
2356
+    $urltovirtualcard = '/user/virtualcard.php?id=' . ((int) $user->id);
2357 2357
     $virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->transnoentitiesnoconv("PublicVirtualCardUrl") . (is_object($user) ? ' - ' . $user->getFullName($langs) : '') . ' (' . $stringforfirstkey . ' v)', img_picto($langs->trans("PublicVirtualCardUrl") . ' (' . $stringforfirstkey . ' v)', 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v');
2358 2358
     $logoutLink = '<a accesskey="l" href="' . $urllogout . '" class="button-top-menu-dropdown" title="' . dol_escape_htmltag($langs->trans("Logout") . ' (' . $stringforfirstkey . ' l)') . '"><i class="fa fa-sign-out-alt padingright"></i><span class="hideonsmartphone">' . $langs->trans("Logout") . '</span></a>';
2359 2359
 
@@ -3597,7 +3597,7 @@  discard block
 block discarded – undo
3597 3597
         $forceping = GETPOST('forceping', 'alpha');
3598 3598
         if (($_SERVER["PHP_SELF"] == constant('BASE_URL') . '/index.php') || $forceping) {
3599 3599
             //print '<!-- instance_unique_id='.$conf->file->instance_unique_id.' MAIN_FIRST_PING_OK_ID='.$conf->global->MAIN_FIRST_PING_OK_ID.' -->';
3600
-            $hash_unique_id = dol_hash('dolibarr' . $conf->file->instance_unique_id, 'sha256');   // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only.
3600
+            $hash_unique_id = dol_hash('dolibarr' . $conf->file->instance_unique_id, 'sha256'); // Note: if the global salt changes, this hash changes too so ping may be counted twice. We don't mind. It is for statistics purpose only.
3601 3601
 
3602 3602
             if (
3603 3603
                 !getDolGlobalString('MAIN_FIRST_PING_OK_DATE')
@@ -3639,8 +3639,8 @@  discard block
 block discarded – undo
3639 3639
                                         hash_algo: 'dol_hash-sha256',
3640 3640
                                         hash_unique_id: '<?php echo dol_escape_js($hash_unique_id); ?>',
3641 3641
                                         action: 'dolibarrping',
3642
-                                        version: '<?php echo (float)DOL_VERSION; ?>',
3643
-                                        entity: '<?php echo (int)$conf->entity; ?>',
3642
+                                        version: '<?php echo (float) DOL_VERSION; ?>',
3643
+                                        entity: '<?php echo (int) $conf->entity; ?>',
3644 3644
                                         dbtype: '<?php echo dol_escape_js($db->type); ?>',
3645 3645
                                         country_code: '<?php echo $mysoc->country_code ? dol_escape_js($mysoc->country_code) : 'unknown'; ?>',
3646 3646
                                         php_version: '<?php echo dol_escape_js(phpversion()); ?>',
Please login to merge, or discard this patch.
public/htdocs/core/lib/html.lib.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     $form = new Form($db);
82 82
 
83
-    $templatenameforexport = $website->name_template;   // Example 'website_template-corporate'
83
+    $templatenameforexport = $website->name_template; // Example 'website_template-corporate'
84 84
     if (empty($templatenameforexport)) {
85 85
         $templatenameforexport = 'website_' . $website->ref;
86 86
     }
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                 } else {
677 677
                     $width = 14;
678 678
                     $cssclass = 'photorefcenter';
679
-                    $picto = $object->picto;  // @phan-suppress-current-line PhanUndeclaredProperty
679
+                    $picto = $object->picto; // @phan-suppress-current-line PhanUndeclaredProperty
680 680
                     $prefix = 'object_';
681 681
                     if ($object->element == 'project' && !$object->public) {  // @phan-suppress-current-line PhanUndeclaredProperty
682 682
                         $picto = 'project'; // instead of projectpub
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
     }
787 787
     // Show address and email
788 788
     if (method_exists($object, 'getBannerAddress') && !in_array($object->element, array('product', 'bookmark', 'ecm_directories', 'ecm_files'))) {
789
-        $moreaddress = $object->getBannerAddress('refaddress', $object);    // address, email, url, social networks
789
+        $moreaddress = $object->getBannerAddress('refaddress', $object); // address, email, url, social networks
790 790
         if ($moreaddress) {
791 791
             $morehtmlref .= '<div class="refidno refaddress">';
792 792
             $morehtmlref .= $moreaddress;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
     if (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && (getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') == '1' || preg_match('/' . preg_quote($object->element, '/') . '/i', $conf->global->MAIN_SHOW_TECHNICAL_ID)) && !empty($object->id)) {
797 797
         $morehtmlref .= '<div style="clear: both;"></div>';
798 798
         $morehtmlref .= '<div class="refidno opacitymedium">';
799
-        $morehtmlref .= $langs->trans("TechnicalID") . ': ' . ((int)$object->id);
799
+        $morehtmlref .= $langs->trans("TechnicalID") . ': ' . ((int) $object->id);
800 800
         $morehtmlref .= '</div>';
801 801
     }
802 802
 
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
             $type = 'AC_EMAIL';
955 955
             $linktoaddaction = '';
956 956
             if (getDolGlobalString('AGENDA_ADDACTIONFOREMAIL')) {
957
-                $linktoaddaction = '<a href="' . constant('BASE_URL') . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . urlencode($type) . '&amp;contactid=' . ((int)$cid) . '&amp;socid=' . ((int)$socid) . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
957
+                $linktoaddaction = '<a href="' . constant('BASE_URL') . '/comm/action/card.php?action=create&amp;backtopage=1&amp;actioncode=' . urlencode($type) . '&amp;contactid=' . ((int) $cid) . '&amp;socid=' . ((int) $socid) . '">' . img_object($langs->trans("AddAction"), "calendar") . '</a>';
958 958
             }
959 959
             if ($linktoaddaction) {
960 960
                 $newemail = '<div>' . $newemail . ' ' . $linktoaddaction . '</div>';
@@ -1334,7 +1334,7 @@  discard block
 block discarded – undo
1334 1334
             $url = make_substitutions($url, $substitarray);
1335 1335
             if (!getDolGlobalString('CLICKTODIAL_DO_NOT_USE_AJAX_CALL')) {
1336 1336
                 // Default and recommended: New method using ajax without submitting a page making a javascript history.go(-1) back
1337
-                $newphoneastart = '<a href="' . $url . '" class="cssforclicktodial">';  // Call of ajax is handled by the lib_foot.js.php on class 'cssforclicktodial'
1337
+                $newphoneastart = '<a href="' . $url . '" class="cssforclicktodial">'; // Call of ajax is handled by the lib_foot.js.php on class 'cssforclicktodial'
1338 1338
                 $newphoneaend = '</a>';
1339 1339
             } else {
1340 1340
                 // Old method
@@ -1365,7 +1365,7 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
     if (getDolGlobalString('CONTACT_PHONEMOBILE_SHOW_LINK_TO_WHATSAPP') && $withpicto == 'mobile') {
1367 1367
         // Link to Whatsapp
1368
-        $newphone .= ' <a href="https://wa.me/' . $newphonewa . '" target="_blank"';// Use api to whatasapp contacts
1368
+        $newphone .= ' <a href="https://wa.me/' . $newphonewa . '" target="_blank"'; // Use api to whatasapp contacts
1369 1369
         $newphone .= '><span class="paddingright fab fa-whatsapp" style="color:#25D366;" title="WhatsApp"></span></a>';
1370 1370
     }
1371 1371
 
@@ -1864,7 +1864,7 @@  discard block
 block discarded – undo
1864 1864
             top_httphead();
1865 1865
         }
1866 1866
         //http_response_code(500);      // If we use 500, message is not output with some command line tools
1867
-        http_response_code(202);        // If we use 202, this is not really an error message, but this allow to output message on command line tools
1867
+        http_response_code(202); // If we use 202, this is not really an error message, but this allow to output message on command line tools
1868 1868
     }
1869 1869
 
1870 1870
     if (empty($dolibarr_main_prod)) {
@@ -2134,7 +2134,7 @@  discard block
 block discarded – undo
2134 2134
     }
2135 2135
     $return .= '<td class="nobordernopadding valignmiddle col-title">';
2136 2136
     $return .= '<div class="titre inline-block">';
2137
-    $return .= $title;  // $title is already HTML sanitized content
2137
+    $return .= $title; // $title is already HTML sanitized content
2138 2138
     $return .= '</div>';
2139 2139
     $return .= '</td>';
2140 2140
     if (dol_strlen($morehtmlcenter)) {
@@ -2181,7 +2181,7 @@  discard block
 block discarded – undo
2181 2181
         $totalnboflines = abs($totalnboflines);
2182 2182
     }
2183 2183
 
2184
-    $page = (int)$page;
2184
+    $page = (int) $page;
2185 2185
 
2186 2186
     if ($picto == 'setup') {
2187 2187
         $picto = 'title_setup.png';
@@ -2212,8 +2212,8 @@  discard block
 block discarded – undo
2212 2212
 
2213 2213
     print '<td class="nobordernopadding valignmiddle col-title">';
2214 2214
     print '<div class="titre inline-block">';
2215
-    print $title;   // $title may contains HTML
2216
-    if (!empty($title) && $savtotalnboflines >= 0 && (string)$savtotalnboflines != '') {
2215
+    print $title; // $title may contains HTML
2216
+    if (!empty($title) && $savtotalnboflines >= 0 && (string) $savtotalnboflines != '') {
2217 2217
         print '<span class="opacitymedium colorblack paddingleft">(' . $totalnboflines . ')</span>';
2218 2218
     }
2219 2219
     print '</div></td>';
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
 
2226 2226
     // Right
2227 2227
     print '<td class="nobordernopadding valignmiddle right col-right">';
2228
-    print '<input type="hidden" name="pageplusoneold" value="' . ((int)$page + 1) . '">';
2228
+    print '<input type="hidden" name="pageplusoneold" value="' . ((int) $page + 1) . '">';
2229 2229
     if ($sortfield) {
2230 2230
         $options .= "&sortfield=" . urlencode($sortfield);
2231 2231
     }
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
     }
2345 2345
 
2346 2346
     if (empty($hidenavigation)) {
2347
-        if ((int)$limit > 0 && empty($hideselectlimit)) {
2347
+        if ((int) $limit > 0 && empty($hideselectlimit)) {
2348 2348
             $pagesizechoices = '10:10,15:15,20:20,25:25,50:50,100:100,250:250,500:500,1000:1000';
2349 2349
             $pagesizechoices .= ',5000:5000,10000:10000,20000:20000';
2350 2350
             //$pagesizechoices.=',0:'.$langs->trans("All");     // Not yet supported
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
                 $key = $tmp[0];
2378 2378
                 $val = $tmp[1];
2379 2379
                 if ($key != '' && $val != '') {
2380
-                    if ((int)$key == (int)$limit) {
2380
+                    if ((int) $key == (int) $limit) {
2381 2381
                         $selected = ' selected="selected"';
2382 2382
                     }
2383 2383
                     print '<option name="' . $key . '"' . $selected . '>' . dol_escape_htmltag($val) . '</option>' . "\n";
@@ -2578,7 +2578,7 @@  discard block
 block discarded – undo
2578 2578
         if (is_object($objcon) && $objcon->id > 0) {
2579 2579
             $force_filter_contact = true;
2580 2580
             $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "actioncomm_resources as r ON a.id = r.fk_actioncomm";
2581
-            $sql .= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . ((int)$objcon->id);
2581
+            $sql .= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . ((int) $objcon->id);
2582 2582
         }
2583 2583
 
2584 2584
         if (is_object($filterobj) && get_only_class($filterobj) == 'Societe') {
@@ -2587,7 +2587,7 @@  discard block
 block discarded – undo
2587 2587
             $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "element_resources as er";
2588 2588
             $sql .= " ON er.resource_type = 'dolresource'";
2589 2589
             $sql .= " AND er.element_id = a.id";
2590
-            $sql .= " AND er.resource_id = " . ((int)$filterobj->id);
2590
+            $sql .= " AND er.resource_id = " . ((int) $filterobj->id);
2591 2591
         } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Adherent') {
2592 2592
             $sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
2593 2593
         } elseif (is_object($filterobj) && get_only_class($filterobj) == 'CommandeFournisseur') {
@@ -2605,42 +2605,42 @@  discard block
 block discarded – undo
2605 2605
         $sql .= " WHERE a.entity IN (" . getEntity('agenda') . ")";
2606 2606
         if (!$force_filter_contact) {
2607 2607
             if (is_object($filterobj) && in_array(get_only_class($filterobj), array('Societe', 'Client', 'Fournisseur')) && $filterobj->id) {
2608
-                $sql .= " AND a.fk_soc = " . ((int)$filterobj->id);
2608
+                $sql .= " AND a.fk_soc = " . ((int) $filterobj->id);
2609 2609
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Project' && $filterobj->id) {
2610
-                $sql .= " AND a.fk_project = " . ((int)$filterobj->id);
2610
+                $sql .= " AND a.fk_project = " . ((int) $filterobj->id);
2611 2611
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Adherent') {
2612 2612
                 $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
2613 2613
                 if ($filterobj->id) {
2614
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2614
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2615 2615
                 }
2616 2616
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'CommandeFournisseur') {
2617 2617
                 $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'";
2618 2618
                 if ($filterobj->id) {
2619
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2619
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2620 2620
                 }
2621 2621
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Product') {
2622 2622
                 $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
2623 2623
                 if ($filterobj->id) {
2624
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2624
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2625 2625
                 }
2626 2626
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Ticket') {
2627 2627
                 $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'ticket'";
2628 2628
                 if ($filterobj->id) {
2629
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2629
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2630 2630
                 }
2631 2631
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'BOM') {
2632 2632
                 $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'bom'";
2633 2633
                 if ($filterobj->id) {
2634
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2634
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2635 2635
                 }
2636 2636
             } elseif (is_object($filterobj) && get_only_class($filterobj) == 'Contrat') {
2637 2637
                 $sql .= " AND a.fk_element = o.rowid AND a.elementtype = 'contract'";
2638 2638
                 if ($filterobj->id) {
2639
-                    $sql .= " AND a.fk_element = " . ((int)$filterobj->id);
2639
+                    $sql .= " AND a.fk_element = " . ((int) $filterobj->id);
2640 2640
                 }
2641 2641
             }
2642 2642
         } else {
2643
-            $sql .= " AND u.rowid = " . ((int)$filterobj->id);
2643
+            $sql .= " AND u.rowid = " . ((int) $filterobj->id);
2644 2644
         }
2645 2645
 
2646 2646
         // Condition on actioncode
@@ -3328,7 +3328,7 @@  discard block
 block discarded – undo
3328 3328
         $showonlyonhover = 0;
3329 3329
     }*/
3330 3330
 
3331
-    $tag = 'span';  // Using div (like any style of type 'block') does not work when using the js copy code.
3331
+    $tag = 'span'; // Using div (like any style of type 'block') does not work when using the js copy code.
3332 3332
     if ($texttoshow === 'none') {
3333 3333
         $result = '<span class="clipboardCP' . ($showonlyonhover ? ' clipboardCPShowOnHover' : '') . '"><' . $tag . ' class="clipboardCPValue hidewithsize">' . dol_escape_htmltag($valuetocopy, 1, 1) . '</' . $tag . '><span class="clipboardCPValueToPrint"></span><span class="clipboardCPButton far fa-clipboard opacitymedium paddingleft paddingright"></span><span class="clipboardCPText"></span></span>';
3334 3334
     } elseif ($texttoshow) {
@@ -3669,7 +3669,7 @@  discard block
 block discarded – undo
3669 3669
         $table_element = 'adherent_type';
3670 3670
     } elseif ($elementType == 'bank_account') {
3671 3671
         $classpath = 'compta/bank/class';
3672
-        $module = 'bank';   // We need $conf->bank->dir_output and not $conf->banque->dir_output
3672
+        $module = 'bank'; // We need $conf->bank->dir_output and not $conf->banque->dir_output
3673 3673
         $classfile = 'account';
3674 3674
         $classname = 'Account';
3675 3675
     } elseif ($elementType == 'category') {
@@ -4321,8 +4321,8 @@  discard block
 block discarded – undo
4321 4321
 
4322 4322
 
4323 4323
     $parameters = array(
4324
-        'TCompiledAttr' => $TCompiledAttr,              // array
4325
-        'compiledAttributes' => $compiledAttributes,    // string
4324
+        'TCompiledAttr' => $TCompiledAttr, // array
4325
+        'compiledAttributes' => $compiledAttributes, // string
4326 4326
         'attr' => $attr,
4327 4327
         'tag' => $tag,
4328 4328
         'label' => $label,
@@ -4438,7 +4438,7 @@  discard block
 block discarded – undo
4438 4438
                     if ($posstart > 0) {
4439 4439
                         $res1 = substr($str, $posstart + 1, $posend - $posstart - 1);
4440 4440
                         if (is_numeric($res1)) {
4441
-                            $postab = (int)$res1;
4441
+                            $postab = (int) $res1;
4442 4442
                             $values[1] = '+' . substr($str, $posend + 1);
4443 4443
                         }
4444 4444
                     }
@@ -5014,7 +5014,7 @@  discard block
 block discarded – undo
5014 5014
 
5015 5015
             if (!empty($out) && getDolGlobalString('MAIN_RESTRICTHTML_ONLY_VALID_HTML') && $check != 'restricthtmlallowunvalid') {
5016 5016
                 try {
5017
-                    libxml_use_internal_errors(false);  // Avoid to fill memory with xml errors
5017
+                    libxml_use_internal_errors(false); // Avoid to fill memory with xml errors
5018 5018
                     if (LIBXML_VERSION < 20900) {
5019 5019
                         // Avoid load of external entities (security problem).
5020 5020
                         // Required only if LIBXML_VERSION < 20900
@@ -5055,7 +5055,7 @@  discard block
 block discarded – undo
5055 5055
                         // See options at https://tidy.sourceforge.net/docs/quickref.html
5056 5056
                         $config = array(
5057 5057
                             'clean' => false,
5058
-                            'quote-marks' => false,     // do not replace " that are used for real text content (not a string symbol for html attribute) into &quot;
5058
+                            'quote-marks' => false, // do not replace " that are used for real text content (not a string symbol for html attribute) into &quot;
5059 5059
                             'doctype' => 'strict',
5060 5060
                             'show-body-only' => true,
5061 5061
                             "indent-attributes" => false,
@@ -5098,7 +5098,7 @@  discard block
 block discarded – undo
5098 5098
                  * @param string[] $m
5099 5099
                  * @return string
5100 5100
                  */
5101
-                static function ($m) {
5101
+                static function($m) {
5102 5102
                     return Filters::realCharForNumericEntities($m);
5103 5103
                 },
5104 5104
                 $out
@@ -5231,7 +5231,7 @@  discard block
 block discarded – undo
5231 5231
  */
5232 5232
 function dol_htmlcleanlastbr($stringtodecode)
5233 5233
 {
5234
-    $ret = preg_replace('/&nbsp;$/i', "", $stringtodecode);     // Because wysiwyg editor may add a &nbsp; at end of last line
5234
+    $ret = preg_replace('/&nbsp;$/i', "", $stringtodecode); // Because wysiwyg editor may add a &nbsp; at end of last line
5235 5235
     $ret = preg_replace('/(<br>|<br(\s[\sa-zA-Z_="]*)?\/?>|' . "\n" . '|' . "\r" . ')+$/i', "", $ret);
5236 5236
     return $ret;
5237 5237
 }
@@ -5251,7 +5251,7 @@  discard block
 block discarded – undo
5251 5251
     if ($keepsomeentities) {
5252 5252
         $newstring = strtr($newstring, array('&amp;' => '__andamp__', '&lt;' => '__andlt__', '&gt;' => '__andgt__', '"' => '__dquot__'));
5253 5253
     }
5254
-    $newstring = html_entity_decode((string)$newstring, (int)$b, (string)$c);
5254
+    $newstring = html_entity_decode((string) $newstring, (int) $b, (string) $c);
5255 5255
     if ($keepsomeentities) {
5256 5256
         $newstring = strtr($newstring, array('__andamp__' => '&amp;', '__andlt__' => '&lt;', '__andgt__' => '&gt;', '__dquot__' => '"'));
5257 5257
     }
@@ -5327,7 +5327,7 @@  discard block
 block discarded – undo
5327 5327
                             if (isset($valuetoclean)) {
5328 5328
                                 do {
5329 5329
                                     $oldvaluetoclean = $valuetoclean;
5330
-                                    $valuetoclean = preg_replace('/\/\*.*\*\//m', '', $valuetoclean);   // clean css comments
5330
+                                    $valuetoclean = preg_replace('/\/\*.*\*\//m', '', $valuetoclean); // clean css comments
5331 5331
                                     $valuetoclean = preg_replace('/position\s*:\s*[a-z]+/mi', '', $valuetoclean);
5332 5332
                                     if ($els->item($i)->tagName == 'a') {   // more paranoiac cleaning for clickable tags.
5333 5333
                                         $valuetoclean = preg_replace('/display\s*:/mi', '', $valuetoclean);
@@ -5415,7 +5415,7 @@  discard block
 block discarded – undo
5415 5415
         $tempbis = $temp;
5416 5416
         do {
5417 5417
             $temp = $tempbis;
5418
-            $tempbis = str_replace('<>', '', $temp);    // No reason to have this into a text, except if value is to try bypass the next html cleaning
5418
+            $tempbis = str_replace('<>', '', $temp); // No reason to have this into a text, except if value is to try bypass the next html cleaning
5419 5419
             $tempbis = preg_replace($pattern, '', $tempbis);
5420 5420
             //$idowhile++; print $temp.'-'.$tempbis."\n"; if ($idowhile > 100) break;
5421 5421
         } while ($tempbis != $temp);
@@ -5470,7 +5470,7 @@  discard block
 block discarded – undo
5470 5470
             "header", "footer", "nav", "section", "menu", "menuitem"    // html5 tags
5471 5471
         );
5472 5472
     }
5473
-    $allowed_tags[] = "comment";        // this tags is added to manage comment <!--...--> that are replaced into <comment>...</comment>
5473
+    $allowed_tags[] = "comment"; // this tags is added to manage comment <!--...--> that are replaced into <comment>...</comment>
5474 5474
     if ($allowiframe) {
5475 5475
         if (!in_array('iframe', $allowed_tags)) {
5476 5476
             $allowed_tags[] = "iframe";
@@ -5485,7 +5485,7 @@  discard block
 block discarded – undo
5485 5485
     $allowed_tags_string = implode("><", $allowed_tags);
5486 5486
     $allowed_tags_string = '<' . $allowed_tags_string . '>';
5487 5487
 
5488
-    $stringtoclean = str_replace('<!DOCTYPE html>', '__!DOCTYPE_HTML__', $stringtoclean);   // Replace DOCTYPE to avoid to have it removed by the strip_tags
5488
+    $stringtoclean = str_replace('<!DOCTYPE html>', '__!DOCTYPE_HTML__', $stringtoclean); // Replace DOCTYPE to avoid to have it removed by the strip_tags
5489 5489
 
5490 5490
     $stringtoclean = dol_string_nounprintableascii($stringtoclean, 0);
5491 5491
 
@@ -5495,7 +5495,7 @@  discard block
 block discarded – undo
5495 5495
     $stringtoclean = preg_replace('/&colon;/i', ':', $stringtoclean);
5496 5496
     $stringtoclean = preg_replace('/&#58;|&#0+58|&#x3A/i', '', $stringtoclean); // refused string ':' encoded (no reason to have a : encoded like this) to disable 'javascript:...'
5497 5497
 
5498
-    $temp = strip_tags($stringtoclean, $allowed_tags_string);   // Warning: This remove also undesired </>, so may changes string obfuscated with </> that pass the injection detection into a harmfull string
5498
+    $temp = strip_tags($stringtoclean, $allowed_tags_string); // Warning: This remove also undesired </>, so may changes string obfuscated with </> that pass the injection detection into a harmfull string
5499 5499
 
5500 5500
     if ($cleanalsosomestyles) { // Clean for remaining html tags
5501 5501
         $temp = preg_replace('/position\s*:\s*(absolute|fixed)\s*!\s*important/i', '', $temp); // Note: If hacker try to introduce css comment into string to bypass this regex, the string must also be encoded by the dol_htmlentitiesbr during output so it become harmless
@@ -5512,7 +5512,7 @@  discard block
 block discarded – undo
5512 5512
 
5513 5513
     $temp = str_replace('__!DOCTYPE_HTML__', '<!DOCTYPE html>', $temp); // Restore the DOCTYPE
5514 5514
 
5515
-    $temp = preg_replace('/<comment>([^>]*)<\/comment>/', '<!--\1-->', $temp);  // Restore html comments
5515
+    $temp = preg_replace('/<comment>([^>]*)<\/comment>/', '<!--\1-->', $temp); // Restore html comments
5516 5516
 
5517 5517
 
5518 5518
     return $temp;
Please login to merge, or discard this patch.
public/htdocs/core/lib/functions2.lib.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
167 167
 
168 168
     $deltadateforserver = getServerTimeZoneInt('now');
169
-    $deltadateforclient = ((int)$_SESSION['dol_tz'] + (int)$_SESSION['dol_dst']);
169
+    $deltadateforclient = ((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
170 170
     //$deltadateforcompany=((int) $_SESSION['dol_tz'] + (int) $_SESSION['dol_dst']);
171 171
     $deltadateforuser = round($deltadateforclient - $deltadateforserver);
172 172
     //print "x".$deltadateforserver." - ".$deltadateforclient." - ".$deltadateforuser;
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
     while (preg_match('/\{([A-Z]+)\-([1-9])\}/', $tmpmask, $regKey)) {
1017 1017
         $maskperso[$regKey[1]] = '{' . $regKey[1] . '-' . $regKey[2] . '}';
1018 1018
         // @phan-suppress-next-line PhanParamSuspiciousOrder
1019
-        $maskpersonew[$regKey[1]] = str_pad('', (int)$regKey[2], '_', STR_PAD_RIGHT);
1019
+        $maskpersonew[$regKey[1]] = str_pad('', (int) $regKey[2], '_', STR_PAD_RIGHT);
1020 1020
         $tmpmask = preg_replace('/\{' . $regKey[1] . '\-' . $regKey[2] . '\}/i', $maskpersonew[$regKey[1]], $tmpmask);
1021 1021
     }
1022 1022
 
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
     if ($maskraz > 0) {   // A reset is required
1080 1080
         if ($maskraz == 99) {
1081
-            $maskraz = (int)date('m', $date);
1081
+            $maskraz = (int) date('m', $date);
1082 1082
             $resetEveryMonth = true;
1083 1083
         }
1084 1084
         if ($maskraz > 12) {
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
         $yearcomp = 0;
1132 1132
 
1133 1133
         if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') {    // $yearoffsettype is - or +
1134
-            $currentyear = (int)date("Y", $date);
1134
+            $currentyear = (int) date("Y", $date);
1135 1135
             $fiscaldate = dol_mktime('0', '0', '0', $maskraz, '1', $currentyear);
1136 1136
             $newyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear);
1137 1137
             $nextnewyeardate = dol_mktime('0', '0', '0', '1', '1', $currentyear + 1);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
                 // If after or equal of current new year date
1148 1148
                 $yearoffset = -1;
1149 1149
             }
1150
-        } elseif ((int)date("m", $date) < $maskraz && empty($resetEveryMonth)) {
1150
+        } elseif ((int) date("m", $date) < $maskraz && empty($resetEveryMonth)) {
1151 1151
             // For backward compatibility
1152 1152
             $yearoffset = -1;
1153 1153
         }   // If current month lower that month of return to zero, year is previous year
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
         } elseif ($yearlen == 2) {
1158 1158
             $yearcomp = sprintf("%02d", idate("y", $date) + $yearoffset);
1159 1159
         } elseif ($yearlen == 1) {
1160
-            $yearcomp = (int)substr(date('y', $date), 1, 1) + $yearoffset;
1160
+            $yearcomp = (int) substr(date('y', $date), 1, 1) + $yearoffset;
1161 1161
         }
1162 1162
         if ($monthcomp > 1 && empty($resetEveryMonth)) {    // Test with month is useless if monthcomp = 0 or 1 (0 is same as 1) (regis: $monthcomp can't equal 0)
1163 1163
             if ($yearlen == 4) {
@@ -1391,9 +1391,9 @@  discard block
 block discarded – undo
1391 1391
 
1392 1392
         // We replace special codes except refclient
1393 1393
         if (!empty($yearoffsettype) && !is_numeric($yearoffsettype) && $yearoffsettype != '=') {    // yearoffsettype is - or +, so we don't want current year
1394
-            $numFinal = preg_replace('/\{yyyy\}/i', (string)((int)date("Y", $date) + $yearoffset), $numFinal);
1395
-            $numFinal = preg_replace('/\{yy\}/i', (string)((int)date("y", $date) + $yearoffset), $numFinal);
1396
-            $numFinal = preg_replace('/\{y\}/i', (string)((int)substr((string)date("y", $date), 1, 1) + $yearoffset), $numFinal);
1394
+            $numFinal = preg_replace('/\{yyyy\}/i', (string) ((int) date("Y", $date) + $yearoffset), $numFinal);
1395
+            $numFinal = preg_replace('/\{yy\}/i', (string) ((int) date("y", $date) + $yearoffset), $numFinal);
1396
+            $numFinal = preg_replace('/\{y\}/i', (string) ((int) substr((string) date("y", $date), 1, 1) + $yearoffset), $numFinal);
1397 1397
         } else { // we want yyyy to be current year
1398 1398
             $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal);
1399 1399
             $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal);
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
     }
1550 1550
     if ($maskraz >= 0) {
1551 1551
         if ($maskraz == 99) {
1552
-            $maskraz = (int)date('m');
1552
+            $maskraz = (int) date('m');
1553 1553
             $resetEveryMonth = true;
1554 1554
         }
1555 1555
         if ($maskraz > 12) {
@@ -1644,9 +1644,9 @@  discard block
 block discarded – undo
1644 1644
 
1645 1645
     if (preg_match('/^([0-9]+)\-([0-9]+)\-([0-9]+)\s?([0-9]+)?:?([0-9]+)?/i', $stime, $reg)) {
1646 1646
         // Date est au format 'YYYY-MM-DD' ou 'YYYY-MM-DD HH:MM:SS'
1647
-        $annee = (int)$reg[1];
1648
-        $mois = (int)$reg[2];
1649
-        $jour = (int)$reg[3];
1647
+        $annee = (int) $reg[1];
1648
+        $mois = (int) $reg[2];
1649
+        $jour = (int) $reg[3];
1650 1650
     }
1651 1651
 
1652 1652
     /*
@@ -1657,33 +1657,33 @@  discard block
 block discarded – undo
1657 1657
      */
1658 1658
 
1659 1659
     // Definition du Jeudi de la semaine
1660
-    if ((int)date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) { // Dimanche
1660
+    if ((int) date("w", mktime(12, 0, 0, $mois, $jour, $annee)) == 0) { // Dimanche
1661 1661
         $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - 3 * 24 * 60 * 60;
1662 1662
     } elseif (date("w", mktime(12, 0, 0, $mois, $jour, $annee)) < 4) { // du Lundi au Mercredi
1663
-        $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - (int)date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60;
1664
-    } elseif ((int)date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) { // du Vendredi au Samedi
1665
-        $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - ((int)date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60;
1663
+        $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) + (4 - (int) date("w", mktime(12, 0, 0, $mois, $jour, $annee))) * 24 * 60 * 60;
1664
+    } elseif ((int) date("w", mktime(12, 0, 0, $mois, $jour, $annee)) > 4) { // du Vendredi au Samedi
1665
+        $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee) - ((int) date("w", mktime(12, 0, 0, $mois, $jour, $annee)) - 4) * 24 * 60 * 60;
1666 1666
     } else { // Jeudi
1667 1667
         $jeudiSemaine = mktime(12, 0, 0, $mois, $jour, $annee);
1668 1668
     }
1669 1669
 
1670 1670
     // Definition du premier Jeudi de l'annee
1671
-    if ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) == 0) { // Dimanche
1672
-        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60;
1673
-    } elseif ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) < 4) { // du Lundi au Mercredi
1674
-        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine)) + (4 - (int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine)))) * 24 * 60 * 60;
1675
-    } elseif ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) > 4) { // du Vendredi au Samedi
1676
-        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine)) + (7 - ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60;
1671
+    if ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) == 0) { // Dimanche
1672
+        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine)) + 4 * 24 * 60 * 60;
1673
+    } elseif ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) < 4) { // du Lundi au Mercredi
1674
+        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine)) + (4 - (int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine)))) * 24 * 60 * 60;
1675
+    } elseif ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) > 4) { // du Vendredi au Samedi
1676
+        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine)) + (7 - ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60;
1677 1677
     } else { // Jeudi
1678
-        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine));
1678
+        $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine));
1679 1679
     }
1680 1680
 
1681 1681
     // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine";
1682 1682
     $numeroSemaine = (
1683 1683
             (
1684
-                (int)date("z", mktime(12, 0, 0, (int)date("m", $jeudiSemaine), (int)date("d", $jeudiSemaine), (int)date("Y", $jeudiSemaine)))
1684
+                (int) date("z", mktime(12, 0, 0, (int) date("m", $jeudiSemaine), (int) date("d", $jeudiSemaine), (int) date("Y", $jeudiSemaine)))
1685 1685
                 -
1686
-                (int)date("z", mktime(12, 0, 0, (int)date("m", $premierJeudiAnnee), (int)date("d", $premierJeudiAnnee), (int)date("Y", $premierJeudiAnnee)))
1686
+                (int) date("z", mktime(12, 0, 0, (int) date("m", $premierJeudiAnnee), (int) date("d", $premierJeudiAnnee), (int) date("Y", $premierJeudiAnnee)))
1687 1687
             ) / 7
1688 1688
         ) + 1;
1689 1689
 
@@ -1691,10 +1691,10 @@  discard block
 block discarded – undo
1691 1691
     if ($numeroSemaine == 53) {
1692 1692
         // Les annees qui commencent un Jeudi et les annees bissextiles commencant un Mercredi en possedent 53
1693 1693
         if (
1694
-            ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) == 4)
1694
+            ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) == 4)
1695 1695
             || (
1696
-                ((int)date("w", mktime(12, 0, 0, 1, 1, (int)date("Y", $jeudiSemaine))) == 3)
1697
-                && ((int)date("z", mktime(12, 0, 0, 12, 31, (int)date("Y", $jeudiSemaine))) == 365)
1696
+                ((int) date("w", mktime(12, 0, 0, 1, 1, (int) date("Y", $jeudiSemaine))) == 3)
1697
+                && ((int) date("z", mktime(12, 0, 0, 12, 31, (int) date("Y", $jeudiSemaine))) == 365)
1698 1698
             )
1699 1699
         ) {
1700 1700
             $numeroSemaine = 53;
@@ -1762,8 +1762,8 @@  discard block
 block discarded – undo
1762 1762
 
1763 1763
     // We remove old parameters for all keys in $tab
1764 1764
     $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_param";
1765
-    $sql .= " WHERE fk_user = " . ((int)$user->id);
1766
-    $sql .= " AND entity = " . ((int)$conf->entity);
1765
+    $sql .= " WHERE fk_user = " . ((int) $user->id);
1766
+    $sql .= " AND entity = " . ((int) $conf->entity);
1767 1767
     $sql .= " AND param in (";
1768 1768
     $i = 0;
1769 1769
     foreach ($tab as $key => $value) {
@@ -1787,7 +1787,7 @@  discard block
 block discarded – undo
1787 1787
         // Set new parameters
1788 1788
         if ($value) {
1789 1789
             $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_param(fk_user,entity,param,value)";
1790
-            $sql .= " VALUES (" . ((int)$user->id) . "," . ((int)$conf->entity) . ",";
1790
+            $sql .= " VALUES (" . ((int) $user->id) . "," . ((int) $conf->entity) . ",";
1791 1791
             $sql .= " '" . $db->escape($key) . "','" . $db->escape($value) . "')";
1792 1792
 
1793 1793
             dol_syslog("functions2.lib::dol_set_user_param", LOG_DEBUG);
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
     $rgb['g'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
2550 2550
     $rgb['b'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
2551 2551
     if ($alpha !== false) {
2552
-        $rgb['a'] = (float)$alpha;
2552
+        $rgb['a'] = (float) $alpha;
2553 2553
         $string = 'rgba(' . implode(',', array_map('strval', $rgb)) . ')';
2554 2554
     } else {
2555 2555
         $string = 'rgb(' . implode(',', array_map('strval', $rgb)) . ')';
@@ -2882,7 +2882,7 @@  discard block
 block discarded – undo
2882 2882
         $code = ob_get_clean();
2883 2883
         $code = strip_tags($code);
2884 2884
         if (preg_match("'syntax error, (.+) in .+ on line (\d+)$'s", $code, $code)) {
2885
-            $code[2] = (int)$code[2];
2885
+            $code[2] = (int) $code[2];
2886 2886
             $code = $code[2] <= $braces
2887 2887
                 ? array($code[1], $code[2])
2888 2888
                 : array('unexpected $end' . substr($code[1], 14), $braces);
Please login to merge, or discard this patch.
Dolibarr/Core/Model/Constant.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
             $query->where('entity', $entity);
156 156
         }
157 157
         return $query
158
-            ->get(['name', 'entity', 'value']);  // Return only the columns 'name', 'entity' y 'value'.
158
+            ->get(['name', 'entity', 'value']); // Return only the columns 'name', 'entity' y 'value'.
159 159
     }
160 160
 
161 161
     public static function deleteByNameLike(string $name_like, ?int $entity = null): ?bool
@@ -218,6 +218,6 @@  discard block
 block discarded – undo
218 218
             ->orWhere('name', 'LIKE', 'MAIN_MODULE_%_MODULEFOREXTERNAL')
219 219
             ->orderBy('name')
220 220
             ->orderBy('entity')
221
-            ->get(['name', 'entity', 'value']);  // Return only the columns 'name', 'entity' y 'value'.
221
+            ->get(['name', 'entity', 'value']); // Return only the columns 'name', 'entity' y 'value'.
222 222
     }
223 223
 }
Please login to merge, or discard this patch.
Dolibarr/Core/Base/DolibarrModules.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -555,9 +555,9 @@  discard block
 block discarded – undo
555 555
 
556 556
                 // If the module is active
557 557
                 foreach ($this->rights as $key => $value) {
558
-                    $r_id = $this->rights[$key][self::KEY_ID];  // permission id in llx_rights_def (not unique because primary key is couple id-entity)
558
+                    $r_id = $this->rights[$key][self::KEY_ID]; // permission id in llx_rights_def (not unique because primary key is couple id-entity)
559 559
                     $r_label = $this->rights[$key][self::KEY_LABEL];
560
-                    $r_type = $this->rights[$key][self::KEY_TYPE] ?? 'w';   // TODO deprecated
560
+                    $r_type = $this->rights[$key][self::KEY_TYPE] ?? 'w'; // TODO deprecated
561 561
                     $r_default = $this->rights[$key][self::KEY_DEFAULT] ?? 0;
562 562
                     $r_perms = $this->rights[$key][self::KEY_FIRST_LEVEL] ?? '';
563 563
                     $r_subperms = $this->rights[$key][self::KEY_SECOND_LEVEL] ?? '';
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 
586 586
                     // Search if perm already present
587 587
                     $sql = "SELECT count(*) as nb FROM " . MAIN_DB_PREFIX . "rights_def";
588
-                    $sql .= " WHERE entity = " . ((int)$entity);
589
-                    $sql .= " AND id = " . ((int)$r_id);
588
+                    $sql .= " WHERE entity = " . ((int) $entity);
589
+                    $sql .= " AND id = " . ((int) $r_id);
590 590
 
591 591
                     $resqlselect = $this->db->query($sql);
592 592
                     if ($resqlselect) {
@@ -598,19 +598,19 @@  discard block
 block discarded – undo
598 598
                             $sql .= ", libelle";
599 599
                             $sql .= ", module";
600 600
                             $sql .= ", module_origin";
601
-                            $sql .= ", type";   // TODO deprecated
601
+                            $sql .= ", type"; // TODO deprecated
602 602
                             $sql .= ", bydefault";
603 603
                             $sql .= ", perms";
604 604
                             $sql .= ", subperms";
605 605
                             $sql .= ", enabled";
606 606
                             $sql .= ") VALUES (";
607
-                            $sql .= ((int)$r_id);
608
-                            $sql .= ", " . ((int)$entity);
607
+                            $sql .= ((int) $r_id);
608
+                            $sql .= ", " . ((int) $entity);
609 609
                             $sql .= ", '" . $this->db->escape($r_label) . "'";
610 610
                             $sql .= ", '" . $this->db->escape($r_module) . "'";
611 611
                             $sql .= ", '" . $this->db->escape($r_module_origin) . "'";
612
-                            $sql .= ", '" . $this->db->escape($r_type) . "'";   // TODO deprecated
613
-                            $sql .= ", " . ((int)$r_default);
612
+                            $sql .= ", '" . $this->db->escape($r_type) . "'"; // TODO deprecated
613
+                            $sql .= ", " . ((int) $r_default);
614 614
                             $sql .= ", '" . $this->db->escape($r_perms) . "'";
615 615
                             $sql .= ", '" . $this->db->escape($r_subperms) . "'";
616 616
                             $sql .= ", '" . $this->db->escape($r_enabled) . "'";
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
         }
847 847
 
848 848
         // Run complementary sql requests
849
-        $num = count((array)$array_sql);
849
+        $num = count((array) $array_sql);
850 850
         for ($i = 0; $i < $num; $i++) {
851 851
             if (!$err) {
852 852
                 dol_syslog(get_only_class($this) . "::_remove", LOG_DEBUG);
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
                 $moduleNameInConf = 'supplier_proposal';
872 872
             }
873 873
 
874
-            unset($conf->modules[$moduleNameInConf]);   // Add this module in list of enabled modules so isModEnabled() will work (conf->module->enabled must no more be used)
874
+            unset($conf->modules[$moduleNameInConf]); // Add this module in list of enabled modules so isModEnabled() will work (conf->module->enabled must no more be used)
875 875
 
876 876
             return 1;
877 877
         } else {
@@ -1050,7 +1050,7 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
                 $sql = "DELETE FROM " . MAIN_DB_PREFIX . "boxes_def";
1052 1052
                 $sql .= " WHERE file = '" . $this->db->escape($file) . "'";
1053
-                $sql .= " AND entity = " . $conf->entity;     // Do not use getEntity here, we want to delete only in current company
1053
+                $sql .= " AND entity = " . $conf->entity; // Do not use getEntity here, we want to delete only in current company
1054 1054
 
1055 1055
                 dol_syslog(get_only_class($this) . "::delete_boxes", LOG_DEBUG);
1056 1056
                 $resql = $this->db->query($sql);
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
         // Delete all entities if core module
1115 1115
         if (empty($this->core_enabled)) {
1116
-            $sql .= " AND entity = " . ((int)$conf->entity);
1116
+            $sql .= " AND entity = " . ((int) $conf->entity);
1117 1117
         }
1118 1118
 
1119 1119
         dol_syslog(get_only_class($this) . "::delete_permissions", LOG_DEBUG);
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 
1143 1143
         $sql = "DELETE FROM " . MAIN_DB_PREFIX . "menu";
1144 1144
         $sql .= " WHERE module = '" . $this->db->escape($module) . "'";
1145
-        $sql .= " AND menu_handler = 'all'";    // We delete only lines that were added manually or by the module activation. We keep entry added by menuhandler like 'auguria'
1145
+        $sql .= " AND menu_handler = 'all'"; // We delete only lines that were added manually or by the module activation. We keep entry added by menuhandler like 'auguria'
1146 1146
         $sql .= " AND entity IN (0, " . $conf->entity . ")";
1147 1147
 
1148 1148
         dol_syslog(get_only_class($this) . "::delete_menus", LOG_DEBUG);
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
         if ($pathoffile) {     // Mostly for external modules
1197 1197
             $content = file_get_contents($pathoffile, false, null, 0, 1024 * 1024); // Max size loaded 1Mb
1198 1198
 
1199
-            if ((float)DOL_VERSION >= 6.0) {
1199
+            if ((float) DOL_VERSION >= 6.0) {
1200 1200
                 @include_once DOL_DOCUMENT_ROOT . '/core/lib/parsemd.lib.php';
1201 1201
 
1202 1202
                 $content = dolMd2Html(
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
         if ($filefound) {     // Mostly for external modules
1297 1297
             $content = file_get_contents($pathoffile);
1298 1298
 
1299
-            if ((float)DOL_VERSION >= 6.0) {
1299
+            if ((float) DOL_VERSION >= 6.0) {
1300 1300
                 @include_once DOL_DOCUMENT_ROOT . '/core/lib/parsemd.lib.php';
1301 1301
 
1302 1302
                 $content = dolMd2Html($content, 'parsedown', array('doc/' => dol_buildpath(strtolower($this->name) . '/doc/', 1)));
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                     $ignoreerror = $val['ignoreerror'];
1575 1575
                 }
1576 1576
                 // Add current entity id
1577
-                $sql = str_replace('__ENTITY__', (string)$conf->entity, $sql);
1577
+                $sql = str_replace('__ENTITY__', (string) $conf->entity, $sql);
1578 1578
 
1579 1579
                 dol_syslog(get_only_class($this) . "::_init ignoreerror=" . $ignoreerror, LOG_DEBUG);
1580 1580
                 $result = $this->db->query($sql, $ignoreerror);
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
                                 }
1952 1952
 
1953 1953
                                 $sql = "INSERT INTO " . MAIN_DB_PREFIX . "boxes (box_id, position, box_order, fk_user, entity)";
1954
-                                $sql .= " VALUES (" . ((int)$lastid) . ", " . ((int)$key2) . ", '0', 0, " . ((int)$conf->entity) . ")";
1954
+                                $sql .= " VALUES (" . ((int) $lastid) . ", " . ((int) $key2) . ", '0', 0, " . ((int) $conf->entity) . ")";
1955 1955
 
1956 1956
                                 dol_syslog(get_only_class($this) . "::insert_boxes onto page " . $key2 . "=" . $val2, LOG_DEBUG);
1957 1957
                                 $resql = $this->db->query($sql);
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
                 if ($parameters) {
2035 2035
                     $sql .= " AND params = '".$this->db->escape($parameters)."'";
2036 2036
                 }*/
2037
-                $sql .= " AND entity = " . ((int)$entity); // Must be exact entity
2037
+                $sql .= " AND entity = " . ((int) $entity); // Must be exact entity
2038 2038
 
2039 2039
                 $now = dol_now();
2040 2040
 
@@ -2082,7 +2082,7 @@  discard block
 block discarded – undo
2082 2082
                                 $sql .= "'" . $this->db->escape($priority) . "', ";
2083 2083
                             }
2084 2084
                             if (is_int($status)) {
2085
-                                $sql .= ((int)$status) . ", ";
2085
+                                $sql .= ((int) $status) . ", ";
2086 2086
                             }
2087 2087
                             $sql .= $entity . ",";
2088 2088
                             $sql .= "'" . $this->db->escape($test) . "'";
@@ -2394,7 +2394,7 @@  discard block
 block discarded – undo
2394 2394
 
2395 2395
         $return .= '<div class="valignmiddle inline-block info-box-more">';
2396 2396
         //if ($versiontrans) print img_warning($langs->trans("Version").' '.$this->getVersion(1)).' ';
2397
-        $return .= '<a class="valignmiddle inline-block" href="javascript:document_preview(\'' . constant('BASE_URL') . '/admin/modulehelp.php?id=' . ((int)$this->numero) . '\',\'text/html\',\'' . dol_escape_js($langs->trans("Module")) . '\')">' . img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule") . ' - ' : '') . $langs->trans("ClickToShowDescription"), $imginfo) . '</a>';
2397
+        $return .= '<a class="valignmiddle inline-block" href="javascript:document_preview(\'' . constant('BASE_URL') . '/admin/modulehelp.php?id=' . ((int) $this->numero) . '\',\'text/html\',\'' . dol_escape_js($langs->trans("Module")) . '\')">' . img_picto(($this->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule") . ' - ' : '') . $langs->trans("ClickToShowDescription"), $imginfo) . '</a>';
2398 2398
         $return .= '</div><br>';
2399 2399
 
2400 2400
         $return .= '<div class="valignmiddle inline-block info-box-actions">';
@@ -2550,7 +2550,7 @@  discard block
 block discarded – undo
2550 2550
     {
2551 2551
         require_once constant('DOL_DOCUMENT_ROOT') . '/core/lib/geturl.lib.php';
2552 2552
         if (!empty($this->url_last_version)) {
2553
-            $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0);    // Accept http or https links on external remote server only
2553
+            $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, array(), array('http', 'https'), 0); // Accept http or https links on external remote server only
2554 2554
             if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) {
2555 2555
                 // Security warning :  be careful with remote data content, the module editor could be hacked (or evil) so limit to a-z A-Z 0-9 _ . -
2556 2556
                 $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/", "", $lastVersion['content']);
Please login to merge, or discard this patch.
Dolibarr/Modules/Api.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -148,11 +148,11 @@
 block discarded – undo
148 148
 
149 149
         // Add here list of permission defined by an id, a label, a boolean and two constant strings.
150 150
         // Example:
151
-        $this->rights[$r][0] = $this->numero + $r;  // Permission id (must not be already used)
151
+        $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used)
152 152
         $this->rights[$r][1] = 'Generate/modify users API key'; // Permission label
153
-        $this->rights[$r][3] = 0;                   // Permission by default for new user (0/1)
154
-        $this->rights[$r][4] = 'apikey';                // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2'))
155
-        $this->rights[$r][5] = 'generate';              // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2'))
153
+        $this->rights[$r][3] = 0; // Permission by default for new user (0/1)
154
+        $this->rights[$r][4] = 'apikey'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2'))
155
+        $this->rights[$r][5] = 'generate'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2'))
156 156
         $r++;
157 157
 
158 158
 
Please login to merge, or discard this patch.
public/htdocs/install/repair.php 1 patch
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption : 0;
154 154
 $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey : '';
155 155
 
156
-$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int)$conf->db->port);
156
+$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port);
157 157
 new Database();
158 158
 
159 159
 if ($db->connected) {
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
         $name = $reg[1];
392 392
 
393 393
         if (GETPOST('standard', 'alpha') !== 'confirmed') {
394
-            print '<tr><td>Widget ' . $constant->name . ' set in entity ' . $constant->entity . ' with value ' . $constant->value . ' -> Module ' . $name . ' not enabled in entity ' . ((int)$constant->entity) . ', we should delete record (not done, mode test)</td></tr>';
394
+            print '<tr><td>Widget ' . $constant->name . ' set in entity ' . $constant->entity . ' with value ' . $constant->value . ' -> Module ' . $name . ' not enabled in entity ' . ((int) $constant->entity) . ', we should delete record (not done, mode test)</td></tr>';
395 395
             continue;
396 396
         }
397 397
 
398
-        print '<tr><td>Widget ' . $constant->name . ' set in entity ' . $constant->entity . ' with value ' . $constant->value . ' -> Module ' . $name . ' not enabled in entity ' . ((int)$constant->entity) . ', we delete record</td></tr>';
398
+        print '<tr><td>Widget ' . $constant->name . ' set in entity ' . $constant->entity . ' with value ' . $constant->value . ' -> Module ' . $name . ' not enabled in entity ' . ((int) $constant->entity) . ', we delete record</td></tr>';
399 399
         Constant::deleteByName($constant->name, $constant->entity);
400 400
     }
401 401
 }
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
                     $module_instance = Constant::getByName('MAIN_MODULE_' . $module, $obj->entity);
427 427
                     if ($module_instance && $module_instance->value !== 0) {
428 428
                         // Module not found, so we canremove entry
429
-                        $sqldeletea = "DELETE FROM " . MAIN_DB_PREFIX . "boxes WHERE entity = " . ((int)$obj->entity) . " AND box_id IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "boxes_def WHERE file = '" . $db->escape($obj->file) . "' AND entity = " . ((int)$obj->entity) . ")";
430
-                        $sqldeleteb = "DELETE FROM " . MAIN_DB_PREFIX . "boxes_def WHERE file = '" . $db->escape($obj->file) . "' AND entity = " . ((int)$obj->entity);
429
+                        $sqldeletea = "DELETE FROM " . MAIN_DB_PREFIX . "boxes WHERE entity = " . ((int) $obj->entity) . " AND box_id IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "boxes_def WHERE file = '" . $db->escape($obj->file) . "' AND entity = " . ((int) $obj->entity) . ")";
430
+                        $sqldeleteb = "DELETE FROM " . MAIN_DB_PREFIX . "boxes_def WHERE file = '" . $db->escape($obj->file) . "' AND entity = " . ((int) $obj->entity);
431 431
 
432 432
                         if (GETPOST('standard', 'alpha') == 'confirmed') {
433 433
                             $db->query($sqldeletea);
434 434
                             $db->query($sqldeleteb);
435 435
 
436
-                            print '<tr><td>Constant ' . $obj->file . ' set in boxes_def for entity ' . $obj->entity . ' but MAIN_MODULE_' . strtoupper($module) . ' not defined in entity ' . ((int)$obj->entity) . ', we delete record</td></tr>';
436
+                            print '<tr><td>Constant ' . $obj->file . ' set in boxes_def for entity ' . $obj->entity . ' but MAIN_MODULE_' . strtoupper($module) . ' not defined in entity ' . ((int) $obj->entity) . ', we delete record</td></tr>';
437 437
                         } else {
438
-                            print '<tr><td>Constant ' . $obj->file . ' set in boxes_def for entity ' . $obj->entity . ' but MAIN_MODULE_' . strtoupper($module) . ' not defined in entity ' . ((int)$obj->entity) . ', we should delete record (not done, mode test)</td></tr>';
438
+                            print '<tr><td>Constant ' . $obj->file . ' set in boxes_def for entity ' . $obj->entity . ' but MAIN_MODULE_' . strtoupper($module) . ' not defined in entity ' . ((int) $obj->entity) . ', we should delete record (not done, mode test)</td></tr>';
439 439
                         }
440 440
                     }
441 441
                 }
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
             if (!empty($name)) {
482 482
                 $filetotest = $dolibarr_main_data_root . '/societe/logos/' . $name . $ext;
483 483
                 $filetotestsmall = $dolibarr_main_data_root . '/societe/logos/thumbs/' . $name . '_small' . $ext;
484
-                $exists = (int)dol_is_file($filetotest);
484
+                $exists = (int) dol_is_file($filetotest);
485 485
                 print 'Check thirdparty ' . $obj->rowid . ' name=' . $obj->name . ' logo=' . $obj->logo . ' file ' . $filetotest . " exists=" . $exists . "<br>\n";
486 486
                 if ($exists) {
487 487
                     $filetarget = $dolibarr_main_data_root . '/societe/' . $obj->rowid . '/logos/' . $name . $ext;
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 $filetotest = $dolibarr_main_data_root . '/users/' . substr(sprintf('%08d', $obj->rowid), -1, 1) . '/' . substr(sprintf('%08d', $obj->rowid), -2, 1) . '/' . $name . $ext;
556 556
                 $filetotestsmall = $dolibarr_main_data_root . '/users/' . substr(sprintf('%08d', $obj->rowid), -1, 1) . '/' . substr(sprintf('%08d', $obj->rowid), -2, 1) . '/thumbs/' . $name . '_small' . $ext;
557 557
                 $filetotestmini = $dolibarr_main_data_root . '/users/' . substr(sprintf('%08d', $obj->rowid), -1, 1) . '/' . substr(sprintf('%08d', $obj->rowid), -2, 1) . '/thumbs/' . $name . '_mini' . $ext;
558
-                $exists = (int)dol_is_file($filetotest);
558
+                $exists = (int) dol_is_file($filetotest);
559 559
                 print 'Check user ' . $obj->rowid . ' lastname=' . $obj->lastname . ' firstname=' . $obj->firstname . ' photo=' . $obj->photo . ' file ' . $filetotest . " exists=" . $exists . "<br>\n";
560 560
                 if ($exists) {
561 561
                     $filetarget = $dolibarr_main_data_root . '/users/' . $obj->rowid . '/' . $name . $ext;
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
                         // If product is not a product that support batches, we can clean stock by deleting the product batch lines
916 916
                         print ' -> Delete qty ' . $obj->reelbatch . ' for any lot linked to fk_product_stock=' . $obj->psrowid;
917 917
                         $sql2 = "DELETE FROM " . MAIN_DB_PREFIX . "product_batch";
918
-                        $sql2 .= " WHERE fk_product_stock = " . ((int)$obj->psrowid);
918
+                        $sql2 .= " WHERE fk_product_stock = " . ((int) $obj->psrowid);
919 919
                         print '<br>' . $sql2;
920 920
 
921 921
                         if (GETPOST('clean_product_stock_batch') == 'confirmed') {
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                             // Method 1
931 931
                             print ' -> Insert qty ' . ($obj->reel - $obj->reelbatch) . ' with lot 000000 linked to fk_product_stock=' . $obj->psrowid;
932 932
                             $sql2 = "INSERT INTO " . MAIN_DB_PREFIX . "product_batch(fk_product_stock, batch, qty)";
933
-                            $sql2 .= "VALUES(" . ((int)$obj->psrowid) . ", '000000', " . ((float)($obj->reel - $obj->reelbatch)) . ")";
933
+                            $sql2 .= "VALUES(" . ((int) $obj->psrowid) . ", '000000', " . ((float) ($obj->reel - $obj->reelbatch)) . ")";
934 934
                             print '<br>' . $sql2;
935 935
 
936 936
                             if (GETPOST('clean_product_stock_batch') == 'confirmed') {
@@ -945,9 +945,9 @@  discard block
 block discarded – undo
945 945
                         }
946 946
                         if ($methodtofix == 'updatestock') {
947 947
                             // Method 2
948
-                            print ' -> Update qty of product_stock with qty = ' . ($obj->reelbatch ? ((float)$obj->reelbatch) : '0') . ' for ps.rowid = ' . ((int)$obj->psrowid);
948
+                            print ' -> Update qty of product_stock with qty = ' . ($obj->reelbatch ? ((float) $obj->reelbatch) : '0') . ' for ps.rowid = ' . ((int) $obj->psrowid);
949 949
                             $sql2 = "UPDATE " . MAIN_DB_PREFIX . "product_stock";
950
-                            $sql2 .= " SET reel = " . ($obj->reelbatch ? ((float)$obj->reelbatch) : '0') . " WHERE rowid = " . ((int)$obj->psrowid);
950
+                            $sql2 .= " SET reel = " . ($obj->reelbatch ? ((float) $obj->reelbatch) : '0') . " WHERE rowid = " . ((int) $obj->psrowid);
951 951
                             print '<br>' . $sql2;
952 952
 
953 953
                             if (GETPOST('clean_product_stock_batch') == 'confirmed') {
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
 
1043 1043
                 if (GETPOST('set_empty_time_spent_amount') == 'confirmed') {
1044 1044
                     $sql2 = "UPDATE " . MAIN_DB_PREFIX . "element_time";
1045
-                    $sql2 .= " SET thm = " . $obj->user_thm . " WHERE thm IS NULL AND fk_user = " . ((int)$obj->user_id);
1045
+                    $sql2 .= " SET thm = " . $obj->user_thm . " WHERE thm IS NULL AND fk_user = " . ((int) $obj->user_id);
1046 1046
                     $resql2 = $db->query($sql2);
1047 1047
                     if (!$resql2) {
1048 1048
                         $error++;
@@ -1107,13 +1107,13 @@  discard block
 block discarded – undo
1107 1107
             }
1108 1108
             if ($key == 'js') {
1109 1109
                 $value = $obj->value;
1110
-                $valuearray = (array)json_decode($value);  // Force cast into array because sometimes it is a stdClass
1110
+                $valuearray = (array) json_decode($value); // Force cast into array because sometimes it is a stdClass
1111 1111
                 $reloffile = $valuearray[0];
1112 1112
                 $reloffile = preg_replace('/^\//', '', $valuearray[0]);
1113 1113
             }
1114 1114
             if ($key == 'css') {
1115 1115
                 $value = $obj->value;
1116
-                $valuearray = (array)json_decode($value);  // Force cast into array because sometimes it is a stdClass
1116
+                $valuearray = (array) json_decode($value); // Force cast into array because sometimes it is a stdClass
1117 1117
                 if ($value && (!is_array($valuearray) || count($valuearray) == 0)) {
1118 1118
                     $valuearray = array();
1119 1119
                     $valuearray[0] = $value; // If value was not a json array but a string
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
                     $result = 'found'; // If error, we force like if we found to avoid any deletion
1130 1130
                 }
1131 1131
             } else {
1132
-                $result = 'found';  //
1132
+                $result = 'found'; //
1133 1133
             }
1134 1134
 
1135 1135
             if (!$result) {
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
                 if ($obj->id > 0) {
1182 1182
                     print '<tr><td>Found line with id ' . $obj->id . ', label "' . $obj->label . '" of module "' . $obj->module . '" to delete';
1183 1183
                     if (GETPOST('clean_perm_table', 'alpha') == 'confirmed') {
1184
-                        $sqldelete = "DELETE FROM " . MAIN_DB_PREFIX . "rights_def WHERE id = " . ((int)$obj->id);
1184
+                        $sqldelete = "DELETE FROM " . MAIN_DB_PREFIX . "rights_def WHERE id = " . ((int) $obj->id);
1185 1185
                         $resqldelete = $db->query($sqldelete);
1186 1186
                         if (!$resqldelete) {
1187 1187
                             dol_print_error($db);
@@ -1433,8 +1433,8 @@  discard block
 block discarded – undo
1433 1433
         }
1434 1434
         while ($obj_dispatch = $db->fetch_object($resql_dispatch)) {
1435 1435
             $sql_line = 'SELECT line.rowid, line.qty FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet AS line';
1436
-            $sql_line .= ' WHERE line.fk_commande = ' . ((int)$obj_dispatch->fk_commande);
1437
-            $sql_line .= ' AND   line.fk_product  = ' . ((int)$obj_dispatch->fk_product);
1436
+            $sql_line .= ' WHERE line.fk_commande = ' . ((int) $obj_dispatch->fk_commande);
1437
+            $sql_line .= ' AND   line.fk_product  = ' . ((int) $obj_dispatch->fk_product);
1438 1438
             $resql_line = $db->query($sql_line);
1439 1439
 
1440 1440
             // s’il y a plusieurs lignes avec le même produit sur cette commande fournisseur,
@@ -1462,20 +1462,20 @@  discard block
 block discarded – undo
1462 1462
                 $qty_for_line = min($remaining_qty, $obj_line->qty);
1463 1463
                 if ($first_iteration) {
1464 1464
                     $sql_attach = 'UPDATE ' . MAIN_DB_PREFIX . 'receptiondet_batch';
1465
-                    $sql_attach .= ' SET fk_elementdet = ' . ((int)$obj_line->rowid) . ', qty = ' . ((float)$qty_for_line);
1466
-                    $sql_attach .= ' WHERE rowid = ' . ((int)$obj_dispatch->rowid);
1465
+                    $sql_attach .= ' SET fk_elementdet = ' . ((int) $obj_line->rowid) . ', qty = ' . ((float) $qty_for_line);
1466
+                    $sql_attach .= ' WHERE rowid = ' . ((int) $obj_dispatch->rowid);
1467 1467
                     $first_iteration = false;
1468 1468
                 } else {
1469 1469
                     $sql_attach_values = array(
1470
-                        (string)((int)$obj_dispatch->fk_element),
1471
-                        (string)((int)$obj_dispatch->fk_product),
1472
-                        (string)((int)$obj_line->rowid),
1473
-                        (string)((float)$qty_for_line),
1474
-                        (string)((int)$obj_dispatch->fk_entrepot),
1475
-                        (string)((int)$obj_dispatch->fk_user),
1470
+                        (string) ((int) $obj_dispatch->fk_element),
1471
+                        (string) ((int) $obj_dispatch->fk_product),
1472
+                        (string) ((int) $obj_line->rowid),
1473
+                        (string) ((float) $qty_for_line),
1474
+                        (string) ((int) $obj_dispatch->fk_entrepot),
1475
+                        (string) ((int) $obj_dispatch->fk_user),
1476 1476
                         $obj_dispatch->datec ? "'" . $db->idate($db->jdate($obj_dispatch->datec)) . "'" : 'NULL',
1477 1477
                         $obj_dispatch->comment ? "'" . $db->escape($obj_dispatch->comment) . "'" : 'NULL',
1478
-                        $obj_dispatch->status ? (string)((int)$obj_dispatch->status) : 'NULL',
1478
+                        $obj_dispatch->status ? (string) ((int) $obj_dispatch->status) : 'NULL',
1479 1479
                         $obj_dispatch->tms ? "'" . $db->idate($db->jdate($obj_dispatch->tms)) . "'" : 'NULL',
1480 1480
                         $obj_dispatch->batch ? "'" . $db->escape($obj_dispatch->batch) . "'" : 'NULL',
1481 1481
                         $obj_dispatch->eatby ? "'" . $db->escape($obj_dispatch->eatby) . "'" : 'NULL',
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
                     $sql_attach = 'INSERT INTO ' . MAIN_DB_PREFIX . 'receptiondet_batch';
1487 1487
                     $sql_attach .= ' (fk_element, fk_product, fk_elementdet, qty, fk_entrepot, fk_user, datec, comment, status, tms, batch, eatby, sellby)';
1488
-                    $sql_attach .= " VALUES (" . $sql_attach_values . ")";  // The string is already sanitized
1488
+                    $sql_attach .= " VALUES (" . $sql_attach_values . ")"; // The string is already sanitized
1489 1489
                 }
1490 1490
 
1491 1491
                 if ($repair_link_dispatch_lines_supplier_order_lines == 'confirmed') {
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
             $newRef = $supplierOrder->getNextNumRef($soc);
1567 1567
 
1568
-            $sql = "UPDATE " . MAIN_DB_PREFIX . "commande_fournisseur cf SET cf.ref = '" . $db->escape($newRef) . "' WHERE cf.rowid = " . (int)$supplierOrder->id;
1568
+            $sql = "UPDATE " . MAIN_DB_PREFIX . "commande_fournisseur cf SET cf.ref = '" . $db->escape($newRef) . "' WHERE cf.rowid = " . (int) $supplierOrder->id;
1569 1569
             if (!$db->query($sql)) {
1570 1570
                 $err++;
1571 1571
             }
Please login to merge, or discard this patch.