From 16d1bf9b007494f38a2957cc664dc45809e22a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Dec 2020 10:17:28 +0100 Subject: [PATCH] fix unknown variable --- htdocs/api/class/api_setup.class.php | 360 ++++++++++++--------------- 1 file changed, 163 insertions(+), 197 deletions(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 47ab4686a1d..fbeb2cc931b 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -75,10 +75,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_input_method as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -112,70 +110,68 @@ class Setup extends DolibarrApi return $list; } - /** - * Get the list of ordering origins. - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Number of items per page - * @param int $page Page number {@min 0} - * @param int $active Payment type is active or not {@min 0} {@max 1} - * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" - * - * @url GET dictionary/ordering_origins - * - * @return array [List of ordering reasons] - * - * @throws RestException 400 - */ - public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') - { - $list = array(); + /** + * Get the list of ordering origins. + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Number of items per page + * @param int $page Page number {@min 0} + * @param int $active Payment type is active or not {@min 0} {@max 1} + * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'OrderByWWW')" + * + * @url GET dictionary/ordering_origins + * + * @return array [List of ordering reasons] + * + * @throws RestException 400 + */ + public function getOrderingOrigins($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + { + $list = array(); - if (!DolibarrApiAccess::$user->rights->commande->lire) { - throw new RestException(401); - } + if (!DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } - $sql = "SELECT rowid, code, label, module"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; - $sql .= " WHERE t.active = ".$active; - // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $sql = "SELECT rowid, code, label, module"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_input_reason as t"; + $sql .= " WHERE t.active = ".$active; + // Add sql filters + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } - $sql .= $this->db->order($sortfield, $sortorder); + $sql .= $this->db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($limit) { + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); - } + $sql .= $this->db->plimit($limit, $offset); + } - $result = $this->db->query($sql); + $result = $this->db->query($sql); - if ($result) { - $num = $this->db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - for ($i = 0; $i < $min; $i++) { - $list[] = $this->db->fetch_object($result); - } - } else { - throw new RestException(400, $this->db->lasterror()); - } + if ($result) { + $num = $this->db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + for ($i = 0; $i < $min; $i++) { + $list[] = $this->db->fetch_object($result); + } + } else { + throw new RestException(400, $this->db->lasterror()); + } - return $list; - } + return $list; + } /** * Get the list of payments types. @@ -206,10 +202,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_paiement').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -272,10 +266,8 @@ class Setup extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_departements as t"; $sql .= " WHERE 1 = 1"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -374,10 +366,8 @@ class Setup extends DolibarrApi $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_country as t"; $sql .= " WHERE 1 = 1"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -551,10 +541,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_availability as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -659,10 +647,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -720,13 +706,15 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, type, libelle as label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as t"; $sql .= " WHERE t.active = ".$active; - if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($type) { + $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; + } + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -784,12 +772,12 @@ class Setup extends DolibarrApi $sql = "SELECT id, code, label, accountancy_code, active, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees as t"; $sql .= " WHERE t.active = ".$active; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -848,13 +836,15 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, element as type, libelle as label, source, module, position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_type_contact as t"; $sql .= " WHERE t.active = ".$active; - if ($type) $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($type) { + $sql .= " AND type LIKE '%".$this->db->escape($type)."%'"; + } + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -911,12 +901,12 @@ class Setup extends DolibarrApi $sql = "SELECT rowid, code, label, module"; $sql .= " FROM ".MAIN_DB_PREFIX."c_civility as t"; $sql .= " WHERE t.active = ".$active; - if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + if ($module) { + $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -970,7 +960,9 @@ class Setup extends DolibarrApi { $list = array(); $sql = "SELECT t.code_iso, t.label, t.unicode"; - if (!empty($multicurrency)) $sql .= " , cr.date_sync, cr.rate "; + if (!empty($multicurrency)) { + $sql .= " , cr.date_sync, cr.rate "; + } $sql .= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; if (!empty($multicurrency)) { $sql .= " JOIN ".MAIN_DB_PREFIX."multicurrency as m ON m.code=t.code_iso"; @@ -985,10 +977,8 @@ class Setup extends DolibarrApi } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1043,18 +1033,22 @@ class Setup extends DolibarrApi throw new RestException(401, 'Only an admin user can get list of extrafields'); } - if ($type == 'thirdparty') $type = 'societe'; - if ($type == 'contact') $type = 'socpeople'; + if ($type == 'thirdparty') { + $type = 'societe'; + } + if ($type == 'contact') { + $type = 'socpeople'; + } $sql = "SELECT t.rowid, t.name, t.label, t.type, t.size, t.elementtype, t.fieldunique, t.fieldrequired, t.param, t.pos, t.alwayseditable, t.perms, t.list, t.fielddefault, t.fieldcomputed"; $sql .= " FROM ".MAIN_DB_PREFIX."extrafields as t"; $sql .= " WHERE t.entity IN (".getEntity('extrafields').")"; - if (!empty($type)) $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; + if (!empty($type)) { + $sql .= " AND t.elementtype = '".$this->db->escape($type)."'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1064,12 +1058,9 @@ class Setup extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); $resql = $this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - while ($tab = $this->db->fetch_object($resql)) - { + if ($resql) { + if ($this->db->num_rows($resql)) { + while ($tab = $this->db->fetch_object($resql)) { // New usage $list[$tab->elementtype][$tab->name]['type'] = $tab->type; $list[$tab->elementtype][$tab->name]['label'] = $tab->label; @@ -1090,8 +1081,7 @@ class Setup extends DolibarrApi throw new RestException(503, 'Error when retrieving list of extra fields : '.$this->db->lasterror()); } - if (!count($list)) - { + if (!count($list)) { throw new RestException(404, 'No extrafield found'); } @@ -1123,13 +1113,15 @@ class Setup extends DolibarrApi $sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ziptown as t"; $sql .= " AND t.active = ".$active; - if ($zipcode) $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; - if ($town) $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; + if ($zipcode) { + $sql .= " AND t.zip LIKE '%".$this->db->escape($zipcode)."%'"; + } + if ($town) { + $sql .= " AND t.town LIKE '%".$this->db->escape($town)."%'"; + } // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1192,10 +1184,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_payment_term').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1252,10 +1242,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_shipment_mode').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(400, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1313,10 +1301,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1380,10 +1366,8 @@ class Setup extends DolibarrApi $sql .= " WHERE t.entity IN (".getEntity('c_socialnetworks').")"; $sql .= " AND t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1440,10 +1424,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1500,10 +1482,8 @@ class Setup extends DolibarrApi $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; $sql .= " WHERE t.active = ".$active; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1562,10 +1542,8 @@ class Setup extends DolibarrApi // if ($type) $sql .= " AND t.type LIKE '%".$this->db->escape($type)."%'"; // if ($module) $sql .= " AND t.module LIKE '%".$this->db->escape($module)."%'"; // Add sql filters - if ($sqlfilters) - { - if (!DolibarrApi::_checkFilters($sqlfilters)) - { + if ($sqlfilters) { + if (!DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -1604,13 +1582,13 @@ class Setup extends DolibarrApi * * @url GET /company * - * @return array|mixed Data without useless information + * @return Object Mysoc object * * @throws RestException 403 Forbidden */ public function getCompany() { - global $mysoc; + global $conf, $mysoc; if (!DolibarrApiAccess::$user->admin && (empty($conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY) || DolibarrApiAccess::$user->login != $conf->global->API_LOGINS_ALLOWED_FOR_GET_COMPANY)) { @@ -1710,8 +1688,7 @@ class Setup extends DolibarrApi global $langs, $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) - { + && (empty($conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK)) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_INTEGRITY_CHECK'); } @@ -1731,10 +1708,16 @@ class Setup extends DolibarrApi $xmlfile = DOL_DOCUMENT_ROOT.$xmlshortfile; // Remote file to compare to $xmlremote = ($target == 'default' ? '' : $target); - if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) $xmlremote = $conf->global->MAIN_FILECHECK_URL; + if (empty($xmlremote) && !empty($conf->global->MAIN_FILECHECK_URL)) { + $xmlremote = $conf->global->MAIN_FILECHECK_URL; + } $param = 'MAIN_FILECHECK_URL_'.DOL_VERSION; - if (empty($xmlremote) && !empty($conf->global->$param)) $xmlremote = $conf->global->$param; - if (empty($xmlremote)) $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; + if (empty($xmlremote) && !empty($conf->global->$param)) { + $xmlremote = $conf->global->$param; + } + if (empty($xmlremote)) { + $xmlremote = 'https://www.dolibarr.org/files/stable/signatures/filelist-'.DOL_VERSION.'.xml'; + } if ($target == 'local') { if (dol_is_file($xmlfile)) { @@ -1756,8 +1739,7 @@ class Setup extends DolibarrApi } } - if ($xml) - { + if ($xml) { $checksumconcat = array(); $file_list = array(); $out = ''; @@ -1776,14 +1758,15 @@ class Setup extends DolibarrApi $out .= ''."\n"; $i = 0; - foreach ($xml->dolibarr_constants[0]->constant as $constant) // $constant is a simpleXMLElement - { + foreach ($xml->dolibarr_constants[0]->constant as $constant) { // $constant is a simpleXMLElement $constname = $constant['name']; $constvalue = (string) $constant; $constvalue = (empty($constvalue) ? '0' : $constvalue); // Value found $value = ''; - if ($constname && $conf->global->$constname != '') $value = $conf->global->$constname; + if ($constname && $conf->global->$constname != '') { + $value = $conf->global->$constname; + } $valueforchecksum = (empty($value) ? '0' : $value); $checksumconcat[] = $valueforchecksum; @@ -1797,8 +1780,7 @@ class Setup extends DolibarrApi $out .= "\n"; } - if ($i == 0) - { + if ($i == 0) { $out .= ''.$langs->trans("None").''; } $out .= ''; @@ -1808,9 +1790,7 @@ class Setup extends DolibarrApi } // Scan htdocs - if (is_object($xml->dolibarr_htdocs_dir[0])) - { - //var_dump($xml->dolibarr_htdocs_dir[0]['includecustom']);exit; + if (is_object($xml->dolibarr_htdocs_dir[0])) { $includecustom = (empty($xml->dolibarr_htdocs_dir[0]['includecustom']) ? 0 : $xml->dolibarr_htdocs_dir[0]['includecustom']); // Defined qualified files (must be same than into generate_filelist_xml.php) @@ -1821,11 +1801,9 @@ class Setup extends DolibarrApi // Fill file_list with files in signature, new files, modified files $ret = getFilesUpdated($file_list, $xml->dolibarr_htdocs_dir[0], '', DOL_DOCUMENT_ROOT, $checksumconcat); // Fill array $file_list // Complete with list of new files - foreach ($scanfiles as $keyfile => $valfile) - { + foreach ($scanfiles as $keyfile => $valfile) { $tmprelativefilename = preg_replace('/^'.preg_quote(DOL_DOCUMENT_ROOT, '/').'/', '', $valfile['fullname']); - if (!in_array($tmprelativefilename, $file_list['insignature'])) - { + if (!in_array($tmprelativefilename, $file_list['insignature'])) { $md5newfile = @md5_file($valfile['fullname']); // Can fails if we don't have permission to open/read file $file_list['added'][] = array('filename'=>$tmprelativefilename, 'md5'=>$md5newfile); } @@ -1842,11 +1820,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("ExpectedChecksum").''; $out .= ''."\n"; $tmpfilelist = dol_sort_array($file_list['missing'], 'filename'); - if (is_array($tmpfilelist) && count($tmpfilelist)) - { + if (is_array($tmpfilelist) && count($tmpfilelist)) { $i = 0; - foreach ($tmpfilelist as $file) - { + foreach ($tmpfilelist as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1877,11 +1853,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("DateModification").''; $out .= ''."\n"; $tmpfilelist2 = dol_sort_array($file_list['updated'], 'filename'); - if (is_array($tmpfilelist2) && count($tmpfilelist2)) - { + if (is_array($tmpfilelist2) && count($tmpfilelist2)) { $i = 0; - foreach ($tmpfilelist2 as $file) - { + foreach ($tmpfilelist2 as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1925,11 +1899,9 @@ class Setup extends DolibarrApi $out .= ''.$langs->trans("DateModification").''; $out .= ''."\n"; $tmpfilelist3 = dol_sort_array($file_list['added'], 'filename'); - if (is_array($tmpfilelist3) && count($tmpfilelist3)) - { + if (is_array($tmpfilelist3) && count($tmpfilelist3)) { $i = 0; - foreach ($tmpfilelist3 as $file) - { + foreach ($tmpfilelist3 as $file) { $i++; $out .= ''; $out .= ''.$i.''."\n"; @@ -1958,8 +1930,7 @@ class Setup extends DolibarrApi // Show warning - if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) - { + if (empty($tmpfilelist) && empty($tmpfilelist2) && empty($tmpfilelist3)) { //setEventMessages($langs->trans("FileIntegrityIsStrictlyConformedWithReference"), null, 'mesgs'); } else { //setEventMessages($langs->trans("FileIntegritySomeFilesWereRemovedOrModified"), null, 'warnings'); @@ -1970,17 +1941,13 @@ class Setup extends DolibarrApi // Scan scripts - - asort($checksumconcat); // Sort list of checksum - //var_dump($checksumconcat); $checksumget = md5(join(',', $checksumconcat)); $checksumtoget = trim((string) $xml->dolibarr_htdocs_dir_checksum); $outexpectedchecksum = ($checksumtoget ? $checksumtoget : $langs->trans("Unknown")); if ($checksumget == $checksumtoget) { - if (count($file_list['added'])) - { + if (count($file_list['added'])) { $resultcode = 'warning'; $resultcomment = 'FileIntegrityIsOkButFilesWereAdded'; //$outcurrentchecksum = $checksumget.' - '.$langs->trans("FileIntegrityIsOkButFilesWereAdded").''; @@ -2019,8 +1986,7 @@ class Setup extends DolibarrApi global $conf; if (!DolibarrApiAccess::$user->admin - && (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) - { + && (empty($conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES) || DolibarrApiAccess::$user->login != $conf->global->API_LOGIN_ALLOWED_FOR_GET_MODULES)) { throw new RestException(403, 'Error API open to admin users only or to the users with logins defined into constant API_LOGIN_ALLOWED_FOR_GET_MODULES'); }