@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | // For dolistore search |
71 | 71 | $options = []; |
72 | 72 | $options['per_page'] = 20; |
73 | -$options['categorie'] = ((int)(GETPOSTINT('categorie') ? GETPOSTINT('categorie') : 0)); |
|
74 | -$options['start'] = ((int)(GETPOSTINT('start') ? GETPOSTINT('start') : 0)); |
|
75 | -$options['end'] = ((int)(GETPOSTINT('end') ? GETPOSTINT('end') : 0)); |
|
73 | +$options['categorie'] = ((int) (GETPOSTINT('categorie') ? GETPOSTINT('categorie') : 0)); |
|
74 | +$options['start'] = ((int) (GETPOSTINT('start') ? GETPOSTINT('start') : 0)); |
|
75 | +$options['end'] = ((int) (GETPOSTINT('end') ? GETPOSTINT('end') : 0)); |
|
76 | 76 | $options['search'] = GETPOST('search_keyword', 'alpha'); |
77 | 77 | $dolistore = new Dolistore(false); |
78 | 78 | |
@@ -311,13 +311,13 @@ discard block |
||
311 | 311 | exit; |
312 | 312 | } elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') { |
313 | 313 | $result = unActivateModule($value, 0); |
314 | - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int)$conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); |
|
314 | + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); |
|
315 | 315 | if ($result) { |
316 | 316 | setEventMessages($result, null, 'errors'); |
317 | 317 | header("Location: " . $_SERVER['PHP_SELF'] . "?mode=" . $mode . $param . ($page_y ? '&page_y=' . $page_y : '')); |
318 | 318 | } |
319 | 319 | $resarray = activateModule($value, 0, 1); |
320 | - dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int)$conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); |
|
320 | + dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); |
|
321 | 321 | if (!empty($resarray['errors'])) { |
322 | 322 | setEventMessages('', $resarray['errors'], 'errors'); |
323 | 323 | } else { |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | } else { |
463 | 463 | $familykey = $objMod->family; |
464 | 464 | } |
465 | - '@phan-var-force string $familykey'; // if not, phan considers $familykey may be null |
|
465 | + '@phan-var-force string $familykey'; // if not, phan considers $familykey may be null |
|
466 | 466 | |
467 | 467 | $moduleposition = ($objMod->module_position ? $objMod->module_position : '50'); |
468 | 468 | if ($objMod->isCoreOrExternalModule() == 'external' && $moduleposition < 100000) { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | if ($external && !in_array($familykey, $listOfOfficialModuleGroups)) { |
484 | 484 | // If module is extern and into a custom group (not into an official predefined one), it must appear at end (custom groups should not be before official groups). |
485 | 485 | if (is_numeric($familyposition)) { |
486 | - $familyposition = sprintf("%03d", (int)$familyposition + 100); |
|
486 | + $familyposition = sprintf("%03d", (int) $familyposition + 100); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | } |
941 | 941 | } |
942 | 942 | } |
943 | - } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string)$objMod->config_page_url, $regs)) { |
|
943 | + } elseif (preg_match('/^([^@]+)@([^@]+)$/i', (string) $objMod->config_page_url, $regs)) { |
|
944 | 944 | $codetoconfig .= '<a class="valignmiddle" href="' . dol_buildpath('/' . $regs[2] . '/admin/' . $regs[1], 1) . '?save_lastsearch_values=1&backtopage=' . urlencode($backtourl) . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15') . '</a>'; |
945 | 945 | } else { |
946 | - $codetoconfig .= '<a class="valignmiddle" href="' . ((string)$objMod->config_page_url) . '?save_lastsearch_values=1&backtopage=' . urlencode($backtourl) . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15') . '</a>'; |
|
946 | + $codetoconfig .= '<a class="valignmiddle" href="' . ((string) $objMod->config_page_url) . '?save_lastsearch_values=1&backtopage=' . urlencode($backtourl) . '" title="' . $langs->trans("Setup") . '">' . img_picto($langs->trans("Setup"), "setup", 'style="padding-right: 6px"', false, 0, 0, '', 'fa-15') . '</a>'; |
|
947 | 947 | } |
948 | 948 | } else { |
949 | 949 | $codetoconfig .= img_picto($langs->trans("NothingToSetup"), "setup", 'class="opacitytransp" style="padding-right: 6px"', false, 0, 0, '', 'fa-15'); |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | // Help |
1039 | 1039 | print '<td class="center nowrap" style="width: 82px;">'; |
1040 | 1040 | //print $form->textwithpicto('', $text, 1, $imginfo, 'minheight20', 0, 2, 1); |
1041 | - print '<a href="javascript:document_preview(\'' . DOL_URL_ROOT . '/admin/modulehelp.php?id=' . ((int)$objMod->numero) . '\',\'text/html\',\'' . dol_escape_js($langs->trans("Module")) . '\')">' . img_picto(($objMod->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule") . ' - ' : '') . $langs->trans("ClickToShowDescription"), $imginfo) . '</a>'; |
|
1041 | + print '<a href="javascript:document_preview(\'' . DOL_URL_ROOT . '/admin/modulehelp.php?id=' . ((int) $objMod->numero) . '\',\'text/html\',\'' . dol_escape_js($langs->trans("Module")) . '\')">' . img_picto(($objMod->isCoreOrExternalModule() == 'external' ? $langs->trans("ExternalModule") . ' - ' : '') . $langs->trans("ClickToShowDescription"), $imginfo) . '</a>'; |
|
1042 | 1042 | print '</td>'; |
1043 | 1043 | |
1044 | 1044 | // Version |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | <div id="category-tree-left"> |
1169 | 1169 | <ul class="tree"> |
1170 | 1170 | <?php |
1171 | - echo $dolistore->get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?> |
|
1171 | + echo $dolistore->get_categories(); // Do not use dol_escape_htmltag here, it is already a structured content?> |
|
1172 | 1172 | </ul> |
1173 | 1173 | </div> |
1174 | 1174 | <div id="listing-content"> |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | if ($pathoffile) { // Mostly for external modules |
456 | 456 | $content = file_get_contents($pathoffile); |
457 | 457 | |
458 | - if ((float)DOL_VERSION >= 6.0) { |
|
458 | + if ((float) DOL_VERSION >= 6.0) { |
|
459 | 459 | @include_once BASE_PATH . '/../Dolibarr/Lib/ParseMd.php'; |
460 | 460 | |
461 | 461 | $content = dolMd2Html( |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | if ($filefound) { // Mostly for external modules |
558 | 558 | $content = file_get_contents($pathoffile); |
559 | 559 | |
560 | - if ((float)DOL_VERSION >= 6.0) { |
|
560 | + if ((float) DOL_VERSION >= 6.0) { |
|
561 | 561 | @include_once BASE_PATH . '/../Dolibarr/Lib/ParseMd.php'; |
562 | 562 | |
563 | 563 | $content = dolMd2Html($content, 'parsedown', ['doc/' => dol_buildpath(strtolower($this->name) . '/doc/', 1)]); |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | |
677 | 677 | $sql = "SELECT tms FROM " . $dbPrefix . "const"; |
678 | 678 | $sql .= " WHERE " . $this->db->decrypt('name') . " = '" . $this->db->escape($this->const_name) . "'"; |
679 | - $sql .= " AND entity IN (0, " . ((int)$conf->entity) . ")"; |
|
679 | + $sql .= " AND entity IN (0, " . ((int) $conf->entity) . ")"; |
|
680 | 680 | |
681 | 681 | dol_syslog(get_class($this) . "::getLastActiveDate", LOG_DEBUG); |
682 | 682 | $resql = $this->db->query($sql); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | $sql = "INSERT INTO " . $dbPrefix . "const (name, value, visible, entity, note) VALUES"; |
890 | 890 | $sql .= " (" . $this->db->encrypt($this->const_name); |
891 | 891 | $sql .= ", " . $this->db->encrypt('1'); |
892 | - $sql .= ", 0, " . ((int)$entity); |
|
892 | + $sql .= ", 0, " . ((int) $entity); |
|
893 | 893 | $sql .= ", '" . $this->db->escape($note) . "')"; |
894 | 894 | |
895 | 895 | dol_syslog(get_class($this) . "::_active insert activation constant", LOG_DEBUG); |
@@ -950,7 +950,7 @@ discard block |
||
950 | 950 | $sql .= ", " . $this->db->encrypt($newvalue); |
951 | 951 | $sql .= ", null"; |
952 | 952 | $sql .= ", '0'"; |
953 | - $sql .= ", " . ((int)$entity); |
|
953 | + $sql .= ", " . ((int) $entity); |
|
954 | 954 | $sql .= ")"; |
955 | 955 | |
956 | 956 | $resql = $this->db->query($sql); |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | $sql .= ", " . $this->db->encrypt($newvalue, 1); |
1065 | 1065 | $sql .= ", null"; |
1066 | 1066 | $sql .= ", '0'"; |
1067 | - $sql .= ", " . ((int)$entity); |
|
1067 | + $sql .= ", " . ((int) $entity); |
|
1068 | 1068 | $sql .= ")"; |
1069 | 1069 | |
1070 | 1070 | dol_syslog(get_class($this) . "::insert_module_parts for key=" . $this->const_name . "_" . strtoupper($key), LOG_DEBUG); |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | $sql = "SELECT count(*) as nb"; |
1123 | 1123 | $sql .= " FROM " . $dbPrefix . "const"; |
1124 | 1124 | $sql .= " WHERE " . $this->db->decrypt('name') . " = '" . $this->db->escape($name) . "'"; |
1125 | - $sql .= " AND entity = " . ((int)$entity); |
|
1125 | + $sql .= " AND entity = " . ((int) $entity); |
|
1126 | 1126 | |
1127 | 1127 | $result = $this->db->query($sql); |
1128 | 1128 | if ($result) { |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | $sql = "INSERT INTO " . $dbPrefix . "boxes (box_id, position, box_order, fk_user, entity)"; |
1228 | - $sql .= " VALUES (" . ((int)$lastid) . ", " . ((int)$key2) . ", '0', 0, " . ((int)$conf->entity) . ")"; |
|
1228 | + $sql .= " VALUES (" . ((int) $lastid) . ", " . ((int) $key2) . ", '0', 0, " . ((int) $conf->entity) . ")"; |
|
1229 | 1229 | |
1230 | 1230 | dol_syslog(get_class($this) . "::insert_boxes onto page " . $key2 . "=" . $val2, LOG_DEBUG); |
1231 | 1231 | $resql = $this->db->query($sql); |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | if ($parameters) { |
1312 | 1312 | $sql .= " AND params = '".$this->db->escape($parameters)."'"; |
1313 | 1313 | }*/ |
1314 | - $sql .= " AND entity = " . ((int)$entity); // Must be exact entity |
|
1314 | + $sql .= " AND entity = " . ((int) $entity); // Must be exact entity |
|
1315 | 1315 | |
1316 | 1316 | $now = dol_now(); |
1317 | 1317 | |
@@ -1359,7 +1359,7 @@ discard block |
||
1359 | 1359 | $sql .= "'" . $this->db->escape($priority) . "', "; |
1360 | 1360 | } |
1361 | 1361 | if (is_int($status)) { |
1362 | - $sql .= ((int)$status) . ", "; |
|
1362 | + $sql .= ((int) $status) . ", "; |
|
1363 | 1363 | } |
1364 | 1364 | $sql .= $entity . ","; |
1365 | 1365 | $sql .= "'" . $this->db->escape($test) . "'"; |
@@ -1425,7 +1425,7 @@ discard block |
||
1425 | 1425 | if ($obj !== null && !empty($obj->value) && !empty($this->rights)) { |
1426 | 1426 | // If the module is active |
1427 | 1427 | foreach ($this->rights as $key => $value) { |
1428 | - $r_id = $this->rights[$key][0]; // permission id in llx_rights_def (not unique because primary key is couple id-entity) |
|
1428 | + $r_id = $this->rights[$key][0]; // permission id in llx_rights_def (not unique because primary key is couple id-entity) |
|
1429 | 1429 | $r_desc = $this->rights[$key][1]; |
1430 | 1430 | $r_type = isset($this->rights[$key][2]) ? $this->rights[$key][2] : ''; |
1431 | 1431 | $r_def = empty($this->rights[$key][3]) ? 0 : $this->rights[$key][3]; |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | |
1440 | 1440 | // Search if perm already present |
1441 | 1441 | $sql = "SELECT count(*) as nb FROM " . $dbPrefix . "rights_def"; |
1442 | - $sql .= " WHERE id = " . ((int)$r_id) . " AND entity = " . ((int)$entity); |
|
1442 | + $sql .= " WHERE id = " . ((int) $r_id) . " AND entity = " . ((int) $entity); |
|
1443 | 1443 | |
1444 | 1444 | $resqlselect = $this->db->query($sql); |
1445 | 1445 | if ($resqlselect) { |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | |
1727 | 1727 | if ($row[0] == 0) { |
1728 | 1728 | $sql = "INSERT INTO " . $dbPrefix . "const (name, type, value, note, visible, entity)"; |
1729 | - $sql .= " VALUES (" . $this->db->encrypt($name) . ", 'chaine', " . $this->db->encrypt($dir) . ", '" . $this->db->escape("Directory for module " . $this->name) . "', '0', " . ((int)$conf->entity) . ")"; |
|
1729 | + $sql .= " VALUES (" . $this->db->encrypt($name) . ", 'chaine', " . $this->db->encrypt($dir) . ", '" . $this->db->escape("Directory for module " . $this->name) . "', '0', " . ((int) $conf->entity) . ")"; |
|
1730 | 1730 | |
1731 | 1731 | dol_syslog(get_class($this) . "::insert_dirs", LOG_DEBUG); |
1732 | 1732 | $this->db->query($sql); |
@@ -1819,7 +1819,7 @@ discard block |
||
1819 | 1819 | } |
1820 | 1820 | |
1821 | 1821 | // Run complementary sql requests |
1822 | - $num = count((array)$array_sql); |
|
1822 | + $num = count((array) $array_sql); |
|
1823 | 1823 | for ($i = 0; $i < $num; $i++) { |
1824 | 1824 | if (!$err) { |
1825 | 1825 | dol_syslog(get_class($this) . "::_remove", LOG_DEBUG); |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | |
1930 | 1930 | $sql = "DELETE FROM " . $dbPrefix . "const"; |
1931 | 1931 | $sql .= " WHERE " . $this->db->decrypt('name') . " LIKE '" . $this->db->escape($this->const_name) . "_" . strtoupper($key) . "'"; |
1932 | - $sql .= " AND entity = " . ((int)$entity); |
|
1932 | + $sql .= " AND entity = " . ((int) $entity); |
|
1933 | 1933 | |
1934 | 1934 | if (!$this->db->query($sql)) { |
1935 | 1935 | $this->error = $this->db->lasterror(); |
@@ -2042,7 +2042,7 @@ discard block |
||
2042 | 2042 | |
2043 | 2043 | $sql = "DELETE FROM " . $dbPrefix . "boxes_def"; |
2044 | 2044 | $sql .= " WHERE file = '" . $this->db->escape($file) . "'"; |
2045 | - $sql .= " AND entity = " . $conf->entity; // Do not use getEntity here, we want to delete only in current company |
|
2045 | + $sql .= " AND entity = " . $conf->entity; // Do not use getEntity here, we want to delete only in current company |
|
2046 | 2046 | |
2047 | 2047 | dol_syslog(get_class($this) . "::delete_boxes", LOG_DEBUG); |
2048 | 2048 | $resql = $this->db->query($sql); |
@@ -2255,7 +2255,7 @@ discard block |
||
2255 | 2255 | |
2256 | 2256 | $return .= '<div class="valignmiddle inline-block info-box-more">'; |
2257 | 2257 | //if ($versiontrans) print img_warning($langs->trans("Version").' '.$this->getVersion(1)).' '; |
2258 | - $return .= '<a class="valignmiddle inline-block" href="javascript:document_preview(\'' . DOL_URL_ROOT . '/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>'; |
|
2258 | + $return .= '<a class="valignmiddle inline-block" href="javascript:document_preview(\'' . DOL_URL_ROOT . '/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>'; |
|
2259 | 2259 | $return .= '</div><br>'; |
2260 | 2260 | |
2261 | 2261 | $return .= '<div class="valignmiddle inline-block info-box-actions">'; |
@@ -2416,7 +2416,7 @@ discard block |
||
2416 | 2416 | { |
2417 | 2417 | require_once BASE_PATH . '/../Dolibarr/Lib/GetUrl.php'; |
2418 | 2418 | if (!empty($this->url_last_version)) { |
2419 | - $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, [], ['http', 'https'], 0); // Accept http or https links on external remote server only |
|
2419 | + $lastVersion = getURLContent($this->url_last_version, 'GET', '', 1, [], ['http', 'https'], 0); // Accept http or https links on external remote server only |
|
2420 | 2420 | if (isset($lastVersion['content']) && strlen($lastVersion['content']) < 30) { |
2421 | 2421 | // 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 _ . - |
2422 | 2422 | $this->lastVersion = preg_replace("/[^a-zA-Z0-9_\.\-]+/", "", $lastVersion['content']); |
@@ -456,8 +456,8 @@ |
||
456 | 456 | }*/ |
457 | 457 | |
458 | 458 | $sql = array( |
459 | - "DELETE FROM " . MAIN_DB_PREFIX . "document_model WHERE nom = '" . $this->db->escape($this->const[0][2]) . "' AND type='member' AND entity = " . ((int)$conf->entity), |
|
460 | - "INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity) VALUES('" . $this->db->escape($this->const[0][2]) . "','member'," . ((int)$conf->entity) . ")" |
|
459 | + "DELETE FROM " . MAIN_DB_PREFIX . "document_model WHERE nom = '" . $this->db->escape($this->const[0][2]) . "' AND type='member' AND entity = " . ((int) $conf->entity), |
|
460 | + "INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity) VALUES('" . $this->db->escape($this->const[0][2]) . "','member'," . ((int) $conf->entity) . ")" |
|
461 | 461 | ); |
462 | 462 | |
463 | 463 | return $this->_init($sql, $options); |
@@ -439,8 +439,8 @@ discard block |
||
439 | 439 | // If we ask to add a given permission, we first load properties of this permission (module, perms and subperms). |
440 | 440 | $sql = "SELECT module, perms, subperms"; |
441 | 441 | $sql .= " FROM " . $dbPrefix . "rights_def"; |
442 | - $sql .= " WHERE id = " . ((int)$rid); |
|
443 | - $sql .= " AND entity = " . ((int)$entity); |
|
442 | + $sql .= " WHERE id = " . ((int) $rid); |
|
443 | + $sql .= " AND entity = " . ((int) $entity); |
|
444 | 444 | |
445 | 445 | $result = $this->db->query($sql); |
446 | 446 | if ($result) { |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | } |
458 | 458 | |
459 | 459 | // Define the where for the permission to add |
460 | - $whereforadd = "id=" . ((int)$rid); |
|
460 | + $whereforadd = "id=" . ((int) $rid); |
|
461 | 461 | // Add also inherited permissions |
462 | 462 | if (!empty($subperms)) { |
463 | 463 | $whereforadd .= " OR (module='" . $this->db->escape($module) . "' AND perms='" . $this->db->escape($perms) . "' AND (subperms='lire' OR subperms='read'))"; |
@@ -486,15 +486,15 @@ discard block |
||
486 | 486 | //print "$module-$perms-$subperms"; |
487 | 487 | $sql = "SELECT id"; |
488 | 488 | $sql .= " FROM " . $dbPrefix . "rights_def"; |
489 | - $sql .= " WHERE entity = " . ((int)$entity); |
|
489 | + $sql .= " WHERE entity = " . ((int) $entity); |
|
490 | 490 | if (!empty($whereforadd) && $whereforadd != 'allmodules') { |
491 | - $sql .= " AND (" . $whereforadd . ")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized |
|
491 | + $sql .= " AND (" . $whereforadd . ")"; // Note: parenthesis are important because whereforadd can contains OR. Also note that $whereforadd is already sanitized |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | $sqldelete = "DELETE FROM " . $dbPrefix . "user_rights"; |
495 | - $sqldelete .= " WHERE fk_user = " . ((int)$this->id) . " AND fk_id IN ("; |
|
495 | + $sqldelete .= " WHERE fk_user = " . ((int) $this->id) . " AND fk_id IN ("; |
|
496 | 496 | $sqldelete .= $sql; |
497 | - $sqldelete .= ") AND entity = " . ((int)$entity); |
|
497 | + $sqldelete .= ") AND entity = " . ((int) $entity); |
|
498 | 498 | if (!$this->db->query($sqldelete)) { |
499 | 499 | $error++; |
500 | 500 | } |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if ($obj) { |
511 | 511 | $nid = $obj->id; |
512 | 512 | |
513 | - $sql = "INSERT INTO " . $dbPrefix . "user_rights (entity, fk_user, fk_id) VALUES (" . ((int)$entity) . ", " . ((int)$this->id) . ", " . ((int)$nid) . ")"; |
|
513 | + $sql = "INSERT INTO " . $dbPrefix . "user_rights (entity, fk_user, fk_id) VALUES (" . ((int) $entity) . ", " . ((int) $this->id) . ", " . ((int) $nid) . ")"; |
|
514 | 514 | if (!$this->db->query($sql)) { |
515 | 515 | $error++; |
516 | 516 | } |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $sql = "SELECT module, perms, subperms"; |
577 | 577 | $sql .= " FROM " . $dbPrefix . "rights_def"; |
578 | 578 | $sql .= " WHERE id = '" . $this->db->escape($rid) . "'"; |
579 | - $sql .= " AND entity = " . ((int)$entity); |
|
579 | + $sql .= " AND entity = " . ((int) $entity); |
|
580 | 580 | |
581 | 581 | $result = $this->db->query($sql); |
582 | 582 | if ($result) { |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | } |
594 | 594 | |
595 | 595 | // Where clause for the list of permissions to delete |
596 | - $wherefordel = "id=" . ((int)$rid); |
|
596 | + $wherefordel = "id=" . ((int) $rid); |
|
597 | 597 | // Suppression des droits induits |
598 | 598 | if ($subperms == 'lire' || $subperms == 'read') { |
599 | 599 | $wherefordel .= " OR (module='" . $this->db->escape($module) . "' AND perms='" . $this->db->escape($perms) . "' AND subperms IS NOT NULL)"; |
@@ -622,9 +622,9 @@ discard block |
||
622 | 622 | //print "$module-$perms-$subperms"; |
623 | 623 | $sql = "SELECT id"; |
624 | 624 | $sql .= " FROM " . $dbPrefix . "rights_def"; |
625 | - $sql .= " WHERE entity = " . ((int)$entity); |
|
625 | + $sql .= " WHERE entity = " . ((int) $entity); |
|
626 | 626 | if (!empty($wherefordel) && $wherefordel != 'allmodules') { |
627 | - $sql .= " AND (" . $wherefordel . ")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized |
|
627 | + $sql .= " AND (" . $wherefordel . ")"; // Note: parenthesis are important because wherefordel can contains OR. Also note that $wherefordel is already sanitized |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // avoid admin can remove his own important rights |
@@ -636,10 +636,10 @@ discard block |
||
636 | 636 | } |
637 | 637 | |
638 | 638 | $sqldelete = "DELETE FROM " . $dbPrefix . "user_rights"; |
639 | - $sqldelete .= " WHERE fk_user = " . ((int)$this->id) . " AND fk_id IN ("; |
|
639 | + $sqldelete .= " WHERE fk_user = " . ((int) $this->id) . " AND fk_id IN ("; |
|
640 | 640 | $sqldelete .= $sql; |
641 | 641 | $sqldelete .= ")"; |
642 | - $sqldelete .= " AND entity = " . ((int)$entity); |
|
642 | + $sqldelete .= " AND entity = " . ((int) $entity); |
|
643 | 643 | |
644 | 644 | $resql = $this->db->query($sqldelete); |
645 | 645 | if (!$resql) { |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | public function getrights($moduletag = '', $forcereload = 0) |
697 | 697 | { |
698 | 698 | global $conf; |
699 | - $dbPrefix=$conf->db->prefix; |
|
699 | + $dbPrefix = $conf->db->prefix; |
|
700 | 700 | |
701 | 701 | $alreadyloaded = false; |
702 | 702 | |
@@ -736,9 +736,9 @@ discard block |
||
736 | 736 | } else { |
737 | 737 | // On table r=rights_def, the unique key is (id, entity) because id is hard coded into module descriptor and insert during module activation. |
738 | 738 | // So we must include the filter on entity on both table r. and ur. |
739 | - $sql .= " AND r.entity = " . ((int)$conf->entity) . " AND ur.entity = " . ((int)$conf->entity); |
|
739 | + $sql .= " AND r.entity = " . ((int) $conf->entity) . " AND ur.entity = " . ((int) $conf->entity); |
|
740 | 740 | } |
741 | - $sql .= " AND ur.fk_user= " . ((int)$this->id); |
|
741 | + $sql .= " AND ur.fk_user= " . ((int) $this->id); |
|
742 | 742 | $sql .= " AND r.perms IS NOT NULL"; |
743 | 743 | if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { |
744 | 744 | $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled |
@@ -797,19 +797,19 @@ discard block |
||
797 | 797 | if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { |
798 | 798 | $sql .= " AND gu.entity IN (0," . $conf->entity . ")"; |
799 | 799 | } else { |
800 | - $sql .= " AND r.entity = " . ((int)$conf->entity); |
|
800 | + $sql .= " AND r.entity = " . ((int) $conf->entity); |
|
801 | 801 | } |
802 | 802 | } else { |
803 | - $sql .= " AND gr.entity = " . ((int)$conf->entity); // Only groups created in current entity |
|
803 | + $sql .= " AND gr.entity = " . ((int) $conf->entity); // Only groups created in current entity |
|
804 | 804 | // The entity on the table usergroup_user should be useless and should never be used because it is already into gr and r. |
805 | 805 | // but when using MULTICOMPANY_TRANSVERSE_MODE, we may insert record that make rubbish result due to duplicate record of |
806 | 806 | // other entities, so we are forced to add a filter here |
807 | 807 | $sql .= " AND gu.entity IN (0," . $conf->entity . ")"; |
808 | - $sql .= " AND r.entity = " . ((int)$conf->entity); // Only permission of modules enabled in current entity |
|
808 | + $sql .= " AND r.entity = " . ((int) $conf->entity); // Only permission of modules enabled in current entity |
|
809 | 809 | } |
810 | 810 | // End of strange business rule |
811 | 811 | $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; |
812 | - $sql .= " AND gu.fk_user = " . ((int)$this->id); |
|
812 | + $sql .= " AND gu.fk_user = " . ((int) $this->id); |
|
813 | 813 | $sql .= " AND r.perms IS NOT NULL"; |
814 | 814 | if ($moduletag) { |
815 | 815 | $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
@@ -959,8 +959,8 @@ discard block |
||
959 | 959 | |
960 | 960 | // Save in database |
961 | 961 | $sql = "UPDATE " . $dbPrefix . "user"; |
962 | - $sql .= " SET statut = " . ((int)$status); |
|
963 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
962 | + $sql .= " SET statut = " . ((int) $status); |
|
963 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
964 | 964 | $result = $this->db->query($sql); |
965 | 965 | |
966 | 966 | dol_syslog(get_class($this) . "::setstatus", LOG_DEBUG); |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | dol_syslog(get_class($this) . "::delete", LOG_DEBUG); |
1026 | 1026 | |
1027 | 1027 | // Remove rights |
1028 | - $sql = "DELETE FROM " . $dbPrefix . "user_rights WHERE fk_user = " . ((int)$this->id); |
|
1028 | + $sql = "DELETE FROM " . $dbPrefix . "user_rights WHERE fk_user = " . ((int) $this->id); |
|
1029 | 1029 | |
1030 | 1030 | if (!$error && !$this->db->query($sql)) { |
1031 | 1031 | $error++; |
@@ -1033,14 +1033,14 @@ discard block |
||
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | // Remove group |
1036 | - $sql = "DELETE FROM " . $dbPrefix . "usergroup_user WHERE fk_user = " . ((int)$this->id); |
|
1036 | + $sql = "DELETE FROM " . $dbPrefix . "usergroup_user WHERE fk_user = " . ((int) $this->id); |
|
1037 | 1037 | if (!$error && !$this->db->query($sql)) { |
1038 | 1038 | $error++; |
1039 | 1039 | $this->error = $this->db->lasterror(); |
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | // Remove params |
1043 | - $sql = "DELETE FROM " . $dbPrefix . "user_param WHERE fk_user = " . ((int)$this->id); |
|
1043 | + $sql = "DELETE FROM " . $dbPrefix . "user_param WHERE fk_user = " . ((int) $this->id); |
|
1044 | 1044 | if (!$error && !$this->db->query($sql)) { |
1045 | 1045 | $error++; |
1046 | 1046 | $this->error = $this->db->lasterror(); |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | // If contact, remove link |
1050 | 1050 | if ($this->contact_id > 0) { |
1051 | - $sql = "UPDATE " . $dbPrefix . "socpeople SET fk_user_creat = null WHERE rowid = " . ((int)$this->contact_id); |
|
1051 | + $sql = "UPDATE " . $dbPrefix . "socpeople SET fk_user_creat = null WHERE rowid = " . ((int) $this->contact_id); |
|
1052 | 1052 | if (!$error && !$this->db->query($sql)) { |
1053 | 1053 | $error++; |
1054 | 1054 | $this->error = $this->db->lasterror(); |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | |
1067 | 1067 | // Remove user |
1068 | 1068 | if (!$error) { |
1069 | - $sql = "DELETE FROM " . $dbPrefix . "user WHERE rowid = " . ((int)$this->id); |
|
1069 | + $sql = "DELETE FROM " . $dbPrefix . "user WHERE rowid = " . ((int) $this->id); |
|
1070 | 1070 | dol_syslog(get_class($this) . "::delete", LOG_DEBUG); |
1071 | 1071 | if (!$this->db->query($sql)) { |
1072 | 1072 | $error++; |
@@ -1161,7 +1161,7 @@ discard block |
||
1161 | 1161 | |
1162 | 1162 | if ($entity < 0) { |
1163 | 1163 | if ((!isModEnabled('multicompany') || !getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) && (!empty($user->entity))) { |
1164 | - $sql .= " WHERE u.entity IN (0, " . ((int)$conf->entity) . ")"; |
|
1164 | + $sql .= " WHERE u.entity IN (0, " . ((int) $conf->entity) . ")"; |
|
1165 | 1165 | } else { |
1166 | 1166 | $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
1167 | 1167 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) { |
1171 | 1171 | $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
1172 | 1172 | } else { |
1173 | - $sql .= " WHERE u.entity IN (0, " . ((int)(($entity != '' && $entity >= 0) ? $entity : $conf->entity)) . ")"; // search in entity provided in parameter |
|
1173 | + $sql .= " WHERE u.entity IN (0, " . ((int) (($entity != '' && $entity >= 0) ? $entity : $conf->entity)) . ")"; // search in entity provided in parameter |
|
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
@@ -1186,9 +1186,9 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | $sql .= ")"; |
1188 | 1188 | } elseif ($fk_socpeople > 0) { |
1189 | - $sql .= " AND u.fk_socpeople = " . ((int)$fk_socpeople); |
|
1189 | + $sql .= " AND u.fk_socpeople = " . ((int) $fk_socpeople); |
|
1190 | 1190 | } else { |
1191 | - $sql .= " AND u.rowid = " . ((int)$id); |
|
1191 | + $sql .= " AND u.rowid = " . ((int) $id); |
|
1192 | 1192 | } |
1193 | 1193 | $sql .= " ORDER BY u.entity ASC"; // Avoid random result when there is 2 login in 2 different entities |
1194 | 1194 | |
@@ -1252,15 +1252,15 @@ discard block |
||
1252 | 1252 | $this->email = $obj->email; |
1253 | 1253 | $this->email_oauth2 = $obj->email_oauth2; |
1254 | 1254 | $this->personal_email = $obj->personal_email; |
1255 | - $this->socialnetworks = ($obj->socialnetworks ? (array)json_decode($obj->socialnetworks, true) : []); |
|
1255 | + $this->socialnetworks = ($obj->socialnetworks ? (array) json_decode($obj->socialnetworks, true) : []); |
|
1256 | 1256 | $this->job = $obj->job; |
1257 | 1257 | $this->signature = $obj->signature; |
1258 | 1258 | $this->admin = $obj->admin; |
1259 | 1259 | $this->note_public = $obj->note_public; |
1260 | 1260 | $this->note_private = $obj->note_private; |
1261 | - $this->note = $obj->note_private; // deprecated |
|
1261 | + $this->note = $obj->note_private; // deprecated |
|
1262 | 1262 | |
1263 | - $this->statut = $obj->status; // deprecated |
|
1263 | + $this->statut = $obj->status; // deprecated |
|
1264 | 1264 | $this->status = $obj->status; |
1265 | 1265 | |
1266 | 1266 | $this->photo = $obj->photo; |
@@ -1347,8 +1347,8 @@ discard block |
||
1347 | 1347 | |
1348 | 1348 | // Load user->conf for user |
1349 | 1349 | $sql = "SELECT param, value FROM " . $dbPrefix . "user_param"; |
1350 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
1351 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
1350 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
1351 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
1352 | 1352 | //dol_syslog(get_class($this).'::fetch load personalized conf', LOG_DEBUG); |
1353 | 1353 | $resql = $this->db->query($sql); |
1354 | 1354 | if ($resql) { |
@@ -1385,7 +1385,7 @@ discard block |
||
1385 | 1385 | // Load user->default_values for user. TODO Save this in memcached ? |
1386 | 1386 | |
1387 | 1387 | $defaultValues = new DefaultValues($this->db); |
1388 | - $result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,' . $this->id . ') AND (entity:in:' . (isset($this->entity) ? $this->entity : $conf->entity) . ',' . $conf->entity . ')'); // User 0 (all) + me (if defined) |
|
1388 | + $result = $defaultValues->fetchAll('', '', 0, 0, '(t.user_id:in:0,' . $this->id . ') AND (entity:in:' . (isset($this->entity) ? $this->entity : $conf->entity) . ',' . $conf->entity . ')'); // User 0 (all) + me (if defined) |
|
1389 | 1389 | //$result = $defaultValues->fetchAll('', '', 0, 0, array('t.user_id'=>array(0, $this->id), 'entity'=>array((isset($this->entity) ? $this->entity : $conf->entity), $conf->entity))); // User 0 (all) + me (if defined) |
1390 | 1390 | |
1391 | 1391 | if (!is_array($result) && $result < 0) { |
@@ -1546,12 +1546,12 @@ discard block |
||
1546 | 1546 | $result = $this->create($user, 1); |
1547 | 1547 | if ($result > 0) { |
1548 | 1548 | $sql = "UPDATE " . $dbPrefix . "user"; |
1549 | - $sql .= " SET fk_socpeople=" . ((int)$contact->id); |
|
1549 | + $sql .= " SET fk_socpeople=" . ((int) $contact->id); |
|
1550 | 1550 | $sql .= ", civility='" . $this->db->escape($contact->civility_code) . "'"; |
1551 | 1551 | if ($contact->socid > 0) { |
1552 | - $sql .= ", fk_soc=" . ((int)$contact->socid); |
|
1552 | + $sql .= ", fk_soc=" . ((int) $contact->socid); |
|
1553 | 1553 | } |
1554 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
1554 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
1555 | 1555 | |
1556 | 1556 | $resql = $this->db->query($sql); |
1557 | 1557 | |
@@ -1606,8 +1606,8 @@ discard block |
||
1606 | 1606 | // Clean parameters |
1607 | 1607 | $this->setUpperOrLowerCase(); |
1608 | 1608 | |
1609 | - $this->civility_code = trim((string)$this->civility_code); |
|
1610 | - $this->login = trim((string)$this->login); |
|
1609 | + $this->civility_code = trim((string) $this->civility_code); |
|
1610 | + $this->login = trim((string) $this->login); |
|
1611 | 1611 | if (!isset($this->entity)) { |
1612 | 1612 | $this->entity = $conf->entity; // If not defined, we use default value |
1613 | 1613 | } |
@@ -1639,7 +1639,7 @@ discard block |
||
1639 | 1639 | |
1640 | 1640 | // Check if login already exists in same entity or into entity 0. |
1641 | 1641 | if ($this->login) { |
1642 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
1642 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
1643 | 1643 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
1644 | 1644 | if ($resqltochecklogin) { |
1645 | 1645 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -1654,7 +1654,7 @@ discard block |
||
1654 | 1654 | } |
1655 | 1655 | } |
1656 | 1656 | if (!empty($this->email)) { |
1657 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
1657 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
1658 | 1658 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
1659 | 1659 | if ($resqltochecklogin) { |
1660 | 1660 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -1671,7 +1671,7 @@ discard block |
||
1671 | 1671 | |
1672 | 1672 | // Insert into database |
1673 | 1673 | $sql = "INSERT INTO " . $dbPrefix . "user (datec, login, ldap_sid, entity)"; |
1674 | - $sql .= " VALUES('" . $this->db->idate($this->datec) . "', '" . $this->db->escape($this->login) . "', '" . $this->db->escape($this->ldap_sid) . "', " . ((int)$this->entity) . ")"; |
|
1674 | + $sql .= " VALUES('" . $this->db->idate($this->datec) . "', '" . $this->db->escape($this->login) . "', '" . $this->db->escape($this->ldap_sid) . "', " . ((int) $this->entity) . ")"; |
|
1675 | 1675 | $result = $this->db->query($sql); |
1676 | 1676 | |
1677 | 1677 | dol_syslog(get_class($this) . "::create", LOG_DEBUG); |
@@ -1747,7 +1747,7 @@ discard block |
||
1747 | 1747 | $num = 0; |
1748 | 1748 | $sql = "SELECT id FROM " . $dbPrefix . "rights_def"; |
1749 | 1749 | $sql .= " WHERE bydefault = 1"; |
1750 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
1750 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
1751 | 1751 | |
1752 | 1752 | $resql = $this->db->query($sql); |
1753 | 1753 | if ($resql) { |
@@ -1802,47 +1802,47 @@ discard block |
||
1802 | 1802 | dol_syslog(get_class($this) . "::update notrigger=" . $notrigger . ", nosyncmember=" . $nosyncmember . ", nosyncmemberpass=" . $nosyncmemberpass); |
1803 | 1803 | |
1804 | 1804 | // Clean parameters |
1805 | - $this->civility_code = trim((string)$this->civility_code); |
|
1806 | - $this->lastname = trim((string)$this->lastname); |
|
1807 | - $this->firstname = trim((string)$this->firstname); |
|
1808 | - $this->ref_employee = trim((string)$this->ref_employee); |
|
1809 | - $this->national_registration_number = trim((string)$this->national_registration_number); |
|
1805 | + $this->civility_code = trim((string) $this->civility_code); |
|
1806 | + $this->lastname = trim((string) $this->lastname); |
|
1807 | + $this->firstname = trim((string) $this->firstname); |
|
1808 | + $this->ref_employee = trim((string) $this->ref_employee); |
|
1809 | + $this->national_registration_number = trim((string) $this->national_registration_number); |
|
1810 | 1810 | $this->employee = ($this->employee > 0 ? $this->employee : 0); |
1811 | - $this->login = trim((string)$this->login); |
|
1812 | - $this->gender = trim((string)$this->gender); |
|
1811 | + $this->login = trim((string) $this->login); |
|
1812 | + $this->gender = trim((string) $this->gender); |
|
1813 | 1813 | |
1814 | - $this->pass = trim((string)$this->pass); |
|
1815 | - $this->api_key = trim((string)$this->api_key); |
|
1814 | + $this->pass = trim((string) $this->pass); |
|
1815 | + $this->api_key = trim((string) $this->api_key); |
|
1816 | 1816 | $this->datestartvalidity = empty($this->datestartvalidity) ? '' : $this->datestartvalidity; |
1817 | 1817 | $this->dateendvalidity = empty($this->dateendvalidity) ? '' : $this->dateendvalidity; |
1818 | 1818 | |
1819 | - $this->address = trim((string)$this->address); |
|
1820 | - $this->zip = trim((string)$this->zip); |
|
1821 | - $this->town = trim((string)$this->town); |
|
1819 | + $this->address = trim((string) $this->address); |
|
1820 | + $this->zip = trim((string) $this->zip); |
|
1821 | + $this->town = trim((string) $this->town); |
|
1822 | 1822 | |
1823 | 1823 | $this->state_id = ($this->state_id > 0 ? $this->state_id : 0); |
1824 | 1824 | $this->country_id = ($this->country_id > 0 ? $this->country_id : 0); |
1825 | - $this->office_phone = trim((string)$this->office_phone); |
|
1826 | - $this->office_fax = trim((string)$this->office_fax); |
|
1827 | - $this->user_mobile = trim((string)$this->user_mobile); |
|
1828 | - $this->personal_mobile = trim((string)$this->personal_mobile); |
|
1829 | - $this->email = trim((string)$this->email); |
|
1830 | - $this->personal_email = trim((string)$this->personal_email); |
|
1831 | - |
|
1832 | - $this->job = trim((string)$this->job); |
|
1833 | - $this->signature = trim((string)$this->signature); |
|
1834 | - $this->note_public = trim((string)$this->note_public); |
|
1835 | - $this->note_private = trim((string)$this->note_private); |
|
1836 | - $this->openid = trim((string)$this->openid); |
|
1825 | + $this->office_phone = trim((string) $this->office_phone); |
|
1826 | + $this->office_fax = trim((string) $this->office_fax); |
|
1827 | + $this->user_mobile = trim((string) $this->user_mobile); |
|
1828 | + $this->personal_mobile = trim((string) $this->personal_mobile); |
|
1829 | + $this->email = trim((string) $this->email); |
|
1830 | + $this->personal_email = trim((string) $this->personal_email); |
|
1831 | + |
|
1832 | + $this->job = trim((string) $this->job); |
|
1833 | + $this->signature = trim((string) $this->signature); |
|
1834 | + $this->note_public = trim((string) $this->note_public); |
|
1835 | + $this->note_private = trim((string) $this->note_private); |
|
1836 | + $this->openid = trim((string) $this->openid); |
|
1837 | 1837 | $this->admin = ($this->admin > 0 ? $this->admin : 0); |
1838 | 1838 | |
1839 | - $this->accountancy_code = trim((string)$this->accountancy_code); |
|
1840 | - $this->color = trim((string)$this->color); |
|
1839 | + $this->accountancy_code = trim((string) $this->accountancy_code); |
|
1840 | + $this->color = trim((string) $this->color); |
|
1841 | 1841 | $this->dateemployment = empty($this->dateemployment) ? '' : $this->dateemployment; |
1842 | 1842 | $this->dateemploymentend = empty($this->dateemploymentend) ? '' : $this->dateemploymentend; |
1843 | 1843 | |
1844 | 1844 | $this->birth = empty($this->birth) ? '' : $this->birth; |
1845 | - $this->fk_warehouse = (int)$this->fk_warehouse; |
|
1845 | + $this->fk_warehouse = (int) $this->fk_warehouse; |
|
1846 | 1846 | |
1847 | 1847 | $this->setUpperOrLowerCase(); |
1848 | 1848 | |
@@ -1868,7 +1868,7 @@ discard block |
||
1868 | 1868 | |
1869 | 1869 | // Check if login already exists in same entity or into entity 0. |
1870 | 1870 | if (!empty($this->oldcopy) && $this->oldcopy->login != $this->login) { |
1871 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
1871 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND login = '" . $this->db->escape($this->login) . "'"; |
|
1872 | 1872 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
1873 | 1873 | if ($resqltochecklogin) { |
1874 | 1874 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -1882,7 +1882,7 @@ discard block |
||
1882 | 1882 | } |
1883 | 1883 | } |
1884 | 1884 | if (!empty($this->oldcopy) && !empty($this->email) && $this->oldcopy->email != $this->email) { |
1885 | - $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int)$this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
1885 | + $sqltochecklogin = "SELECT COUNT(*) as nb FROM " . $dbPrefix . "user WHERE entity IN (" . $this->db->sanitize((int) $this->entity) . ", 0) AND email = '" . $this->db->escape($this->email) . "'"; |
|
1886 | 1886 | $resqltochecklogin = $this->db->query($sqltochecklogin); |
1887 | 1887 | if ($resqltochecklogin) { |
1888 | 1888 | $objtochecklogin = $this->db->fetch_object($resqltochecklogin); |
@@ -1903,13 +1903,13 @@ discard block |
||
1903 | 1903 | $sql .= ", firstname = '" . $this->db->escape($this->firstname) . "'"; |
1904 | 1904 | $sql .= ", ref_employee = '" . $this->db->escape($this->ref_employee) . "'"; |
1905 | 1905 | $sql .= ", national_registration_number = '" . $this->db->escape($this->national_registration_number) . "'"; |
1906 | - $sql .= ", employee = " . (int)$this->employee; |
|
1906 | + $sql .= ", employee = " . (int) $this->employee; |
|
1907 | 1907 | $sql .= ", login = '" . $this->db->escape($this->login) . "'"; |
1908 | 1908 | $sql .= ", api_key = " . ($this->api_key ? "'" . $this->db->escape(dolEncrypt($this->api_key, '', '', 'dolibarr')) . "'" : "null"); |
1909 | 1909 | $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman' |
1910 | 1910 | $sql .= ", birth=" . (strval($this->birth) != '' ? "'" . $this->db->idate($this->birth, 'tzserver') . "'" : 'null'); |
1911 | 1911 | if (!empty($user->admin)) { |
1912 | - $sql .= ", admin = " . (int)$this->admin; // admin flag can be set/unset only by an admin user |
|
1912 | + $sql .= ", admin = " . (int) $this->admin; // admin flag can be set/unset only by an admin user |
|
1913 | 1913 | } |
1914 | 1914 | $sql .= ", address = '" . $this->db->escape($this->address) . "'"; |
1915 | 1915 | $sql .= ", zip = '" . $this->db->escape($this->zip) . "'"; |
@@ -1952,13 +1952,13 @@ discard block |
||
1952 | 1952 | } |
1953 | 1953 | $sql .= ", weeklyhours= " . ($this->weeklyhours != '' ? "'" . $this->db->escape($this->weeklyhours) . "'" : "null"); |
1954 | 1954 | if (!empty($user->admin) && empty($user->entity) && $user->id != $this->id) { |
1955 | - $sql .= ", entity = " . ((int)$this->entity); // entity flag can be set/unset only by an another superadmin user |
|
1955 | + $sql .= ", entity = " . ((int) $this->entity); // entity flag can be set/unset only by an another superadmin user |
|
1956 | 1956 | } |
1957 | 1957 | $sql .= ", default_range = " . ($this->default_range > 0 ? $this->default_range : 'null'); |
1958 | 1958 | $sql .= ", default_c_exp_tax_cat = " . ($this->default_c_exp_tax_cat > 0 ? $this->default_c_exp_tax_cat : 'null'); |
1959 | 1959 | $sql .= ", fk_warehouse = " . ($this->fk_warehouse > 0 ? $this->fk_warehouse : "null"); |
1960 | 1960 | $sql .= ", lang = " . ($this->lang ? "'" . $this->db->escape($this->lang) . "'" : "null"); |
1961 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
1961 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
1962 | 1962 | |
1963 | 1963 | dol_syslog(get_class($this) . "::update", LOG_DEBUG); |
1964 | 1964 | $resql = $this->db->query($sql); |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | // If user is linked to a member, remove old link to this member |
1980 | 1980 | if ($this->fk_member > 0) { |
1981 | 1981 | dol_syslog(get_class($this) . "::update remove link with member. We will recreate it later", LOG_DEBUG); |
1982 | - $sql = "UPDATE " . $dbPrefix . "user SET fk_member = NULL where fk_member = " . ((int)$this->fk_member); |
|
1982 | + $sql = "UPDATE " . $dbPrefix . "user SET fk_member = NULL where fk_member = " . ((int) $this->fk_member); |
|
1983 | 1983 | $resql = $this->db->query($sql); |
1984 | 1984 | if (!$resql) { |
1985 | 1985 | $this->error = $this->db->error(); |
@@ -1989,7 +1989,7 @@ discard block |
||
1989 | 1989 | } |
1990 | 1990 | // Set link to user |
1991 | 1991 | dol_syslog(get_class($this) . "::update set link with member", LOG_DEBUG); |
1992 | - $sql = "UPDATE " . $dbPrefix . "user SET fk_member =" . ($this->fk_member > 0 ? ((int)$this->fk_member) : 'null') . " where rowid = " . ((int)$this->id); |
|
1992 | + $sql = "UPDATE " . $dbPrefix . "user SET fk_member =" . ($this->fk_member > 0 ? ((int) $this->fk_member) : 'null') . " where rowid = " . ((int) $this->id); |
|
1993 | 1993 | $resql = $this->db->query($sql); |
1994 | 1994 | if (!$resql) { |
1995 | 1995 | $this->error = $this->db->error(); |
@@ -2216,7 +2216,7 @@ discard block |
||
2216 | 2216 | } else { |
2217 | 2217 | $sql .= ", pass = '" . $this->db->escape($password) . "'"; |
2218 | 2218 | } |
2219 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
2219 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
2220 | 2220 | |
2221 | 2221 | dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); |
2222 | 2222 | $result = $this->db->query($sql); |
@@ -2274,7 +2274,7 @@ discard block |
||
2274 | 2274 | // After receiving confirmation link, we will erase and store it in pass_crypted |
2275 | 2275 | $sql = "UPDATE " . $dbPrefix . "user"; |
2276 | 2276 | $sql .= " SET pass_temp = '" . $this->db->escape($password) . "'"; |
2277 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
2277 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
2278 | 2278 | |
2279 | 2279 | dol_syslog(get_class($this) . "::setPassword", LOG_DEBUG); // No log |
2280 | 2280 | $result = $this->db->query($sql); |
@@ -2351,7 +2351,7 @@ discard block |
||
2351 | 2351 | } elseif (!empty($this->pass_crypted)) { // If an encrypted password is already known, we save it directly into database because the previous create did not save it. |
2352 | 2352 | $sql = "UPDATE " . $dbPrefix . "user"; |
2353 | 2353 | $sql .= " SET pass_crypted = '" . $this->db->escape($this->pass_crypted) . "'"; |
2354 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
2354 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
2355 | 2355 | |
2356 | 2356 | $resql = $this->db->query($sql); |
2357 | 2357 | if (!$resql) { |
@@ -2361,8 +2361,8 @@ discard block |
||
2361 | 2361 | |
2362 | 2362 | if ($result > 0 && $member->socid) { // If member is linked to a thirdparty |
2363 | 2363 | $sql = "UPDATE " . $dbPrefix . "user"; |
2364 | - $sql .= " SET fk_soc=" . ((int)$member->socid); |
|
2365 | - $sql .= " WHERE rowid=" . ((int)$this->id); |
|
2364 | + $sql .= " SET fk_soc=" . ((int) $member->socid); |
|
2365 | + $sql .= " WHERE rowid=" . ((int) $this->id); |
|
2366 | 2366 | |
2367 | 2367 | dol_syslog(get_class($this) . "::create_from_member", LOG_DEBUG); |
2368 | 2368 | $resql = $this->db->query($sql); |
@@ -2413,7 +2413,7 @@ discard block |
||
2413 | 2413 | $sql .= " datelastlogin = '" . $this->db->idate($now) . "',"; |
2414 | 2414 | $sql .= " iplastlogin = '" . $this->db->escape($userremoteip) . "',"; |
2415 | 2415 | $sql .= " tms = tms"; // The last update date must change because the last login date is updated |
2416 | - $sql .= " WHERE rowid = " . ((int)$this->id); |
|
2416 | + $sql .= " WHERE rowid = " . ((int) $this->id); |
|
2417 | 2417 | |
2418 | 2418 | dol_syslog(get_class($this) . "::update_last_login_date user->id=" . $this->id . " " . $sql, LOG_DEBUG); |
2419 | 2419 | $resql = $this->db->query($sql); |
@@ -2564,7 +2564,7 @@ discard block |
||
2564 | 2564 | // phpcs:enable |
2565 | 2565 | $sql = "SELECT url, login, pass, poste "; |
2566 | 2566 | $sql .= " FROM " . $dbPrefix . "user_clicktodial as u"; |
2567 | - $sql .= " WHERE u.fk_user = " . ((int)$this->id); |
|
2567 | + $sql .= " WHERE u.fk_user = " . ((int) $this->id); |
|
2568 | 2568 | |
2569 | 2569 | $resql = $this->db->query($sql); |
2570 | 2570 | if ($resql) { |
@@ -2603,7 +2603,7 @@ discard block |
||
2603 | 2603 | $this->db->begin(); |
2604 | 2604 | |
2605 | 2605 | $sql = "DELETE FROM " . $dbPrefix . "user_clicktodial"; |
2606 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
2606 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
2607 | 2607 | |
2608 | 2608 | dol_syslog(get_class($this) . '::update_clicktodial', LOG_DEBUG); |
2609 | 2609 | $result = $this->db->query($sql); |
@@ -2649,14 +2649,14 @@ discard block |
||
2649 | 2649 | $this->db->begin(); |
2650 | 2650 | |
2651 | 2651 | $sql = "DELETE FROM " . $dbPrefix . "usergroup_user"; |
2652 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
2653 | - $sql .= " AND fk_usergroup = " . ((int)$group); |
|
2654 | - $sql .= " AND entity = " . ((int)$entity); |
|
2652 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
2653 | + $sql .= " AND fk_usergroup = " . ((int) $group); |
|
2654 | + $sql .= " AND entity = " . ((int) $entity); |
|
2655 | 2655 | |
2656 | 2656 | $result = $this->db->query($sql); |
2657 | 2657 | |
2658 | 2658 | $sql = "INSERT INTO " . $dbPrefix . "usergroup_user (entity, fk_user, fk_usergroup)"; |
2659 | - $sql .= " VALUES (" . ((int)$entity) . "," . ((int)$this->id) . "," . ((int)$group) . ")"; |
|
2659 | + $sql .= " VALUES (" . ((int) $entity) . "," . ((int) $this->id) . "," . ((int) $group) . ")"; |
|
2660 | 2660 | |
2661 | 2661 | $result = $this->db->query($sql); |
2662 | 2662 | if ($result) { |
@@ -2705,12 +2705,12 @@ discard block |
||
2705 | 2705 | $this->db->begin(); |
2706 | 2706 | |
2707 | 2707 | $sql = "DELETE FROM " . $dbPrefix . "usergroup_user"; |
2708 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
2709 | - $sql .= " AND fk_usergroup = " . ((int)$group); |
|
2708 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
2709 | + $sql .= " AND fk_usergroup = " . ((int) $group); |
|
2710 | 2710 | if (empty($entity)) { |
2711 | - $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. |
|
2711 | + $sql .= " AND entity IN (0, 1)"; // group may be in entity 0 (so $entity=0) and link with user into entity 1. |
|
2712 | 2712 | } else { |
2713 | - $sql .= " AND entity = " . ((int)$entity); |
|
2713 | + $sql .= " AND entity = " . ((int) $entity); |
|
2714 | 2714 | } |
2715 | 2715 | |
2716 | 2716 | $result = $this->db->query($sql); |
@@ -2896,7 +2896,7 @@ discard block |
||
2896 | 2896 | */ |
2897 | 2897 | public function getLibStatut($mode = 0) |
2898 | 2898 | { |
2899 | - return $this->LibStatut(isset($this->statut) ? (int)$this->statut : (int)$this->status, $mode); |
|
2899 | + return $this->LibStatut(isset($this->statut) ? (int) $this->statut : (int) $this->status, $mode); |
|
2900 | 2900 | } |
2901 | 2901 | |
2902 | 2902 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
@@ -3048,7 +3048,7 @@ discard block |
||
3048 | 3048 | $result .= (($option == 'nolink') ? '' : $linkstart); |
3049 | 3049 | if ($withpictoimg) { |
3050 | 3050 | $paddafterimage = ''; |
3051 | - if (abs((int)$withpictoimg) == 1) { |
|
3051 | + if (abs((int) $withpictoimg) == 1) { |
|
3052 | 3052 | $paddafterimage = 'style="margin-' . ($langs->trans("DIRECTION") == 'rtl' ? 'left' : 'right') . ': 3px;"'; |
3053 | 3053 | } |
3054 | 3054 | // Only picto |
@@ -3179,7 +3179,7 @@ discard block |
||
3179 | 3179 | if (!empty($this->socid)) { |
3180 | 3180 | if ($module = 'societe' && $permlevel1 == 'client' && $permlevel2 == 'voir') { |
3181 | 3181 | dump('return 0'); |
3182 | - return 0; // An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself) |
|
3182 | + return 0; // An external user never has the permission ->societe->client->voir to see all thirdparties (always restricted to himself) |
|
3183 | 3183 | } |
3184 | 3184 | } |
3185 | 3185 | |
@@ -3272,7 +3272,7 @@ discard block |
||
3272 | 3272 | |
3273 | 3273 | if ($option == 'xxx') { |
3274 | 3274 | $linkstart = '<a href="' . DOL_URL_ROOT . '/user/card.php?id=' . $this->id . '">'; |
3275 | - $linkend = '</a>'; // @phan-suppress-current-line PhanPluginRedundantAssignment |
|
3275 | + $linkend = '</a>'; // @phan-suppress-current-line PhanPluginRedundantAssignment |
|
3276 | 3276 | } |
3277 | 3277 | |
3278 | 3278 | if ($option == 'nolink') { |
@@ -3589,7 +3589,7 @@ discard block |
||
3589 | 3589 | $this->iplastlogin = '127.0.0.1'; |
3590 | 3590 | $this->datepreviouslogin = $now; |
3591 | 3591 | $this->ippreviouslogin = '127.0.0.1'; |
3592 | - $this->statut = 1; // deprecated |
|
3592 | + $this->statut = 1; // deprecated |
|
3593 | 3593 | $this->status = 1; |
3594 | 3594 | |
3595 | 3595 | $this->entity = 1; |
@@ -3611,7 +3611,7 @@ discard block |
||
3611 | 3611 | $sql = "SELECT u.rowid, u.login as ref, u.datec,"; |
3612 | 3612 | $sql .= " u.tms as date_modification, u.entity"; |
3613 | 3613 | $sql .= " FROM " . $dbPrefix . "user as u"; |
3614 | - $sql .= " WHERE u.rowid = " . ((int)$id); |
|
3614 | + $sql .= " WHERE u.rowid = " . ((int) $id); |
|
3615 | 3615 | |
3616 | 3616 | $result = $this->db->query($sql); |
3617 | 3617 | if ($result) { |
@@ -3684,13 +3684,13 @@ discard block |
||
3684 | 3684 | } |
3685 | 3685 | } |
3686 | 3686 | if ($admin >= 0) { |
3687 | - $sql .= " AND admin = " . (int)$admin; |
|
3687 | + $sql .= " AND admin = " . (int) $admin; |
|
3688 | 3688 | } |
3689 | 3689 | |
3690 | 3690 | $resql = $this->db->query($sql); |
3691 | 3691 | if ($resql) { |
3692 | 3692 | $obj = $this->db->fetch_object($resql); |
3693 | - $nb = (int)$obj->nb; |
|
3693 | + $nb = (int) $obj->nb; |
|
3694 | 3694 | |
3695 | 3695 | $this->db->free($resql); |
3696 | 3696 | return $nb; |
@@ -3765,7 +3765,7 @@ discard block |
||
3765 | 3765 | { |
3766 | 3766 | // phpcs:enable |
3767 | 3767 | $sql = "SELECT rowid FROM " . $dbPrefix . "user"; |
3768 | - $sql .= " WHERE fk_user = " . ((int)$this->id); |
|
3768 | + $sql .= " WHERE fk_user = " . ((int) $this->id); |
|
3769 | 3769 | |
3770 | 3770 | dol_syslog(get_class($this) . "::get_children", LOG_DEBUG); |
3771 | 3771 | $res = $this->db->query($sql); |
@@ -4102,7 +4102,7 @@ discard block |
||
4102 | 4102 | |
4103 | 4103 | $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname"; |
4104 | 4104 | $sql .= " FROM " . $dbPrefix . "user"; |
4105 | - $sql .= " WHERE rowid = " . ((int)$rowid); |
|
4105 | + $sql .= " WHERE rowid = " . ((int) $rowid); |
|
4106 | 4106 | |
4107 | 4107 | $resql = $this->db->query($sql); |
4108 | 4108 | if ($resql) { |
@@ -4142,7 +4142,7 @@ discard block |
||
4142 | 4142 | |
4143 | 4143 | $encodedsecurekey = dol_hash($conf->file->instance_unique_id . 'uservirtualcard' . $this->id . '-' . $this->login, 'md5'); |
4144 | 4144 | if (isModEnabled('multicompany')) { |
4145 | - $entity_qr = '&entity=' . ((int)$conf->entity); |
|
4145 | + $entity_qr = '&entity=' . ((int) $conf->entity); |
|
4146 | 4146 | } else { |
4147 | 4147 | $entity_qr = ''; |
4148 | 4148 | } |
@@ -4196,7 +4196,7 @@ discard block |
||
4196 | 4196 | return -1; |
4197 | 4197 | } |
4198 | 4198 | |
4199 | - $this->findUserIdByEmailCache[$email] = (int)$obj->rowid; |
|
4199 | + $this->findUserIdByEmailCache[$email] = (int) $obj->rowid; |
|
4200 | 4200 | |
4201 | 4201 | return $this->findUserIdByEmailCache[$email]; |
4202 | 4202 | } |
@@ -325,8 +325,8 @@ discard block |
||
325 | 325 | // with |
326 | 326 | // '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,...' |
327 | 327 | // Note: string with 'PCG99-ABREGE','CAPIT', 1234 instead of 'PCG99-ABREGE','CAPIT', '1234' is also supported |
328 | - $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); |
|
329 | - $newsql = preg_replace('/([,\s])0 \+ ' . ((int)$offsetforchartofaccount) . '/ims', '\1 0', $newsql); |
|
328 | + $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); |
|
329 | + $newsql = preg_replace('/([,\s])0 \+ ' . ((int) $offsetforchartofaccount) . '/ims', '\1 0', $newsql); |
|
330 | 330 | //var_dump($newsql); |
331 | 331 | $arraysql[$i] = $newsql; |
332 | 332 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | // Define list of errors we accept (array $okerrors) |
491 | - $okerrors = [ // By default |
|
491 | + $okerrors = [// By default |
|
492 | 492 | 'DB_ERROR_TABLE_ALREADY_EXISTS', |
493 | 493 | 'DB_ERROR_COLUMN_ALREADY_EXISTS', |
494 | 494 | 'DB_ERROR_KEY_NAME_ALREADY_EXISTS', |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | if ($error == 0) { |
558 | 558 | $ok = 1; |
559 | 559 | } else { |
560 | - $ok = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment |
|
560 | + $ok = 0; // @phan-suppress-current-line PhanPluginRedundantAssignment |
|
561 | 561 | } |
562 | 562 | |
563 | 563 | return $ok; |
@@ -587,11 +587,11 @@ discard block |
||
587 | 587 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "const"; |
588 | 588 | $sql .= " WHERE (" . $db->decrypt('name') . " = '" . $db->escape($name) . "'"; |
589 | 589 | if (is_numeric($name)) { |
590 | - $sql .= " OR rowid = " . ((int)$name); |
|
590 | + $sql .= " OR rowid = " . ((int) $name); |
|
591 | 591 | } |
592 | 592 | $sql .= ")"; |
593 | 593 | if ($entity >= 0) { |
594 | - $sql .= " AND entity = " . ((int)$entity); |
|
594 | + $sql .= " AND entity = " . ((int) $entity); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | dol_syslog("admin.lib::dolibarr_del_const", LOG_DEBUG); |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | $sql = "SELECT " . $db->decrypt('value') . " as value"; |
624 | 624 | $sql .= " FROM " . MAIN_DB_PREFIX . "const"; |
625 | 625 | $sql .= " WHERE name = " . $db->encrypt($name); |
626 | - $sql .= " AND entity = " . ((int)$entity); |
|
626 | + $sql .= " AND entity = " . ((int) $entity); |
|
627 | 627 | |
628 | 628 | dol_syslog("admin.lib::dolibarr_get_const", LOG_DEBUG); |
629 | 629 | $resql = $db->query($sql); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "const"; |
675 | 675 | $sql .= " WHERE name = " . $db->encrypt($name); |
676 | 676 | if ($entity >= 0) { |
677 | - $sql .= " AND entity = " . ((int)$entity); |
|
677 | + $sql .= " AND entity = " . ((int) $entity); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | dol_syslog("admin.lib::dolibarr_set_const", LOG_DEBUG); |
@@ -696,7 +696,7 @@ discard block |
||
696 | 696 | $sql .= " VALUES ("; |
697 | 697 | $sql .= $db->encrypt($name); |
698 | 698 | $sql .= ", " . $db->encrypt($newvalue); |
699 | - $sql .= ", '" . $db->escape($type) . "', " . ((int)$visible) . ", '" . $db->escape($note) . "', " . ((int)$entity) . ")"; |
|
699 | + $sql .= ", '" . $db->escape($type) . "', " . ((int) $visible) . ", '" . $db->escape($note) . "', " . ((int) $entity) . ")"; |
|
700 | 700 | |
701 | 701 | //print "sql".$value."-".pg_escape_string($value)."-".$sql;exit; |
702 | 702 | //print "xx".$db->escape($value); |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | $sql = "SELECT COUNT(r.id) as nb"; |
860 | 860 | $sql .= " FROM " . MAIN_DB_PREFIX . "rights_def as r"; |
861 | 861 | $sql .= " WHERE r.libelle NOT LIKE 'tou%'"; // On ignore droits "tous" |
862 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
862 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
863 | 863 | $sql .= " AND bydefault = 1"; |
864 | 864 | if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { |
865 | 865 | $sql .= " AND r.perms NOT LIKE '%_advance'"; // Hide advanced perms if option is not enabled |
@@ -1755,7 +1755,7 @@ discard block |
||
1755 | 1755 | $obj = $db->fetch_object($result); // Take first result of select |
1756 | 1756 | |
1757 | 1757 | if (empty($obj)) { // If not yet into table |
1758 | - $obj = (object)['rowid' => '', 'name' => $const, 'value' => '', 'type' => $type, 'note' => '']; |
|
1758 | + $obj = (object) ['rowid' => '', 'name' => $const, 'value' => '', 'type' => $type, 'note' => '']; |
|
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | if (empty($strictw3c)) { |
@@ -1956,7 +1956,7 @@ discard block |
||
1956 | 1956 | $db->begin(); |
1957 | 1957 | |
1958 | 1958 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "document_model (nom, type, entity, libelle, description)"; |
1959 | - $sql .= " VALUES ('" . $db->escape($name) . "','" . $db->escape($type) . "'," . ((int)$conf->entity) . ", "; |
|
1959 | + $sql .= " VALUES ('" . $db->escape($name) . "','" . $db->escape($type) . "'," . ((int) $conf->entity) . ", "; |
|
1960 | 1960 | $sql .= ($label ? "'" . $db->escape($label) . "'" : 'null') . ", "; |
1961 | 1961 | $sql .= (!empty($description) ? "'" . $db->escape($description) . "'" : "null"); |
1962 | 1962 | $sql .= ")"; |
@@ -1990,7 +1990,7 @@ discard block |
||
1990 | 1990 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "document_model"; |
1991 | 1991 | $sql .= " WHERE nom = '" . $db->escape($name) . "'"; |
1992 | 1992 | $sql .= " AND type = '" . $db->escape($type) . "'"; |
1993 | - $sql .= " AND entity = " . ((int)$conf->entity); |
|
1993 | + $sql .= " AND entity = " . ((int) $conf->entity); |
|
1994 | 1994 | |
1995 | 1995 | dol_syslog("admin.lib::delDocumentModel", LOG_DEBUG); |
1996 | 1996 | $resql = $db->query($sql); |