From d9bf49c5dc2c7c2ce47c37396f2619a467015055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 31 Oct 2020 21:04:38 +0100 Subject: [PATCH 1/6] phpcs --- htdocs/admin/system/modules.php | 8 +- htdocs/admin/workflow.php | 2 +- htdocs/api/class/api_access.class.php | 2 +- htdocs/api/index.php | 2 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/dav/fileserver.php | 2 +- htdocs/debugbar/class/autoloader.php | 2 +- htdocs/product/admin/price_rules.php | 2 +- htdocs/user/class/api_users.class.php | 88 +++++++------------ 9 files changed, 43 insertions(+), 67 deletions(-) diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index 8347a9a6e4c..28dcb6641ef 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -270,13 +270,13 @@ print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $ print ''; // sort list -if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->name, $b->name); }); -if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "name" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->name, $a->name); }); -if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "asc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($a->version, $b->version); }); -if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function(stdClass $a, stdClass $b) { +if ($sortfield == "version" && $sortorder == "desc") usort($moduleList, function (stdClass $a, stdClass $b) { return strcasecmp($b->version, $a->version); }); if ($sortfield == "id" && $sortorder == "asc") usort($moduleList, "compareIdAsc"); if ($sortfield == "id" && $sortorder == "desc") usort($moduleList, "compareIdDesc"); diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 5ee707a8002..6bd3edca2b8 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -139,7 +139,7 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w } // remove not available workflows (based on activated modules and global defined keys) -$workflowcodes = array_filter($workflowcodes, function($var) { +$workflowcodes = array_filter($workflowcodes, function ($var) { return $var['enabled']; }); /* diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 6f6e1a2fb6c..e7b8ac8536b 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -18,7 +18,7 @@ // Create the autoloader for Luracast require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function() { +call_user_func(function () { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; diff --git a/htdocs/api/index.php b/htdocs/api/index.php index f605ff11d85..2fba9fbb554 100644 --- a/htdocs/api/index.php +++ b/htdocs/api/index.php @@ -45,7 +45,7 @@ if (!$res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/AutoLoader.php'; -call_user_func(function() { +call_user_func(function () { $loader = Luracast\Restler\AutoLoader::instance(); spl_autoload_register($loader); return $loader; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7e8d2da34ce..6015bbceece 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1288,7 +1288,7 @@ abstract class CommonDocGenerator if (!empty($fields)) { // Sort extrafields by rank - uasort($fields, function($a, $b) { + uasort($fields, function ($a, $b) { return ($a->rank > $b->rank) ? 1 : -1; }); diff --git a/htdocs/dav/fileserver.php b/htdocs/dav/fileserver.php index c4939bd4069..bd6df769553 100644 --- a/htdocs/dav/fileserver.php +++ b/htdocs/dav/fileserver.php @@ -82,7 +82,7 @@ $tmpDir = $conf->dav->multidir_output[$entity]; // We need root dir, not a dir t // Authentication callback function -$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function($username, $password) { +$authBackend = new \Sabre\DAV\Auth\Backend\BasicCallBack(function ($username, $password) { global $user; global $conf; global $dolibarr_main_authentication, $dolibarr_auto_user; diff --git a/htdocs/debugbar/class/autoloader.php b/htdocs/debugbar/class/autoloader.php index 721febdd13c..91606babb84 100644 --- a/htdocs/debugbar/class/autoloader.php +++ b/htdocs/debugbar/class/autoloader.php @@ -4,7 +4,7 @@ * Simple autoloader, so we don't need Composer just for this. */ -spl_autoload_register(function($class) { +spl_autoload_register(function ($class) { if (preg_match('/^DebugBar/', $class)) { $file = DOL_DOCUMENT_ROOT.'/includes/maximebf/debugbar/src/'.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php'; //var_dump($class.' - '.file_exists($file).' - '.$file); diff --git a/htdocs/product/admin/price_rules.php b/htdocs/product/admin/price_rules.php index 000acb485d2..84510dfabad 100644 --- a/htdocs/product/admin/price_rules.php +++ b/htdocs/product/admin/price_rules.php @@ -141,7 +141,7 @@ for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { $price_options[$i] = $langs->trans('SellingPrice').' '.$i; } -$genPriceOptions = function($level) use ($price_options) { +$genPriceOptions = function ($level) use ($price_options) { $return = array(); diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index dedbd1992f3..d04c735eeed 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -86,7 +86,9 @@ class Users extends DolibarrApi $sql .= ", ".MAIN_DB_PREFIX."categorie_user as c"; } $sql .= ' WHERE t.entity IN ('.getEntity('user').')'; - if ($user_ids) $sql .= " AND t.rowid IN (".$user_ids.")"; + if ($user_ids) { + $sql .= " AND t.rowid IN (".$user_ids.")"; + } // Select products of given category if ($category > 0) { @@ -95,10 +97,8 @@ class Users 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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -107,8 +107,7 @@ class Users extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -118,13 +117,11 @@ class Users extends DolibarrApi $result = $this->db->query($sql); - if ($result) - { + if ($result) { $i = 0; $num = $this->db->num_rows($result); $min = min($num, ($limit <= 0 ? $num : $limit)); - while ($i < $min) - { + while ($i < $min) { $obj = $this->db->fetch_object($result); $user_static = new User($this->db); if ($user_static->fetch($obj->rowid)) { @@ -158,13 +155,11 @@ class Users extends DolibarrApi //} $result = $this->useraccount->fetch($id); - if (!$result) - { + if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -194,13 +189,11 @@ class Users extends DolibarrApi //} $result = $this->useraccount->fetch('', $login); - if (!$result) - { + if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -230,13 +223,11 @@ class Users extends DolibarrApi //} $result = $this->useraccount->fetch('', '', '', 0, -1, $email); - if (!$result) - { + if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -301,13 +292,12 @@ class Users extends DolibarrApi if (!isset($request_data["lastname"])) throw new RestException(400, "lastname field missing");*/ //assign field values - foreach ($request_data as $field => $value) - { + foreach ($request_data as $field => $value) { $this->useraccount->$field = $value; } if ($this->useraccount->create(DolibarrApiAccess::$user) < 0) { - throw new RestException(500, 'Error creating', array_merge(array($this->useraccount->error), $this->useraccount->errors)); + throw new RestException(500, 'Error creating', array_merge(array($this->useraccount->error), $this->useraccount->errors)); } return $this->useraccount->id; } @@ -329,13 +319,11 @@ class Users extends DolibarrApi //} $result = $this->useraccount->fetch($id); - if (!$result) - { + if (!$result) { throw new RestException(404, 'Account not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -356,8 +344,7 @@ class Users extends DolibarrApi // If there is no error, update() returns the number of affected // rows so if the update is a no op, the return value is zezo. - if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0) - { + if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0) { return $this->get($id); } else { throw new RestException(500, $this->useraccount->error); @@ -419,18 +406,15 @@ class Users extends DolibarrApi //throw new RestException(401); //} $result = $this->useraccount->fetch($id); - if (!$result) - { + if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && !empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity)) - { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && !empty(DolibarrApiAccess::$user->admin) && empty(DolibarrApiAccess::$user->entity)) { $entity = (!empty($entity) ? $entity : $conf->entity); } else { // When using API, action is done on entity of logged user because a user of entity X with permission to create user should not be able to @@ -439,8 +423,7 @@ class Users extends DolibarrApi } $result = $this->useraccount->SetInGroup($group, $entity); - if (!($result > 0)) - { + if (!($result > 0)) { throw new RestException(500, $this->useraccount->error); } @@ -480,10 +463,8 @@ class Users extends DolibarrApi $sql .= ' WHERE t.entity IN ('.getEntity('user').')'; if ($group_ids) $sql .= " AND t.rowid IN (".$group_ids.")"; // 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 = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; @@ -492,8 +473,7 @@ class Users extends DolibarrApi $sql .= $this->db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -545,11 +525,10 @@ class Users extends DolibarrApi throw new RestException(401, "You are not allowed to read groups"); } - $group_static = new UserGroup($this->db); - $result = $group_static->fetch($group, '', $load_members); + $group_static = new UserGroup($this->db); + $result = $group_static->fetch($group, '', $load_members); - if (!$result) - { + if (!$result) { throw new RestException(404, 'Group not found'); } @@ -568,13 +547,11 @@ class Users extends DolibarrApi //throw new RestException(401); //} $result = $this->useraccount->fetch($id); - if (!$result) - { + if (!$result) { throw new RestException(404, 'User not found'); } - if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) - { + if (!DolibarrApi::_checkAccessToResource('user', $this->useraccount->id, 'user')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->useraccount->oldcopy = clone $this->useraccount; @@ -636,8 +613,7 @@ class Users extends DolibarrApi $canreadsalary = ((!empty($conf->salaries->enabled) && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (!empty($conf->hrm->enabled) && !empty(DolibarrApiAccess::$user->rights->hrm->employee->read))); - if (!$canreadsalary) - { + if (!$canreadsalary) { unset($object->salary); unset($object->salaryextra); unset($object->thm); From 07432779d93af55ab6e7d4475e458a43f297ca9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Nov 2020 08:48:53 +0100 Subject: [PATCH 2/6] doxygen --- htdocs/adherents/class/adherent.class.php | 44 ++++++++++++++++++----- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c48b00050f8..7da7854d22f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -7,7 +7,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2014-2018 Alexandre Spangaro * Copyright (C) 2015 Marcos García - * Copyright (C) 2015-2018 Frédéric France + * Copyright (C) 2015-2020 Frédéric France * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2018-2019 Thibault FOUCART @@ -60,6 +60,9 @@ class Adherent extends CommonObject */ public $ismultientitymanaged = 1; + /** + * @var string picto + */ public $picto = 'member'; @@ -70,13 +73,19 @@ class Adherent extends CommonObject */ public $login; - //! Clear password in memory + /** + * @var Clear password in memory + */ public $pass; - //! Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + /** + * @var Clear password in database (defined if DATABASE_PWD_ENCRYPTED=0) + */ public $pass_indatabase; - //! Encrypted password in database (always defined) + /** + * @var Encrypted password in database (always defined) + */ public $pass_indatabase_crypted; /** @@ -184,6 +193,9 @@ class Adherent extends CommonObject */ public $poste; + /** + * @var string mor or phy + */ public $morphy; public $public; @@ -191,6 +203,10 @@ class Adherent extends CommonObject // -1:brouillon, 0:resilie, >=1:valide,paye // def in common object //public $status; + + /** + * @var string photo of member + */ public $photo; /** @@ -209,6 +225,9 @@ class Adherent extends CommonObject public $datevalid; + /** + * @var string gender + */ public $gender; public $birth; @@ -258,7 +277,11 @@ class Adherent extends CommonObject */ public $entity; - public $fields = array('rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), + /** + * @var array fields + */ + public $fields = array( + 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 10), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), 'ref_ext' => array('type' => 'varchar(128)', 'label' => 'Ref ext', 'enabled' => 1, 'visible' => 0, 'position' => 20), 'civility' => array('type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'visible' => -1, 'position' => 25), @@ -296,9 +319,10 @@ class Adherent extends CommonObject 'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190), 'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195), 'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500, - 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), + 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort')), 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800), - 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)); + 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805) + ); /** @@ -407,7 +431,8 @@ class Adherent extends CommonObject $infos .= $langs->transnoentities("Public").": ".yn($this->public); // Substitutions - $substitutionarray = array('__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), + $substitutionarray = array( + '__ID__' => $this->id, '__MEMBER_ID__' => $this->id, '__CIVILITY__' => $this->getCivilityLabel(), '__FIRSTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->firstname) : ($this->firstname ? $this->firstname : ''), '__LASTNAME__' => $msgishtml ? dol_htmlentitiesbr($this->lastname) : ($this->lastname ? $this->lastname : ''), '__FULLNAME__' => $msgishtml ? dol_htmlentitiesbr($this->getFullName($langs)) : $this->getFullName($langs), @@ -422,7 +447,8 @@ class Adherent extends CommonObject '__PHONE__' => $msgishtml ? dol_htmlentitiesbr($this->phone) : ($this->phone ? $this->phone : ''), '__PHONEPRO__' => $msgishtml ? dol_htmlentitiesbr($this->phone_perso) : ($this->phone_perso ? $this->phone_perso : ''), '__PHONEMOBILE__' => $msgishtml ? dol_htmlentitiesbr($this->phone_mobile) : ($this->phone_mobile ? $this->phone_mobile : ''), - '__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '')); + '__TYPE__' => $msgishtml ? dol_htmlentitiesbr($this->type) : ($this->type ? $this->type : '') + ); complete_substitutions_array($substitutionarray, $langs, $this); From c2781d5551f969423682765efab5163753eefb78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Nov 2020 08:54:12 +0100 Subject: [PATCH 3/6] doxygen --- htdocs/adherents/class/api_members.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 321d789e03a..954ea42f9b4 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2016 Xebax Christy * Copyright (C) 2017 Regis Houssin * Copyright (C) 2020 Thibault FOUCART + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,9 +84,9 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param int $thirdparty ID of third party + * @param int $thirdparty ID of third party * - * @return array|mixed Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/{thirdparty} * @@ -118,7 +119,7 @@ class Members extends DolibarrApi * * @param string $email Email of third party * - * @return array|mixed Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/email/{email} * @@ -155,9 +156,9 @@ class Members extends DolibarrApi * * Return an array with member informations * - * @param string $barcode Barcode of third party + * @param string $barcode Barcode of third party * - * @return array|mixed Data without useless information + * @return Object Data without useless information * * @url GET thirdparty/barcode/{barcode} * @@ -301,7 +302,7 @@ class Members extends DolibarrApi * * @param int $id ID of member to update * @param array $request_data Datas - * @return int + * @return Object Updated object */ public function put($id, $request_data = null) { From 26406b0f9fb2a6c575721f3b7533fe196aae2806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Nov 2020 08:56:56 +0100 Subject: [PATCH 4/6] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 7da7854d22f..1dde1971b0f 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -178,6 +178,11 @@ class Adherent extends CommonObject */ public $phone_perso; + /** + * @var string Professional Phone number + */ + public $phone_pro; + /** * @var string Mobile phone number */ From 7b8c05250f74bf8169ecd94c27eab83484bbf6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 1 Nov 2020 09:13:02 +0100 Subject: [PATCH 5/6] fix vcard birthday of member --- htdocs/adherents/vcard.php | 49 +++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/htdocs/adherents/vcard.php b/htdocs/adherents/vcard.php index 1bf1f5c01ce..32b4a6de2d6 100644 --- a/htdocs/adherents/vcard.php +++ b/htdocs/adherents/vcard.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,8 +40,7 @@ $result = restrictedArea($user, 'adherent', $id, '', '', 'socid', 'rowid', $objc $result = $adherent->fetch($id); -if ($result <= 0) -{ +if ($result <= 0) { dol_print_error($adherent->error); exit; } @@ -48,8 +48,7 @@ if ($result <= 0) $physicalperson = 1; $company = new Societe($db); -if ($adherent->socid) -{ +if ($adherent->socid) { $result = $company->fetch($adherent->socid); } @@ -72,37 +71,35 @@ $v->setAddress("", "", $adherent->address, $adherent->town, $adherent->state, $a $v->setLabel("", "", $adherent->address, $adherent->town, $adherent->state, $adherent->zip, $country, "TYPE=WORK"); $v->setEmail($adherent->email); -$v->setNote($adherent->note); +$v->setNote($adherent->note_public); $v->setTitle($adherent->poste); // Data from linked company -if ($company->id) -{ +if ($company->id) { $v->setURL($company->url, "TYPE=WORK"); - if (!$adherent->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); - if (!$adherent->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); - if (!$adherent->zip) $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); - + if (!$adherent->phone_pro) { + $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE"); + } + if (!$adherent->fax) { + $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX"); + } + if (!$adherent->zip) { + $v->setAddress("", "", $company->address, $company->town, $company->state, $company->zip, $company->country, "TYPE=WORK;POSTAL"); + } // when company e-mail is empty, use only adherent e-mail - if (empty(trim($company->email))) - { + if (empty(trim($company->email))) { // was set before, don't set twice - } - // when adherent e-mail is empty, use only company e-mail - elseif (empty(trim($adherent->email))) - { + } elseif (empty(trim($adherent->email))) { + // when adherent e-mail is empty, use only company e-mail $v->setEmail($company->email); - } - // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) - elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) - { + } elseif (strtolower(end(explode("@", $adherent->email))) == strtolower(end(explode("@", $company->email)))) { + // when e-mail domain of adherent and company are the same, use adherent e-mail at first (and company e-mail at second) $v->setEmail($adherent->email); // support by Microsoft Outlook (2019 and possible earlier) $v->setEmail($company->email, 'INTERNET'); - } - // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) - else { + } else { + // when e-mail of adherent and company complete different use company e-mail at first (and adherent e-mail at second) $v->setEmail($company->email); // support by Microsoft Outlook (2019 and possible earlier) @@ -115,7 +112,9 @@ if ($company->id) // Personal informations $v->setPhoneNumber($adherent->phone_perso, "TYPE=HOME;VOICE"); -if ($adherent->birthday) $v->setBirthday($adherent->birthday); +if ($adherent->birth) { + $v->setBirthday($adherent->birth); +} $db->close(); From e19e56e14cb4941491d8cfe81b9425ae9eddc52e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Nov 2020 10:21:51 +0100 Subject: [PATCH 6/6] FIX to avoid error with geoip --- htdocs/core/class/dolgeoip.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 2619d09602b..215a1710b82 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -92,10 +92,13 @@ class DolGeoIP } elseif (function_exists('geoip_open')) { $this->gi = geoip_open($datfile, GEOIP_STANDARD); - } else { + } + elseif (function_exists('geoip_country_code_by_name')) { $this->gi = 'NOGI'; // We are using embedded php geoip functions //print 'function_exists(geoip_country_code_by_name))='.function_exists('geoip_country_code_by_name'); //print geoip_database_info(); + } else { + $this->gi = ''; // For avoid error } }