@@ -217,7 +217,7 @@ |
||
217 | 217 | { |
218 | 218 | $string = ""; |
219 | 219 | $chaine = "abcdefghijklmnopqrstuvwxyz123456789"; |
220 | - mt_srand((int)((float)microtime() * 1000000)); |
|
220 | + mt_srand((int) ((float) microtime() * 1000000)); |
|
221 | 221 | for ($i = 0; $i < $car; $i++) { |
222 | 222 | $string .= $chaine[mt_rand() % strlen($chaine)]; |
223 | 223 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | // For MultiCompany module. |
44 | 44 | // Do not use GETPOST here, function is not defined and this test must be done before including main.inc.php |
45 | 45 | // Because 2 entities can have the same ref. |
46 | -$entity = (!empty($_GET['e']) ? (int)$_GET['e'] : (!empty($_POST['e']) ? (int)$_POST['e'] : 1)); |
|
46 | +$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); |
|
47 | 47 | if (is_numeric($entity)) { |
48 | 48 | define("DOLENTITY", $entity); |
49 | 49 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | // For MultiCompany module. |
46 | 46 | // Do not use GETPOST here, function is not defined and define must be done before including main.inc.php |
47 | 47 | // Because 2 entities can have the same ref. |
48 | -$entity = (!empty($_GET['e']) ? (int)$_GET['e'] : (!empty($_POST['e']) ? (int)$_POST['e'] : 1)); |
|
48 | +$entity = (!empty($_GET['e']) ? (int) $_GET['e'] : (!empty($_POST['e']) ? (int) $_POST['e'] : 1)); |
|
49 | 49 | if (is_numeric($entity)) { |
50 | 50 | define("DOLENTITY", $entity); |
51 | 51 | } |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $arrayofmassactions = array(); |
209 | 209 | |
210 | 210 | $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage; |
211 | -$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup |
|
211 | +$htmlofselectarray = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage, getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')); // This also change content of $arrayfields with user setup |
|
212 | 212 | $selectedfields = ($mode != 'kanban' ? $htmlofselectarray : ''); |
213 | 213 | $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); |
214 | 214 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | usort( |
296 | 296 | $moduleList, |
297 | 297 | /** @return int */ |
298 | - function (stdClass $a, stdClass $b) { |
|
298 | + function(stdClass $a, stdClass $b) { |
|
299 | 299 | return strcasecmp($a->name, $b->name); |
300 | 300 | } |
301 | 301 | ); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | usort( |
304 | 304 | $moduleList, |
305 | 305 | /** @return int */ |
306 | - static function (stdClass $a, stdClass $b) { |
|
306 | + static function(stdClass $a, stdClass $b) { |
|
307 | 307 | return strcasecmp($b->name, $a->name); |
308 | 308 | } |
309 | 309 | ); |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | usort( |
312 | 312 | $moduleList, |
313 | 313 | /** @return int */ |
314 | - static function (stdClass $a, stdClass $b) { |
|
314 | + static function(stdClass $a, stdClass $b) { |
|
315 | 315 | return strcasecmp($a->version, $b->version); |
316 | 316 | } |
317 | 317 | ); |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | usort( |
320 | 320 | $moduleList, |
321 | 321 | /** @return int */ |
322 | - static function (stdClass $a, stdClass $b) { |
|
322 | + static function(stdClass $a, stdClass $b) { |
|
323 | 323 | return strcasecmp($b->version, $a->version); |
324 | 324 | } |
325 | 325 | ); |
@@ -418,11 +418,11 @@ discard block |
||
418 | 418 | */ |
419 | 419 | function compareIdAsc(stdClass $a, stdClass $b) |
420 | 420 | { |
421 | - if ((int)$a->id == (int)$b->id) { |
|
421 | + if ((int) $a->id == (int) $b->id) { |
|
422 | 422 | return 0; |
423 | 423 | } |
424 | 424 | |
425 | - return ((int)$a->id < (int)$b->id) ? -1 : 1; |
|
425 | + return ((int) $a->id < (int) $b->id) ? -1 : 1; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | /** |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | */ |
435 | 435 | function compareIdDesc(stdClass $a, stdClass $b) |
436 | 436 | { |
437 | - if ((int)$a->id == (int)$b->id) { |
|
437 | + if ((int) $a->id == (int) $b->id) { |
|
438 | 438 | return 0; |
439 | 439 | } |
440 | 440 | |
441 | - return ((int)$b->id < (int)$a->id) ? -1 : 1; |
|
441 | + return ((int) $b->id < (int) $a->id) ? -1 : 1; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | // Force entity if a value is provided into HTTP header. Otherwise, will use the entity of user of token used. |
76 | 76 | if (!empty($_SERVER['HTTP_DOLAPIENTITY'])) { |
77 | - define("DOLENTITY", (int)$_SERVER['HTTP_DOLAPIENTITY']); |
|
77 | + define("DOLENTITY", (int) $_SERVER['HTTP_DOLAPIENTITY']); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | // Response for preflight requests (used by browser when into a CORS context) |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | // If MAIN_API_DEBUG is set to 1, we save logs into file "dolibarr_api.log" |
184 | 184 | if (getDolGlobalString('MAIN_API_DEBUG')) { |
185 | 185 | $r = $api->r; |
186 | - $r->onCall(function () use ($r) { |
|
186 | + $r->onCall(function() use ($r) { |
|
187 | 187 | // Don't log Luracast Restler Explorer resources calls |
188 | 188 | //if (!preg_match('/^explorer/', $r->url)) { |
189 | 189 | // 'method' => $api->r->requestMethod, |
@@ -448,8 +448,8 @@ discard block |
||
448 | 448 | $sql = "SELECT up.value"; |
449 | 449 | $sql .= " FROM " . MAIN_DB_PREFIX . "user_param as up"; |
450 | 450 | $sql .= " WHERE up.param = 'API_COUNT_CALL'"; |
451 | - $sql .= " AND up.fk_user = " . ((int)$userid); |
|
452 | - $sql .= " AND up.entity = " . ((int)$conf->entity); |
|
451 | + $sql .= " AND up.fk_user = " . ((int) $userid); |
|
452 | + $sql .= " AND up.entity = " . ((int) $conf->entity); |
|
453 | 453 | |
454 | 454 | $result = $db->query($sql); |
455 | 455 | if ($result) { |
@@ -458,14 +458,14 @@ discard block |
||
458 | 458 | if ($nbrows == 0) { |
459 | 459 | $sql2 = "INSERT INTO " . MAIN_DB_PREFIX . "user_param"; |
460 | 460 | $sql2 .= " (fk_user, entity, param, value)"; |
461 | - $sql2 .= " VALUES (" . ((int)$userid) . ", " . ((int)$conf->entity) . ", 'API_COUNT_CALL', 1)"; |
|
461 | + $sql2 .= " VALUES (" . ((int) $userid) . ", " . ((int) $conf->entity) . ", 'API_COUNT_CALL', 1)"; |
|
462 | 462 | } else { |
463 | 463 | $updateapi = true; |
464 | 464 | $sql2 = "UPDATE " . MAIN_DB_PREFIX . "user_param as up"; |
465 | 465 | $sql2 .= " SET up.value = up.value + 1"; |
466 | 466 | $sql2 .= " WHERE up.param = 'API_COUNT_CALL'"; |
467 | - $sql2 .= " AND up.fk_user = " . ((int)$userid); |
|
468 | - $sql2 .= " AND up.entity = " . ((int)$conf->entity); |
|
467 | + $sql2 .= " AND up.fk_user = " . ((int) $userid); |
|
468 | + $sql2 .= " AND up.entity = " . ((int) $conf->entity); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | $result2 = $db->query($sql2); |
@@ -153,8 +153,8 @@ discard block |
||
153 | 153 | $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def as r,"; |
154 | 154 | $sql .= " " . MAIN_DB_PREFIX . "usergroup_rights as gr"; |
155 | 155 | $sql .= " WHERE gr.fk_id = r.id"; |
156 | - $sql .= " AND gr.entity = " . ((int)$entity); |
|
157 | - $sql .= " AND gr.fk_usergroup = " . ((int)$object->id); |
|
156 | + $sql .= " AND gr.entity = " . ((int) $entity); |
|
157 | + $sql .= " AND gr.fk_usergroup = " . ((int) $object->id); |
|
158 | 158 | |
159 | 159 | dol_syslog("get user perms", LOG_DEBUG); |
160 | 160 | $result = $db->query($sql); |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | $sql = "SELECT r.id, r.libelle as label, r.module, r.perms, r.subperms, r.module_position, r.bydefault"; |
261 | 261 | $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def as r"; |
262 | 262 | $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" |
263 | - $sql .= " AND r.entity = " . ((int)$entity); |
|
263 | + $sql .= " AND r.entity = " . ((int) $entity); |
|
264 | 264 | if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { |
265 | 265 | $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is disable |
266 | 266 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $login = GETPOST('login', 'alpha') ? GETPOST('login', 'alpha') : (empty($argv[5]) ? '' : $argv[5]); |
78 | 78 | $pass = GETPOST('pass', 'alpha') ? GETPOST('pass', 'alpha') : (empty($argv[6]) ? '' : $argv[6]); |
79 | 79 | $pass_verif = GETPOST('pass_verif', 'alpha') ? GETPOST('pass_verif', 'alpha') : (empty($argv[7]) ? '' : $argv[7]); |
80 | -$force_install_lockinstall = (int)(!empty($force_install_lockinstall) ? $force_install_lockinstall : (GETPOST('installlock', 'aZ09') ? GETPOST('installlock', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]))); |
|
80 | +$force_install_lockinstall = (int) (!empty($force_install_lockinstall) ? $force_install_lockinstall : (GETPOST('installlock', 'aZ09') ? GETPOST('installlock', 'aZ09') : (empty($argv[8]) ? '' : $argv[8]))); |
|
81 | 81 | |
82 | 82 | $success = 0; |
83 | 83 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $conf->db->dolibarr_main_db_encryption = isset($dolibarr_main_db_encryption) ? $dolibarr_main_db_encryption : 0; |
170 | 170 | $conf->db->dolibarr_main_db_cryptkey = isset($dolibarr_main_db_cryptkey) ? $dolibarr_main_db_cryptkey : ''; |
171 | 171 | |
172 | - $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int)$conf->db->port); |
|
172 | + $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, (int) $conf->db->port); |
|
173 | 173 | |
174 | 174 | // Create the global $hookmanager object |
175 | 175 | include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; |
@@ -236,8 +236,8 @@ discard block |
||
236 | 236 | $newuser->admin = 1; |
237 | 237 | $newuser->entity = 0; |
238 | 238 | |
239 | - $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email |
|
240 | - $conf->global->USER_PASSWORD_GENERATED = ''; // To not use any rule for password validation |
|
239 | + $conf->global->USER_MAIL_REQUIRED = 0; // Force global option to be sure to create a new user with no email |
|
240 | + $conf->global->USER_PASSWORD_GENERATED = ''; // To not use any rule for password validation |
|
241 | 241 | |
242 | 242 | $result = $newuser->create($createuser, 1); |
243 | 243 | if ($result > 0) { |
@@ -317,8 +317,8 @@ discard block |
||
317 | 317 | // with |
318 | 318 | // 'INSERT INTO llx_accounting_account (entity, rowid, fk_pcg_version, pcg_type, account_number, account_parent, label, active) VALUES (__ENTITY__, 1401 + 200100000, 'PCG99-ABREGE','CAPIT', '1234', 1400 + 200100000,...' |
319 | 319 | // Note: string with 'PCG99-ABREGE','CAPIT', 1234 instead of 'PCG99-ABREGE','CAPIT', '1234' is also supported |
320 | - $newsql = preg_replace('/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims', 'VALUES (__ENTITY__, \1 + ' . ((int)$offsetforchartofaccount) . ', \2, \3 + ' . ((int)$offsetforchartofaccount), $newsql); |
|
321 | - $newsql = preg_replace('/([,\s])0 \+ ' . ((int)$offsetforchartofaccount) . '/ims', '\1 0', $newsql); |
|
320 | + $newsql = preg_replace('/VALUES\s*\(__ENTITY__, \s*(\d+)\s*,(\s*\'[^\',]*\'\s*,\s*\'[^\',]*\'\s*,\s*\'?[^\',]*\'?\s*),\s*\'?([^\',]*)\'?/ims', 'VALUES (__ENTITY__, \1 + ' . ((int) $offsetforchartofaccount) . ', \2, \3 + ' . ((int) $offsetforchartofaccount), $newsql); |
|
321 | + $newsql = preg_replace('/([,\s])0 \+ ' . ((int) $offsetforchartofaccount) . '/ims', '\1 0', $newsql); |
|
322 | 322 | //var_dump($newsql); |
323 | 323 | $arraysql[$i] = $newsql; |
324 | 324 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $sql = preg_replace('/__DATABASE__/i', $db->escape($database), $sql); |
418 | 418 | } |
419 | 419 | |
420 | - $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : (string)$conf->entity), $sql); |
|
420 | + $newsql = preg_replace('/__ENTITY__/i', (!empty($entity) ? $entity : (string) $conf->entity), $sql); |
|
421 | 421 | |
422 | 422 | // Add log of request |
423 | 423 | if (!$silent) { |
@@ -594,11 +594,11 @@ discard block |
||
594 | 594 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "const"; |
595 | 595 | $sql .= " WHERE (" . $db->decrypt('name') . " = '" . $db->escape($name) . "'"; |
596 | 596 | if (is_numeric($name)) { |
597 | - $sql .= " OR rowid = " . ((int)$name); |
|
597 | + $sql .= " OR rowid = " . ((int) $name); |
|
598 | 598 | } |
599 | 599 | $sql .= ")"; |
600 | 600 | if ($entity >= 0) { |
601 | - $sql .= " AND entity = " . ((int)$entity); |
|
601 | + $sql .= " AND entity = " . ((int) $entity); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | dol_syslog("admin.lib::dolibarr_del_const", LOG_DEBUG); |
@@ -629,7 +629,7 @@ discard block |
||
629 | 629 | $sql = "SELECT " . $db->decrypt('value') . " as value"; |
630 | 630 | $sql .= " FROM " . MAIN_DB_PREFIX . "const"; |
631 | 631 | $sql .= " WHERE name = " . $db->encrypt($name); |
632 | - $sql .= " AND entity = " . ((int)$entity); |
|
632 | + $sql .= " AND entity = " . ((int) $entity); |
|
633 | 633 | |
634 | 634 | dol_syslog("admin.lib::dolibarr_get_const", LOG_DEBUG); |
635 | 635 | $resql = $db->query($sql); |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "const"; |
679 | 679 | $sql .= " WHERE name = " . $db->encrypt($name); |
680 | 680 | if ($entity >= 0) { |
681 | - $sql .= " AND entity = " . ((int)$entity); |
|
681 | + $sql .= " AND entity = " . ((int) $entity); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | $sql .= " VALUES ("; |
701 | 701 | $sql .= $db->encrypt($name); |
702 | 702 | $sql .= ", " . $db->encrypt($newvalue); |
703 | - $sql .= ", '" . $db->escape($type) . "', " . ((int)$visible) . ", '" . $db->escape($note) . "', " . ((int)$entity) . ")"; |
|
703 | + $sql .= ", '" . $db->escape($type) . "', " . ((int) $visible) . ", '" . $db->escape($note) . "', " . ((int) $entity) . ")"; |
|
704 | 704 | |
705 | 705 | //print "sql".$value."-".pg_escape_string($value)."-".$sql;exit; |
706 | 706 | //print "xx".$db->escape($value); |
@@ -862,7 +862,7 @@ discard block |
||
862 | 862 | $sql = "SELECT COUNT(r.id) as nb"; |
863 | 863 | $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def as r"; |
864 | 864 | $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" |
865 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
865 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
866 | 866 | $sql .= " AND bydefault = 1"; |
867 | 867 | if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { |
868 | 868 | $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled |
@@ -1695,7 +1695,7 @@ discard block |
||
1695 | 1695 | $obj = $db->fetch_object($result); // Take first result of select |
1696 | 1696 | |
1697 | 1697 | if (empty($obj)) { // If not yet into table |
1698 | - $obj = (object)array('rowid' => '', 'name' => $const, 'value' => '', 'type' => $type, 'note' => ''); |
|
1698 | + $obj = (object) array('rowid' => '', 'name' => $const, 'value' => '', 'type' => $type, 'note' => ''); |
|
1699 | 1699 | } |
1700 | 1700 | |
1701 | 1701 | if (empty($strictw3c)) { |
@@ -1895,7 +1895,7 @@ discard block |
||
1895 | 1895 | $db->begin(); |
1896 | 1896 | |
1897 | 1897 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity, libelle, description)"; |
1898 | - $sql .= " VALUES ('" . $db->escape($name) . "','" . $db->escape($type) . "'," . ((int)$conf->entity) . ", "; |
|
1898 | + $sql .= " VALUES ('" . $db->escape($name) . "','" . $db->escape($type) . "'," . ((int) $conf->entity) . ", "; |
|
1899 | 1899 | $sql .= ($label ? "'" . $db->escape($label) . "'" : 'null') . ", "; |
1900 | 1900 | $sql .= (!empty($description) ? "'" . $db->escape($description) . "'" : "null"); |
1901 | 1901 | $sql .= ")"; |
@@ -1928,7 +1928,7 @@ discard block |
||
1928 | 1928 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "document_model"; |
1929 | 1929 | $sql .= " WHERE nom = '" . $db->escape($name) . "'"; |
1930 | 1930 | $sql .= " AND type = '" . $db->escape($type) . "'"; |
1931 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
1931 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
1932 | 1932 | |
1933 | 1933 | dol_syslog("admin.lib::delDocumentModel", LOG_DEBUG); |
1934 | 1934 | $resql = $db->query($sql); |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | // Add here list of permission defined by an id, a label, a boolean and two constant strings. |
145 | 145 | // Example: |
146 | - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) |
|
146 | + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) |
|
147 | 147 | $this->rights[$r][1] = 'Generate/modify users API key'; // Permission label |
148 | - $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
149 | - $this->rights[$r][4] = 'apikey'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2')) |
|
150 | - $this->rights[$r][5] = 'generate'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2')) |
|
148 | + $this->rights[$r][3] = 0; // Permission by default for new user (0/1) |
|
149 | + $this->rights[$r][4] = 'apikey'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2')) |
|
150 | + $this->rights[$r][5] = 'generate'; // In php code, permission will be checked by test if ($user->hasRight('permkey','level1','level2')) |
|
151 | 151 | $r++; |
152 | 152 | |
153 | 153 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | // Remove old constants with entity fields different of 0 |
232 | 232 | $sql = array( |
233 | - "DELETE FROM " . MAIN_DB_PREFIX . "const WHERE name = " . $this->db->encrypt('MAIN_MODULE_API'), // API can't be enabled per environment. Why ? |
|
233 | + "DELETE FROM " . MAIN_DB_PREFIX . "const WHERE name = " . $this->db->encrypt('MAIN_MODULE_API'), // API can't be enabled per environment. Why ? |
|
234 | 234 | "DELETE FROM " . MAIN_DB_PREFIX . "const WHERE name = " . $this->db->encrypt('API_PRODUCTION_MODE') // Not in production mode by default at activation |
235 | 235 | ); |
236 | 236 |