From 2dfc8df6487403de2092acc4d625c8179a026b5a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 02:02:46 +0100 Subject: [PATCH 01/90] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- htdocs/core/class/fileupload.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 0a9523a5e82..b8b4d4e0cc5 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -495,7 +495,7 @@ class FileUpload $error = 0; if (isset($_REQUEST['_method']) && $_REQUEST['_method'] === 'DELETE') { - return $this->delete(); + return $this->delete($_REQUEST['file']); } //var_dump($_FILES); From c01b7e793cf39ced7e009bb3999d576f9d3f97ea Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Sat, 3 Feb 2024 02:06:14 +0100 Subject: [PATCH 02/90] Close #27774 new contact in project (#27947) * Close #27774 new contact in project * add test to not show * fix as advised --------- Co-authored-by: Hystepik --- htdocs/core/tpl/contacts.tpl.php | 24 ++++++- htdocs/langs/en_US/errors.lang | 2 + htdocs/projet/contact.php | 107 ++++++++++++++++++++++--------- 3 files changed, 100 insertions(+), 33 deletions(-) diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index e2ec740ac66..85b904d53c3 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -113,7 +113,28 @@ if ($permission) {
global->MAIN_INFO_SOCIETE_NOM; ?>
-
select_dolusers($user->id, 'userid', 0, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, 0, '', 0, '', 'minwidth100imp widthcentpercentminusxx maxwidth400'); ?>
+
+ select_dolusers($user->id, 'userid', 1, (!empty($userAlreadySelected) ? $userAlreadySelected : null), 0, null, null, 0, 56, 0, '', 0, '', 'minwidth100imp widthcentpercentminusxx maxwidth400 userselectcontact'); + if (empty($hideaddcontactforgroups) && $module == 'project') { + print ' '.$langs->trans("or").' '; + echo img_object('', 'group', 'class="pictofixedwidth"').$form->select_dolgroups(0, 'groupid', 1, '', 0, '', array(), '0', false, 'minwidth100imp widthcentpercentminusxx maxwidth400 groupselectcontact'); + } + ?> + +
 
">
- id not defined OperNotDefined=Oper not defined +ErrorThisContactXIsAlreadyDefinedAsThisType=%s is already defined as contact for this type. +ErrorThisGroupIsAlreadyDefinedAsThisType=The contacts with this group are already defined as contact for this type. diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 43297b14009..b9926768a95 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -165,50 +165,83 @@ if (empty($reshook)) { $contactid = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $groupid = GETPOSTINT('groupid'); + $contactarray = array(); + $errorgroup = 0; + $errorgrouparray = array(); - if (! ($contactid > 0)) { + if ($groupid > 0) { + require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php'; + $usergroup = new UserGroup($db); + $result = $usergroup->fetch($groupid); + if ($result > 0) { + $tmpcontactarray = $usergroup->listUsersForGroup(); + if ($contactarray <= 0) { + $error++; + } else { + foreach ($tmpcontactarray as $tmpuser) { + $contactarray[] = $tmpuser->id; + } + } + } else { + $error++; + } + } elseif (! ($contactid > 0)) { $error++; $langs->load("errors"); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Contact")), null, 'errors'); + } else { + $contactarray[] = $contactid; } $result = 0; $result = $object->fetch($id); - if (!$error && $result > 0 && $id > 0) { - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); + foreach ($contactarray as $key => $contactid) { + $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - if ($result == 0) { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } elseif ($result < 0) { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); + if ($result == 0) { + if ($groupid > 0) { + $errorgroup++; + $errorgrouparray[] = $contactid; + } else { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } + } elseif ($result < 0) { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + if ($groupid > 0) { + $errorgroup++; + $errorgrouparray[] = $contactid; + } else { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } } - } - $affecttotask=GETPOST('tasksavailable', 'intcomma'); - if (!empty($affecttotask)) { - require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; - $task_to_affect = explode(',', $affecttotask); - if (!empty($task_to_affect)) { - foreach ($task_to_affect as $task_id) { - if (GETPOSTISSET('person_'.$task_id) && GETPOST('person_'.$task_id, 'san_alpha')) { - $tasksToAffect = new Task($db); - $result=$tasksToAffect->fetch($task_id); - if ($result < 0) { - setEventMessages($tasksToAffect->error, null, 'errors'); - } else { - $result = $tasksToAffect->add_contact($contactid, GETPOST('person_role_'.$task_id), GETPOST("source", 'aZ09')); + $affecttotask=GETPOST('tasksavailable', 'intcomma'); + if (!empty($affecttotask)) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php'; + $task_to_affect = explode(',', $affecttotask); + if (!empty($task_to_affect)) { + foreach ($task_to_affect as $task_id) { + if (GETPOSTISSET('person_'.$task_id) && GETPOST('person_'.$task_id, 'san_alpha')) { + $tasksToAffect = new Task($db); + $result=$tasksToAffect->fetch($task_id); if ($result < 0) { - if ($tasksToAffect->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($tasksToAffect->error, $tasksToAffect->errors, 'errors'); + setEventMessages($tasksToAffect->error, null, 'errors'); + } else { + $result = $tasksToAffect->add_contact($contactid, GETPOST('person_role_'.$task_id), GETPOST("source", 'aZ09')); + if ($result < 0) { + if ($tasksToAffect->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } else { + setEventMessages($tasksToAffect->error, $tasksToAffect->errors, 'errors'); + } } } } @@ -217,6 +250,18 @@ if (empty($reshook)) { } } } + if ($errorgroup > 0) { + $langs->load("errors"); + if ($errorgroup == count($contactarray)) { + setEventMessages($langs->trans("ErrorThisGroupIsAlreadyDefinedAsThisType"), null, 'errors'); + } else { + $tmpuser = new User($db); + foreach ($errorgrouparray as $key => $value) { + $tmpuser->fetch($value); + setEventMessages($langs->trans("ErrorThisContactXIsAlreadyDefinedAsThisType", dolGetFirstLastname($tmpuser->firstname, $tmpuser->lastname)), null, 'errors'); + } + } + } if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); From 4c2149884c05b2480b7028b6e5085b56e18c81ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 03:35:28 +0100 Subject: [PATCH 03/90] Qual: Introduce getDataToShowPhoto to prepare generic code --- htdocs/core/class/commonobject.class.php | 39 ++++++++++++++++++++++++ htdocs/core/class/html.form.class.php | 29 ++++++++---------- htdocs/core/lib/functions.lib.php | 6 ++-- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index c8e8c7176ec..d2e757bf383 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9030,6 +9030,45 @@ abstract class CommonObject return $buyPrice; } + /** + * getDataToShowPhoto + * + * @param string $modulepart Module part + * @param string $imagesize Image size + * @return array Array of data to show photo + */ + public function getDataToShowPhoto($modulepart, $imagesize) + { + global $conf; + + $newmodulepart = $modulepart; + if ($modulepart == 'unknown' && !empty($this->module)) { + $newmodulepart = $this->module; + } + + $id = $this->id; + + $dir = $conf->$newmodulepart->dir_output; + if (!empty($this->photo)) { + if (dolIsAllowedForPreview($object->photo)) { + if ((string) $imagesize == 'mini') { + $file = get_exdir(0, 0, 0, 0, $this, $newmodulepart) . 'photos/' . dol_sanitizeFileName(getImageFileNameForSize($this->photo, '_mini')); + } elseif ((string) $imagesize == 'small') { + $file = get_exdir(0, 0, 0, 0, $this, $newmodulepart) . 'photos/' . dol_sanitizeFileName(getImageFileNameForSize($this->photo, '_small')); + } else { + $file = get_exdir(0, 0, 0, 0, $this, $newmodulepart) . 'photos/' . dol_sanitizeFileName($this->photo); + } + $originalfile = get_exdir(0, 0, 0, 0, $this, $newmodulepart) . 'photos/' . dol_sanitizeFileName($this->photo); + } + } + + $altfile = ''; + $email = empty($this->email) ? '' : $this->email; + $capture = ''; + + return array('dir' => $dir, 'file' => $file, 'originalfile' => $originalfile, 'altfile' => $altfile, 'email' => $email, 'capture' => $capture); + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show photos of an object (nbmax maximum), into several columns diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 772faafa2bb..77c64a9bf05 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9844,7 +9844,6 @@ class Form $entity = (empty($object->entity) ? $conf->entity : $object->entity); $id = (empty($object->id) ? $object->rowid : $object->id); - $ret = ''; $dir = ''; $file = ''; $originalfile = ''; @@ -9922,29 +9921,25 @@ class Form $capture = 'user'; } else { // Generic case to show photos - $dir = $conf->$modulepart->dir_output; - if (!empty($object->photo)) { - if (dolIsAllowedForPreview($object->photo)) { - if ((string) $imagesize == 'mini') { - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_mini'); - } elseif ((string) $imagesize == 'small') { - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . getImageFileNameForSize($object->photo, '_small'); - } else { - $file = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; - } - $originalfile = get_exdir($id, 2, 0, 0, $object, $modulepart) . 'photos/' . $object->photo; - } + // TODO Implement this method in previous objects so we can always use this generic method. + if (method_exists($object, 'getDataToShowPhoto')) { + $tmpdata = $object->getDataToShowPhoto($modulepart, $imagesize); + + $dir = $tmpdata['dir']; + $file = $tmpdata['file']; + $originalfile = $tmpdata['originalfile']; + $altfile = $tmpdata['altfile']; + $email = $tmpdata['email']; + $capture = $tmpdata['capture']; } - if (getDolGlobalString('MAIN_OLD_IMAGE_LINKS')) { - $altfile = $object->id . ".jpg"; // For backward compatibility - } - $email = $object->email; } if ($forcecapture) { $capture = $forcecapture; } + $ret = ''; + if ($dir) { if ($file && file_exists($dir . "/" . $file)) { if ($addlinktofullsize) { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 382576c36d3..1418ca9680a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2373,9 +2373,9 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi if (class_exists("Imagick")) { if ($object->element == 'expensereport' || $object->element == 'propal' || $object->element == 'commande' || $object->element == 'facture' || $object->element == 'supplier_proposal') { $modulepart = $object->element; - } elseif ($object->element == 'fichinter') { + } elseif ($object->element == 'fichinter' || $object->element == 'intervention') { $modulepart = 'ficheinter'; - } elseif ($object->element == 'contrat') { + } elseif ($object->element == 'contrat' || $object->element == 'contract') { $modulepart = 'contract'; } elseif ($object->element == 'order_supplier') { $modulepart = 'supplier_order'; @@ -2455,7 +2455,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi } } else { if ($showimage) { - if ($modulepart != 'unknown') { + if ($modulepart != 'unknown' || method_exists($object, 'getDataToShowPhoto')) { $phototoshow = ''; // Check if a preview file is available if (in_array($modulepart, array('propal', 'commande', 'facture', 'ficheinter', 'contract', 'supplier_order', 'supplier_proposal', 'supplier_invoice', 'expensereport')) && class_exists("Imagick")) { From aa5a09f621e0fe7e7bf85696fc47085a5e3f8bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20A?= <35066297+c3do@users.noreply.github.com> Date: Sat, 3 Feb 2024 03:39:20 +0100 Subject: [PATCH 04/90] FIX External user security issue in thirdparties (#27975) * FIX External user security issue in thirdparties An external user can create a third party or delete his own card when all rights are given to him. * replace spaces by tabulations * Useless !empty condition --------- Co-authored-by: Laurent Destailleur --- htdocs/societe/card.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 7c0edb9f450..2cbf22d296d 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -112,6 +112,10 @@ if (!empty($backtopagejsfields)) { $socid = GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'); if ($user->socid) { + if (in_array($action, ['add', 'create', 'merge', 'confirm_merge', 'delete', 'confirm_delete'])) { + accessforbidden(); + } + $socid = $user->socid; } if (empty($socid) && $action == 'view') { From a75e6032be8a73f1f7b16fd4231195791d7335cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Feb 2024 03:39:59 +0100 Subject: [PATCH 05/90] NEW api_thirdparties add and delete representatives (#27943) * Update api_thirdparties.class.php * Update api_thirdparties.class.php --- .../societe/class/api_thirdparties.class.php | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index d4f783470bd..74fb2015d8d 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -467,6 +467,68 @@ class Thirdparties extends DolibarrApi return $this->_cleanObjectDatas($this->company); } + /** + * Add a customer representative to a thirdparty + * + * @param int $id Id of thirdparty + * @param int $representative_id Id of representative + * @return Object|void + * + * @url POST {id}/representative/{representative_id} + */ + public function addRepresentative($id, $representative_id) + { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { + throw new RestException(403); + } + $result = $this->company->fetch($id); + if (!$result) { + throw new RestException(404, 'Thirdparty not found'); + } + $usertmp = new User($this->db); + $result = $usertmp->fetch($representative_id); + if (!$result) { + throw new RestException(404, 'User not found'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->company->add_commercial(DolibarrApiAccess::$user, $representative_id); + + return $result; + } + + /** + * Delete a customer representative to a thirdparty + * + * @param int $id Id of thirdparty + * @param int $representative_id Id of representative + * @return Object|void + * + * @url DELETE {id}/representative/{representative_id} + */ + public function deleteRepresentative($id, $representative_id) + { + if (!DolibarrApiAccess::$user->hasRight('societe', 'supprimer')) { + throw new RestException(403); + } + $result = $this->company->fetch($id); + if (!$result) { + throw new RestException(404, 'Thirdparty not found'); + } + $usertmp = new User($this->db); + $result = $usertmp->fetch($representative_id); + if (!$result) { + throw new RestException(404, 'User not found'); + } + if (!DolibarrApi::_checkAccessToResource('societe', $this->company->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $result = $this->company->del_commercial(DolibarrApiAccess::$user, $representative_id); + + return $result; + } + /** * Get customer categories for a thirdparty * From a42c03b0338a6c56db63ca36889fdd76c71393ec Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 03:41:24 +0100 Subject: [PATCH 06/90] qual: Update fournisseur.facture.class.php - $vat_reverse_charge shall be int (not bool) (#27941) see commit e62204d Co-authored-by: Laurent Destailleur --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 7795428d807..d10d044273c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -230,7 +230,7 @@ class FactureFournisseur extends CommonInvoice public $transport_mode_id; /** - * @var int VAT reverse charge can be used on the invoice + * @var int<0,1> VAT reverse charge can be used on the invoice */ public $vat_reverse_charge; From 0fd7d724d44ee32a28e7c19223d3096868f440e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 03:47:21 +0100 Subject: [PATCH 07/90] Fix missing trans --- htdocs/langs/en_US/website.lang | 4 ++++ htdocs/webportal/class/webportalmember.class.php | 2 +- htdocs/webportal/class/webportalorder.class.php | 2 +- htdocs/webportal/class/webportalpartnership.class.php | 2 +- htdocs/webportal/class/webportalpropal.class.php | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index 779e63b23d2..b73f3a35264 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -231,3 +231,7 @@ WebPortalErrorFetchLoggedThirdParty=Error when loading third-party (Id : %s) WebPortalErrorFetchLoggedMember=Error when loading member (Id : %s) WebPortalErrorFetchLoggedPartnership=Error when loading partnership (Third-party Id : %s, Member Id : %s) ExportIntoGIT=Export into sources +WebPortalMember=Membership +WebPortalOrder=Sale Order +WebPortalPartnership=Partnership +WebPortalPropal=Proposal diff --git a/htdocs/webportal/class/webportalmember.class.php b/htdocs/webportal/class/webportalmember.class.php index 89165eaf2ed..3eaef8f7379 100644 --- a/htdocs/webportal/class/webportalmember.class.php +++ b/htdocs/webportal/class/webportalmember.class.php @@ -224,7 +224,7 @@ class WebPortalMember extends Adherent $datas = []; if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { - return ['optimize' => $langs->trans("ShowWebPortalMember")]; + return ['optimize' => $langs->trans("WebPortalMember")]; } $datas['picto'] = img_picto('', $this->picto) . ' ' . $langs->trans("WebPortalMember") . ''; if (isset($this->status)) { diff --git a/htdocs/webportal/class/webportalorder.class.php b/htdocs/webportal/class/webportalorder.class.php index 7cf96715b96..12b1586e4c3 100644 --- a/htdocs/webportal/class/webportalorder.class.php +++ b/htdocs/webportal/class/webportalorder.class.php @@ -169,7 +169,7 @@ class WebPortalOrder extends Commande $datas = []; if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { - return ['optimize' => $langs->trans("ShowWebPortalOrder")]; + return ['optimize' => $langs->trans("WebPortalOrder")]; } $datas['picto'] = img_picto('', $this->picto) . ' ' . $langs->trans("WebPortalOrder") . ''; if (isset($this->status)) { diff --git a/htdocs/webportal/class/webportalpartnership.class.php b/htdocs/webportal/class/webportalpartnership.class.php index 884bdf3a57d..9aa428aa2fe 100644 --- a/htdocs/webportal/class/webportalpartnership.class.php +++ b/htdocs/webportal/class/webportalpartnership.class.php @@ -202,7 +202,7 @@ class WebPortalPartnership extends Partnership $datas = []; if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { - return ['optimize' => $langs->trans("ShowWebPortalPartnership")]; + return ['optimize' => $langs->trans("WebPortalPartnership")]; } $datas['picto'] = img_picto('', $this->picto) . ' ' . $langs->trans("WebPortalPartnership") . ''; if (isset($this->status)) { diff --git a/htdocs/webportal/class/webportalpropal.class.php b/htdocs/webportal/class/webportalpropal.class.php index 03bef3664d1..d53fa5f07ab 100644 --- a/htdocs/webportal/class/webportalpropal.class.php +++ b/htdocs/webportal/class/webportalpropal.class.php @@ -169,7 +169,7 @@ class WebPortalPropal extends Propal $datas = []; if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) { - return ['optimize' => $langs->trans("ShowWebPortalPropal")]; + return ['optimize' => $langs->trans("WebPortalPropal")]; } $datas['picto'] = img_picto('', $this->picto) . ' ' . $langs->trans("WebPortalPropal") . ''; if (isset($this->status)) { From ee37c2204c27dd5640b508ae7613e44dec56a4de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 03:50:34 +0100 Subject: [PATCH 08/90] Fix langs --- htdocs/don/paiement/list.php | 2 +- htdocs/langs/en_US/donations.lang | 1 + htdocs/langs/en_US/multicurrency.lang | 1 - htdocs/langs/fr_FR/donations.lang | 2 -- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/don/paiement/list.php b/htdocs/don/paiement/list.php index 4f9b91530a2..2b27e6e936e 100644 --- a/htdocs/don/paiement/list.php +++ b/htdocs/don/paiement/list.php @@ -316,7 +316,7 @@ print ''; print ''; print ''; -print_barre_liste($langs->trans("DonationsReglement"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); +print_barre_liste($langs->trans("DonationPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit, 0, 0, 1); if ($search_all) { foreach ($fieldstosearchall as $key => $val) { diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 2f97f9ae818..e60a65efb46 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -31,6 +31,7 @@ DONATION_ART200=Show article 200 from CGI if you are concerned DONATION_ART238=Show article 238 from CGI if you are concerned DONATION_ART978=Show article 978 from CGI if you are concerned DonationPayment=Donation payment +DonationPayments=Donation payments DonationValidated=Donation %s validated DonationUseThirdparties=Use the address of an existing thirdparty as the address of the donor DonationsStatistics=Donation's statistics diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index 866a83a32ed..e73eae58d42 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -16,7 +16,6 @@ CurrenciesUsed_help_to_add=Add the different currencies and rates you need to us rate=rate MulticurrencyReceived=Received, original currency MulticurrencyRemainderToTake=Remaining amount, original currency -MulticurrencyPaymentAmount=Payment amount, original currency AmountToOthercurrency=Amount To (in currency of receiving account) CurrencyRateSyncSucceed=Currency rate synchronization done successfully MULTICURRENCY_USE_CURRENCY_ON_DOCUMENT=Use the currency of the document for online payments diff --git a/htdocs/langs/fr_FR/donations.lang b/htdocs/langs/fr_FR/donations.lang index 4cf3f4ca493..617877bcf73 100644 --- a/htdocs/langs/fr_FR/donations.lang +++ b/htdocs/langs/fr_FR/donations.lang @@ -33,8 +33,6 @@ DONATION_ART978=Afficher article 978 du CGI si vous êtes concernés DonationPayment=Paiement du don DonationValidated=Don %s validé -DonationsReglement= Règlements reçus pour les dons - DonationUseThirdparties=Utiliser un tiers existant comme coordonnées du donateur DonationsStatistics=Statistiques des dons From c0417615b1242a83d9301e6e13cbeac6f4068c77 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 04:02:54 +0100 Subject: [PATCH 09/90] Remove useless files in web templates --- .../blog-our-company-is-now-on-dolibarr.php | 5 - ...log-our-new-web-site-has-been-launched.php | 5 - .../containers/blog.php | 5 - .../containers/careers.php | 5 - .../containers/carriere.php | 5 - .../containers/clients-testimonials.php | 5 - .../containers/contact.php | 5 - .../containers/faq.php | 5 - .../containers/footer.php | 5 - .../containers/header.php | 5 - .../containers/home.php | 5 - .../containers/index.php | 11 - .../containers/our-team.php | 5 - .../containers/page179.tpl.php | 99 --- .../containers/page180.tpl.php | 84 --- .../containers/page181.tpl.php | 85 --- .../containers/page182.tpl.php | 129 ---- .../containers/page183.tpl.php | 84 --- .../containers/page184.tpl.php | 78 --- .../containers/page185.tpl.php | 84 --- .../containers/page186.tpl.php | 91 --- .../containers/page187.tpl.php | 132 ---- .../containers/page188.tpl.php | 134 ---- .../containers/page189.tpl.php | 576 ------------------ .../containers/page190.tpl.php | 115 ---- .../containers/page191.tpl.php | 110 ---- .../containers/page192.tpl.php | 186 ------ .../containers/page193.tpl.php | 100 --- .../containers/page194.tpl.php | 84 --- .../containers/page195.tpl.php | 112 ---- .../containers/page196.tpl.php | 82 --- .../containers/partners.php | 5 - .../containers/pricing.php | 5 - .../containers/privacy-policies.php | 5 - .../containers/product-p.php | 5 - .../containers/search.php | 5 - .../containers/service-s.php | 5 - .../containers/test2.php | 4 - .../containers/index.php | 5 - .../containers/page202.tpl.php | 315 ---------- .../containers/index.php | 4 - .../containers/page80.tpl.php | 331 ---------- .../containers/index.php | 4 - .../containers/page148.tpl.php | 296 --------- .../containers/about.php | 5 - .../containers/contact.php | 5 - .../containers/footer.php | 5 - .../containers/header.php | 5 - .../containers/index.php | 5 - .../containers/menu.php | 5 - .../containers/page248.tpl.php | 113 ---- .../containers/page249.tpl.php | 368 ----------- .../containers/page250.tpl.php | 475 --------------- .../containers/page251.tpl.php | 273 --------- .../containers/page252.tpl.php | 93 --- .../containers/page253.tpl.php | 98 --- .../containers/credits.php | 4 - .../containers/footer.php | 4 - .../containers/generic.php | 4 - .../containers/home.php | 4 - .../containers/index.php | 11 - .../containers/menu.php | 4 - .../containers/page20.tpl.php | 75 --- .../containers/page21.tpl.php | 91 --- .../containers/page22.tpl.php | 119 ---- .../containers/page23.tpl.php | 163 ----- .../containers/page24.tpl.php | 48 -- .../containers/page25.tpl.php | 44 -- .../containers/this-is-a-blog-post.php | 4 - 69 files changed, 5450 deletions(-) delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-company-is-now-on-dolibarr.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-new-web-site-has-been-launched.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/blog.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/careers.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/carriere.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/clients-testimonials.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/contact.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/faq.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/footer.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/header.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/home.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/our-team.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page179.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page180.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page181.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page182.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page183.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page184.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page185.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page186.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page187.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page188.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page189.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page190.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page191.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page192.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page193.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page194.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page195.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/page196.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/partners.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/pricing.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/privacy-policies.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/product-p.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/search.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/service-s.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-corporate/containers/test2.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/page202.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-noimg/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-noimg/containers/page80.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/page148.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/about.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/contact.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/footer.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/header.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/menu.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page248.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page249.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page251.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page252.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-restaurant/containers/page253.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/credits.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/footer.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/generic.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/home.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/index.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/menu.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page20.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page21.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page22.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page23.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page24.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/page25.tpl.php delete mode 100644 htdocs/install/doctemplates/websites/website_template-stellar/containers/this-is-a-blog-post.php diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-company-is-now-on-dolibarr.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-company-is-now-on-dolibarr.php deleted file mode 100644 index 99c4f10314b..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-company-is-now-on-dolibarr.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page180.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-new-web-site-has-been-launched.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-new-web-site-has-been-launched.php deleted file mode 100644 index 248bb708f48..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog-our-new-web-site-has-been-launched.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page181.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog.php deleted file mode 100644 index 43a0212d3f6..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/blog.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page179.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/careers.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/careers.php deleted file mode 100644 index a2c8a7165a7..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/careers.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page182.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/carriere.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/carriere.php deleted file mode 100644 index f32f4818ac4..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/carriere.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page183.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/clients-testimonials.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/clients-testimonials.php deleted file mode 100644 index 2c01e32e135..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/clients-testimonials.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page184.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/contact.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/contact.php deleted file mode 100644 index 2c9c69905fa..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/contact.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page185.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/faq.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/faq.php deleted file mode 100644 index 94f01880f4e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/faq.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page186.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/footer.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/footer.php deleted file mode 100644 index 533ddc027a2..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/footer.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page187.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/header.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/header.php deleted file mode 100644 index 831c7ded51a..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/header.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page188.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/home.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/home.php deleted file mode 100644 index 86a6639e327..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/home.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page189.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/index.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/index.php deleted file mode 100644 index 5ac34065524..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/index.php +++ /dev/null @@ -1,11 +0,0 @@ - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/our-team.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/our-team.php deleted file mode 100644 index 1afe5d1523d..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/our-team.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page190.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page179.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page179.tpl.php deleted file mode 100644 index 7a474b5595e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page179.tpl.php +++ /dev/null @@ -1,99 +0,0 @@ - - - -Blog - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
The latest news... -
-
-
-
-
-
-
-
- - -
-

- - load("main"); - $fuser = new User($db); - $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', 5, 0, array('type_container'=>'blogpost', 'status'=>1, 'lang'=>'null,'.$websitepage->lang)); - foreach($arrayofblogs as $blog) - { - print ''; - } - ?> -
-
- -

- - - -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page180.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page180.tpl.php deleted file mode 100644 index 538fc1764e4..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page180.tpl.php +++ /dev/null @@ -1,84 +0,0 @@ - - - -Our company is now on Dolibarr ERP CRM - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
title; ?> -
-
-
-
-
-
-
-
- -
-


- Like several thousands of companies, our company (name ?>) has moved all its information system to Dolibarr ERP CRM. More than 20 applications have been replaced by only one, easier to use and fully integrated. - This is an important step in improving all of our services. - -


- -
- -

-
Screenshot of our new Open Source solution
-
- - - -





-
- - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page181.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page181.tpl.php deleted file mode 100644 index a8a484ccf44..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page181.tpl.php +++ /dev/null @@ -1,85 +0,0 @@ - - - -Our new web site has been launched - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - -
-
-
-
-
-
-
-
-
title; ?> -
-
-
-
-
-
-
-
- -
-





- - - Our new website, based on Dolibarr CMS, has been launched.
- Now it is modern and directly integrated with the internal management tools of the company. Many new online services will be available for our customers... - - -


- -
- -

-
Theme of our new web site
-
- - -





-
- - - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page182.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page182.tpl.php deleted file mode 100644 index 49735b4f21a..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page182.tpl.php +++ /dev/null @@ -1,129 +0,0 @@ - - - -Careers - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page183.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page183.tpl.php deleted file mode 100644 index bf4d4c92682..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page183.tpl.php +++ /dev/null @@ -1,84 +0,0 @@ - - - -Carrière - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Offres d'emploi -
-
-
-
-
-
-
-
- - -
-
-
-
-
-Nous n'avons pas d'offres d'emploi ouvertes en ce moment...
-
-
-
-
-
-
- - -

- - - -
- - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page184.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page184.tpl.php deleted file mode 100644 index fca2346bede..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page184.tpl.php +++ /dev/null @@ -1,78 +0,0 @@ - - - -Clients Testimonials - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Testimonials -
-
-
-
-
-
-
-
- - -
-

-

What they say about us

-



- Send us your testimonial (by email to email; ?>) -



-

-
- -

- - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page185.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page185.tpl.php deleted file mode 100644 index f478da7021f..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page185.tpl.php +++ /dev/null @@ -1,84 +0,0 @@ - - - -Contact - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Contact -
-
-
-
-
-
-
-
- - -
-
-

Contact us:



- email ?>
- getFullAddress() ?>
-
-
- - - -
-
- -
- -


- - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page186.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page186.tpl.php deleted file mode 100644 index 111e4615774..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page186.tpl.php +++ /dev/null @@ -1,91 +0,0 @@ - - - -FAQ - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
FAQs -
-
-
-
-
-
-
-
- - -
-
-


Frequently Asked Questions

-
-
-
-

How can I contact you ?


-You can contact us by using this page. -
-
-
-

What is your privacy policy ?


-You may find information about our privacy policy on this page. - - -



- -
-
- - -

- - - -
- - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page187.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page187.tpl.php deleted file mode 100644 index 615a2214885..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page187.tpl.php +++ /dev/null @@ -1,132 +0,0 @@ - - - -Footer - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -
- -
-
-
-
-
-
- -
- -
-
- -
-
- -
-
-
- -
- -
-
- -
-
- - componentSelectLang('auto', $weblangs, 'margin-top-10'); ?> -
-
-
- -
- -
-
-
- -
-
-
- -
-
-
-
getFullAddress(1, '
', 1); ?>
-
-
-
-

Follow Us:

-
    - socialnetworks as $key => $value) { - print '
  • '; - } ?> -
-
-
-
-
-
-
-
- -
-
- Website generated and powered by Dolibarr ERP & CRM -
-
- -
- - - -
- - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page188.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page188.tpl.php deleted file mode 100644 index 99e9ddd3e9f..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page188.tpl.php +++ /dev/null @@ -1,134 +0,0 @@ - - - -Header and Top Menu - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - -
-
-
- -
-
-
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page189.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page189.tpl.php deleted file mode 100644 index 3dec20c6b08..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page189.tpl.php +++ /dev/null @@ -1,576 +0,0 @@ - - - -Home - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - - - -
-
-
-
-
-
-
-
-
Boost your business -
-
-

We provide powerful solutions for all businesses

-
- -
-
-
-
-
-
-
-
-
-
-
 Best prices on the market  -
-
-

Our optimized processes allows us to provide you very competitive prices

-
- -
-
-
-
-
-
-
-
-
-
-
-
-
- - - - -
-
-
-
-
-
- -
-
-

Our sales representative are also technicians.

-
-
-
-
-
- -
-

Take a look at our offers...

-
-
-
-
-
- -
-

Our customer-supplier relationship is very appreciated by our customers

-
-
-
-
-
-
-
- -
-
-

We continue to follow and assist you after the sale. Contact us at any time.

-
-
-
-
-
- - - -
-
-

Looking for

-

a high quality service?

-

With a lot of experience, hiring us is a security for your business!

-
-
-
11
-
Years of Experience
-
-
-
- query($sql); $obj = $db->fetch_object($resql); print $obj->nb; ?> -
-
Experts
-
-
-
- query($sql); $obj = $db->fetch_object($resql); print $obj->nb; ?> -
-
Trusted Clients
-
-
-
- -
-
-
- - - - -
-
- -
-
- - - -
-
-

our team

-
-
- -
-
-
-
- - - -
-
-
-
-
-

Request a callback

-
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
-
- - - -
-
-
-
-
-

successful cases

- -
-
-
-
-
- - - -
-
-

Latest News

-
- fetchAll($website->id, 'DESC', 'date_creation', $MAXNEWS, 0, array('type_container'=>'blogpost', 'status'=>1, 'lang'=>'null,'.$websitepage->lang)); - foreach($arrayofblogs as $blog) - { - ?> - - - -
-
-
- - - - - -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page190.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page190.tpl.php deleted file mode 100644 index 63255c34db5..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page190.tpl.php +++ /dev/null @@ -1,115 +0,0 @@ - - - -Our team - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Our team -
-
-
-
-
-
-
-
- - -
-

-

The crew...




- query($sql); - if (! $resql) dol_print_error($db); - while ($obj = $db->fetch_object($resql)) - { - $arrayofusers[]=$obj->rowid; - } - - print '
'; - foreach($arrayofusers as $id) - { - $fuser->fetch($id); - - print '
'; - print '
'; - print '
'; - if ($fuser->photo) print Form::showphoto('userphoto', $fuser, 100, 0, 0, 'photowithmargin', '', 0); - //print ''; - else print ''; - print '
'; - print '
'; - print '
'.$fuser->firstname.'
'; - print '
    '; - //print '
  • September 24, 2018
  • '; - if ($fuser->job) print '
  • '.$fuser->job.'
  • '; - else print '
  • '; - print '
'; - print '
'; - print '
'; - print '
'; - } - print '
'; - - ?> -
-
- -

- - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page191.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page191.tpl.php deleted file mode 100644 index b52ee75825e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page191.tpl.php +++ /dev/null @@ -1,110 +0,0 @@ - - - -Partners - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Partners -
-
-
-
-
-
-
-
- - -
-
-

Our partners...

-
-
-
-
-
- -
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-
-
- - -

- - - -
- - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page192.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page192.tpl.php deleted file mode 100644 index 3344e971e80..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page192.tpl.php +++ /dev/null @@ -1,186 +0,0 @@ - - - -Pricing - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Our plans -
-
-
-
-
-
-
-
- - - - - -
-
- -
-
- - - -

- - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page193.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page193.tpl.php deleted file mode 100644 index 4e6f65e80a5..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page193.tpl.php +++ /dev/null @@ -1,100 +0,0 @@ - - - -Privacy Policies - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - - - -
-
-
-
-
-
-
-
-
Privacy Policy -
-
-
-
-
-
-
-
- -


- -
-
-

Information collected and used


-

* Your customer information (email, phone, business name, first and last name of contact, address, postal code, country and VAT number) are stored when you become a customer. This information allows us to bill you. -

* If you paid using our online service, we also store the last 4 digits of your card. The full details of your credit card is stored by our payment provider Stripe (the world leader in online payment).

-

* You have the option to request the deletion of your data and the above information at any time (except data required y fiscal tracking rules, like your invoices).

-

* The Privacy Policies and GDPR referral contact for our services is: global->MAIN_INFO_GDPR; ?>

-


-

Data Storage and Backups


-

* The storage of collected data (see 'Information collected and used') is done in a database.

-

* We made one backup every week. Only 4 weeks are kept.

-


-

Subcontractor


-

* Our services relies on the following subcontractors and service:
-** The host of computer servers, which is ABC company. These servers are hosted in US. No customer information is communicated to this subcontractor who only provides the hardware and network layer, the installation and operation being carried out by us directly.
-** The online payment service Stripe, which is used, to ensure regular payment of subscription or your invoices paid online.

-


-

Software Protection


-

* Our services runs on Linux Ubuntu systems and software. They benefit from regular security updates when the operating system editor (Ubuntu Canonical) publishes them.

-

* Our services are accessible in HTTPS (HTTP encrypted) only, encrypted with SHA256 certificates.

-

* Our technical platform are protected by various solutions.

-


-

Data theft


-

* In case of suspicion of a theft of the data we have collected (see first point 'Information collected and used'), customers will be informed by email, at email corresponding to their customer account

-

 

-
-
- - - - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page194.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page194.tpl.php deleted file mode 100644 index e4aa79e1291..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page194.tpl.php +++ /dev/null @@ -1,84 +0,0 @@ - - - -Product P - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Product P -
-
-
-
-
-
-
-
- - -
-
-
-
-
-This is a description page of our product P...
-
-
-
-
-
-
- - -

- - - -
- - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page195.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page195.tpl.php deleted file mode 100644 index 0e1774d931b..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page195.tpl.php +++ /dev/null @@ -1,112 +0,0 @@ - - - -Search Page - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Search -
-
-
-
-
-
-
-
- -


- -
- -
- -
-
- - load("main"); - - if (function_exists('getPagesFromSearchCriterias')) - { - if (GETPOSTISSET('s')) - { - $listofpages = getPagesFromSearchCriterias('page', 'meta', GETPOST('s', 'alphanohtml')); - if ($listofpages['code'] == 'OK') - { - foreach($listofpages['list'] as $websitepagefound) - { - print '
'.$websitepagefound->title.' - '.$websitepagefound->description.'
'; - } - } - else - { - // If error, show message - print $listofpages['message']; - } - } - } - else - { - print $weblangs->trans("FeatureNotYetAvailable"); - } - ?> - -





-
- - - -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page196.tpl.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/page196.tpl.php deleted file mode 100644 index d52718bcfc8..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/page196.tpl.php +++ /dev/null @@ -1,82 +0,0 @@ - - - -Service S - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - -
- - - -
-
-
-
-
-
-
-
-
Service S -
-
-
-
-
-
-
-
- - -
-
-
-
-
-This is a description page of our service S...
-
-
-
-
-
-
- - -

- - - -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/partners.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/partners.php deleted file mode 100644 index 44e501d9f4d..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/partners.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page191.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/pricing.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/pricing.php deleted file mode 100644 index d2866cadf43..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/pricing.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page192.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/privacy-policies.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/privacy-policies.php deleted file mode 100644 index 59dc87944fe..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/privacy-policies.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page193.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/product-p.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/product-p.php deleted file mode 100644 index beac94b27c8..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/product-p.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page194.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/search.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/search.php deleted file mode 100644 index 359c5bf3b26..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/search.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page195.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/service-s.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/service-s.php deleted file mode 100644 index f69f6e7a13e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/service-s.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page196.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-corporate/containers/test2.php b/htdocs/install/doctemplates/websites/website_template-corporate/containers/test2.php deleted file mode 100644 index 9939ba32bf6..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-corporate/containers/test2.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page126.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/index.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/index.php deleted file mode 100644 index 967c5deb878..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/index.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page202.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/page202.tpl.php b/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/page202.tpl.php deleted file mode 100644 index 11a32b36968..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/page202.tpl.php +++ /dev/null @@ -1,315 +0,0 @@ - - - -Home page - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -email; - $message = GETPOST('message', 'alpha'); - $cmail = new CMailFile('Contact from website', $to, $from, $message); - if ($cmail->sendfile()) { - ?> - - trans("ErrorFailedToSendMail", $from, $to).'. '.$cmail->error; - } -} -?> -
- - -
-
-
-
-

Get Productive

-

- Lorem ipsum dolor, sit amet consectetur adipisicing - elit. Ab fuga nobis omnis alias, aliquid iste cumque - tempora nim reprehenderit quia itaque debitis, - nostrum labore rerum reiciendis laboriosam unde, - tempore corporis. -

- landing-img -
- - Learn More - -
-
-
-
-
-
-
-

- LOREM IPSUM DOLOR SIT AMET EZAJB -

- article -
-
-

Our Company

-

- Lorem ipsum dolor, sit amet consectetur adipisicing - elit. Ab fuga nobis omnis alias, aliquid iste cumque - tempora nim reprehenderit quia itaque debitis, - nostrum labore rerum reiciendis laboriosam unde, - tempore corporis. -

-
-
-
-
-
-
-
-
-

Founders

-
    -
  • -

    Author One

    -
  • -
  • -

    Author Two

    -
  • -
  • -

    Author Three

    -
  • -
  • -

    Author Four

    -
  • -
-
-
-

About

-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Veritatis accusantium earum sed odit velit laudantium ex libero quisquam consectetur, - dolorem vero ipsam perferendis quibusdam itaque omnis a consequatur error repellat. -

-
-
-
-
- -
-

Contact us

- -

Do you have any questions? Please do not hesitate to contact us directly. Our team will come back to you within - a matter of hours to help you.

- -
- - -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
-
-
- -
-
-
-
- - -
-
-
    -
  • -

    getFullAddress() ?>

    -
  • - -
  • -

    phone ?>

    -
  • - -
  • -

    email ?>

    -
  • -
-
- -
- - -
-
- -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/index.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/index.php deleted file mode 100644 index 64331a0ec08..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/index.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page80.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-noimg/containers/page80.tpl.php b/htdocs/install/doctemplates/websites/website_template-noimg/containers/page80.tpl.php deleted file mode 100644 index 742993e5a85..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-noimg/containers/page80.tpl.php +++ /dev/null @@ -1,331 +0,0 @@ - - - -index - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - - - - Template - - - - - -email; - $message = GETPOST('message', 'alpha'); - $cmail = new CMailFile('Contact from website', $to, $from, $message); - if ($cmail->sendfile()) { - ?> - - trans("ErrorFailedToSendMail", $from, $to).'. '.$cmail->error; - } -} -?> -
-
- - -
-
- -
-
-
-

- Brand - Name -

-

- Hello fellows, here is a description of the - brand -

- - - -
-
-
-
- -
-
-
-
-

Products

-
-
-
-
-
- -
-

Product 1

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
- -
-

Product 2

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
- -
-

Product 3

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
- -
-

Product 4

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
- -
-

Product 5

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
- -
-

Product 6

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- - - -
-
-
-
-
-
- -
-
-
-

Contact us

-

- Email: email ?> -

-

- Phone-number: phone ?> -

-
-
-

- Or complete the form -

-
-
- - -
-
-
- - -
-
- - -
-
- - -
-
-
-
- - -
-
-
-
- -
-
-
-
-
-
- -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/index.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/index.php deleted file mode 100644 index b4e33361f1b..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/index.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page148.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/page148.tpl.php b/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/page148.tpl.php deleted file mode 100644 index 97f91ac61df..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/page148.tpl.php +++ /dev/null @@ -1,296 +0,0 @@ - - - -index - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - - - - Template - - - - - -
-
-
-
-
-
-

Our company

-

- Lorem ipsum dolor, sit amet consectetur adipisicing elit. Nostrum excepturi ipsa consequatur accusamus eveniet dignissimos necessitatibus provident dolore cupiditate. -

-
-

- It uses utility classes for typography and spacing to space content out within the - larger container. -

-

- - - - - - -

-
-
-
- landingpage -
-
-
-
- -
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
- ... -
-

LoremIpsum

-

- Some quick example text to build on the - card title and make up the bulk of the - card's content. -

- -
-
-
-
-
-
-
-
-
-
-

UNLIMITED FOR ALL

-

Lorem, ipsum dolor sit amet consectetur adipisicing elit. Minus molestias voluptatibus voluptatem Lorem ipsum dolor, sit amet consectetur adipisicing elit. Veritatis officia voluptatem incidunt tempore esse porro sequi eveniet eum corrupti quo.

-
-
-

$79/month

-
-
-

WHAT YOU WILL GET

-

Lorem ipsum dolor sit, amet consectetur


-

Lorem ipsum dolor sit, amet consectetur


-

Lorem ipsum dolor sit, amet consectetur


- - - -
-
-
-
-
-
-
-
-
-
-
-

Contact us

-
-
- email ?>
- getFullAddress() ?>
-
-
- - -
-
- -
- -


- -
-
-
-
-
-
- -
- -
- socialnetworks as $key => $value) { - print ''; - } ?> - -
- -
- - - -
- © 2022 Dolibarr: - Dolicloud.com -
- -
-
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/about.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/about.php deleted file mode 100644 index 560719a4fda..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/about.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page248.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/contact.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/contact.php deleted file mode 100644 index e3a18e3b92d..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/contact.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page249.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/footer.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/footer.php deleted file mode 100644 index 4052f2ff8e9..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/footer.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page252.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/header.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/header.php deleted file mode 100644 index 530e4397e93..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/header.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page253.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/index.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/index.php deleted file mode 100644 index 08ce45517af..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/index.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page250.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/menu.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/menu.php deleted file mode 100644 index 57315e4da18..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/menu.php +++ /dev/null @@ -1,5 +0,0 @@ -ref.'/page251.tpl.php'; -?> diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page248.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page248.tpl.php deleted file mode 100644 index 9acf79aaec9..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page248.tpl.php +++ /dev/null @@ -1,113 +0,0 @@ - - - -About us - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - -
-
- - - -
-
-
- -
-

Team Members

-
- -
-
- - -
-

Sophia

- -

CEO & Founder

-
-
-
- -
-
- - -

Benjamin W.

- -

Restaurant Manager

-
-
- -
-
- - -

Muchen Jack

- -

Senior Chef

-
-
- -
-
-
- -
- -
- - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page249.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page249.tpl.php deleted file mode 100644 index faf8513d064..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page249.tpl.php +++ /dev/null @@ -1,368 +0,0 @@ - - - -Contact us - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -email; - $message = GETPOST('message', 'alpha'); - $cmail = new CMailFile('Contact from website', $to, $from, $message); - if ($cmail->sendfile()) { - ?> - - trans("ErrorFailedToSendMail", $from, $to).'. '.$cmail->error; - } -} -?> - - - - -
-
- - -
- -
-
-
-
-

Leave a message

-
- -
-
- - - -
- - - -
- -
- - - -
- -
- - - - - - - -
- -
- -
-
-
- -
-
Weekdays
- -
- $day : " .getDolGlobalString("MAIN_INFO_OPENINGHOURS_$day") ."

"; - } - ?> -
- -
Weekends
- -
-

Saturday and Sunday

- -

to be determined !

-
-
- -
-

- -

- getFullAddress() ?> -

- - -
-
- -
-
-
-
-
-
- - - - - - -
- - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php deleted file mode 100644 index ed509115c54..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php +++ /dev/null @@ -1,475 +0,0 @@ - - - -index - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-

- Delicious Steaks -

- -
-
-
- - - - - -
-
-
-
-
- -
- -
-
-
- -
-
- - -
- -
- - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page251.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page251.tpl.php deleted file mode 100644 index 50fb446dd2e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page251.tpl.php +++ /dev/null @@ -1,273 +0,0 @@ - - - -Our menus - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - -
-
- - - - - - - -
- -
- - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page252.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page252.tpl.php deleted file mode 100644 index 568a538488b..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page252.tpl.php +++ /dev/null @@ -1,93 +0,0 @@ - - - -Footer - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page253.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page253.tpl.php deleted file mode 100644 index 10896678ceb..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page253.tpl.php +++ /dev/null @@ -1,98 +0,0 @@ - - - -Header - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/credits.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/credits.php deleted file mode 100644 index 9413220a642..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/credits.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page20.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/footer.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/footer.php deleted file mode 100644 index f49ea9820eb..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/footer.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page21.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/generic.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/generic.php deleted file mode 100644 index 125a586cbbf..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/generic.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page22.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/home.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/home.php deleted file mode 100644 index 17b2d2fcb5e..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/home.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page23.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/index.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/index.php deleted file mode 100644 index 3f2d97e57ac..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/index.php +++ /dev/null @@ -1,11 +0,0 @@ -ref.'/page24.tpl.php'; diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page20.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page20.tpl.php deleted file mode 100644 index ace3135f312..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page20.tpl.php +++ /dev/null @@ -1,75 +0,0 @@ - - - -Credits - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - -
- - - - - - - - -
- - -
- -

- -This site is edited by name; ?> - - -

- -
- -
- - - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page21.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page21.tpl.php deleted file mode 100644 index 9cbab5789c9..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page21.tpl.php +++ /dev/null @@ -1,91 +0,0 @@ - - - -Footer - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -
-
-

Aliquam sed mauris

-

Sed lorem ipsum dolor sit amet et nullam consequat feugiat consequat magna adipiscing tempus etiam dolore veroeros. eget dapibus mauris. Cras aliquet, nisl ut viverra sollicitudin, ligula erat egestas velit, vitae tincidunt odio.

- -
-
-

Etiam feugiat

-
-
Address
-
getFullAddress(1, '
'); ?>
-
Phone
-
phone; ?>
-
Email
-
email; ?>
-
-
- -
- - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page22.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page22.tpl.php deleted file mode 100644 index 87bf7faf346..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page22.tpl.php +++ /dev/null @@ -1,119 +0,0 @@ - - - -Generic page - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - -
- - - - - - - - -
- - -
- -

Magna feugiat lorem

-

Donec eget ex magna. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque venenatis dolor imperdiet dolor mattis sagittis. Praesent rutrum sem diam, vitae egestas enim auctor sit amet. Pellentesque leo mauris, consectetur id ipsum sit amet, fergiat. Pellentesque in mi eu massa lacinia malesuada et a elit. Donec urna ex, lacinia in purus ac, pretium pulvinar mauris. Curabitur sapien risus, commodo eget turpis at, elementum convallis fames ac ante ipsum primis in faucibus.

-

Pellentesque venenatis dolor imperdiet dolor mattis sagittis. Praesent rutrum sem diam, vitae egestas enim auctor sit amet.

-

Tempus veroeros

-

Cep risus aliquam gravida cep ut lacus amet. Adipiscing faucibus nunc placerat. Tempus adipiscing turpis non blandit accumsan eget lacinia nunc integer interdum amet aliquam ut orci non col ut ut praesent.

-
- - -
-

Latest Blog posts

-
- loadLangs(array("main","website")); - $fuser = new User($db); - $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', 5, 0, array('type_container'=>'blogpost', 'status'=>1, 'lang'=>'null,'.$websitepage->lang)); // , 'keywords'=>$keyword - if (is_numeric($arrayofblogs) && $arrayofblogs < 0) { - print '
'.$weblangs->trans($websitepage->error).'
'; - } elseif (is_array($arrayofblogs) && ! empty($arrayofblogs)) { - foreach ($arrayofblogs as $blog) { - print ''; - } - } else { - print '
'; - print '
'; - //print $weblangs->trans("NoArticlesFoundForTheKeyword", $keyword); - print $weblangs->trans("NoArticlesFound"); - print '
'; - print '
'; - } - ?> -
-
- -
- - - - - - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page23.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page23.tpl.php deleted file mode 100644 index bd1eda51e55..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page23.tpl.php +++ /dev/null @@ -1,163 +0,0 @@ - - - -My personal blog - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -
- - - - - - - - -
- - -
-
-
-
-

Ipsum sed adipiscing

-
-

Sed lorem ipsum dolor sit amet nullam consequat feugiat consequat magna - adipiscing magna etiam amet veroeros. Lorem ipsum dolor tempus sit cursus. - Tempus nisl et nullam lorem ipsum dolor sit amet aliquam.

- -
- -
-
- - -
-
-

Magna veroeros

-
-
    -
  • - -

    Ipsum consequat

    -

    Sed lorem amet ipsum dolor et amet nullam consequat a feugiat consequat tempus veroeros sed consequat.

    -
  • -
  • - -

    Amed sed feugiat

    -

    Sed lorem amet ipsum dolor et amet nullam consequat a feugiat consequat tempus veroeros sed consequat.

    -
  • -
  • - -

    Dolor nullam

    -

    Sed lorem amet ipsum dolor et amet nullam consequat a feugiat consequat tempus veroeros sed consequat.

    -
  • -
- -
- - -
-
-

Ipsum consequat

-

Donec imperdiet consequat consequat. Suspendisse feugiat congue
- posuere. Nulla massa urna, fermentum eget quam aliquet.

-
-
    -
  • - - 5,120 Etiam -
  • -
  • - - 8,192 Magna -
  • -
  • - - 2,048 Tempus -
  • -
  • - - 4,096 Aliquam -
  • -
  • - - 1,024 Nullam -
  • -
-

Nim elementum nisl et mi a commodo porttitor. Morbi sit amet nisl eu arcu faucibus hendrerit vel a risus. Nim a orci mi, elementum ac arcu sit amet, fermentum pellentesque et purus. Integer maximus varias lorem, sed convallis diam accumsan sed. Etiam porttitor placerat sapien, sed eleifend a enim pulvinar faucibus semper quis ut arcu. Ut non nisl a mollis est efficitur vestibulum. Integer eget purus nec nulla mattis et accumsan ut magna libero. Morbi auctor iaculis porttitor. Sed ut magna ac risus et hendrerit scelerisque. Praesent eleifend lacus in lectus aliquam porta. Cras eu ornare dui curabitur lacinia.

- -
- - -
-
-

Congue imperdiet

-

Donec imperdiet consequat consequat. Suspendisse feugiat congue
- posuere. Nulla massa urna, fermentum eget quam aliquet.

-
- -
- -
- - - -
- - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page24.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page24.tpl.php deleted file mode 100644 index 3ea7a55dbd5..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page24.tpl.php +++ /dev/null @@ -1,48 +0,0 @@ - - - -Menu - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - - - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page25.tpl.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/page25.tpl.php deleted file mode 100644 index ec9e02f4914..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/page25.tpl.php +++ /dev/null @@ -1,44 +0,0 @@ - - - -This is a Blog post - - - - - - - - - -use_manifest) { print ''."\n"; } ?> - - - - - - - - - - - - -
- This is a blog post article... -
- - - - diff --git a/htdocs/install/doctemplates/websites/website_template-stellar/containers/this-is-a-blog-post.php b/htdocs/install/doctemplates/websites/website_template-stellar/containers/this-is-a-blog-post.php deleted file mode 100644 index 0b70a249b2c..00000000000 --- a/htdocs/install/doctemplates/websites/website_template-stellar/containers/this-is-a-blog-post.php +++ /dev/null @@ -1,4 +0,0 @@ -ref.'/page25.tpl.php'; From e88965677e7b8a487ad7a99f6ce6ecaa2ad73a37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 11:38:34 +0100 Subject: [PATCH 10/90] Clean code --- .../class/fournisseur.commande.class.php | 27 +++++++++---------- htdocs/langs/en_US/admin.lang | 1 - htdocs/langs/en_US/agenda.lang | 1 - htdocs/langs/en_US/eventorganization.lang | 1 - htdocs/langs/en_US/knowledgemanagement.lang | 1 - htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/recruitment.lang | 1 - htdocs/langs/en_US/stocks.lang | 1 - htdocs/langs/en_US/suppliers.lang | 1 - htdocs/langs/en_US/website.lang | 2 -- 10 files changed, 13 insertions(+), 24 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 14bd62e50f6..ed5cbf3947f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -612,7 +612,6 @@ class CommandeFournisseur extends CommonOrder */ public function fetch_lines($only_product = 0) { - global $conf; // phpcs:enable $this->lines = array(); @@ -753,7 +752,7 @@ class CommandeFournisseur extends CommonOrder */ public function valid($user, $idwarehouse = 0, $notrigger = 0) { - global $langs, $conf; + global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; @@ -888,7 +887,7 @@ class CommandeFournisseur extends CommonOrder public function LibStatut($status, $mode = 0, $billed = 0) { // phpcs:enable - global $conf, $langs, $hookmanager; + global $langs, $hookmanager; if (empty($this->labelStatus) || empty($this->labelStatusShort)) { $langs->load('orders'); @@ -1021,7 +1020,7 @@ class CommandeFournisseur extends CommonOrder */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1, $addlinktonotes = 0) { - global $langs, $conf, $user, $hookmanager; + global $langs, $user, $hookmanager; $result = ''; $params = [ @@ -1112,7 +1111,7 @@ class CommandeFournisseur extends CommonOrder */ public function getNextNumRef($soc) { - global $db, $langs, $conf; + global $langs, $conf; $langs->load("orders"); if (getDolGlobalString('COMMANDE_SUPPLIER_ADDON_NUMBER')) { @@ -3306,7 +3305,7 @@ class CommandeFournisseur extends CommonOrder */ public function getInputMethod() { - global $db, $langs; + global $langs; if ($this->methode_commande_id > 0) { $sql = "SELECT rowid, code, libelle as label"; @@ -3435,18 +3434,18 @@ class CommandeFournisseur extends CommonOrder /** * Function used to replace a product id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old product id - * @param int $dest_id New product id + * @param DoliDB $dbs Database handler + * @param int $origin_id Old product id + * @param int $dest_id New product id * @return bool */ - public static function replaceProduct(DoliDB $db, $origin_id, $dest_id) + public static function replaceProduct(DoliDB $dbs, $origin_id, $dest_id) { $tables = array( 'commande_fournisseurdet' ); - return CommonObject::commonReplaceProduct($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceProduct($dbs, $origin_id, $dest_id, $tables); } /** @@ -3489,6 +3488,8 @@ class CommandeFournisseur extends CommonOrder { global $conf, $langs; + $langs->load('orders'); + $text = ''; if ($this->statut == self::STATUS_ORDERSENT || $this->statut == self::STATUS_RECEIVED_PARTIALLY) { @@ -3518,8 +3519,6 @@ class CommandeFournisseur extends CommonOrder */ public function calcAndSetStatusDispatch(User $user, $closeopenorder = 1, $comment = '') { - global $conf, $langs; - if (isModEnabled("supplier_order")) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; @@ -3817,8 +3816,6 @@ class CommandeFournisseurLigne extends CommonOrderLine */ public function fetch($rowid) { - global $conf; - $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.product_type, cd.description, cd.qty, cd.tva_tx, cd.special_code,'; $sql .= ' cd.localtax1_tx, cd.localtax2_tx, cd.localtax1_type, cd.localtax2_type, cd.ref as ref_supplier,'; $sql .= ' cd.remise, cd.remise_percent, cd.subprice,'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 1a8c9492605..47c34482e82 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2337,7 +2337,6 @@ ExportUseLowMemoryModeHelp=Use the low memory mode to generate the dump file (co ModuleWebhookName = Webhook ModuleWebhookDesc = Interface to catch dolibarr triggers and send data of the event to an URL WebhookSetup = Webhook setup -Settings = Settings WebhookSetupPage = Webhook setup page ShowQuickAddLink=Show a button to quickly add an element in top right menu ShowSearchAreaInTopMenu=Show the search area in the top menu diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 1d9dbcf07c0..793b3cb1862 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -190,7 +190,6 @@ MenuBookcalIndex=Online appointment BookcalLabelAvailabilityHelp=Label of the availability range. For example:
General availability
Availability during christmas holidays DurationOfRange=Duration of ranges BookCalSetup = Online appointment setup -Settings = Settings BookCalSetupPage = Online appointment setup page BOOKCAL_PUBLIC_INTERFACE_TOPIC = Interface title About = About diff --git a/htdocs/langs/en_US/eventorganization.lang b/htdocs/langs/en_US/eventorganization.lang index 30c3f5d6b59..8cfd9f6f981 100644 --- a/htdocs/langs/en_US/eventorganization.lang +++ b/htdocs/langs/en_US/eventorganization.lang @@ -34,7 +34,6 @@ PaymentEvent=Payment of event NewRegistration=Registration EventOrganizationSetup=Event Organization setup EventOrganization=Event organization -Settings=Settings EventOrganizationSetupPage = Event Organization setup page EVENTORGANIZATION_TASK_LABEL = Label of tasks to create automatically when project is validated EVENTORGANIZATION_TASK_LABELTooltip = When you validate an event to organize, some tasks can be automatically created in the project

For example:
Send Call for Conferences
Send Call for Booths
Validate suggestions of Conferences
Validate application for Booths
Open subscriptions to the event for attendees
Send a remind of the event to speakers
Send a remind of the event to Booth hosters
Send a remind of the event to attendees diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index acf1bd62f11..1f83c02cae1 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -26,7 +26,6 @@ ModuleKnowledgeManagementDesc=Manage a Knowledge Management (KM) or Help-Desk ba # Admin page # KnowledgeManagementSetup = Knowledge Management System setup -Settings = Settings KnowledgeManagementSetupPage = Knowledge Management System setup page diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8c144fbae3e..490b9be3b37 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1261,3 +1261,4 @@ InvoiceSubtype=Invoice subtype ConfirmMassReverse=Bulk Reverse confirmation ConfirmMassReverseQuestion=Are you sure you want to reverse the %s selected record(s)? Encrypted=Encrypted +Settings=Settings diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 50085bd578f..5a3ed4be055 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -26,7 +26,6 @@ ModuleRecruitmentDesc = Manage and follow recruitment campaigns for new job posi # Admin page # RecruitmentSetup = Recruitment setup -Settings = Settings RecruitmentSetupPage = Enter here the setup of main options for the recruitment module RecruitmentArea=Recruitement area PublicInterfaceRecruitmentDesc=Public pages of jobs are public URLs to show and answer to open jobs. There is one different link for each open job, found on each job record. diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 929374d21f0..70a25ea5e27 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -314,7 +314,6 @@ StockStransferIncrementedShort=Stocks transferred StockStransferIncrementedShortCancel=Increase of destination warehouses canceled StockTransferNoBatchForProduct=Product %s doesn't use batch, clear batch on line and retry StockTransferSetup = Stocks Transfer module configuration -Settings=Settings StockTransferSetupPage = Configuration page for stocks transfer module StockTransferRightRead=Read stocks transfers StockTransferRightCreateUpdate=Create/Update stocks transfers diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 08895194016..770a143c231 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -8,7 +8,6 @@ NewSupplierInvoice = New vendor invoice History=History ListOfSuppliers=List of vendors ShowSupplier=Show vendor -OrderDate=Order date BuyingPriceMin=Best buying price BuyingPriceMinShort=Best buying price TotalBuyingPriceMinShort=Total of subproducts buying prices diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index b73f3a35264..fda6c9c16b5 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -157,7 +157,6 @@ Booking=Booking Reservation=Reservation PagesViewedPreviousMonth=Pages viewed (previous month) PagesViewedTotal=Pages viewed (total) -Visibility=Visibility Everyone=Everyone AssignedContacts=Assigned contacts WebsiteTypeLabel=Type of Web site @@ -170,7 +169,6 @@ ModuleWebPortalDesc=A ready to use native web portal for customers, suppliers, p WebPortalDescription=Public web portal module for membership and partnership WebPortalSetup=WebPortal setup WebPortalCSS=Web portal CSS -Settings=Settings WebPortalSetupPage=WebPortal setup page WEBPORTAL_TITLE=Brand name on header of public page UserAccountForWebPortalAreInThirdPartyTabHelp=Users accounts for WebPortal can be set on each third party card in Website accounts tab From 19e4e8647634bd94338fdd486ecf7514837a6ca2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 11:43:54 +0100 Subject: [PATCH 11/90] Fix duplicate translation key --- htdocs/imports/import.php | 2 +- htdocs/langs/en_US/blockedlog.lang | 2 -- htdocs/langs/en_US/datapolicy.lang | 1 - htdocs/langs/en_US/exports.lang | 1 - htdocs/langs/en_US/ticket.lang | 2 +- htdocs/langs/en_US/website.lang | 2 ++ htdocs/public/webportal/tpl/menu.tpl.php | 4 ++-- htdocs/ticket/class/ticket.class.php | 2 +- 8 files changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 4eb466dbf76..1f20107db80 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/import.lib.php'; // Load translation files required by the page -$langs->loadLangs(array('exports', 'compta', 'errors')); +$langs->loadLangs(array('exports', 'compta', 'errors', 'admin')); // Security check $result = restrictedArea($user, 'import'); diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang index cb66945f888..06ccc6b6b37 100644 --- a/htdocs/langs/en_US/blockedlog.lang +++ b/htdocs/langs/en_US/blockedlog.lang @@ -1,5 +1,4 @@ BlockedLog=Unalterable Logs -Field=Field BlockedLogDesc=This module tracks some events into an unalterable log (that you can't modify once recorded) into a block chain, in real time. This module provides compatibility with requirements of laws of some countries (like France with the law Finance 2016 - Norme NF525). Fingerprints=Archived events and fingerprints FingerprintsDesc=This is the tool to browse or extract the unalterable logs. Unalterable logs are generated and archived locally into a dedicated table, in real time when you record a business event. You can use this tool to export this archive and save it into an external support (some countries, like France, ask that you do it every year). Note that, there is no feature to purge this log and every change tried to be done directly into this log (by a hacker for example) will be reported with a non-valid fingerprint. If you really need to purge this table because you used your application for a demo/test purpose and want to clean your data to start your production, you can ask your reseller or integrator to reset your database (all your data will be removed). @@ -13,7 +12,6 @@ OkCheckFingerprintValidity=Archived log record is valid. The data on this line w OkCheckFingerprintValidityButChainIsKo=Archived log seems valid compared to previous one but the chain was corrupted previously. AddedByAuthority=Stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority -ShowDetails=Show stored details BlockedLogBillDownload=Customer invoice download BlockedLogBillPreview=Customer invoice preview BlockedlogInfoDialog=Log Details diff --git a/htdocs/langs/en_US/datapolicy.lang b/htdocs/langs/en_US/datapolicy.lang index 6b4413f812b..0597a45db88 100644 --- a/htdocs/langs/en_US/datapolicy.lang +++ b/htdocs/langs/en_US/datapolicy.lang @@ -84,6 +84,5 @@ DATAPOLICY_SEND = Send GDPR email MailSent = Email has been sent # ERROR -ErrorSubjectIsRequired = Error : The subject of email is required. Indicate it in the module setup =Due to a technical problem, we were unable to register your choice. We apologize for that. Contact us to send us your choice. NUMBER_MONTH_BEFORE_DELETION = Number of month before deletion diff --git a/htdocs/langs/en_US/exports.lang b/htdocs/langs/en_US/exports.lang index 94ca852beca..29311b3b466 100644 --- a/htdocs/langs/en_US/exports.lang +++ b/htdocs/langs/en_US/exports.lang @@ -62,7 +62,6 @@ ChooseFileToImport=Upload file then click on the %s icon to select file as sourc SourceFileFormat=Source file format FieldsInSourceFile=Fields in source file FieldsInTargetDatabase=Target fields in Dolibarr database (bold=mandatory) -Field=Field NoFields=No fields MoveField=Move field column number %s ExampleOfImportFile=Example_of_import_file diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index e1493e9c14b..f0e29804344 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -69,7 +69,7 @@ Read=Read Assigned=Assigned NeedMoreInformation=Waiting for reporter feedback NeedMoreInformationShort=Waiting for feedback -Answered=Answered +TicketAnswered=Answered Waiting=Waiting SolvedClosed=Solved Deleted=Deleted diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index fda6c9c16b5..45cb1781e5c 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -233,3 +233,5 @@ WebPortalMember=Membership WebPortalOrder=Sale Order WebPortalPartnership=Partnership WebPortalPropal=Proposal +WebPortalGroupMenuAdmin=Administration +WebPortalGroupMenuTechnical=System \ No newline at end of file diff --git a/htdocs/public/webportal/tpl/menu.tpl.php b/htdocs/public/webportal/tpl/menu.tpl.php index 5496b14b213..a3226003109 100644 --- a/htdocs/public/webportal/tpl/menu.tpl.php +++ b/htdocs/public/webportal/tpl/menu.tpl.php @@ -92,14 +92,14 @@ $navGroupMenu = array( 'id' => 'administrative', 'rank' => -1, // negative value for undefined, it will be set by the min item rank for this group 'url' => '', - 'name' => $langs->trans('GroupMenuAdministrative'), + 'name' => $langs->trans('WebPortalGroupMenuAdmin'), 'children' => array() ), 'technical' => array( 'id' => 'technical', 'rank' => -1, // negative value for undefined, it will be set by the min item rank for this group 'url' => '', - 'name' => $langs->trans('GroupMenuTechnical'), + 'name' => $langs->trans('WebPortalGroupMenuTechnical'), 'children' => array() ), ); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index b17e0f26286..802583e7ac2 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -344,7 +344,7 @@ class Ticket extends CommonObject 'email_date' => array('type'=>'datetime', 'label'=>'EmailDate', 'visible'=>-2, 'enabled'=>1, 'position'=>541), 'progress' => array('type'=>'integer', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>2, 'csslist'=>'width50'), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>'getDolGlobalString("TICKET_ENABLE_RESOLUTION")', 'position'=>550, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'SolvedClosed', 9 => 'Deleted')), + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'TicketAnswered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'SolvedClosed', 9 => 'Deleted')), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900), ); // END MODULEBUILDER PROPERTIES From f1ec8a0640f30ada2db6a6a1ee9b1f77da946618 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:12:07 +0100 Subject: [PATCH 12/90] Fix duplicate translation key --- htdocs/compta/bank/line.php | 2 +- htdocs/compta/charges/index.php | 4 ++-- htdocs/compta/journal/purchasesjournal.php | 3 ++- htdocs/compta/localtax/card.php | 2 +- htdocs/compta/localtax/class/localtax.class.php | 2 +- htdocs/compta/paiement/cheque/index.php | 2 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/compta/paiement/list.php | 2 +- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 2 +- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- htdocs/don/paiement/list.php | 2 +- .../expensereport/class/paymentexpensereport.class.php | 2 +- htdocs/expensereport/payment/list.php | 2 +- htdocs/fourn/paiement/list.php | 2 +- htdocs/langs/en_US/admin.lang | 3 --- htdocs/langs/en_US/agenda.lang | 3 --- htdocs/langs/en_US/banks.lang | 1 - htdocs/langs/en_US/cashdesk.lang | 1 - htdocs/langs/en_US/categories.lang | 1 - htdocs/langs/en_US/cron.lang | 3 +-- htdocs/langs/en_US/knowledgemanagement.lang | 1 - htdocs/langs/en_US/main.lang | 2 ++ htdocs/langs/en_US/recruitment.lang | 1 - htdocs/loan/card.php | 4 ++-- htdocs/salaries/class/salary.class.php | 10 ---------- 27 files changed, 23 insertions(+), 42 deletions(-) diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 41875945a1b..2ff4b955b55 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -375,7 +375,7 @@ if ($result) { $i++; // Bank account - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print ''; // $objp->fk_account may be not > 0 if data was lost by an old bug. In such a case, we let a chance to user to fix it. if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 5458cd50301..99553c95bb7 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -148,7 +148,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (isModEnabled("banque")) { - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -318,7 +318,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (isModEnabled("banque")) { - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 09e52081228..afe25f104c7 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -247,7 +247,8 @@ foreach ($tabfac as $key => $val) { print ''; print "".dol_print_date($db->jdate($val["date"])).""; print "".$invoicestatic->getNomUrl(1).""; - print "".$k."".$line['label'].""; + print "".$k.""; + print "".$line['label'].""; if (isset($line['inv'])) { print ''.($mt < 0 ? price(-$mt) : '').""; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 0f520b3d380..894aa3986d1 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -186,7 +186,7 @@ if ($action == 'create') { print ""; // Bank account - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print img_picto('', 'bank_account', 'pictofixedwidth'); $form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2, '', 0, 'maxwidth500 widthcentpercentminusx'); // Affiche liste des comptes courant print ''; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index e93c461f2b4..69453df58fd 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -486,7 +486,7 @@ class Localtax extends CommonObject return -4; } if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount")); return -5; } if (isModEnabled("banque") && (empty($this->paymenttype) || $this->paymenttype <= 0)) { diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 1cc8659754e..98d938a23af 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -148,7 +148,7 @@ foreach ($arrayofpaymentmodetomanage as $val) { } print ''; print ''.$langs->trans("Date").""; - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print ''.$langs->trans("NbOfCheques").''; print ''.$langs->trans("Amount").''; print ''.$langs->trans("Status").''; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 781f0ad8056..8aa74f5fe2a 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -93,7 +93,7 @@ $arrayfields = array( 'bc.ref' => array('label'=>"Ref", 'checked'=>1, 'position'=>10), 'bc.type' => array('label'=>"Type", 'checked'=>1, 'position'=>20), 'bc.date_bordereau' => array('label'=>"DateCreation", 'checked'=>1, 'position'=>30), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>40), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>40), 'bc.nbcheque' => array('label'=>"NbOfCheques", 'checked'=>1, 'position'=>50), 'bc.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>60), 'bc.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>70) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 98d4adb5c60..b478b2e0314 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -104,7 +104,7 @@ $arrayfields = array( 's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40), 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled("banque"))), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), 'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"), 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))), diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index cd7a7969e7a..749e9497c25 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -248,7 +248,7 @@ print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $pa print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); if (isModEnabled("banque")) { print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "pc.fk_bank", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 1684bd9a96d..7a0c249992c 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -584,7 +584,7 @@ class Tva extends CommonObject return -4; } if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount")); return -5; } if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 864997ac473..7268933be1b 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -290,7 +290,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(10, 32); - $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); + $pdf->MultiCell(0, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L'); pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); $pdf->SetFont('', '', $default_font_size); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index a230e3e5aa9..fa291a7b0e5 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -437,7 +437,7 @@ class pdf_paiement extends CommonDocGenerator $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10); $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L'); + $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L'); $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10); diff --git a/htdocs/don/paiement/list.php b/htdocs/don/paiement/list.php index 2b27e6e936e..267c01f9e9c 100644 --- a/htdocs/don/paiement/list.php +++ b/htdocs/don/paiement/list.php @@ -94,7 +94,7 @@ $arrayfields = array( 'c.code' => array('label'=>"Type", 'checked'=>1, 'position'=>40), 'pd.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>70, 'enabled'=>(isModEnabled("banque"))), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>70, 'enabled'=>(isModEnabled("banque"))), 'pd.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 7ffe3f3987d..6ce84881a73 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -754,7 +754,7 @@ class PaymentExpenseReport extends CommonObject $return .= '
'.$langs->trans("Type").' : '.$this->fk_typepayment.''; } if (property_exists($this, 'fk_bank') && !is_null($this->fk_bank)) { - $return .= '
'.$langs->trans("Account").' : '.$this->fk_bank.''; + $return .= '
'.$langs->trans("BankAccount").' : '.$this->fk_bank.''; } if (property_exists($this, 'amount')) { $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 5b67b635ff4..ee6ad1dc38c 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -107,7 +107,7 @@ $arrayfields = array( 'u.login' =>array('label'=>"User", 'checked'=>1, 'position'=>30), 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), 'pndf.num_payment' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), - 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), + 'ba.label' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), 'pndf.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index cd42464d2f3..2112f64f385 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -102,7 +102,7 @@ $arrayfields = array( 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), - 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), + 'ba.label' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 47c34482e82..0655ef02361 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -149,7 +149,6 @@ MaxNbOfLinesForBoxes=Max. number of lines for widgets AllWidgetsWereEnabled=All available widgets are enabled WidgetAvailable=Widget available PositionByDefault=Default order -Position=Position MenusDesc=Menu managers set content of the two menu bars (horizontal and vertical). MenusEditorDesc=The menu editor allows you to define custom menu entries. Use it carefully to avoid instability and permanently unreachable menu entries.
Some modules add menu entries (in menu All mostly). If you remove some of these entries by mistake, you can restore them disabling and reenabling the module. MenuForUsers=Menu for users @@ -220,7 +219,6 @@ ModulesMarketPlaces=Find external app/modules ModulesDevelopYourModule=Develop your own app/modules ModulesDevelopDesc=You may also develop your own module or find a partner to develop one for you. DOLISTOREdescriptionLong=Instead of switching on www.dolistore.com web site to find an external module, you can use this embedded tool that will perform the search on the external market place for you (may be slow, need an internet access)... -NewModule=New module FreeModule=Free CompatibleUpTo=Compatible with version %s NotCompatible=This module does not seem compatible with your Dolibarr %s (Min %s - Max %s). @@ -1213,7 +1211,6 @@ EnableMultilangInterface=Enable multilanguage support for customer or vendor rel EnableShowLogo=Show the company logo in the menu CompanyInfo=Company/Organization CompanyIds=Company/Organization identities -CompanyName=Name CompanyAddress=Address CompanyZip=Zip CompanyTown=Town diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 793b3cb1862..657d885e5dc 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -8,8 +8,6 @@ LocalAgenda=Default calendar ActionsOwnedBy=Event owned by ActionsOwnedByShort=Owner AffectedTo=Assigned to -Event=Event -Events=Events EventsNb=Number of events ListOfActions=List of events EventReports=Event reports @@ -192,7 +190,6 @@ DurationOfRange=Duration of ranges BookCalSetup = Online appointment setup BookCalSetupPage = Online appointment setup page BOOKCAL_PUBLIC_INTERFACE_TOPIC = Interface title -About = About BookCalAbout = About BookCal BookCalAboutPage = BookCal about page Calendars=Calendars diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index c6970765e9c..a7ff18831ab 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -67,7 +67,6 @@ AccountsArea=Accounts area AccountCard=Account card DeleteAccount=Delete account ConfirmDeleteAccount=Are you sure you want to delete this account? -Account=Account BankTransactionByCategories=Bank entries by categories BankTransactionForCategory=Bank entries for category %s RemoveFromRubrique=Remove link with category diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index dba0ab25634..49053c063e7 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -90,7 +90,6 @@ ColorTheme=Color theme Colorful=Colorful HeadBar=Head Bar SortProductField=Field for sorting products -Browser=Browser BrowserMethodDescription=Simple and easy receipt printing. Only a few parameters to configure the receipt. Print via browser. TakeposConnectorMethodDescription=External module with extra features. Possibility to print from the cloud. PrintMethod=Print method diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 5471c4afad0..8a4d3783d64 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -103,4 +103,3 @@ WebsitePagesCategoriesArea=Page-Container Categories KnowledgemanagementsCategoriesArea=KM article Categories UseOrOperatorForCategories=Use 'OR' operator for categories AddObjectIntoCategory=Assign to the category -Position=Position diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 52de5a48b82..b40a7df0318 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -1,6 +1,5 @@ # Dolibarr language file - Source file is en_US - cron -# About page -# Right +# Permissions Permission23101 = Read Scheduled job Permission23102 = Create/update Scheduled job Permission23103 = Delete Scheduled job diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index 1f83c02cae1..e0d1fabecfc 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -32,7 +32,6 @@ KnowledgeManagementSetupPage = Knowledge Management System setup page # # About page # -About = About KnowledgeManagementAbout = About Knowledge Management KnowledgeManagementAboutPage = Knowledge Management about page diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 490b9be3b37..3b20265b276 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -963,6 +963,7 @@ AutomaticallyCalculated=Automatically calculated TitleSetToDraft=Go back to draft ConfirmSetToDraft=Are you sure you want to go back to Draft status? ImportId=Import id +Event=Event Events=Events EMailTemplates=Email templates FileNotShared=File not shared to external public @@ -1213,6 +1214,7 @@ CanceledHidden=Canceled hidden CanceledShown=Canceled shown Terminate=Terminate Terminated=Terminated +Position=Position AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 5a3ed4be055..fcbf87e49f4 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -34,7 +34,6 @@ EnablePublicRecruitmentPages=Enable public pages of open jobs # # About page # -About = About RecruitmentAbout = About Recruitment RecruitmentAboutPage = Recruitment about page NbOfEmployeesExpected=Expected nb of employees diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index d29665eef9b..981d805e52b 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -291,11 +291,11 @@ if ($action == 'create') { // Bank account if (isModEnabled("banque")) { - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant print ''; } else { - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print $langs->trans("NoBankAccountDefined"); print ''; } diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index bf3af9539d1..344992f84cc 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -363,16 +363,6 @@ class Salary extends CommonObject $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - /* if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - }*/ $this->db->begin(); From ba2c11c53454b5daf2e47dda739343fea6fa090b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:12:07 +0100 Subject: [PATCH 13/90] Fix duplicate translation key --- htdocs/compta/bank/line.php | 2 +- htdocs/compta/charges/index.php | 4 ++-- htdocs/compta/journal/purchasesjournal.php | 3 ++- htdocs/compta/localtax/card.php | 2 +- htdocs/compta/localtax/class/localtax.class.php | 2 +- htdocs/compta/paiement/cheque/index.php | 2 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/compta/paiement/list.php | 2 +- htdocs/compta/sociales/payments.php | 2 +- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/core/modules/cheque/doc/pdf_blochet.class.php | 2 +- htdocs/core/modules/rapport/pdf_paiement.class.php | 2 +- htdocs/don/paiement/list.php | 2 +- .../expensereport/class/paymentexpensereport.class.php | 2 +- htdocs/expensereport/payment/list.php | 2 +- htdocs/fourn/paiement/list.php | 2 +- htdocs/langs/en_US/admin.lang | 6 +----- htdocs/langs/en_US/agenda.lang | 3 --- htdocs/langs/en_US/banks.lang | 1 - htdocs/langs/en_US/cashdesk.lang | 1 - htdocs/langs/en_US/categories.lang | 1 - htdocs/langs/en_US/cron.lang | 3 +-- htdocs/langs/en_US/knowledgemanagement.lang | 1 - htdocs/langs/en_US/main.lang | 2 ++ htdocs/langs/en_US/members.lang | 4 ---- htdocs/langs/en_US/recruitment.lang | 1 - htdocs/loan/card.php | 4 ++-- htdocs/salaries/class/salary.class.php | 10 ---------- 28 files changed, 24 insertions(+), 48 deletions(-) diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 41875945a1b..2ff4b955b55 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -375,7 +375,7 @@ if ($result) { $i++; // Bank account - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print ''; // $objp->fk_account may be not > 0 if data was lost by an old bug. In such a case, we let a chance to user to fix it. if (($objp->rappro || $bankline->getVentilExportCompta()) && $objp->fk_account > 0) { diff --git a/htdocs/compta/charges/index.php b/htdocs/compta/charges/index.php index 5458cd50301..99553c95bb7 100644 --- a/htdocs/compta/charges/index.php +++ b/htdocs/compta/charges/index.php @@ -148,7 +148,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pc.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (isModEnabled("banque")) { - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; @@ -318,7 +318,7 @@ if (isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) { print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); if (isModEnabled("banque")) { - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder); print "\n"; diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 09e52081228..afe25f104c7 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -247,7 +247,8 @@ foreach ($tabfac as $key => $val) { print ''; print "".dol_print_date($db->jdate($val["date"])).""; print "".$invoicestatic->getNomUrl(1).""; - print "".$k."".$line['label'].""; + print "".$k.""; + print "".$line['label'].""; if (isset($line['inv'])) { print ''.($mt < 0 ? price(-$mt) : '').""; diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php index 0f520b3d380..894aa3986d1 100644 --- a/htdocs/compta/localtax/card.php +++ b/htdocs/compta/localtax/card.php @@ -186,7 +186,7 @@ if ($action == 'create') { print ""; // Bank account - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print img_picto('', 'bank_account', 'pictofixedwidth'); $form->select_comptes(GETPOST("accountid", "int"), "accountid", 0, "courant=1", 2, '', 0, 'maxwidth500 widthcentpercentminusx'); // Affiche liste des comptes courant print ''; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index e93c461f2b4..69453df58fd 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -486,7 +486,7 @@ class Localtax extends CommonObject return -4; } if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount")); return -5; } if (isModEnabled("banque") && (empty($this->paymenttype) || $this->paymenttype <= 0)) { diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 1cc8659754e..98d938a23af 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -148,7 +148,7 @@ foreach ($arrayofpaymentmodetomanage as $val) { } print ''; print ''.$langs->trans("Date").""; - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print ''.$langs->trans("NbOfCheques").''; print ''.$langs->trans("Amount").''; print ''.$langs->trans("Status").''; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 781f0ad8056..8aa74f5fe2a 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -93,7 +93,7 @@ $arrayfields = array( 'bc.ref' => array('label'=>"Ref", 'checked'=>1, 'position'=>10), 'bc.type' => array('label'=>"Type", 'checked'=>1, 'position'=>20), 'bc.date_bordereau' => array('label'=>"DateCreation", 'checked'=>1, 'position'=>30), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>40), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>40), 'bc.nbcheque' => array('label'=>"NbOfCheques", 'checked'=>1, 'position'=>50), 'bc.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>60), 'bc.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>70) diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php index 98d4adb5c60..b478b2e0314 100644 --- a/htdocs/compta/paiement/list.php +++ b/htdocs/compta/paiement/list.php @@ -104,7 +104,7 @@ $arrayfields = array( 's.nom' => array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 'c.libelle' => array('label'=>"Type", 'checked'=>1, 'position'=>40), 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>50, 'enabled'=>(isModEnabled("banque"))), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), 'p.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>70, 'tooltip'=>"ChequeOrTransferNumber"), 'p.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), 'p.statut' => array('label'=>"Status", 'checked'=>1, 'position'=>90, 'enabled'=>(getDolGlobalString('BILL_ADD_PAYMENT_VALIDATION'))), diff --git a/htdocs/compta/sociales/payments.php b/htdocs/compta/sociales/payments.php index cd7a7969e7a..749e9497c25 100644 --- a/htdocs/compta/sociales/payments.php +++ b/htdocs/compta/sociales/payments.php @@ -248,7 +248,7 @@ print_liste_field_titre("PaymentMode", $_SERVER["PHP_SELF"], "pct.code", "", $pa print_liste_field_titre("Numero", $_SERVER["PHP_SELF"], "pc.num_paiement", "", $param, '', $sortfield, $sortorder, '', 'ChequeOrTransferNumber'); if (isModEnabled("banque")) { print_liste_field_titre("BankTransactionLine", $_SERVER["PHP_SELF"], "pc.fk_bank", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); } print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "cs.amount", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pc.amount", "", $param, 'class="right"', $sortfield, $sortorder); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 1684bd9a96d..7a0c249992c 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -584,7 +584,7 @@ class Tva extends CommonObject return -4; } if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount")); return -5; } if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 864997ac473..7268933be1b 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -290,7 +290,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $pdf->SetFont('', '', $default_font_size); $pdf->SetXY(10, 32); - $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L'); + $pdf->MultiCell(0, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L'); pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1); $pdf->SetFont('', '', $default_font_size); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index a230e3e5aa9..fa291a7b0e5 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -437,7 +437,7 @@ class pdf_paiement extends CommonDocGenerator $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10); $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2); - $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L'); + $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L'); $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10); diff --git a/htdocs/don/paiement/list.php b/htdocs/don/paiement/list.php index 2b27e6e936e..267c01f9e9c 100644 --- a/htdocs/don/paiement/list.php +++ b/htdocs/don/paiement/list.php @@ -94,7 +94,7 @@ $arrayfields = array( 'c.code' => array('label'=>"Type", 'checked'=>1, 'position'=>40), 'pd.num_paiement' => array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), 'transaction' => array('label'=>"BankTransactionLine", 'checked'=>1, 'position'=>60, 'enabled'=>(isModEnabled("banque"))), - 'ba.label' => array('label'=>"Account", 'checked'=>1, 'position'=>70, 'enabled'=>(isModEnabled("banque"))), + 'ba.label' => array('label'=>"BankAccount", 'checked'=>1, 'position'=>70, 'enabled'=>(isModEnabled("banque"))), 'pd.amount' => array('label'=>"Amount", 'checked'=>1, 'position'=>80), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 7ffe3f3987d..6ce84881a73 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -754,7 +754,7 @@ class PaymentExpenseReport extends CommonObject $return .= '
'.$langs->trans("Type").' : '.$this->fk_typepayment.''; } if (property_exists($this, 'fk_bank') && !is_null($this->fk_bank)) { - $return .= '
'.$langs->trans("Account").' : '.$this->fk_bank.''; + $return .= '
'.$langs->trans("BankAccount").' : '.$this->fk_bank.''; } if (property_exists($this, 'amount')) { $return .= '
'.$langs->trans("Amount").' : '.price($this->amount).''; diff --git a/htdocs/expensereport/payment/list.php b/htdocs/expensereport/payment/list.php index 5b67b635ff4..ee6ad1dc38c 100644 --- a/htdocs/expensereport/payment/list.php +++ b/htdocs/expensereport/payment/list.php @@ -107,7 +107,7 @@ $arrayfields = array( 'u.login' =>array('label'=>"User", 'checked'=>1, 'position'=>30), 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), 'pndf.num_payment' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), - 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), + 'ba.label' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), 'pndf.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/fourn/paiement/list.php b/htdocs/fourn/paiement/list.php index cd42464d2f3..2112f64f385 100644 --- a/htdocs/fourn/paiement/list.php +++ b/htdocs/fourn/paiement/list.php @@ -102,7 +102,7 @@ $arrayfields = array( 's.nom' =>array('label'=>"ThirdParty", 'checked'=>1, 'position'=>30), 'c.libelle' =>array('label'=>"Type", 'checked'=>1, 'position'=>40), 'p.num_paiement' =>array('label'=>"Numero", 'checked'=>1, 'position'=>50, 'tooltip'=>"ChequeOrTransferNumber"), - 'ba.label' =>array('label'=>"Account", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), + 'ba.label' =>array('label'=>"BankAccount", 'checked'=>1, 'position'=>60, 'enable'=>(isModEnabled("banque"))), 'p.amount' =>array('label'=>"Amount", 'checked'=>1, 'position'=>70), ); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 47c34482e82..06bcb0712ed 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -149,7 +149,6 @@ MaxNbOfLinesForBoxes=Max. number of lines for widgets AllWidgetsWereEnabled=All available widgets are enabled WidgetAvailable=Widget available PositionByDefault=Default order -Position=Position MenusDesc=Menu managers set content of the two menu bars (horizontal and vertical). MenusEditorDesc=The menu editor allows you to define custom menu entries. Use it carefully to avoid instability and permanently unreachable menu entries.
Some modules add menu entries (in menu All mostly). If you remove some of these entries by mistake, you can restore them disabling and reenabling the module. MenuForUsers=Menu for users @@ -220,7 +219,6 @@ ModulesMarketPlaces=Find external app/modules ModulesDevelopYourModule=Develop your own app/modules ModulesDevelopDesc=You may also develop your own module or find a partner to develop one for you. DOLISTOREdescriptionLong=Instead of switching on www.dolistore.com web site to find an external module, you can use this embedded tool that will perform the search on the external market place for you (may be slow, need an internet access)... -NewModule=New module FreeModule=Free CompatibleUpTo=Compatible with version %s NotCompatible=This module does not seem compatible with your Dolibarr %s (Min %s - Max %s). @@ -435,6 +433,7 @@ MassConvert=Launch bulk conversion PriceFormatInCurrentLanguage=Price Format In Current Language String=String String1Line=String (1 line) +Text=Text TextLong=Long text TextLongNLines=Long text (n lines) HtmlText=Html text @@ -1213,7 +1212,6 @@ EnableMultilangInterface=Enable multilanguage support for customer or vendor rel EnableShowLogo=Show the company logo in the menu CompanyInfo=Company/Organization CompanyIds=Company/Organization identities -CompanyName=Name CompanyAddress=Address CompanyZip=Zip CompanyTown=Town @@ -1752,8 +1750,6 @@ BarcodeDescQRCODE=Barcode of type QR code GenbarcodeLocation=Bar code generation command line tool (used by internal engine for some bar code types). Must be compatible with "genbarcode".
For example: /usr/local/bin/genbarcode BarcodeInternalEngine=Internal engine BarCodeNumberManager=Manager to auto define barcode numbers -##### Prelevements ##### -WithdrawalsSetup=Setup of module Direct Debit payments ##### ExternalRSS ##### ExternalRSSSetup=External RSS imports setup NewRSS=New RSS Feed diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 793b3cb1862..657d885e5dc 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -8,8 +8,6 @@ LocalAgenda=Default calendar ActionsOwnedBy=Event owned by ActionsOwnedByShort=Owner AffectedTo=Assigned to -Event=Event -Events=Events EventsNb=Number of events ListOfActions=List of events EventReports=Event reports @@ -192,7 +190,6 @@ DurationOfRange=Duration of ranges BookCalSetup = Online appointment setup BookCalSetupPage = Online appointment setup page BOOKCAL_PUBLIC_INTERFACE_TOPIC = Interface title -About = About BookCalAbout = About BookCal BookCalAboutPage = BookCal about page Calendars=Calendars diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index c6970765e9c..a7ff18831ab 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -67,7 +67,6 @@ AccountsArea=Accounts area AccountCard=Account card DeleteAccount=Delete account ConfirmDeleteAccount=Are you sure you want to delete this account? -Account=Account BankTransactionByCategories=Bank entries by categories BankTransactionForCategory=Bank entries for category %s RemoveFromRubrique=Remove link with category diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index dba0ab25634..49053c063e7 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -90,7 +90,6 @@ ColorTheme=Color theme Colorful=Colorful HeadBar=Head Bar SortProductField=Field for sorting products -Browser=Browser BrowserMethodDescription=Simple and easy receipt printing. Only a few parameters to configure the receipt. Print via browser. TakeposConnectorMethodDescription=External module with extra features. Possibility to print from the cloud. PrintMethod=Print method diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang index 5471c4afad0..8a4d3783d64 100644 --- a/htdocs/langs/en_US/categories.lang +++ b/htdocs/langs/en_US/categories.lang @@ -103,4 +103,3 @@ WebsitePagesCategoriesArea=Page-Container Categories KnowledgemanagementsCategoriesArea=KM article Categories UseOrOperatorForCategories=Use 'OR' operator for categories AddObjectIntoCategory=Assign to the category -Position=Position diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 52de5a48b82..b40a7df0318 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -1,6 +1,5 @@ # Dolibarr language file - Source file is en_US - cron -# About page -# Right +# Permissions Permission23101 = Read Scheduled job Permission23102 = Create/update Scheduled job Permission23103 = Delete Scheduled job diff --git a/htdocs/langs/en_US/knowledgemanagement.lang b/htdocs/langs/en_US/knowledgemanagement.lang index 1f83c02cae1..e0d1fabecfc 100644 --- a/htdocs/langs/en_US/knowledgemanagement.lang +++ b/htdocs/langs/en_US/knowledgemanagement.lang @@ -32,7 +32,6 @@ KnowledgeManagementSetupPage = Knowledge Management System setup page # # About page # -About = About KnowledgeManagementAbout = About Knowledge Management KnowledgeManagementAboutPage = Knowledge Management about page diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 490b9be3b37..3b20265b276 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -963,6 +963,7 @@ AutomaticallyCalculated=Automatically calculated TitleSetToDraft=Go back to draft ConfirmSetToDraft=Are you sure you want to go back to Draft status? ImportId=Import id +Event=Event Events=Events EMailTemplates=Email templates FileNotShared=File not shared to external public @@ -1213,6 +1214,7 @@ CanceledHidden=Canceled hidden CanceledShown=Canceled shown Terminate=Terminate Terminated=Terminated +Position=Position AddLineOnPosition=Add line on position (at the end if empty) ConfirmAllocateCommercial=Assign sales representative confirmation ConfirmAllocateCommercialQuestion=Are you sure you want to assign the %s selected record(s)? diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 34148bf11e2..f64890f6525 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -124,10 +124,6 @@ ExportDataset_member_1=Members and contributions ImportDataset_member_1=Members LastMembersModified=Latest %s modified members LastSubscriptionsModified=Latest %s modified contributions -String=String -Text=Text -Int=Int -DateAndTime=Date and time PublicMemberCard=Public member card SubscriptionNotRecorded=Contribution not recorded AddSubscription=Create contribution diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index 5a3ed4be055..fcbf87e49f4 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -34,7 +34,6 @@ EnablePublicRecruitmentPages=Enable public pages of open jobs # # About page # -About = About RecruitmentAbout = About Recruitment RecruitmentAboutPage = Recruitment about page NbOfEmployeesExpected=Expected nb of employees diff --git a/htdocs/loan/card.php b/htdocs/loan/card.php index d29665eef9b..981d805e52b 100644 --- a/htdocs/loan/card.php +++ b/htdocs/loan/card.php @@ -291,11 +291,11 @@ if ($action == 'create') { // Bank account if (isModEnabled("banque")) { - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; $form->select_comptes(GETPOST("accountid"), "accountid", 0, "courant=1", 1); // Show list of bank account with courant print ''; } else { - print ''.$langs->trans("Account").''; + print ''.$langs->trans("BankAccount").''; print $langs->trans("NoBankAccountDefined"); print ''; } diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index bf3af9539d1..344992f84cc 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -363,16 +363,6 @@ class Salary extends CommonObject $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); return -5; } - /* if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - }*/ $this->db->begin(); From 77a72e0012a45e0d1272c1e00ec978235aa3a63c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:29:25 +0100 Subject: [PATCH 14/90] Fix duplicate key --- htdocs/langs/en_US/main.lang | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 3b20265b276..9df46dbc8dd 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1181,7 +1181,6 @@ ConfirmAffectUserQuestion=Are you sure you want to assign users to the %s select ConfirmSetSupervisorQuestion=Are you sure you want to set supervisor to the %s selected record(s)? ConfirmUpdatePriceQuestion=Are you sure you want to update the price of the %s selected record(s)? CategTypeNotFound=No tag type found for type of records -Rate=Rate SupervisorNotFound=Supervisor not found CopiedToClipboard=Copied to clipboard InformationOnLinkToContract=This amount is only the total of all the lines of the contract. No notion of time is taken into consideration. From 625084723cb4ed7f3ae07df7a0cda21ce9c762b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:34:59 +0100 Subject: [PATCH 15/90] Fix $object --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d2e757bf383..39f6ae6f23c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -9050,7 +9050,7 @@ abstract class CommonObject $dir = $conf->$newmodulepart->dir_output; if (!empty($this->photo)) { - if (dolIsAllowedForPreview($object->photo)) { + if (dolIsAllowedForPreview($this->photo)) { if ((string) $imagesize == 'mini') { $file = get_exdir(0, 0, 0, 0, $this, $newmodulepart) . 'photos/' . dol_sanitizeFileName(getImageFileNameForSize($this->photo, '_mini')); } elseif ((string) $imagesize == 'small') { From 1c780251efd7d2ac52bd09118346b15817b4a973 Mon Sep 17 00:00:00 2001 From: Yacine Ahmaich Date: Sat, 3 Feb 2024 12:36:15 +0100 Subject: [PATCH 16/90] Fix: 'user_logo' in the user substitution array, it results in a error. (#27979) This error is caused by not reading from the /photos directory where the profile image is stored alongside with thumbs. Note: We use the small variant because its size makes it look perfect in the generated docs. --- htdocs/core/class/commondocgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index d87123a97c9..5fd23d9058a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -193,7 +193,7 @@ abstract class CommonDocGenerator // phpcs:enable global $conf, $extrafields; - $logotouse = $conf->user->dir_output.'/'.get_exdir($user->id, 2, 0, 1, $user, 'user').'/'.$user->photo; + $logotouse = $conf->user->dir_output . '/' . get_exdir(0, 0, 0, 0, $user, 'user') . 'photos/' . getImageFileNameForSize($user->photo, '_small'); $array_user = array( 'myuser_lastname'=>$user->lastname, From 12a7991c1541b696330e55bd9d05ebd406d8caaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 3 Feb 2024 12:36:29 +0100 Subject: [PATCH 17/90] fix phpstan (#27978) From e40b1f92924f5446d62ab7d59448c1f72922e429 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Sat, 3 Feb 2024 12:37:29 +0100 Subject: [PATCH 18/90] Close #27777 : new massaction subscription creation (#27861) * Close #27777 : new massaction subscription creation * fix amount * Add some fields in formquestion --------- Co-authored-by: Hystepik --- htdocs/adherents/list.php | 63 +++++++++++++++++++++++++++++++++ htdocs/langs/en_US/members.lang | 8 ++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 2114f6107c0..1eda77b6587 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -335,6 +335,38 @@ if (empty($reshook)) { } } + // Create external user + if ($action == 'createsubscription_confirm' && $confirm == "yes" && $user->hasRight('adherent', 'creer')) { + $tmpmember = new Adherent($db); + $adht = new AdherentType($db); + $error = 0; + $nbcreated = 0; + $now = dol_now(); + $amount = price2num(GETPOST('amount', 'alpha')); + $db->begin(); + foreach ($toselect as $id) { + $res = $tmpmember->fetch($id); + if ($res > 0) { + $result = $tmpmember->subscription($now, $amount); + if ($result < 0) { + $error++; + } else { + $nbcreated++; + } + } else { + $error++; + } + } + + if (!$error) { + setEventMessages($langs->trans("XSubsriptionCreated", $nbcreated), null, 'mesgs'); + $db->commit(); + } else { + setEventMessages($langs->trans("XSubsriptionError", $error), null, 'mesgs'); + $db->rollback(); + } + } + // Mass actions $objectclass = 'Adherent'; $objectlabel = 'Members'; @@ -706,6 +738,9 @@ if (isModEnabled('category') && $user->hasRight('adherent', 'creer')) { if ($user->hasRight('adherent', 'creer') && $user->hasRight('user', 'user', 'creer')) { $arrayofmassactions['createexternaluser'] = img_picto('', 'user', 'class="pictofixedwidth"').$langs->trans("CreateExternalUser"); } +if ($user->hasRight('adherent', 'creer')) { + $arrayofmassactions['createsubscription'] = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("CreateSubscription"); +} if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) { $arrayofmassactions = array(); } @@ -740,6 +775,34 @@ $topicmail = "Information"; $modelmail = "member"; $objecttmp = new Adherent($db); $trackid = 'mem'.$object->id; +if ($massaction == 'createsubscription') { + $tmpmember = new Adherent($db); + $adht = new AdherentType($db); + $amount = 0; + foreach ($toselect as $id) { + $now = dol_now(); + $tmpmember->fetch($id); + $res = $adht->fetch($tmpmember->typeid); + if ($res > 0) { + $amounttmp = $adht->amount; + if (!empty($tmpmember->last_subscription_amount) && !GETPOSTISSET('newamount') && is_numeric($amounttmp)) { + $amounttmp = max($tmpmember->last_subscription_amount, $amount); + } + $amount = max(0, $amounttmp, $amount); + } else { + $error++; + } + } + + $date = dol_print_date(dol_now(), "%d/%m/%Y"); + $formquestion = array( + array('label' => $langs->trans("DateSubscription"), 'type' => 'other', 'value' => $date), + array('label' => $langs->trans("Amount"), 'type' => 'text', 'value' => price($amount, 0, '', 0), 'name' => 'amount'), + array('type' => 'separator'), + array('label' => $langs->trans("MoreActions"), 'type' => 'other', 'value' => $langs->trans("None").' '.img_warning($langs->trans("WarningNoComplementaryActionDone"))), + ); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSubsriptionCreation"), $langs->trans("ConfirmMassSubsriptionCreationQuestion", count($toselect)), "createsubscription_confirm", $formquestion, '', 0, 200, 500, 1); +} include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index f64890f6525..05946edce75 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -239,4 +239,10 @@ MemberLastname=Member lastname MemberCodeDesc=Member Code, unique for all members MemberSubscriptionStartFirstDayOf=The start date of a membership corresponds to the first day of a MemberSubscriptionStartAfter=Minimum period before the entry into force of the start date of a subscription except renewals (example +3m = +3 months, -5d = -5 days, +1Y = +1 year) -SubscriptionLinkedToConciliatedTransaction=Membership is linked to a conciliated transaction so this modification is not allowed. \ No newline at end of file +SubscriptionLinkedToConciliatedTransaction=Membership is linked to a conciliated transaction so this modification is not allowed. +ConfirmMassSubsriptionCreation=Confirm subscription creation +ConfirmMassSubsriptionCreationQuestion=Are you sure you want to create the %s selected subscription(s)? +XSubsriptionCreated=%s subscription(s) created +XSubsriptionErrors=%s subscription(s) where in error +CreateSubscription=Create subscription +WarningNoComplementaryActionDone=No Complementary action on recording will be executed with this massaction \ No newline at end of file From 49c7a86b32db5d1713438267e68a61fa9ad4c2a8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:58:48 +0100 Subject: [PATCH 19/90] Debug v19 --- htdocs/comm/mailing/index.php | 45 +++++++++++++++++++---------------- htdocs/langs/en_US/mails.lang | 2 ++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index 1f28a16a9d3..e12f0a68d81 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -58,28 +58,31 @@ print load_fiche_titre($title); //print ''; print '
'; +$titlesearch = $langs->trans("SearchAMailing"); +if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + $titlesearch .= ' | '.$langs->trans("smsing"); +} + +// Search into emailings +print '
'; +print ''; +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; + +print "
'.$titlesearch.'
'; +print $langs->trans("Ref").':
'; +print $langs->trans("Other").':

\n"; -//if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo -//{ - // Search into emailings - print '
'; - print ''; - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print "
'.$langs->trans("SearchAMailing").'
'; - print $langs->trans("Ref").':
'; - print $langs->trans("Other").':

\n"; -//} // Affiche stats de tous les modules de destinataires mailings print ''; -print ''; +print ''; $dir = DOL_DOCUMENT_ROOT."/core/modules/mailings"; $handle = opendir($dir); @@ -101,14 +104,14 @@ if (is_resource($handle)) { $qualified = 1; foreach ($mailmodule->require_module as $key) { - if (empty($conf->$key->enabled) || (!$user->admin && $mailmodule->require_admin)) { + if (!isModEnabled($key) || (!$user->admin && !empty($mailmodule->require_admin))) { $qualified = 0; - //print "Les pr�requis d'activation du module mailing ne sont pas respect�s. Il ne sera pas actif"; + //print "Prerequisites are not not, selector won't be active"; break; } } - // Si le module mailing est qualifi� + // If emailing is qualified for statistic section if ($qualified) { foreach ($mailmodule->getSqlArrayForStats() as $sql) { print ''; @@ -118,10 +121,10 @@ if (is_resource($handle)) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) { $obj = $db->fetch_object($result); - print ''; + print ''; $i++; } diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index aaddd278084..38901ccf3a3 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -2,6 +2,7 @@ Mailing=EMailing EMailing=EMailing EMailings=EMailings +SMSings=SMSings AllEMailings=All eMailings MailCard=EMailing card MailRecipients=Recipients @@ -24,6 +25,7 @@ BodyNotIn=Not in Body ShowEMailing=Show emailing ListOfEMailings=List of emailings NewMailing=New emailing +NewSMSing=New smsing EditMailing=Edit emailing ResetMailing=Resend emailing DeleteMailing=Delete emailing From cc1eefa0fe45364237071ee7caeabe229b1dff8a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 12:58:57 +0100 Subject: [PATCH 20/90] WIP SMSing --- htdocs/core/menus/standard/eldy.lib.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index f0ac60ee212..4930959df6d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -2427,9 +2427,16 @@ function get_left_menu_tools($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu } if (isModEnabled('mailing')) { - $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $langs->trans("EMailings"), 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 0, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); - $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $langs->trans("NewMailing"), 1, $user->hasRight('mailing', 'creer')); - $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $langs->trans("List"), 1, $user->hasRight('mailing', 'lire')); + $titleindex = $langs->trans("EMailings"); + $titlenew = $langs->trans("NewMailing"); + $titlelist = $langs->trans("List"); + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + $titleindex .= ' | '.$langs->trans("SMSings"); + $titlenew .= ' | '.$langs->trans("NewSMSing"); + } + $newmenu->add("/comm/mailing/index.php?leftmenu=mailing", $titleindex, 0, $user->hasRight('mailing', 'lire'), '', $mainmenu, 'mailing', 0, '', '', '', img_picto('', 'email', 'class="paddingright pictofixedwidth"')); + $newmenu->add("/comm/mailing/card.php?leftmenu=mailing&action=create", $titlenew, 1, $user->hasRight('mailing', 'creer')); + $newmenu->add("/comm/mailing/list.php?leftmenu=mailing", $titlelist, 1, $user->hasRight('mailing', 'lire')); } if (isModEnabled('export')) { From 283425bae587938ebc09c8045b314d560f9d58c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 13:24:33 +0100 Subject: [PATCH 21/90] WIP EMAILINGS_SUPPORT_ALSO_SMS --- htdocs/comm/mailing/class/mailing.class.php | 5 ++++ htdocs/comm/mailing/index.php | 25 ++++++++++++++----- .../install/mysql/migration/19.0.0-20.0.0.sql | 3 +++ .../mysql/tables/llx_mailing-mailing.sql | 14 ++++------- 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index e7058d81216..d5160aefd8b 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -46,6 +46,11 @@ class Mailing extends CommonObject */ public $picto = 'email'; + /** + * @var string Type of message ('email', 'sms') + */ + public $messtype; + /** * @var string title */ diff --git a/htdocs/comm/mailing/index.php b/htdocs/comm/mailing/index.php index e12f0a68d81..8fee4a7935f 100644 --- a/htdocs/comm/mailing/index.php +++ b/htdocs/comm/mailing/index.php @@ -152,7 +152,7 @@ print '
'; * List of last emailings */ $limit = 10; -$sql = "SELECT m.rowid, m.titre, m.nbemail, m.statut, m.date_creat"; +$sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut as status, m.date_creat, m.messtype"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; $sql .= " WHERE m.entity = ".$conf->entity; $sql .= " ORDER BY m.date_creat DESC"; @@ -163,9 +163,18 @@ if ($result) { print '
'.$langs->trans("TargetsStatistics").'
'.$langs->trans("TargetsStatistics").'
'.img_object('', $mailmodule->picto).' '.$obj->label.''.$obj->nb.''; + print ''.img_object('', $mailmodule->picto).' '.dol_escape_htmltag($obj->label).''.$obj->nb.'
'; print ''; print ''; + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print ''; + } print ''; - print ''; - print ''; + print ''; + print ''; + print ''; $num = $db->num_rows($result); if ($num > 0) { @@ -176,13 +185,17 @@ if ($result) { $mailstatic = new Mailing($db); $mailstatic->id = $obj->rowid; $mailstatic->ref = $obj->rowid; + $mailstatic->messtype = $obj->messtype; print ''; print ''; - print ''; + print ''; + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print ''; + } print ''; - print ''; - print ''; + print ''; + print ''; print ''; $i++; } diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index d1f6998aa2e..ff4da61dc87 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -211,3 +211,6 @@ ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtex -- Rename const to add customer categories on not customer/prospect third-party if enabled UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT' WHERE name = 'THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER'; + +ALTER TABLE llx_mailing ADD COLUMN messtype varchar(16) DEFAULT 'email' after rowid; + diff --git a/htdocs/install/mysql/tables/llx_mailing-mailing.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.sql index 809054cc879..eb03b17853b 100644 --- a/htdocs/install/mysql/tables/llx_mailing-mailing.sql +++ b/htdocs/install/mysql/tables/llx_mailing-mailing.sql @@ -18,15 +18,10 @@ -- ======================================================================== --- draft : 0 --- valid : 1 --- approved : 2 --- sent : 3 - create table llx_mailing ( rowid integer AUTO_INCREMENT PRIMARY KEY, - statut smallint DEFAULT 0, -- + messtype varchar(16) DEFAULT 'email', -- 'email' or 'sms' or ... titre varchar(128), -- Ref of mailing entity integer DEFAULT 1 NOT NULL, -- multi company id sujet varchar(128), -- Sujet of mailing @@ -34,9 +29,9 @@ create table llx_mailing bgcolor varchar(8), -- Backgroud color of mailing bgimage varchar(255), -- Backgroud image of mailing evenunsubscribe smallint DEFAULT 0, -- If 1, email will be send event if recipient has opt-out to emailings - cible varchar(60), + cible varchar(60), -- ??? nbemail integer, - email_from varchar(160), -- Email address of sender + email_from varchar(160), -- Email address or Phone of sender name_from varchar(128), -- Name to show of sender email_replyto varchar(160), -- Email address for reply email_errorsto varchar(160), -- Email addresse for errors @@ -50,11 +45,12 @@ create table llx_mailing fk_user_modif integer, -- user of last modification fk_user_valid integer, -- user validator fk_user_appro integer, -- not used - extraparams varchar(255), -- for stock other parameters with json format + extraparams varchar(255), -- to stock other parameters with json format joined_file1 varchar(255), joined_file2 varchar(255), joined_file3 varchar(255), joined_file4 varchar(255), + statut smallint DEFAULT 0, -- status (draft:0, valid: 1, approved: 2, sent: 3) note_private text, note_public text )ENGINE=innodb; From d99a3d9f354f18e6d75c2bb729eb5bc16ac2d95e Mon Sep 17 00:00:00 2001 From: UT from dolibit <45215329+dolibit-ut@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:37:00 +0100 Subject: [PATCH 22/90] Update ChangeLog (#27980) add => added moved "SEC:" into "For developers or integrators" section --- ChangeLog | 125 +++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc13087832a..0cfaa1ca3ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,9 +29,10 @@ For users: ---------- NEW: Compatibility with PHP 8.2 NEW: Module Workstation (used to enhance the module BOM and Manufacturing Order) is now stable +NEW: Add a CLI tool to regenerate all documents NEW: Add a confirmation popup when deleting extrafields NEW: Add type 'icon' type for extrafields -NEW: Close #20930 Use ajax for state loading after country change +NEW: #20930 Use ajax for state loading after country change NEW: #23331 Add support for parent projects (#24856) NEW: #22531 Expense report - Add two fields into export : Qty & Unit price (excl.) (#26309) NEW: #22626 date filter thirdparties contracts projects (#22707) @@ -42,54 +43,51 @@ NEW: Accountancy: Add quick navigation with keyboard shortcut on ledger (#26221) NEW: Accountancy: FEC/FEC2 format export with attachments (#26192) NEW: Accountancy: Option to choose length of lettering code NEW: Accountancy: Chart of accounts ES PCG08-PYME-CAT in catalan language -NEW: Add a button to create a product or a service from an order or an invoice (#26173) -NEW: Add a button to re-encrypt data of a dolcrypt extrafield password -NEW: Add a CLI tool to regenerate all documents -NEW: Add a goto url from smartphone search page -NEW: Add all id prof checker on thirdparty for code compta customer and supplier -NEW: Add a protection on purgeFiles -NEW: Add chart of accounts PCG08-PYME-CAT for ES in catalan language -NEW: add constant to check if qty shipped not greater than qty ordered -NEW: Add context for the movement stock (role toconsume/toproduce) on mrp -NEW: Add contract link on ticket -NEW: Add culum Technical ID in list of details lines of an order (#26164) -NEW: Add custom compute for exports -NEW: Add custom Text on footer total (#26334) -NEW: Add different picto for each type of extrafields (date, string, ...) -NEW: Added of a popup on validation instead of a database fielld to know if the user wants to include subwarehouse -NEW: Added of the field "include_sub_warehouse" in the table "llx_inventory" -NEW: Added VAT free & VAT amounts on payment input -NEW: Add ext payment system ID in the payment page with link to Stripe -NEW: Add field TechnicalID in list of users -NEW: Add filter on status of line of a dictionary -NEW: Add get_substitutionarray_other() on shipping odt (#25080) -NEW: add IdProfCheck on thirdparty for BE (xxxx.xxx.xxx) -NEW: Add index on prelevement_demande -NEW: Add invoice subtype in customer invoice (#26543) and template invoice (SQL part) (#26535) -NEW: Add label to price level when changing price (#26240) -NEW: Add modifications of template invoices into agenda -NEW: Add more company information (ProfId7 to 10) (#25266) -NEW: Add more information to holiday mailings (#25461) -NEW: Add more param on fetch() to prepare perf optimization -NEW: Add more tables activated by module activation only -NEW: Add new field into $fields array + Creation of the function getChildWarehouse() -NEW: Add option for cancel consumed and produced lines (delete lines and rollback stocks) when delete or cancel an manufacturing order (#26254) -NEW: Add option in PDF for purchase order and quotation to hide prices -NEW: Add option TAKEPOS_HIDE_PRODUCT_PRICES to hide prices in TakePOS -NEW: add order supplier submit notif -NEW: add parent product column on list -NEW: Add picto in product/service list in object lines (#25511) -NEW: Add possibility to choose separator #21426 -NEW: Add preselected update keys attribute to import class and select it by default if filled -NEW: Add recurring behaviour -NEW: add recursive deletion option for child m os (#26102) -NEW: Add refactoring user permission (#26162) -NEW: add sorting of product price list by customer (#26483) -NEW: Add tab Events/Agenda on recurring invoices -NEW: Add the formEditObjectLine hook on commande card and invoice card -NEW: Add the picto phone of thirdparty on the kanban view of projects -NEW: Add the status of partnership to select partnership for emailing -NEW: add Ticket tab on contract +NEW: added a button to create a product or a service from an order or an invoice (#26173) +NEW: added a button to re-encrypt data of a dolcrypt extrafield password +NEW: added a goto url from smartphone search page +NEW: added all id prof checker on thirdparty for code compta customer and supplier +NEW: added protection on purgeFiles +NEW: added a constant to check if qty shipped not greater than qty ordered +NEW: added context for the movement stock (role toconsume/toproduce) on mrp +NEW: added contract link on ticket +NEW: added column 'Technical ID' in list of details lines of an order (#26164) +NEW: added custom compute for exports +NEW: added custom text on footer total (#26334) +NEW: added different picto for each type of extrafields (date, string, ...) +NEW: added a popup on validation instead of a database field to know if the user wants to include subwarehouse +NEW: added the field "include_sub_warehouse" in the table "llx_inventory" +NEW: added VAT free & VAT amounts on payment input +NEW: added ext payment system ID in the payment page with link to Stripe +NEW: added field Technical ID in list of users +NEW: added filter on status of line of a dictionary +NEW: added get_substitutionarray_other() on shipping odt (#25080) +NEW: added IdProfCheck on thirdparty for BE (xxxx.xxx.xxx) +NEW: added index on prelevement_demande +NEW: added invoice subtype in customer invoice (#26543) and template invoice (SQL part) (#26535) +NEW: added a label to price level when changing price (#26240) +NEW: added modifications of template invoices into agenda +NEW: added more company information (ProfId7 to 10) (#25266) +NEW: added more information to holiday mailings (#25461) +NEW: added more param on fetch() to prepare perf optimization +NEW: added more tables activated by module activation only +NEW: added new field into $fields array + Creation of the function getChildWarehouse() +NEW: added option for cancel consumed and produced lines (delete lines and rollback stocks) when delete or cancel an manufacturing order (#26254) +NEW: added option in PDF for purchase order and quotation to hide prices +NEW: added order supplier submit notif +NEW: added parent product column on list +NEW: added picto in product/service list in object lines (#25511) +NEW: added possibility to choose separator #21426 +NEW: added preselected update keys attribute to import class and select it by default if filled +NEW: added recurring behaviour +NEW: added recursive deletion option for child MOs (#26102) +NEW: added refactoring user permission (#26162) +NEW: added sorting of product price list by customer (#26483) +NEW: added tab Events/Agenda on recurring invoices +NEW: added the formEditObjectLine hook on commande card and invoice card +NEW: added the picto phone of thirdparty on the kanban view of projects +NEW: added the status of partnership to select partnership for emailing +NEW: added Ticket tab on contract NEW: Agenda: agenda per user use quarter hour split instead of half hour split NEW: Allow generation of delivery note through REST-API (#26226) NEW: Allow sync of currency rates with currency layer by default. @@ -108,6 +106,7 @@ NEW: clone skill object (#26526) NEW: column in table prelevement_lignes for fk_user (#26196) NEW: CONF allow modify ticket classification even if closed NEW: conf to display date entry stock exped and sort in date order (#22625) +NEW: Contract: Merge the "Create ..." buttons on contract into one. NEW: create a product from a free line in a document (#22324) NEW: customize position in complete_head_from_modules (#26406) NEW: Date d'entree en stock sur les exped au moment de la création -> Stock date on exped at time of creation @@ -118,19 +117,20 @@ NEW: Donations: Generic doc template for donations (#26338) NEW: drop down for action button show a simple button if only 1 action NEW: Enhance github_commits_perversion to get more stats on git commits NEW: Enhance IPN to support payment_intent.succeeded for both card/ban -NEW: Exports: add product barcode on stock exports +NEW: Exports: added product barcode on stock exports NEW: extrafields password accepts 'dolcrypt' algorithm (reversible algo) NEW: Factorize a lot of code for numbering modules NEW: filter on from/to period rather than month/year (#26378) -NEW: FontAwesome - Add possibility to select another version -NEW: Can generate SEPA files for salaries (#26541) +NEW: FontAwesome - added possibility to select another version NEW: Get list evaluation with skills details in user fiche (#26510) NEW: hidden conf to disable use of dns_get_record (which can become unresponsive) (#26339) +NEW: HR: PDF Generation for each Human Resource Evaluations NEW: improved resource data structure -NEW: Intervention: close notification for interventions +NEW: Interventions: close notification for interventions NEW: Inventory: include sub warehouse in inventory NEW: Inventory: inventory without virtual products (kits) NEW: Invoices: subtypes for customers and vendors (#26233) +NEW: Invoices: start and end date for due date filter on invoice list NEW: Invoice time from task, make task note better display in invoice line NEW: lazy load to substitute project variables (#26451) NEW: LDAP: Active Directory UserAccountControl (#25507) @@ -140,7 +140,6 @@ NEW: Manage rate indirect. (#26449) NEW: Manufacturing Order: add edit line on MO (#26122) NEW: memorize model name for PDF hooks NEW: Menu editor is responsive -NEW: Merge the "Create ..." buttons on contract into one. NEW: ModuleBuilder: Can modify the picto into ModuleBuilder NEW: ModuleBuilder: Form for add object's property on ModuleBuilder NEW: More accurate tooltip on what admin permissions are @@ -151,7 +150,7 @@ NEW: no need to create invoice supplier object on supplier card for standalone c NEW: Open-Surveys: Add a public page to list all open surveys NEW: Option to show label, ref+label or only ref of product in TakePOS NEW: payment full amount detail tooltip -NEW: Payment: Can edit both the Test and Live stripe customer account on payment +NEW: Payments: Can edit both the Test and Live stripe customer account on payment NEW: possibility to deselect line when create a recurring invoice + missing to use fk_parent_line NEW: Projects: List - use select2 multiselect for status NEW: Projects: massactions to delete projects @@ -162,11 +161,11 @@ NEW: Retrieve VAT details from the Greek Ministry of Finance GSIS SOAP web servi NEW: Right for stats orders (#24607) NEW: rights and check access to create portal accounts NEW: Row in list higher height (#26177) +NEW: Salaries: Can generate SEPA files for salaries (#26541) NEW: Save date of RUM creation when creating a Stripe SEPA mandate -NEW: Shipment: can include service (for information and invoicing) (#26407) +NEW: Shipments: can include service (for information and invoicing) (#26407) NEW: Show id of module on the tooltip module help page NEW: show VAT free amount on payment input close #26208 (#26209) -NEW: start and end date for due date filter on invoice list NEW: Sub total in list (#26165) NEW: Support html content for combo list of email recipient NEW: TakePOS: add constant to check qty asked is available (#24820) @@ -174,6 +173,7 @@ NEW: TakePOS: add constant to choose contact instead of customer (#24807) NEW: TakePOS: amount label with or without tax in free product (#24829) NEW: TakePOS: compatibility with lots and serials (#26426) NEW: TakePOS: use default customer, category and product when enable TakePOS (#25031) +NEW: TakePOS: added option TAKEPOS_HIDE_PRODUCT_PRICES to hide prices in TakePOS NEW: Tickets: add and list external contributors on ticket public interface NEW: Third-Parties: add total line to third-parties list (#26148) NEW: Tooltips are using ajax by default @@ -187,12 +187,7 @@ NEW: use account address in sepa mandate (#23642) NEW: VAT rate - Add entity NEW: Website: Support of js into the Dolibarr server preview NEW: When an user unset the batch management of products, transformation of each batch stock movement in global stock movement -NEW: PDF Generation for each Human Resource Evaluations. -SEC: #25512 applicative anti bruteforce - security on too many login attempts (#25520) -SEC: Add action confirm_... as sensitive to need a CSRF token -SEC: Disable not used PHP streams -SEC: Add option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY For developers or integrators: @@ -201,6 +196,12 @@ For developers or integrators: QUAL Reduce very seriously the technical debt (using PHPStan, Psalm and Rector) NEW Tool in dev/tools/rector to autofix code using style coding practice rules +SECURITY +SEC: #25512 applicative anti bruteforce - security on too many login attempts (#25520) +SEC: added action confirm_... as sensitive to need a CSRF token +SEC: Disable not used PHP streams +SEC: added option MAIN_RESTRICTHTML_ONLY_VALID_HTML_TIDY + PERFORMANCE PERF: Removed a useless fetch_thirdparty PERF: Perf avoid 2 useless fetch into the triggers of agenda. From 9aec1a41feec520208c900482eb5496ffbfb9774 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 14:37:17 +0100 Subject: [PATCH 23/90] qual: phpstan for htdocs/compta/paiement/class/cpaiement.class.php (#27981) htdocs/compta/paiement/class/cpaiement.class.php 98 Property Cpaiement::$active (int) does not accept string. htdocs/compta/paiement/class/cpaiement.class.php 253 Property Cpaiement::$active (int) does not accept string. htdocs/compta/paiement/class/cpaiement.class.php 373 Property Cpaiement::$active (int) does not accept string. --- htdocs/compta/paiement/class/cpaiement.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/paiement/class/cpaiement.class.php b/htdocs/compta/paiement/class/cpaiement.class.php index b8a4bb77c64..7dc738d2a00 100644 --- a/htdocs/compta/paiement/class/cpaiement.class.php +++ b/htdocs/compta/paiement/class/cpaiement.class.php @@ -95,7 +95,7 @@ class Cpaiement extends CommonDict $this->type = trim($this->type); } if (isset($this->active)) { - $this->active = trim($this->active); + $this->active = (int) $this->active; } if (isset($this->accountancy_code)) { $this->accountancy_code = trim($this->accountancy_code); @@ -250,7 +250,7 @@ class Cpaiement extends CommonDict $this->type = trim($this->type); } if (isset($this->active)) { - $this->active = trim($this->active); + $this->active = (int) $this->active; } if (isset($this->accountancy_code)) { $this->accountancy_code = trim($this->accountancy_code); @@ -365,12 +365,11 @@ class Cpaiement extends CommonDict public function initAsSpecimen() { $this->id = 0; - $this->code = ''; $this->libelle = ''; $this->label = ''; $this->type = ''; - $this->active = ''; + $this->active = 0; $this->accountancy_code = ''; $this->module = ''; } From 1804ba1433935faefe14a9cf1db906ae89e63176 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 14:38:36 +0100 Subject: [PATCH 24/90] qual: phpstan for htdocs/core/class/cunits.class.php (#27982) * qual: phpstan for htdocs/core/class/cunits.class.php htdocs/core/class/cunits.class.php 88 Property CommonDict::$active (int) does not accept string. htdocs/core/class/cunits.class.php 415 Method CUnits::getUnitFromCode() should return int but returns string. * qual: phpstan - Update functions.lib.php - dol_getIdFromCode() * Update functions.lib.php --- htdocs/core/class/cunits.class.php | 9 +++------ htdocs/core/lib/functions.lib.php | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 4a5326d719e..85d0ce1f4a6 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -85,7 +85,7 @@ class CUnits extends CommonDict $this->libelle = trim($this->short_label); } if (isset($this->unit_type)) { - $this->active = trim($this->unit_type); + $this->active = (int) $this->unit_type; } if (isset($this->active)) { $this->active = (int) $this->active; @@ -406,12 +406,9 @@ class CUnits extends CommonDict */ public function getUnitFromCode($code, $mode = 'code', $unit_type = '') { - if ($mode == 'short_label') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'short_label', 'rowid', 0, " AND unit_type = '".$this->db->escape($unit_type)."'"); - } elseif ($mode == 'code') { - return dol_getIdFromCode($this->db, $code, 'c_units', 'code', 'rowid', 0, " AND unit_type = '". $this->db->escape($unit_type) ."'"); + if ($mode == 'short_label' || $mode == 'code') { + return dol_getIdFromCode($this->db, $code, 'c_units', $mode, 'rowid', 0, " AND unit_type = '".$this->db->escape($unit_type)."'"); } - return $code; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 1418ca9680a..2af8a5cc4e8 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9558,7 +9558,7 @@ function dol_osencode($str) * @param string $fieldid Field to get * @param int $entityfilter Filter by entity * @param string $filters Filters to add. WARNING: string must be escaped for SQL and not coming from user input. - * @return int Return integer <0 if KO, Id of code if OK + * @return int<-1,max> ID of code if OK, 0 if key empty, -1 if KO * @see $langs->getLabelFromKey */ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id', $entityfilter = 0, $filters = '') @@ -9567,7 +9567,7 @@ function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = // If key empty if ($key == '') { - return ''; + return 0; } // Check in cache From 52182852faed18b641440b5ae43cce99077baeea Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 14:38:56 +0100 Subject: [PATCH 25/90] qual: phpstan for htdocs/comm/action/class/actioncommreminder.class.php (#27958) htdocs/comm/action/class/actioncommreminder.class.php 46 PHPDoc type array of property ActionCommReminder::$ismultientitymanaged is not covariant with PHPDoc type int of overridden property CommonObject::$ismultientitymanaged. htdocs/comm/action/class/actioncommreminder.class.php 46 Property ActionCommReminder::$ismultientitymanaged (array) does not accept default value of type int. --- htdocs/comm/action/class/actioncommreminder.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index fff59f3fd11..81d6249eaad 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -41,7 +41,7 @@ class ActionCommReminder extends CommonObject public $table_element = 'actioncomm_reminder'; /** - * @var array Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int Does actioncommreminder support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe */ public $ismultientitymanaged = 0; From f40b891cfed124bcbc9a87166674bf060bfa3c3e Mon Sep 17 00:00:00 2001 From: thomas-Ngr Date: Sat, 3 Feb 2024 14:39:59 +0100 Subject: [PATCH 26/90] NEW Develop new quick edit opportunity status (#27892) * Add ability to quickly edit project status & percentage * TEMP * PHPstan checks --- htdocs/core/class/html.formprojet.class.php | 49 ++++++++++++++++++ htdocs/projet/card.php | 56 +++++++++++++++++---- 2 files changed, 94 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 6e3f37d824c..bb6584ad4ba 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -921,4 +921,53 @@ class FormProjets extends Form return $out; } + + /** + * Output html select to select opportunity status + * + * @param string $page Page + * @param string $selected Id preselected + * @param int $percent_value percentage of the opportunity + * @param string $htmlname_status name of HTML element for status select + * @param string $htmlname_percent name of HTML element for percent input + * @param string $filter optional filters criteras + * @param int $nooutput No print output. Return it only. + * @return void|string + */ + public function formOpportunityStatus($page, $selected = '', $percent_value = 0, $htmlname_status = 'none', $htmlname_percent = 'none', $filter = '', $nooutput = 0) + { + // phpcs:enable + global $conf, $langs; + + $out = ''; + if ($htmlname_status != "none" && $htmlname_percent != 'none') { + $out .= '
'; + $out .= ''; + $out .= ''; + $out .= $this-> selectOpportunityStatus($htmlname_status, $selected, 1, 0, 0, 0, 'minwidth150 inline-block valignmiddle', 1, 1); + $out .= ' / '; + $out .= ' %'; + $out .= ''; + $out .= ''; + $out .= ''; + } else { + if ($selected > 0) { + $code = dol_getIdFromCode($this->db, $selected, 'c_lead_status', 'rowid', 'code'); + $out .= $langs->trans("OppStatus".$code); + + // Opportunity percent + $out.= ' / '; + $out.= price($percent_value, 0, $langs, 1, 0).' %'; + $out.= ''; + } else { + $out .= " "; + } + } + + if ($nooutput) { + return $out; + } else { + print $out; + } + } } diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 74ab3a085de..fac60bca8f5 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -404,6 +404,42 @@ if (empty($reshook)) { } } + if ($action == 'set_opp_status' && $user->rights->projet->creer) { + $error = 0; + if (GETPOSTISSET('opp_status')) { + $object->opp_status = $opp_status; + } + if (GETPOSTISSET('opp_percent')) { + $object->opp_percent = $opp_percent; + } + + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if ($object->opp_amount && ($object->opp_status <= 0)) { + $error++; + setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); + } + } + + if (!$error) { + $result = $object->update($user); + if ($result < 0) { + $error++; + if ($result == -4) { + setEventMessages($langs->trans("ErrorRefAlreadyExists"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } + + if ($error) { + $db->rollback(); + $action = 'edit'; + } else { + $db->commit(); + } + } + // Build doc if ($action == 'builddoc' && $permissiontoadd) { // Save last template used to generate document @@ -1347,18 +1383,16 @@ if ($action == 'create' && $user->hasRight('projet', 'creer')) { if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && !empty($object->usage_opportunity)) { // Opportunity status - print '
'; + print ''; // Opportunity Amount print ''; diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index c488758008e..1626777c106 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -45,12 +45,12 @@ class Bookmark extends CommonObject public $ismultientitymanaged = 1; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'bookmark'; /** - * @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... + * @var string Last error number. For example: 'DB_ERROR_RECORD_ALREADY_EXISTS', '12345', ... */ public $errno; @@ -60,7 +60,7 @@ class Bookmark extends CommonObject public $id; /** - * @var int User ID. If > 0, bookmark of one user. If == 0, bookmark public (for everybody) + * @var int User ID. If > 0, bookmark of one user. If == 0, bookmark public (for everybody) */ public $fk_user; From 021fb83ec60dce561dea94179fcacd23121bbb25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 17:57:12 +0100 Subject: [PATCH 31/90] WIP SMSing --- htdocs/comm/mailing/advtargetemailing.php | 2 +- htdocs/comm/mailing/card.php | 252 ++++++++++++-------- htdocs/comm/mailing/cibles.php | 68 +++--- htdocs/comm/mailing/class/mailing.class.php | 85 +++---- htdocs/comm/mailing/info.php | 2 +- htdocs/comm/mailing/list.php | 65 ++++- htdocs/comm/mailing/note.php | 2 +- htdocs/core/class/CSMSFile.class.php | 18 +- htdocs/langs/en_US/admin.lang | 2 +- htdocs/langs/en_US/mails.lang | 4 +- 10 files changed, 296 insertions(+), 204 deletions(-) diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index fa08d145abf..73fc1826706 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -459,7 +459,7 @@ if ($object->fetch($id) >= 0) { print ""; // Show email selectors - if ($object->statut == 0 && $user->hasRight('mailing', 'creer')) { + if ($object->status == 0 && $user->hasRight('mailing', 'creer')) { include DOL_DOCUMENT_ROOT.'/core/tpl/advtarget.tpl.php'; } } diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 3595296fec3..323cb20e90d 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -162,7 +162,7 @@ if (empty($reshook)) { setEventMessages($langs->trans("NotEnoughPermissions"), null, 'warnings'); $action = ''; } else { - if ($object->statut == 0) { + if ($object->status == 0) { dol_print_error(null, 'ErrorMailIsNotValidated'); exit; } @@ -547,6 +547,7 @@ if (empty($reshook)) { if ($action == 'add') { $mesgs = array(); + $object->messtype = (string) GETPOST("messtype"); $object->email_from = (string) GETPOST("from", 'alphawithlgt'); // Must allow 'name ' $object->email_replyto = (string) GETPOST("replyto", 'alphawithlgt'); // Must allow 'name ' $object->email_errorsto = (string) GETPOST("errorsto", 'alphawithlgt'); // Must allow 'name ' @@ -559,7 +560,7 @@ if (empty($reshook)) { if (!$object->title) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } - if (!$object->sujet) { + if ($object->messtype != 'sms' && !$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } if (!$object->body) { @@ -645,12 +646,14 @@ if (empty($reshook)) { if (!$isupload) { $mesgs = array(); + + //$object->messtype = (string) GETPOST("messtype"); // We must not be able to change the messtype $object->sujet = (string) GETPOST("sujet"); $object->body = (string) GETPOST("bodyemail", 'restricthtml'); $object->bgcolor = preg_replace('/^#/', '', (string) GETPOST("bgcolor")); $object->bgimage = (string) GETPOST("bgimage"); - if (!$object->sujet) { + if ($object->messtype != 'sms' && !$object->sujet) { $mesgs[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTopic")); } if (!$object->body) { @@ -777,7 +780,7 @@ if ($action == 'create') { $htmltext .= ''; - $availablelink = $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'help', '', 0, 2, 'availvar'); + $availablelink = $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'helpclickable', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; @@ -790,9 +793,40 @@ if ($action == 'create') { print ''; - print ''; + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + $arrayoftypes = array("email" => "Email", "sms" => "SMS"); + print ''; + print ''; + + print ''; + } + print '
'.$langs->trans("LastMailings", $limit).''.$langs->trans("Type").''.$langs->trans("DateCreation").''.$langs->trans("NbOfEMails").''.$langs->trans("AllEMailings").'
'; + print $langs->trans("NbOfEMails"); + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print ' | '.$langs->trans("Phone"); + } + print ''.$langs->trans("AllEMailings").'
'.$mailstatic->getNomUrl(1).''.(!empty($obj->title) ? dol_trunc($obj->title, 38) : '').''.dol_escape_htmltag($obj->title).''.dol_escape_htmltag($obj->messtype).''.dol_print_date($db->jdate($obj->date_creat), 'day').''.($obj->nbemail ? $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->statut, 5).''.($obj->nbemail ? (int) $obj->nbemail : "0").''.$mailstatic->LibStatut($obj->status, 5).'
'.$langs->trans("OpportunityStatus").''; - $code = dol_getIdFromCode($db, $object->opp_status, 'c_lead_status', 'rowid', 'code'); - if ($code) { - print $langs->trans("OppStatus".$code); + print '
'.$langs->trans("OpportunityStatus"); + if ($action != 'edit_opp_status' && $user->hasRight('projet', 'creer')) { + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; } - - // Opportunity percent - print ' / '; - if (strcmp($object->opp_percent, '')) { - print price($object->opp_percent, 0, $langs, 1, 0).' %'; - } - print '
'; + $html_name_status = ($action == 'edit_opp_status') ? 'opp_status' : 'none'; + $html_name_percent = ($action == 'edit_opp_status') ? 'opp_percent' : 'none'; + $percent_value = (GETPOSTISSET('opp_percent') ? GETPOST('opp_percent') : (strcmp($object->opp_percent, '') ? vatrate($object->opp_percent) : '')); + $formproject->formOpportunityStatus($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->opp_status, $percent_value, $html_name_status, $html_name_percent); + print '
'.$langs->trans("OpportunityAmount").''; From c3882eb3a0659fbd1d83e7db5499f14e24ebbc2b Mon Sep 17 00:00:00 2001 From: William Mead Date: Sat, 3 Feb 2024 14:41:49 +0100 Subject: [PATCH 27/90] New intervention signed status data structure (#27856) * Added intervention signed action trigger * Added signed status bool * Added intervention signed migration path * Removed sign action trigger * Changed signed to integer --------- Co-authored-by: Laurent Destailleur --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 3 ++- htdocs/install/mysql/tables/llx_fichinter.sql | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index ff4da61dc87..359d160e17b 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -212,5 +212,6 @@ ALTER TABLE llx_knowledgemanagement_knowledgerecord MODIFY COLUMN answer longtex -- Rename const to add customer categories on not customer/prospect third-party if enabled UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT' WHERE name = 'THIRDPARTY_CAN_HAVE_CATEGORY_EVEN_IF_NOT_CUSTOMER_PROSPECT_SUPPLIER'; -ALTER TABLE llx_mailing ADD COLUMN messtype varchar(16) DEFAULT 'email' after rowid; +ALTER TABLE llx_fichinter ADD COLUMN signed integer DEFAULT NULL AFTER duree; +ALTER TABLE llx_mailing ADD COLUMN messtype varchar(16) DEFAULT 'email' after rowid; diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql index b9f9008f202..9e5d932b21a 100644 --- a/htdocs/install/mysql/tables/llx_fichinter.sql +++ b/htdocs/install/mysql/tables/llx_fichinter.sql @@ -39,6 +39,7 @@ create table llx_fichinter datee date, -- date de fin d'intervention datet date, -- date de terminaison de l'intervention duree real, -- duree totale de l'intervention + signed integer DEFAULT NULL, -- signed status description text, note_private text, note_public text, From 55281d3bb9352f43f654260d80622ce53a275cfc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 14:45:14 +0100 Subject: [PATCH 28/90] Fix phpstan --- htdocs/societe/class/societe.class.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index cfe55c80e12..9a668024981 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2664,7 +2664,7 @@ class Societe extends CommonObject * * @param User $user Object user * @param int $commid Id of user - * @return void + * @return int Return <0 if KO, >0 if OK */ public function del_commercial(User $user, $commid) { @@ -2682,9 +2682,16 @@ class Societe extends CommonObject $sql .= " WHERE fk_soc = ".((int) $this->id)." AND fk_user = ".((int) $commid); if (!$this->db->query($sql)) { + $error++; dol_syslog(get_class($this)."::del_commercial Erreur"); } } + + if ($error) { + return -1; + } else { + return 1; + } } /** From bcabb27c92e0b0befdf6c96cb7e2cea2f6a5096b Mon Sep 17 00:00:00 2001 From: William Mead Date: Sat, 3 Feb 2024 14:50:56 +0100 Subject: [PATCH 29/90] NEW supplier order submit method message (#27855) * Added supplier order submit method to message. Added contributor details. * Updated localization with supplier order submit method * Adjusted order method presentation * Update interface_50_modAgenda_ActionsAuto.class.php --------- Co-authored-by: Laurent Destailleur --- .../core/triggers/interface_50_modAgenda_ActionsAuto.class.php | 3 ++- htdocs/langs/en_US/orders.lang | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index c129095017f..40c192a92d6 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2022 Ferran Marcet * Copyright (C) 2023 William Mead * Copyright (C) 2023 Christian Foellmann + * Copyright (C) 2024 William Mead * * 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 @@ -853,7 +854,7 @@ class InterfaceActionsAuto extends DolibarrTriggers if (empty($object->actionmsg2)) { if (empty($object->context['actionmsg2'])) { - $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ? $object->newref : $object->ref)); + $object->actionmsg2 = $langs->transnoentities("SupplierOrderSubmitedInDolibarr", ($object->newref ?: $object->ref), $object->getInputMethod()); } else { $object->actionmsg2 = $object->context['actionmsg2']; } diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index 662348b6977..acee379edad 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -130,7 +130,7 @@ DispatchSupplierOrder=Receiving purchase order %s FirstApprovalAlreadyDone=First approval already done SecondApprovalAlreadyDone=Second approval already done SupplierOrderReceivedInDolibarr=Purchase Order %s received %s -SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted +SupplierOrderSubmitedInDolibarr=Purchase Order %s submitted (%s) SupplierOrderClassifiedBilled=Purchase Order %s set billed OtherOrders=Other orders SupplierOrderValidatedAndApproved=Supplier order is validated and approved : %s From 45718a2a4db9d229b74222b099dfccc94d5d5139 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Sat, 3 Feb 2024 14:53:09 +0100 Subject: [PATCH 30/90] Fix some phpstan warnings (#27884) * Fix some phpstan warnongs * fix CI * fix --------- Co-authored-by: Hystepik Co-authored-by: Laurent Destailleur --- htdocs/adherents/class/subscription.class.php | 2 +- htdocs/api/class/api_access.class.php | 2 +- htdocs/bom/class/bom.class.php | 8 ++++---- htdocs/bom/tpl/objectline_view.tpl.php | 2 +- htdocs/bookmarks/class/bookmark.class.php | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 32daa92d626..535bbab326f 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -43,7 +43,7 @@ class Subscription extends CommonObject public $table_element = 'subscription'; /** - * @var int Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table + * @var string Does myobject support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by fk_soc, 'field@table'=Test with link by field@table */ public $ismultientitymanaged = 'fk_adherent@adherent'; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index e46dfd14d86..82a60bc5116 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -62,7 +62,7 @@ class DolibarrApiAccess implements iAuthenticate /** * @var User $user Loggued user */ - public static $user = ''; + public static $user = null; /** diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 808acba17f6..94e93d1d631 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1475,7 +1475,7 @@ class BOM extends CommonObject $this->error = $tmpproduct->error; return -1; } - $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : (float) $tmpproduct->pmp); + $line->unit_cost = (float) price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : (float) $tmpproduct->pmp); if (empty($line->unit_cost)) { if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) { if ($productFournisseur->fourn_remise_percent != "0") { @@ -1826,17 +1826,17 @@ class BOMLine extends CommonObjectLine // END MODULEBUILDER PROPERTIES /** - * @var int Calculated cost for the BOM line + * @var float Calculated cost for the BOM line */ public $total_cost = 0; /** - * @var int Line unit cost based on product cost price or pmp + * @var float Line unit cost based on product cost price or pmp */ public $unit_cost = 0; /** - * @var Bom array of Bom in line + * @var array array of Bom in line */ public $childBom = array(); diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 1c7b193d2d5..32e976b9848 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -328,7 +328,7 @@ if ($resql) { $workstation = new Workstation($this->db); $res = $workstation->fetch($sub_bom_product->fk_default_workstation); if ($res > 0) { - $sub_bom_line->total_cost = price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); + $sub_bom_line->total_cost = (float) price2num($qty * ($workstation->thm_operator_estimated + $workstation->thm_machine_estimated), 'MT'); } print ''.price(price2num($sub_bom_line->total_cost, 'MT')).'
'.$langs->trans("MailTitle").'
'.$langs->trans("MailFrom").'
'.$langs->trans("Type").''; + print $form->selectarray('messtype', $arrayoftypes, (GETPOSTISSET('messtype') ? GETPOST('messtype') : 'email'), 0, 0); - print '
'.$langs->trans("MailErrorsTo").'
'; + + print '

'; + + print ''; + + print ''; + print ''; + + print ''; // Other attributes $parameters = array(); @@ -806,8 +840,8 @@ if ($action == 'create') { print '

'; print '
'.$langs->trans("MailFrom").'
'.$langs->trans("MailErrorsTo").'
'; - print ''; - print ''; + print ''; @@ -822,7 +856,7 @@ if ($action == 'create') { print dol_get_fiche_end(); - print $form->buttonsSaveCancel("CreateMailing", 'Cancel'); + print $form->buttonsSaveCancel("Create", 'Cancel'); print ''; } else { @@ -845,7 +879,7 @@ if ($action == 'create') { print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id.(!empty($urlfrom) ? '&urlfrom='.urlencode($urlfrom) : ''), $langs->trans("DeleteAMailing"), $langs->trans("ConfirmDeleteMailing"), "confirm_delete", '', '', 1); } - if ($action != 'edit' && $action != 'edithtml') { + if ($action != 'edit' && $action != 'edittxt' &&$action != 'edithtml') { print dol_get_fiche_head($head, 'card', $langs->trans("Mailing"), -1, 'email'); /* @@ -934,7 +968,7 @@ if ($action == 'create') { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) { + if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); @@ -954,9 +988,9 @@ if ($action == 'create') { // From print ''; // Errors to - print ''; } - print ''; print '
'.$langs->trans("MailTopic").'
'.$langs->trans("BackgroundColorByDefault").''; + print '
'.$langs->trans("MailTopic").'
'.$langs->trans("BackgroundColorByDefault").''; print $htmlother->selectColor(GETPOST('bgcolor'), 'bgcolor', '', 0); print '
'; - print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string'); + print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); print ''; - print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string'); + print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); $email = CMailFile::getValidAddress($object->email_from, 2); if ($email && !isValidEmail($email)) { $langs->load("errors"); @@ -969,19 +1003,21 @@ if ($action == 'create') { print '
'; - print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string'); - print ''; - print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->statut < 3, 'string'); - $email = CMailFile::getValidAddress($object->email_errorsto, 2); - if ($email && !isValidEmail($email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadEMail", $email)); - } elseif ($email && !isValidMailDomain($email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadMXDomain", $email)); + if ($object->messtype != 'sms') { + print '
'; + print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + print ''; + print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + $email = CMailFile::getValidAddress($object->email_errorsto, 2); + if ($email && !isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } elseif ($email && !isValidMailDomain($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadMXDomain", $email)); + } + print '
'; print '
'; @@ -992,13 +1028,13 @@ if ($action == 'create') { print ''; // Number of distinct emails - print ''; // Errors to - print ''; } - print ''; print '
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; - if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { + if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) { if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) { $text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB')); } else { @@ -1064,19 +1100,21 @@ if ($action == 'create') { if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test', 'editevenunsubscribe'))) { print "\n\n
\n"; - if (($object->statut == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation_id == $user->id)) { + if (($object->status == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation_id == $user->id)) { print ''.$langs->trans("SetToDraft").''; } - if (($object->statut == 0 || $object->statut == 1 || $object->statut == 2) && $user->hasRight('mailing', 'creer')) { - if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_MAILING')) { + if (($object->status == 0 || $object->status == 1 || $object->status == 2) && $user->hasRight('mailing', 'creer')) { + if (isModEnabled('fckeditor') && getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && $object->messtype != 'sms') { print ''.$langs->trans("EditWithEditor").''; } else { - print ''.$langs->trans("EditWithTextEditor").''; + print ''.$langs->trans("EditWithTextEditor").''; } - if (!empty($conf->use_javascript_ajax)) { - print ''.$langs->trans("EditHTMLSource").''; + if (!getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + if (!empty($conf->use_javascript_ajax)) { + print ''.$langs->trans("EditHTMLSource").''; + } } } @@ -1088,17 +1126,17 @@ if ($action == 'create') { print ''.$langs->trans("TestMailing").''; } - if ($object->statut == 0) { + if ($object->status == 0) { if ($object->nbemail <= 0) { - print ''.$langs->trans("ValidMailing").''; + print ''.$langs->trans("Validate").''; } elseif (!$user->hasRight('mailing', 'valider')) { - print ''.$langs->trans("ValidMailing").''; + print ''.$langs->trans("Validate").''; } else { - print ''.$langs->trans("ValidMailing").''; + print ''.$langs->trans("Validate").''; } } - if (($object->statut == 1 || $object->statut == 2) && $object->nbemail > 0 && $user->hasRight('mailing', 'valider')) { + if (($object->status == 1 || $object->status == 2) && $object->nbemail > 0 && $user->hasRight('mailing', 'valider')) { if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') < 0) { print ''.$langs->trans("SendMailing").''; } elseif (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'send')) { @@ -1112,7 +1150,7 @@ if ($action == 'create') { print ''.$langs->trans("ToClone").''; } - if (($object->statut == 2 || $object->statut == 3) && $user->hasRight('mailing', 'valider')) { + if (($object->status == 2 || $object->status == 3) && $user->hasRight('mailing', 'valider')) { if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'send')) { print ''.$langs->trans("ResetMailing").''; } else { @@ -1120,11 +1158,11 @@ if ($action == 'create') { } } - if (($object->statut <= 1 && $user->hasRight('mailing', 'creer')) || $user->hasRight('mailing', 'supprimer')) { - if ($object->statut > 0 && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'delete'))) { - print ''.$langs->trans("DeleteMailing").''; + if (($object->status <= 1 && $user->hasRight('mailing', 'creer')) || $user->hasRight('mailing', 'supprimer')) { + if ($object->status > 0 && (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('mailing', 'mailing_advance', 'delete'))) { + print ''.$langs->trans("Delete").''; } else { - print ''.$langs->trans("DeleteMailing").''; + print ''.$langs->trans("Delete").''; } } @@ -1187,21 +1225,25 @@ if ($action == 'create') { print ''; // Subject - print ''; + if ($object->messtype != 'sms') { + print ''; + } // Joined files - print ''; } - print ''; // Background color /*print ''; + print ''; // To - print ''; + if ($object->messtype != 'sms') { + print ''; + } print '
'.$langs->trans("MailTopic").''.$object->sujet.'
'.$langs->trans("MailTopic").''.$object->sujet.'
'.$langs->trans("MailFile").''; - // List of files - $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); - if (count($listofpaths)) { - foreach ($listofpaths as $key => $val) { - print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; - print '
'; + if ($object->messtype != 'sms') { + print '
'.$langs->trans("MailFile").''; + // List of files + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { + print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; + print '
'; + } + } else { + print ''.$langs->trans("NoAttachedFiles").'
'; } - } else { - print ''.$langs->trans("NoAttachedFiles").'
'; + print '
'.$langs->trans("BackgroundColorByDefault").''; @@ -1241,7 +1283,7 @@ if ($action == 'create') { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) { + if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); @@ -1268,9 +1310,13 @@ if ($action == 'create') { */ // From - print '
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'; + print $langs->trans("MailFrom"); + print ''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'
'; print '
'; @@ -1288,7 +1334,7 @@ if ($action == 'create') { $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; - if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || $object->statut == 2)) { + if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || $object->status == 2)) { if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) { $text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB')); } else { @@ -1365,54 +1411,60 @@ if ($action == 'create') { print ''; // Subject - print ''; + if ($object->messtype != 'sms') { + print ''; + } $trackid = ''; // TODO To avoid conflicts with 2 mass emailing, we should set a trackid here, even if we use another one into email header. dol_init_file_process($upload_dir, $trackid); // Joined files - $addfileaction = 'addfile'; - print ''; - print ''; + print ''; + // Add link to add file + $maxfilesizearray = getMaxFileSizeArray(); + $maxmin = $maxfilesizearray['maxmin']; + if ($maxmin > 0) { + $out .= ''; // MAX_FILE_SIZE must precede the field type=file + } + $out .= ''; + $out .= ' '; + $out .= ''; + print $out; + print ''; - // Background color - print ''; + // Background color + print ''; + } print '
'.$langs->trans("MailTopic").'
'; + print $langs->trans("MailTopic"); + print '
'.$langs->trans("MailFile").''; - // List of files - $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); + if ($object->messtype != 'sms') { + $addfileaction = 'addfile'; + print '
'.$langs->trans("MailFile").''; + // List of files + $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); - // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript - $out .= ''."\n"; - $out .= ''."\n"; - if (count($listofpaths)) { - foreach ($listofpaths as $key => $val) { - $out .= '
'; - $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; - $out .= ' '; - $out .= '
'; + // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript + $out .= ''."\n"; + $out .= ''."\n"; + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { + $out .= '
'; + $out .= img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; + $out .= ' '; + $out .= '
'; + } + } else { + //$out .= ''.$langs->trans("NoAttachedFiles").'
'; } - } else { - //$out .= ''.$langs->trans("NoAttachedFiles").'
'; - } - // Add link to add file - $maxfilesizearray = getMaxFileSizeArray(); - $maxmin = $maxfilesizearray['maxmin']; - if ($maxmin > 0) { - $out .= ''; // MAX_FILE_SIZE must precede the field type=file - } - $out .= ''; - $out .= ' '; - $out .= ''; - print $out; - print '
'.$langs->trans("BackgroundColorByDefault").''; - print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); - print '
'.$langs->trans("BackgroundColorByDefault").''; + print $htmlother->selectColor($object->bgcolor, 'bgcolor', '', 0); + print '
'; @@ -1426,6 +1478,12 @@ if ($action == 'create') { $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, getDolGlobalInt('FCKEDITOR_ENABLE_MAILING'), 20, '90%'); $doleditor->Create(); } + if ($action == 'edittxt') { + // wysiwyg editor + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('bodyemail', $object->body, '', 600, 'dolibarr_mailings', '', true, true, 0, 20, '90%'); + $doleditor->Create(); + } if ($action == 'edithtml') { // HTML source editor require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index cd7593f8e21..f2c2643c2bc 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -275,7 +275,7 @@ if ($object->fetch($id) >= 0) { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == $object::STATUS_SENTPARTIALY || $object->statut == $object::STATUS_SENTCOMPLETELY) { + if ($object->status == $object::STATUS_SENTPARTIALY || $object->status == $object::STATUS_SENTCOMPLETELY) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $nbok = ($nbtry - $nbko); @@ -314,21 +314,23 @@ if ($object->fetch($id) >= 0) { print '
'.$langs->trans("MailErrorsTo").''; - $emailarray = CMailFile::getArrayAddress($object->email_errorsto); - foreach ($emailarray as $email => $name) { - if ($name != $email) { - print dol_escape_htmltag($name).' <'.$email; - print '>'; - if (!isValidEmail($email)) { - $langs->load("errors"); - print img_warning($langs->trans("ErrorBadEMail", $email)); + if ($object->messtype != 'sms') { + print '
'.$langs->trans("MailErrorsTo").''; + $emailarray = CMailFile::getArrayAddress($object->email_errorsto); + foreach ($emailarray as $email => $name) { + if ($name != $email) { + print dol_escape_htmltag($name).' <'.$email; + print '>'; + if (!isValidEmail($email)) { + $langs->load("errors"); + print img_warning($langs->trans("ErrorBadEMail", $email)); + } + } else { + print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); } - } else { - print dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1); } + print '
'; print '
'; @@ -340,13 +342,13 @@ if ($object->fetch($id) >= 0) { print ''; // Number of distinct emails - print ''; @@ -853,12 +863,12 @@ if ($object->fetch($id) >= 0) { if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index d5160aefd8b..7e18ce5f477 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -88,9 +88,15 @@ class Mailing extends CommonObject /** * @var int status + * @deprecated */ public $statut; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely + /** + * @var int status + */ + public $status; // Status 0=Draft, 1=Validated, 2=Sent partially, 3=Sent completely + /** * @var string email from */ @@ -131,47 +137,11 @@ class Mailing extends CommonObject */ public $joined_file4; - /** - * @var int id of user create - * @deprecated - */ - public $user_creation; - - /** - * @var int id of user create - * @deprecated - */ - public $user_creat; - - /** - * @var int id of user validate - * @deprecated - */ - public $user_validation; - - /** - * @var int id of user validate - * @deprecated - */ - public $user_valid; - - /** - * @var integer|string date_creation - * @deprecated - */ - public $date_creat; - /** * @var integer|string date_creation */ public $date_creation; - /** - * @var int date validate - * @deprecated - */ - public $date_valid; - /** * @var int date validate */ @@ -220,8 +190,6 @@ class Mailing extends CommonObject */ public function __construct($db) { - global $langs; - $this->db = $db; // List of language codes for status @@ -258,12 +226,13 @@ class Mailing extends CommonObject $this->email_from = trim($this->email_from); if (!$this->email_from) { - $this->error = $langs->trans("ErrorMailFromRequired"); + $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("From")); return -1; } $error = 0; $now = dol_now(); + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing"; @@ -275,6 +244,7 @@ class Mailing extends CommonObject } dol_syslog(__METHOD__, LOG_DEBUG); + $resql = $this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mailing"); @@ -328,6 +298,7 @@ class Mailing extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql .= " SET titre = '".$this->db->escape($this->title)."'"; + $sql .= ", messtype = '".$this->db->escape($this->messtype)."'"; $sql .= ", sujet = '".$this->db->escape($this->sujet)."'"; $sql .= ", body = '".$this->db->escape($this->body)."'"; $sql .= ", email_from = '".$this->db->escape($this->email_from)."'"; @@ -375,11 +346,9 @@ class Mailing extends CommonObject */ public function fetch($rowid, $ref = '') { - global $conf; - - $sql = "SELECT m.rowid, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe"; + $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.sujet, m.body, m.bgcolor, m.bgimage, m.evenunsubscribe"; $sql .= ", m.email_from, m.email_replyto, m.email_errorsto"; - $sql .= ", m.statut, m.nbemail"; + $sql .= ", m.statut as status, m.nbemail"; $sql .= ", m.fk_user_creat, m.fk_user_valid"; $sql .= ", m.date_creat"; $sql .= ", m.date_valid"; @@ -401,9 +370,13 @@ class Mailing extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->statut = $obj->statut; - $this->nbemail = $obj->nbemail; $this->title = $obj->title; + $this->messtype = $obj->messtype; + + $this->statut = $obj->status; // deprecated + $this->status = $obj->status; + + $this->nbemail = $obj->nbemail; $this->sujet = $obj->sujet; if (getDolGlobalString('FCKEDITOR_ENABLE_MAILING') && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML5))) { @@ -423,14 +396,16 @@ class Mailing extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_validation_id = $obj->fk_user_valid; - $this->date_creat = $this->db->jdate($obj->date_creat); $this->date_creation = $this->db->jdate($obj->date_creat); - $this->date_valid = $this->db->jdate($obj->date_valid); $this->date_validation = $this->db->jdate($obj->date_valid); $this->date_envoi = $this->db->jdate($obj->date_envoi); $this->extraparams = (array) json_decode($obj->extraparams, true); + if ($this->messtype == 'sms') { + $this->picto = 'phone'; + } + return 1; } else { dol_syslog(get_class($this)."::fetch Erreur -1"); @@ -465,6 +440,7 @@ class Mailing extends CommonObject // Load source object $object->fetch($fromid); $object->id = 0; + $object->status = 0; $object->statut = 0; // Clear fields @@ -487,9 +463,7 @@ class Mailing extends CommonObject $object->user_creation_id = $user->id; $object->user_validation_id = ''; - $object->date_creat = ''; - $object->date_valid = ''; - $object->date_envoi = ''; + $object->date_envoi = null; } // Create clone @@ -728,7 +702,8 @@ class Mailing extends CommonObject */ public function refreshNbOfTargets() { - $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; + $sql = "SELECT COUNT(rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql .= " WHERE fk_mailing = ".((int) $this->id); $resql = $this->db->query($sql); @@ -765,14 +740,14 @@ class Mailing extends CommonObject */ public function getTooltipContentArray($params) { - global $conf, $langs; + global $langs; - $nofetch = !empty($params['nofetch']); + //$nofetch = !empty($params['nofetch']); $langs->load('mails'); $datas = array(); $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("ShowEMailing").''; - if (isset($this->statut)) { + if (isset($this->status)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; @@ -881,7 +856,7 @@ class Mailing extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->status, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/comm/mailing/info.php b/htdocs/comm/mailing/info.php index dccea76c39b..12ca330896b 100644 --- a/htdocs/comm/mailing/info.php +++ b/htdocs/comm/mailing/info.php @@ -66,7 +66,7 @@ if ($object->fetch($id) >= 0) { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) { + if ($object->status == 2 || $object->status == 3) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 973480ca2e6..e60e2295add 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -57,6 +57,7 @@ $pagenext = $page + 1; // Search Fields $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ? GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST("search_ref", "alpha") ? GETPOST("search_ref", "alpha") : GETPOST("sref", "alpha"); +$search_messtype = GETPOST("search_messtype", "alpha"); $filteremail = GETPOST('filteremail', 'alpha'); // Initialize technical objects @@ -122,6 +123,7 @@ if (empty($reshook)) { $search[$key]=''; }*/ $search_ref = ''; + $search_messtype = ''; $search_all = ''; $toselect = array(); $search_array_options = array(); @@ -155,7 +157,7 @@ $morecss = array(); // Build and execute select // -------------------------------------------------------------------- if ($filteremail) { - $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi,"; + $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi,"; $sql .= " mc.statut as sendstatut"; $sqlfields = $sql; // $sql fields to remove for count total @@ -166,8 +168,11 @@ if ($filteremail) { if ($search_ref) { $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; } + if ($search_messtype) { + $sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'"; + } if ($search_all) { - $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + $sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')"; } if (!$sortorder) { $sortorder = "ASC"; @@ -176,17 +181,20 @@ if ($filteremail) { $sortfield = "m.rowid"; } } else { - $sql = "SELECT m.rowid, m.titre as title, m.nbemail, m.statut, m.date_creat as datec, m.date_envoi as date_envoi"; + $sql = "SELECT m.rowid, m.messtype, m.titre as title, m.nbemail, m.statut as status, m.date_creat as datec, m.date_envoi as date_envoi"; $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql .= " WHERE m.entity = ".$conf->entity; + $sql .= " WHERE m.entity = ".((int) $conf->entity); if ($search_ref) { $sql .= " AND m.rowid = '".$db->escape($search_ref)."'"; } + if ($search_messtype) { + $sql .= " AND m.messtype LIKE '".$db->escape($search_messtype)."'"; + } if ($search_all) { - $sql .= " AND (m.titre like '%".$db->escape($search_all)."%' OR m.sujet like '%".$db->escape($search_all)."%' OR m.body like '%".$db->escape($search_all)."%')"; + $sql .= " AND (m.titre LIKE '%".$db->escape($search_all)."%' OR m.sujet LIKE '%".$db->escape($search_all)."%' OR m.body LIKE '%".$db->escape($search_all)."%')"; } if (!$sortorder) { $sortorder = "ASC"; @@ -276,6 +284,16 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($search_ref != '') { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_messtype != '') { + $param .= '&search_type='.urlencode($search_messtype); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} + if ($filteremail) { $param .= '&filteremail='.urlencode($filteremail); } @@ -378,6 +396,12 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print ''; +// Message type +if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print ''; +} // Title print ''; + // Message type + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print ''; + } + // Title print ''; @@ -500,7 +541,7 @@ while ($i < $imaxinloop) { if (!$filteremail) { print ''; + print ''; print ''; // Status @@ -522,7 +563,7 @@ while ($i < $imaxinloop) { if ($filteremail) { print $object::libStatutDest($obj->sendstatut, 2); } else { - print $object->LibStatut($obj->statut, 5); + print $object->LibStatut($obj->status, 5); } print ''; diff --git a/htdocs/comm/mailing/note.php b/htdocs/comm/mailing/note.php index 49cf4b026df..19e623d519b 100644 --- a/htdocs/comm/mailing/note.php +++ b/htdocs/comm/mailing/note.php @@ -29,7 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("mailing", "companies")); +$langs->loadLangs(array("mails", "mailing", "companies")); // Get parameters $id = GETPOST('id', 'int'); diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 9c1f99bbb31..adfb7448c0c 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -124,8 +124,6 @@ class CSMSFile */ public function sendfile() { - global $conf; - $errorlevel = error_reporting(); error_reporting($errorlevel ^ E_WARNING); // Disable warnings @@ -155,8 +153,12 @@ class CSMSFile dol_include_once('/'.$module.'/class/'.strtolower($classfile).'.class.php'); try { $classname = ucfirst($classfile); + + dol_syslog("CSMSFile::sendfile: try to include class ".$classname); + if (class_exists($classname)) { $sms = new $classname($this->db); + $sms->expe = $this->addr_from; $sms->dest = $this->addr_to; $sms->deferred = $this->deferred; @@ -177,6 +179,10 @@ class CSMSFile $this->errors = $sms->errors; if ($res <= 0) { dol_syslog("CSMSFile::sendfile: sms send error=".$this->error, LOG_ERR); + if (getDolGlobalString('MAIN_SMS_DEBUG')) { + $this->dump_sms_result($res); + } + $res = false; } else { dol_syslog("CSMSFile::sendfile: sms send success with id=".$res, LOG_DEBUG); //var_dump($res); // 1973128 @@ -194,8 +200,8 @@ class CSMSFile } else { // Send sms method not correctly defined // -------------------------------------- - - return 'Bad value for MAIN_SMS_SENDMODE constant'; + $sms->error = 'Bad value for MAIN_SMS_SENDMODE constant'; + $res = false; } } else { $this->error = 'No sms sent. Feature is disabled by option MAIN_DISABLE_ALL_SMS'; @@ -249,13 +255,13 @@ class CSMSFile public function dump_sms_result($result) { // phpcs:enable - global $conf, $dolibarr_main_data_root; + global $dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) { // Avoid fatal error on fopen with open_basedir $outputfile = $dolibarr_main_data_root."/dolibarr_sms.log"; $fp = fopen($outputfile, "a+"); - fputs($fp, "\nResult id=".$result); + fputs($fp, "\nResult of SmsSend = ".$result); fclose($fp); dolChmod($outputfile); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 06bcb0712ed..a79dac78826 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -302,7 +302,7 @@ MAIN_DISABLE_ALL_MAILS=Disable all email sending (for test purposes or demos) MAIN_MAIL_FORCE_SENDTO=Send all emails to (instead of real recipients, for test purposes) MAIN_MAIL_ENABLED_USER_DEST_SELECT=Suggest emails of employees (if defined) into the list of predefined recipient when writing a new email MAIN_MAIL_NO_WITH_TO_SELECTED=Do not select a default recipient even if there is only 1 possible choice -MAIN_MAIL_SENDMODE=Email sending method +MAIN_MAIL_SENDMODE=Sending method MAIN_MAIL_SMTPS_ID=SMTP ID (if sending server requires authentication) MAIN_MAIL_SMTPS_PW=SMTP Password (if sending server requires authentication) MAIN_MAIL_EMAIL_TLS=Use TLS (SSL) encryption diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index 38901ccf3a3..ff6f26f1992 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -9,6 +9,7 @@ MailRecipients=Recipients MailRecipient=Recipient MailTitle=Description MailFrom=From +PhoneFrom=From MailErrorsTo=Errors to MailReply=Reply to MailTo=To @@ -32,7 +33,7 @@ DeleteMailing=Delete emailing DeleteAMailing=Delete an emailing PreviewMailing=Preview emailing CreateMailing=Create emailing -TestMailing=Test email +TestMailing=Test ValidMailing=Valid emailing MailingStatusDraft=Draft MailingStatusValidated=Validated @@ -52,6 +53,7 @@ ConfirmValidMailing=Are you sure you want to validate this emailing? ConfirmResetMailing=Warning, by re-initializing emailing %s, you will allow the re-sending this email in a bulk mailing. Are you sure you want to do this? ConfirmDeleteMailing=Are you sure you want to delete this emailing? NbOfUniqueEMails=No. of unique emails +NbOfUniquePhones=No. of unique phones NbOfEMails=No. of EMails TotalNbOfDistinctRecipients=Number of distinct recipients NoTargetYet=No recipients defined yet (Go on tab 'Recipients') From e8d026da727f6825966a09c5066b96339e089062 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 18:15:37 +0100 Subject: [PATCH 32/90] qual: phpdoc Update various mod_xxx.php (#27983) * Update mod_stocktransfer_advanced.php * Update mod_stocktransfer_standard.php * Update mod_facture_fournisseur_cactus.php * Update mod_facture_fournisseur_tulip.php * Update mod_commande_fournisseur_orchidee.php * Update mod_supplier_payment_brodator.php * Update mod_supplier_payment_bronan.php * Update mod_supplier_proposal_marbre.php * Update mod_supplier_proposal_saphir.php * Update mod_takepos_ref_universal.php * Update mod_ticket_universal.php * Update mod_workstation_advanced.php * Update mod_workstation_standard.php * Update mod_knowledgerecord_advanced.php * Update mod_knowledgerecord_standard.php * Update mod_myobject_advanced.php * Update mod_myobject_standard.php * Update mod_partnership_advanced.php * Update mod_recruitmentcandidature_advanced.php * Update mod_recruitmentcandidature_standard.php * Update mod_recruitmentjobposition_advanced.php * Update mod_recruitmentjobposition_standard.php * Update mod_partnership_standard.php * Update mod_stocktransfer_standard.php * Update mod_supplier_payment_brodator.php * Update mod_myobject_standard.php --- .../core/modules/stocktransfer/mod_stocktransfer_advanced.php | 2 +- .../core/modules/stocktransfer/mod_stocktransfer_standard.php | 2 +- .../modules/supplier_invoice/mod_facture_fournisseur_cactus.php | 2 +- .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 2 +- .../supplier_order/mod_commande_fournisseur_orchidee.php | 2 +- .../modules/supplier_payment/mod_supplier_payment_brodator.php | 2 +- .../modules/supplier_payment/mod_supplier_payment_bronan.php | 2 +- .../modules/supplier_proposal/mod_supplier_proposal_marbre.php | 2 +- .../modules/supplier_proposal/mod_supplier_proposal_saphir.php | 2 +- htdocs/core/modules/takepos/mod_takepos_ref_universal.php | 2 +- htdocs/core/modules/ticket/mod_ticket_universal.php | 2 +- htdocs/core/modules/workstation/mod_workstation_advanced.php | 2 +- htdocs/core/modules/workstation/mod_workstation_standard.php | 2 +- .../knowledgemanagement/mod_knowledgerecord_advanced.php | 2 +- .../knowledgemanagement/mod_knowledgerecord_standard.php | 2 +- .../template/core/modules/mymodule/mod_myobject_advanced.php | 2 +- .../template/core/modules/mymodule/mod_myobject_standard.php | 2 +- .../core/modules/partnership/mod_partnership_advanced.php | 2 +- .../core/modules/partnership/mod_partnership_standard.php | 2 +- .../modules/recruitment/mod_recruitmentcandidature_advanced.php | 2 +- .../modules/recruitment/mod_recruitmentcandidature_standard.php | 2 +- .../modules/recruitment/mod_recruitmentjobposition_advanced.php | 2 +- .../modules/recruitment/mod_recruitmentjobposition_standard.php | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php index 8eac5b14f4b..21da56af6bc 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_advanced.php @@ -125,7 +125,7 @@ class mod_stocktransfer_advanced extends ModeleNumRefStockTransfer * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php index 113da55c576..c1e16da016b 100644 --- a/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php +++ b/htdocs/core/modules/stocktransfer/mod_stocktransfer_standard.php @@ -119,7 +119,7 @@ class mod_stocktransfer_standard extends ModeleNumRefStockTransfer * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index ceea6f23f5b..418db94b07e 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -176,7 +176,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices * @param Societe $objsoc Object third party * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, <=0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object, $mode = 'next') { diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index f14a5df4605..b567b7e5522 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -149,7 +149,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * @param Societe $objsoc Object third party * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object, $mode = 'next') { diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 7535fab0482..a0322ab2956 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -123,7 +123,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @param Societe $objsoc Object third party * @param Object $object Object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index 7da2543ab00..b2a26199a32 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -120,7 +120,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index d853273a05e..38d41158f04 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -121,7 +121,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 9d87e91fcfd..97a3507ff3b 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -124,7 +124,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @param Societe $objsoc Object third party * @param SupplierProposal $supplier_proposal Object commercial proposal - * @return string Next value + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($objsoc, $supplier_proposal) { diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index cc28386f054..60b5ec2686c 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -125,7 +125,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * * @param Societe $objsoc Object third party * @param SupplierProposal $supplier_proposal Object commercial proposal - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $supplier_proposal) { diff --git a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php index c88258b790c..35a02f4823c 100644 --- a/htdocs/core/modules/takepos/mod_takepos_ref_universal.php +++ b/htdocs/core/modules/takepos/mod_takepos_ref_universal.php @@ -119,7 +119,7 @@ class mod_takepos_ref_universal extends ModeleNumRefTakepos * @param Societe $objsoc Object thirdparty * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc = null, $invoice = null, $mode = 'next') { diff --git a/htdocs/core/modules/ticket/mod_ticket_universal.php b/htdocs/core/modules/ticket/mod_ticket_universal.php index 15398b43f30..59f37537851 100644 --- a/htdocs/core/modules/ticket/mod_ticket_universal.php +++ b/htdocs/core/modules/ticket/mod_ticket_universal.php @@ -119,7 +119,7 @@ class mod_ticket_universal extends ModeleNumRefTicket * * @param Societe $objsoc Object third party * @param Ticket $ticket Object ticket - * @return string Value if OK, 0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $ticket) { diff --git a/htdocs/core/modules/workstation/mod_workstation_advanced.php b/htdocs/core/modules/workstation/mod_workstation_advanced.php index 6695d26e64c..3081519dad1 100644 --- a/htdocs/core/modules/workstation/mod_workstation_advanced.php +++ b/htdocs/core/modules/workstation/mod_workstation_advanced.php @@ -125,7 +125,7 @@ class mod_workstation_advanced extends ModeleNumRefWorkstation * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/workstation/mod_workstation_standard.php b/htdocs/core/modules/workstation/mod_workstation_standard.php index 2ad954e5f2e..bb8938e6440 100644 --- a/htdocs/core/modules/workstation/mod_workstation_standard.php +++ b/htdocs/core/modules/workstation/mod_workstation_standard.php @@ -116,7 +116,7 @@ class mod_workstation_standard extends ModeleNumRefWorkstation * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php index fc22678a87a..0c1b043f006 100644 --- a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php +++ b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_advanced.php @@ -123,7 +123,7 @@ class mod_knowledgerecord_advanced extends ModeleNumRefKnowledgeRecord * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php index 20ba2817501..3d509d7d25c 100644 --- a/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php +++ b/htdocs/knowledgemanagement/core/modules/knowledgemanagement/mod_knowledgerecord_standard.php @@ -117,7 +117,7 @@ class mod_knowledgerecord_standard extends ModeleNumRefKnowledgeRecord * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php index 967192deaab..22372c541d1 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_advanced.php @@ -122,7 +122,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php index 4260d258ccb..5f7d2f6061f 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php @@ -117,7 +117,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next free value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php index c3b3a888b54..75596eba9ea 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_advanced.php @@ -124,7 +124,7 @@ class mod_partnership_advanced extends ModeleNumRefPartnership * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index f5caef8307b..92c39356a7f 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -117,7 +117,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php index 7f7056a9db4..7cc19971cb3 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_advanced.php @@ -119,7 +119,7 @@ class mod_recruitmentcandidature_advanced extends ModeleNumRefRecruitmentCandida * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php index 24e3120c20f..dca26f27602 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentcandidature_standard.php @@ -117,7 +117,7 @@ class mod_recruitmentcandidature_standard extends ModeleNumRefRecruitmentCandida * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php index 7d0eea8b7cb..4be33bfd352 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_advanced.php @@ -119,7 +119,7 @@ class mod_recruitmentjobposition_advanced extends ModeleNumRefRecruitmentJobPosi * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php index ba63ad8395c..09c69067887 100644 --- a/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php +++ b/htdocs/recruitment/core/modules/recruitment/mod_recruitmentjobposition_standard.php @@ -117,7 +117,7 @@ class mod_recruitmentjobposition_standard extends ModeleNumRefRecruitmentJobPosi * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { From dd56ea3cb76ee8f4de1359cf699af977adbc7415 Mon Sep 17 00:00:00 2001 From: thibdrev Date: Sat, 3 Feb 2024 18:15:55 +0100 Subject: [PATCH 33/90] qual: phpstan for htdocs/core/class/openid.class.php (#27984) htdocs/core/class/openid.class.php 379 Method SimpleOpenID::GetOpenIDServer() should return string but returns false. htdocs/core/class/openid.class.php 525 Method SimpleOpenID::sendDiscoveryRequestToGetXRDS() should return string but returns false. --- htdocs/core/class/openid.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 237acf17f27..9e2c81b87be 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -359,7 +359,7 @@ class SimpleOpenID * Get openid server * * @param string $url Url to found endpoint - * @return string Endpoint + * @return string|false Endpoint, of false if error */ public function GetOpenIDServer($url = '') { @@ -485,7 +485,7 @@ class SimpleOpenID * Get XRDS response and set possible servers. * * @param string $url Url of endpoint to request - * @return string First endpoint OpenID server found. False if it failed to found. + * @return string|false First endpoint OpenID server found. False if it failed to found. */ public function sendDiscoveryRequestToGetXRDS($url = '') { From c82869b6865c4bad6657c0127f32c9cdc2a23b5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Feb 2024 21:11:35 +0100 Subject: [PATCH 34/90] Debug the "validate" feature --- htdocs/core/actions_addupdatedelete.inc.php | 2 +- htdocs/langs/en_US/errors.lang | 1 + .../template/class/myobject.class.php | 21 ++++++++++++++-- .../product/stock/class/productlot.class.php | 24 ++++++++++++++++++- 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 91e1b34dc5d..b50b05be147 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -146,6 +146,7 @@ if ($action == 'add' && !empty($permissiontoadd)) { if (!$error && !empty($val['validate']) && is_callable(array($object, 'validateField'))) { if (!$object->validateField($object->fields, $key, $value)) { $error++; + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -187,7 +188,6 @@ if ($action == 'add' && !empty($permissiontoadd)) { } } else { $db->rollback(); - $error++; // Creation KO if (!empty($object->errors)) { diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 4f0c8c1cbfe..624d106ff5e 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -325,6 +325,7 @@ ErrorSVGFilesNotAllowedAsLinksWithout=SVG files are not allowed as external link ErrorTypeMenu=Impossible to add another menu for the same module on the navbar, not handle yet ErrorObjectNotFound = The object %s is not found, please check your url ErrorCountryCodeMustBe2Char=Country code must be a 2 character string +ErrorABatchShouldNotContainsSpaces=A lot or serial number should not contains spaces ErrorTableExist=Table %s already exist ErrorDictionaryNotFound=Dictionary %s not found diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index a319904e63d..47388ead754 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -102,7 +102,7 @@ class MyObject extends CommonObject * 'arrayofkeyval' to set a list of values if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel"). Note that type can be 'integer' or 'varchar' * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1. * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'validate' is 1 if need to validate with $this->validateField() + * 'validate' is 1 if you need to validate the field with $this->validateField(). Need MAIN_ACTIVATE_VALIDATION_RESULT. * 'copytoclipboard' is 1 or 2 to allow to add a picto to copy value into clipboard (1=picto after label, 2=picto after value) * * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor. @@ -1211,7 +1211,7 @@ class MyObject extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { - global $conf, $langs; + global $langs; $result = 0; $includedocgeneration = 0; @@ -1237,6 +1237,23 @@ class MyObject extends CommonObject return $result; } + /** + * Return validation test result for a field. + * Need MAIN_ACTIVATE_VALIDATION_RESULT to be called. + * + * @param array $fields Array of properties of field to show + * @param string $fieldKey Key of attribute + * @param string $fieldValue value of attribute + * @return bool Return false if fail, true on success, set $this->error for error message + */ + public function validateField($fields, $fieldKey, $fieldValue) + { + // Add your own validation rules here. + // ... + + return parent::validateField($fields, $fieldKey, $fieldValue); + } + /** * Action executed by scheduler * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 7b6089e2028..5a1ea64192c 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -103,7 +103,7 @@ class Productlot extends CommonObject public $fields = array( 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id', 'css'=>'left'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'picto' => 'product', 'css'=>'maxwidth500 widthcentpercentminusxx', 'csslist'=>'maxwidth150'), - 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot'), + 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1, 'picto'=>'lot', 'validate'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>1, 'notnull'=>0, 'position'=>60), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>1, 'notnull'=>0, 'position'=>62), @@ -1261,4 +1261,26 @@ class Productlot extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + + /** + * Return validation test result for a field + * + * @param array $fields Array of properties of field to show + * @param string $fieldKey Key of attribute + * @param string $fieldValue value of attribute + * @return bool Return false if fail, true on success, set $this->error for error message + */ + public function validateField($fields, $fieldKey, $fieldValue) + { + // Add your own validation rules here. + // ... + if ($fieldKey == 'batch') { + if (preg_match('/\s/', $fieldValue)) { + $this->error = 'ErrorABatchShouldNotContainsSpaces'; + return false; + } + } + + return parent::validateField($fields, $fieldKey, $fieldValue); + } } From 4b884f03eeed5b14d28b3b0f05d551bb703a9d15 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 12:14:15 +0100 Subject: [PATCH 35/90] Clean code --- .../product/stock/class/productlot.class.php | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 5a1ea64192c..0aeecdd3cbb 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -775,7 +775,7 @@ class Productlot extends CommonObject public function loadStatsExpedition($socid = 0) { // phpcs:enable - global $db, $conf, $user, $hookmanager, $action; + global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT exp.fk_soc) as nb_customers, COUNT(DISTINCT exp.rowid) as nb,"; $sql .= " COUNT(ed.rowid) as nb_rows, SUM(edb.qty) as qty"; @@ -850,7 +850,7 @@ class Productlot extends CommonObject public function loadStatsSupplierOrder($socid = 0) { // phpcs:enable - global $db, $conf, $user, $hookmanager, $action; + global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT cf.fk_soc) as nb_customers, COUNT(DISTINCT cf.rowid) as nb,"; $sql .= " COUNT(cfd.rowid) as nb_rows, SUM(cfdi.qty) as qty"; @@ -925,7 +925,7 @@ class Productlot extends CommonObject public function loadStatsReception($socid = 0) { // phpcs:enable - global $db, $conf, $user, $hookmanager, $action; + global $user, $hookmanager, $action; $sql = "SELECT COUNT(DISTINCT recep.fk_soc) as nb_customers, COUNT(DISTINCT recep.rowid) as nb,"; $sql .= " COUNT(cfdi.rowid) as nb_rows, SUM(cfdi.qty) as qty"; @@ -1072,7 +1072,7 @@ class Productlot extends CommonObject public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; + //global $langs; //$langs->load('stocks'); @@ -1089,11 +1089,11 @@ class Productlot extends CommonObject */ public function getTooltipContentArray($params) { - global $conf, $langs, $user; + global $langs, $user; $langs->loadLangs(['stocks', 'productbatch']); - $option = $params['option'] ?? ''; + //$option = $params['option'] ?? ''; $datas = []; $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Batch").''; @@ -1124,7 +1124,7 @@ class Productlot extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '', $save_lastsearch_value = -1) { - global $langs, $conf, $hookmanager; + global $langs, $hookmanager; $result = ''; $params = [ @@ -1212,6 +1212,8 @@ class Productlot extends CommonObject { global $conf; + $now = dol_now(); + // Initialise parameters $this->id = 0; $this->ref = 'SPECIMEN'; @@ -1220,13 +1222,13 @@ class Productlot extends CommonObject $this->entity = $conf->entity; $this->fk_product = null; $this->batch = ''; - $this->eatby = ''; - $this->sellby = ''; - $this->datec = ''; - $this->tms = ''; + $this->eatby = $now - 100000; + $this->sellby = $now - 100000; + $this->datec = $now - 3600; + $this->tms = $now; $this->fk_user_creat = null; $this->fk_user_modif = null; - $this->import_key = ''; + $this->import_key = '123456'; } /** @@ -1241,7 +1243,7 @@ class Productlot extends CommonObject */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - global $conf, $user, $langs; + global $langs; $langs->loadLangs(array('stocks', 'productbatch', "products")); $outputlangs->loadLangs(array('stocks', 'productbatch', "products")); @@ -1273,7 +1275,6 @@ class Productlot extends CommonObject public function validateField($fields, $fieldKey, $fieldValue) { // Add your own validation rules here. - // ... if ($fieldKey == 'batch') { if (preg_match('/\s/', $fieldValue)) { $this->error = 'ErrorABatchShouldNotContainsSpaces'; From cc6ede674fac52e18624c18cb730989c506d2424 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 12:39:17 +0100 Subject: [PATCH 36/90] Move rights->x->y into hasRight('x', 'y') --- dev/tools/rector/README.md | 2 ++ .../rector/src/Renaming/GlobalToFunction.php | 1 + htdocs/accountancy/admin/index.php | 4 +-- .../class/api_accountancy.class.php | 2 +- .../action/class/api_agendaevents.class.php | 4 +-- .../comm/propal/class/api_proposals.class.php | 26 +++++++++---------- htdocs/commande/class/api_orders.class.php | 2 +- .../facture/class/api_invoices.class.php | 2 +- htdocs/contrat/class/api_contracts.class.php | 2 +- htdocs/don/class/api_donations.class.php | 4 +-- .../expedition/class/api_shipments.class.php | 2 +- .../class/api_interventions.class.php | 2 +- .../class/api_knowledgemanagement.class.php | 2 +- htdocs/mrp/class/api_mos.class.php | 2 +- .../class/api_partnerships.class.php | 2 +- .../stock/class/api_stockmovements.class.php | 18 ++++++------- .../stock/class/api_warehouses.class.php | 10 +++---- htdocs/projet/class/api_projects.class.php | 2 +- htdocs/projet/class/api_tasks.class.php | 2 +- .../reception/class/api_receptions.class.php | 2 +- .../class/api_recruitments.class.php | 4 +-- htdocs/societe/class/api_contacts.class.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- .../class/api_supplier_proposals.class.php | 2 +- htdocs/ticket/class/api_tickets.class.php | 14 +++++----- htdocs/zapier/class/api_zapier.class.php | 14 +++++----- 26 files changed, 67 insertions(+), 64 deletions(-) diff --git a/dev/tools/rector/README.md b/dev/tools/rector/README.md index c28f7a8d6c5..6ad928af5eb 100644 --- a/dev/tools/rector/README.md +++ b/dev/tools/rector/README.md @@ -18,11 +18,13 @@ composer install ##### To make changes (Add --dry-run for test mode only) ```shell +cd dev/tools/rector ./vendor/bin/rector process --dry-run ``` ##### To make changes on a given directory ```shell +cd dev/tools/rector ./vendor/bin/rector process [--dry-run] [--clear-cache] ../../../htdocs/core/ ``` diff --git a/dev/tools/rector/src/Renaming/GlobalToFunction.php b/dev/tools/rector/src/Renaming/GlobalToFunction.php index fd1a3d7dd66..302a2ff4a2a 100644 --- a/dev/tools/rector/src/Renaming/GlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/GlobalToFunction.php @@ -88,6 +88,7 @@ class GlobalToFunction extends AbstractRector public function refactor(Node $node) { if ($node instanceof Node\Expr\Assign) { + // var is left of = and expr is right if (!isset($node->var)) { return; } diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 636026e526c..ea93f6751fa 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -374,7 +374,7 @@ if (getDolGlobalInt('ACCOUNTING_MANAGE_ZERO')) { } print ''; -// Param a user $user->rights->accounting->chartofaccount can access +// Param a user $user->hasRights('accounting', 'chartofaccount') can access foreach ($list as $key) { print ''; @@ -404,7 +404,7 @@ print ''; print ''; print "\n"; -// Param a user $user->rights->accounting->chartofaccount can access +// Param a user $user->hasRights('accounting', 'chartofaccount') can access foreach ($list_binding as $key) { print ''; diff --git a/htdocs/accountancy/class/api_accountancy.class.php b/htdocs/accountancy/class/api_accountancy.class.php index 8e6649b6e4b..652abb731de 100644 --- a/htdocs/accountancy/class/api_accountancy.class.php +++ b/htdocs/accountancy/class/api_accountancy.class.php @@ -92,7 +92,7 @@ class Accountancy extends DolibarrApi global $conf, $langs; // check rights - if (!DolibarrApiAccess::$user->rights->accounting->mouvements->export) { + if (!DolibarrApiAccess::$user->hasRight('accounting', 'mouvements', 'export')) { throw new RestException(401, 'No permission to export accounting'); } diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index d9f2c1df577..1c21ec62a6e 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -79,7 +79,7 @@ class AgendaEvents extends DolibarrApi throw new RestException(404, 'Agenda Events not found'); } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->read && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read') && $this->actioncomm->userownerid != DolibarrApiAccess::$user->id) { throw new RestException(401, 'Insufficient rights to read event of this owner id. Your id is '.DolibarrApiAccess::$user->id); } @@ -296,7 +296,7 @@ class AgendaEvents extends DolibarrApi $this->actioncomm->oldcopy = clone $this->actioncomm; } - if (!DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'delete') && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insufficient rights to delete an Agenda Event of owner id ".$this->actioncomm->userownerid.' Your id is '.DolibarrApiAccess::$user->id); } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 762027e1475..89589178862 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -247,7 +247,7 @@ class Proposals extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -330,7 +330,7 @@ class Proposals extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -396,7 +396,7 @@ class Proposals extends DolibarrApi */ public function postLines($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -476,7 +476,7 @@ class Proposals extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -554,7 +554,7 @@ class Proposals extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -590,7 +590,7 @@ class Proposals extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -638,7 +638,7 @@ class Proposals extends DolibarrApi */ public function deleteContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -676,7 +676,7 @@ class Proposals extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } @@ -726,7 +726,7 @@ class Proposals extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->propal->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'supprimer')) { throw new RestException(403); } $result = $this->propal->fetch($id); @@ -760,7 +760,7 @@ class Proposals extends DolibarrApi */ public function settodraft($id) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } $result = $this->propal->fetch($id); @@ -816,7 +816,7 @@ class Proposals extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } $result = $this->propal->fetch($id); @@ -863,7 +863,7 @@ class Proposals extends DolibarrApi */ public function close($id, $status, $note_private = '', $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } $result = $this->propal->fetch($id); @@ -907,7 +907,7 @@ class Proposals extends DolibarrApi */ public function setinvoiced($id) { - if (!DolibarrApiAccess::$user->rights->propal->creer) { + if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) { throw new RestException(403); } $result = $this->propal->fetch($id); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2e6ed740f7c..b9f22bd1ebc 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -176,7 +176,7 @@ class Orders extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index d118bdfcbb1..f908b2532da 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -192,7 +192,7 @@ class Invoices extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 7fac4926b1a..e8218881ee8 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -116,7 +116,7 @@ class Contracts extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index b6ca758906b..854e672fc84 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -111,13 +111,13 @@ class Donations extends DolibarrApi $socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids; $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) { + if ((!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids)) { $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) } $sql .= " FROM ".MAIN_DB_PREFIX."don AS t LEFT JOIN ".MAIN_DB_PREFIX."don_extrafields AS ef ON (ef.fk_object = t.rowid)"; // Modification VMR Global Solutions to include extrafields as search parameters in the API GET call, so we will be able to filter on extrafields $sql .= ' WHERE t.entity IN ('.getEntity('don').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) { + if ((!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids)) { $sql .= " AND t.fk_soc = sc.fk_soc"; } if ($thirdparty_ids) { diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index fe3c778153f..43165e78727 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -114,7 +114,7 @@ class Shipments extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 1b8fe55f45a..d48334aeab8 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -123,7 +123,7 @@ class Interventions extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index ceae56fd3fd..34e4159efee 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -149,7 +149,7 @@ class KnowledgeManagement extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index a339ecad597..c88d0174aa7 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -110,7 +110,7 @@ class Mos extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index e161f5b154f..468bc5fb7fa 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -117,7 +117,7 @@ class Partnerships extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/product/stock/class/api_stockmovements.class.php b/htdocs/product/stock/class/api_stockmovements.class.php index 38e0ba177b2..c198d60aadb 100644 --- a/htdocs/product/stock/class/api_stockmovements.class.php +++ b/htdocs/product/stock/class/api_stockmovements.class.php @@ -65,16 +65,16 @@ class StockMovements extends DolibarrApi /* public function get($id) { - if(! DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } $result = $this->stockmovement->fetch($id); - if( ! $result ) { + if (!$result ) { throw new RestException(404, 'warehouse not found'); } - if( ! DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { + if (!DolibarrApi::_checkAccessToResource('warehouse',$this->stockmovement->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -100,7 +100,7 @@ class StockMovements extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } @@ -175,7 +175,7 @@ class StockMovements extends DolibarrApi */ public function post($product_id, $warehouse_id, $qty, $type = 2, $lot = '', $movementcode = '', $movementlabel = '', $price = '', $datem = '', $dlc = '', $dluo = '', $origin_type = '', $origin_id = 0) { - if (!DolibarrApiAccess::$user->rights->stock->creer) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'creer')) { throw new RestException(403); } @@ -218,7 +218,7 @@ class StockMovements extends DolibarrApi /* public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->stock->creer) { + if(! DolibarrApiAccess::$user->hasRight('stock', 'creer')) { throw new RestException(403); } @@ -251,15 +251,15 @@ class StockMovements extends DolibarrApi /* public function delete($id) { - if(! DolibarrApiAccess::$user->rights->stock->supprimer) { + if (! DolibarrApiAccess::$user->hasRight('stock', 'supprimer')) { throw new RestException(403); } $result = $this->stockmovement->fetch($id); - if( ! $result ) { + if (! $result ) { throw new RestException(404, 'stock movement not found'); } - if( ! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { + if (! DolibarrApi::_checkAccessToResource('stock',$this->stockmovement->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } diff --git a/htdocs/product/stock/class/api_warehouses.class.php b/htdocs/product/stock/class/api_warehouses.class.php index a8ef5480eee..c03ba11c01d 100644 --- a/htdocs/product/stock/class/api_warehouses.class.php +++ b/htdocs/product/stock/class/api_warehouses.class.php @@ -62,7 +62,7 @@ class Warehouses extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } @@ -100,7 +100,7 @@ class Warehouses extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } @@ -163,7 +163,7 @@ class Warehouses extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->stock->creer) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'creer')) { throw new RestException(403); } @@ -194,7 +194,7 @@ class Warehouses extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->stock->creer) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'creer')) { throw new RestException(403); } @@ -235,7 +235,7 @@ class Warehouses extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->stock->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'supprimer')) { throw new RestException(403); } $result = $this->warehouse->fetch($id); diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 4c1dc29350d..98540bdb4e6 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -118,7 +118,7 @@ class Projects extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 43f5973c6f8..47d96868994 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -120,7 +120,7 @@ class Tasks extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 69e5b77d616..8c22d9f0e7f 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -111,7 +111,7 @@ class Receptions extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/recruitment/class/api_recruitments.class.php b/htdocs/recruitment/class/api_recruitments.class.php index 53245b17ef8..030c9c81e69 100644 --- a/htdocs/recruitment/class/api_recruitments.class.php +++ b/htdocs/recruitment/class/api_recruitments.class.php @@ -156,7 +156,7 @@ class Recruitments extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } @@ -248,7 +248,7 @@ class Recruitments extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 3a05843410b..af188bb7cae 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -186,7 +186,7 @@ class Contacts extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 74fb2015d8d..bf438c9bc60 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -143,7 +143,7 @@ class Thirdparties extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index be4140a8638..8a0903e17ec 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -107,7 +107,7 @@ class SupplierProposals extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index e4641f65b4a..0b7f6625847 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -126,7 +126,7 @@ class Tickets extends DolibarrApi */ private function getCommon($id = 0, $track_id = '', $ref = '') { - if (!DolibarrApiAccess::$user->rights->ticket->read) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'read')) { throw new RestException(403); } @@ -201,7 +201,7 @@ class Tickets extends DolibarrApi */ public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->ticket->read) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'read')) { throw new RestException(403); } @@ -212,7 +212,7 @@ class Tickets extends DolibarrApi $search_sale = null; // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } @@ -284,7 +284,7 @@ class Tickets extends DolibarrApi public function post($request_data = null) { $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'write')) { throw new RestException(403); } // Check mandatory fields @@ -323,7 +323,7 @@ class Tickets extends DolibarrApi public function postNewMessage($request_data = null) { $ticketstatic = new Ticket($this->db); - if (!DolibarrApiAccess::$user->rights->ticket->write) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'write')) { throw new RestException(403); } // Check mandatory fields @@ -360,7 +360,7 @@ class Tickets extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->ticket->write) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'write')) { throw new RestException(403); } @@ -399,7 +399,7 @@ class Tickets extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->ticket->delete) { + if (!DolibarrApiAccess::$user->hasRight('ticket', 'delete')) { throw new RestException(403); } $result = $this->ticket->fetch($id); diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index 5ad9cc9cb5a..30ab25c938d 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -75,7 +75,7 @@ class Zapier extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->zapier->read) { + if (!DolibarrApiAccess::$user->hasRight('zapier', 'read')) { throw new RestException(403); } @@ -103,7 +103,7 @@ class Zapier extends DolibarrApi */ public function getModulesChoices() { - if (!DolibarrApiAccess::$user->rights->zapier->read) { + if (!DolibarrApiAccess::$user->hasRight('zapier', 'read')) { throw new RestException(403); } @@ -145,7 +145,7 @@ class Zapier extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->zapier->read) { + if (!DolibarrApiAccess::$user->hasRight('zapier', 'read')) { throw new RestException(403); } @@ -158,7 +158,7 @@ class Zapier extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if ($restrictonsocid && !DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) { + if ($restrictonsocid && !DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socid) { $search_sale = DolibarrApiAccess::$user->id; } @@ -227,7 +227,7 @@ class Zapier extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->zapier->write) { + if (!DolibarrApiAccess::$user->hasRight('zapier', 'write')) { throw new RestException(403); } @@ -270,7 +270,7 @@ class Zapier extends DolibarrApi // */ /*public function put($id, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->zapier->write) { + if (! DolibarrApiAccess::$user->hasRight('zapier', 'write')) { throw new RestException(403); } @@ -307,7 +307,7 @@ class Zapier extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->zapier->delete) { + if (!DolibarrApiAccess::$user->hasRight('zapier', 'delete')) { throw new RestException(403); } From fe8dde5c7d0393a888a8af01716c878b9ca00b7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 12:59:24 +0100 Subject: [PATCH 37/90] Move rights->x->y into hasRight('x', 'y') --- .../adherents/class/adherentstats.class.php | 1 - htdocs/admin/emailcollector_list.php | 3 --- htdocs/admin/perms.php | 2 +- htdocs/admin/system/modules.php | 2 +- htdocs/api/class/api_documents.class.php | 18 +++++++-------- htdocs/asset/document.php | 2 +- .../categories/class/api_categories.class.php | 18 +++++++-------- htdocs/contrat/class/api_contracts.class.php | 22 +++++++++---------- .../class/api_knowledgemanagement.class.php | 2 +- htdocs/product/class/api_products.class.php | 2 +- htdocs/societe/class/api_contacts.class.php | 2 +- .../societe/class/api_thirdparties.class.php | 4 ++-- htdocs/user/class/api_users.class.php | 14 ++++++------ 13 files changed, 44 insertions(+), 48 deletions(-) diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 0416a03de81..f99b20f86d5 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -69,7 +69,6 @@ class AdherentStats extends Stats $this->where .= " m.statut != -1"; $this->where .= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")"; - //if (empty($user->rights->societe->client->voir) && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .((int) $user->id); if ($this->memberid) { $this->where .= " AND m.rowid = ".((int) $this->memberid); } diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index 84da0f49c03..833e822c288 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -133,9 +133,6 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -/*$permissiontoread = $user->rights->emailcollector->read; -$permissiontoadd = $user->rights->emailcollector->write; -$permissiontodelete = $user->rights->emailcollector->delete;*/ $permissiontoread = $user->admin; $permissiontoadd = $user->admin; $permissiontodelete = $user->admin; diff --git a/htdocs/admin/perms.php b/htdocs/admin/perms.php index c89c7ad914c..e7c4bd3fbb4 100644 --- a/htdocs/admin/perms.php +++ b/htdocs/admin/perms.php @@ -262,7 +262,7 @@ if ($result) { if ($user->admin) { print ''; diff --git a/htdocs/admin/system/modules.php b/htdocs/admin/system/modules.php index b80b309b512..4cd42fe0243 100644 --- a/htdocs/admin/system/modules.php +++ b/htdocs/admin/system/modules.php @@ -157,7 +157,7 @@ foreach ($modules as $key => $module) { if (empty($rights[0])) { continue; } - $arrayofpermissions[$rights[0]] = array('label'=> 'user->rights->'.$module->rights_class.'->'.$rights[4].(empty($rights[5]) ? '' : '->'.$rights[5])); + $arrayofpermissions[$rights[0]] = array('label'=> 'user->hasRight(\''.$module->rights_class.'\', \''.$rights[4].'\''.(empty($rights[5]) ? '' : ', \''.$rights[5].'\'').')'); $permission[] = $rights[0]; array_push($rights_ids, $rights[0]); diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 715bfab4b8e..826229b1047 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -338,7 +338,7 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; // Can get doc if has permission to read all user or if it is user itself - if (!DolibarrApiAccess::$user->rights->user->user->lire && DolibarrApiAccess::$user->id != $id) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && DolibarrApiAccess::$user->id != $id) { throw new RestException(403); } @@ -352,7 +352,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'adherent' || $modulepart == 'member') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - if (!DolibarrApiAccess::$user->rights->adherent->lire) { + if (!DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(403); } @@ -380,7 +380,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'supplier_proposal') { require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; - if (!DolibarrApiAccess::$user->rights->supplier_proposal->read) { + if (!DolibarrApiAccess::$user->hasRight('supplier_proposal', 'read')) { throw new RestException(403); } @@ -410,7 +410,7 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; - if (empty(DolibarrApiAccess::$user->rights->fournisseur->commande->lire) && empty(DolibarrApiAccess::$user->rights->supplier_order->lire)) { + if (!DolibarrApiAccess::$user->hasRight('fournisseur', 'commande', 'lire') && !DolibarrApiAccess::$user->hasRight('supplier_order', 'lire')) { throw new RestException(403); } @@ -424,7 +424,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -468,7 +468,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -484,7 +484,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - if (!DolibarrApiAccess::$user->rights->agenda->myactions->read && !DolibarrApiAccess::$user->rights->agenda->allactions->read) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'read') && !DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'read')) { throw new RestException(403); } @@ -498,7 +498,7 @@ class Documents extends DolibarrApi } elseif ($modulepart == 'expensereport') { require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; - if (!DolibarrApiAccess::$user->rights->expensereport->read && !DolibarrApiAccess::$user->rights->expensereport->read) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'read') && !DolibarrApiAccess::$user->hasRights('expensereport', 'read')) { throw new RestException(403); } @@ -541,7 +541,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart Ecm not implemented yet.'); // require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; - // if (!DolibarrApiAccess::$user->rights->ecm->read) { + // if (!DolibarrApiAccess::$user->hasRight('ecm', 'read')) { // throw new RestException(403); // } diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index e6359b3a190..460b30d1a90 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -73,7 +73,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->asset->multidir_output[$object->entity ? $object->entity : $conf->entity]."/".get_exdir(0, 0, 0, 1, $object); } -$permissiontoadd = $user->rights->asset->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->hasRight('asset', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) if ($user->socid > 0) { diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 1f3f114124c..e6add11b9b1 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -89,7 +89,7 @@ class Categories extends DolibarrApi */ public function get($id, $include_childs = false) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -136,7 +136,7 @@ class Categories extends DolibarrApi { $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -193,7 +193,7 @@ class Categories extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) { throw new RestException(403); } @@ -224,7 +224,7 @@ class Categories extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->categorie->creer) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'creer')) { throw new RestException(403); } @@ -362,7 +362,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -442,7 +442,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -522,7 +522,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -600,7 +600,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -753,7 +753,7 @@ class Categories extends DolibarrApi { dol_syslog("getObjects($id, $type, $onlyids)", LOG_DEBUG); - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index e8218881ee8..b4f5c8ffcea 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -65,7 +65,7 @@ class Contracts extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->contrat->lire) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'lire')) { throw new RestException(403); } @@ -105,7 +105,7 @@ class Contracts extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->contrat->lire) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'lire')) { throw new RestException(403); } @@ -183,7 +183,7 @@ class Contracts extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(401, "Insufficient rights"); } // Check mandatory fields @@ -223,7 +223,7 @@ class Contracts extends DolibarrApi */ public function getLines($id) { - if (!DolibarrApiAccess::$user->rights->contrat->lire) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'lire')) { throw new RestException(403); } @@ -255,7 +255,7 @@ class Contracts extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -313,7 +313,7 @@ class Contracts extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -376,7 +376,7 @@ class Contracts extends DolibarrApi */ public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -414,7 +414,7 @@ class Contracts extends DolibarrApi */ public function unactivateLine($id, $lineid, $datestart, $comment = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -454,7 +454,7 @@ class Contracts extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -487,7 +487,7 @@ class Contracts extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } @@ -616,7 +616,7 @@ class Contracts extends DolibarrApi */ public function close($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->contrat->creer) { + if (!DolibarrApiAccess::$user->hasRight('contrat', 'creer')) { throw new RestException(403); } $result = $this->contract->fetch($id); diff --git a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php index 34e4159efee..6f12ceadf7d 100644 --- a/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php +++ b/htdocs/knowledgemanagement/class/api_knowledgemanagement.class.php @@ -101,7 +101,7 @@ class KnowledgeManagement extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index ced1acc3509..79847f6f526 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -590,7 +590,7 @@ class Products extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index af188bb7cae..f9483334ce0 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -449,7 +449,7 @@ class Contacts extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index bf438c9bc60..b0fd1609f9b 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -543,7 +543,7 @@ class Thirdparties extends DolibarrApi */ public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } @@ -657,7 +657,7 @@ class Thirdparties extends DolibarrApi */ public function getSupplierCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { - if (!DolibarrApiAccess::$user->rights->categorie->lire) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'lire')) { throw new RestException(403); } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index ea2c9bb3cea..5acf5b0f3a3 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -148,7 +148,7 @@ class Users extends DolibarrApi */ public function get($id, $includepermissions = 0) { - if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && $id != 0 && DolibarrApiAccess::$user->id != $id) { + if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && $id != 0 && DolibarrApiAccess::$user->id != $id) { throw new RestException(401, 'Not allowed'); } @@ -191,7 +191,7 @@ class Users extends DolibarrApi throw new RestException(400, 'Bad parameters'); } - if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) { + if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) { throw new RestException(401, 'Not allowed'); } @@ -230,7 +230,7 @@ class Users extends DolibarrApi throw new RestException(400, 'Bad parameters'); } - if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->email != $email) { + if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->email != $email) { throw new RestException(401, 'Not allowed'); } @@ -263,7 +263,7 @@ class Users extends DolibarrApi */ public function getInfo($includepermissions = 0) { - if (empty(DolibarrApiAccess::$user->rights->user->self->creer) && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) { + if (empty(DolibarrApiAccess::$user->rights->user->self->creer) && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(401, 'Not allowed'); } @@ -442,7 +442,7 @@ class Users extends DolibarrApi */ public function getGroups($id) { - if (empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) { + if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403); } @@ -537,7 +537,7 @@ class Users extends DolibarrApi $obj_ret = array(); - if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) || + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) || getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403, "You are not allowed to read groups"); } @@ -609,7 +609,7 @@ class Users extends DolibarrApi { global $db, $conf; - if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->user->lire) && empty(DolibarrApiAccess::$user->admin)) || + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) || getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403, "You are not allowed to read groups"); } From 840d73a471a8f4c30f9ff7a129d0c203157c64eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 13:17:48 +0100 Subject: [PATCH 38/90] Move rights->x->y into hasRight('x', 'y') --- .../categories/class/api_categories.class.php | 28 +++++++-------- .../comm/propal/class/api_proposals.class.php | 2 +- htdocs/commande/class/api_orders.class.php | 6 ++-- .../template/class/api_mymodule.class.php | 8 ++--- htdocs/product/class/api_products.class.php | 6 ++-- .../reception/class/api_receptions.class.php | 34 +++++++++--------- .../societe/class/api_thirdparties.class.php | 36 +++++++++---------- .../class/api_supplier_proposals.class.php | 4 +-- htdocs/user/class/api_users.class.php | 22 ++++++------ 9 files changed, 73 insertions(+), 73 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e6add11b9b1..c526f4877c5 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -265,7 +265,7 @@ class Categories extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->categorie->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('categorie', 'supprimer')) { throw new RestException(403); } $result = $this->category->fetch($id); @@ -320,7 +320,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if ($type == Categorie::TYPE_PRODUCT && !(DolibarrApiAccess::$user->rights->produit->lire || DolibarrApiAccess::$user->rights->service->lire)) { + if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->rights->produit->lire && !DolibarrApiAccess::$user->rights->service->lire) { throw new RestException(403); } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(403); @@ -372,17 +372,17 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { throw new RestException(403); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); @@ -452,17 +452,17 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { throw new RestException(403); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); @@ -532,17 +532,17 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { throw new RestException(403); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); @@ -610,17 +610,17 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!(DolibarrApiAccess::$user->rights->produit->creer || DolibarrApiAccess::$user->rights->service->creer)) { + if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { throw new RestException(403); } $object = new Product($this->db); } elseif ($type === Categorie::TYPE_CUSTOMER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_SUPPLIER) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } $object = new Societe($this->db); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 89589178862..aa1e3d0e980 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -174,7 +174,7 @@ class Proposals extends DolibarrApi // If the internal user must only see his customers, force searching by him $search_sale = 0; - if (!DolibarrApiAccess::$user->rights->hasRight('societe', 'client', 'voir') && !$socids) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'client', 'voir') && !$socids) { $search_sale = DolibarrApiAccess::$user->id; } diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index b9f22bd1ebc..904134acbe1 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -678,7 +678,7 @@ class Orders extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->commande->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'supprimer')) { throw new RestException(403); } $result = $this->commande->fetch($id); @@ -992,7 +992,7 @@ class Orders extends DolibarrApi public function getOrderShipments($id) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } $obj_ret = array(); @@ -1048,7 +1048,7 @@ class Orders extends DolibarrApi public function createOrderShipment($id, $warehouse_id) { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } if ($warehouse_id <= 0) { diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 42c8d9874ba..615bd359b21 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -71,7 +71,7 @@ class MyModuleApi extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->mymodule->myobject->read) { + if (!DolibarrApiAccess::$user->hasRight('mymodule', 'myobject', 'read')) { throw new RestException(403); } if (!DolibarrApi::_checkAccessToResource('myobject', $id, 'mymodule_myobject')) { @@ -110,7 +110,7 @@ class MyModuleApi extends DolibarrApi $obj_ret = array(); $tmpobject = new MyObject($this->db); - if (!DolibarrApiAccess::$user->rights->mymodule->myobject->read) { + if (!DolibarrApiAccess::$user->hasRight('mymodule', 'myobject', 'read')) { throw new RestException(403); } @@ -195,7 +195,7 @@ class MyModuleApi extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->mymodule->myobject->write) { + if (!DolibarrApiAccess::$user->hasRight('mymodule', 'myobject', 'write')) { throw new RestException(403); } @@ -236,7 +236,7 @@ class MyModuleApi extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->mymodule->myobject->write) { + if (!DolibarrApiAccess::$user->hasRight('mymodule', 'myobject', 'write')) { throw new RestException(403); } if (!DolibarrApi::_checkAccessToResource('myobject', $id, 'mymodule_myobject')) { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 79847f6f526..33fdcaa329f 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -1912,7 +1912,7 @@ class Products extends DolibarrApi * @return array * * @throws RestException 500 System error - * @throws RestException 401 + * @throws RestException 403 * @throws RestException 404 * * @url GET {id}/stock @@ -1924,7 +1924,7 @@ class Products extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('product', $id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $product_model = new Product($this->db); @@ -2001,7 +2001,7 @@ class Products extends DolibarrApi unset($object->supplierprices); // Must use another API to get them - if (empty(DolibarrApiAccess::$user->rights->stock->lire)) { + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { unset($object->stock_reel); unset($object->stock_theorique); unset($object->stock_warehouse); diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 8c22d9f0e7f..ec891fd0f0a 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -221,16 +221,16 @@ class Receptions extends DolibarrApi /* public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->rights->reception->lire) { throw new RestException(403); } $result = $this->reception->fetch($id); - if( ! $result ) { + if (! $result) { throw new RestException(404, 'Reception not found'); } - if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + if (!DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->reception->getLinesArray(); @@ -255,16 +255,16 @@ class Receptions extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->rights->reception->creer) { throw new RestException(403); } $result = $this->reception->fetch($id); - if ( ! $result ) { + if (! $result) { throw new RestException(404, 'Reception not found'); } - if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + if (!DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -323,16 +323,16 @@ class Receptions extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->rights->reception->creer) { throw new RestException(403); } $result = $this->reception->fetch($id); - if ( ! $result ) { + if (! $result) { throw new RestException(404, 'Reception not found'); } - if( ! DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { + if (!DolibarrApi::_checkAccessToResource('reception',$this->reception->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -556,19 +556,19 @@ class Receptions extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->rights->reception->creer) { throw new RestException(403); } - if(empty($id)) { + if (empty($id)) { throw new RestException(400, 'Reception ID is mandatory'); } $result = $this->reception->fetch($id); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Reception not found'); } $result = $this->reception->classifyBilled(DolibarrApiAccess::$user); - if( $result < 0) { + if ($result < 0) { throw new RestException(400, $this->reception->error); } return $result; @@ -595,19 +595,19 @@ class Receptions extends DolibarrApi require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->rights->reception->lire) { throw new RestException(403); } - if(! DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->rights->reception->creer) { throw new RestException(403); } - if(empty($proposalid)) { + if (empty($proposalid)) { throw new RestException(400, 'Order ID is mandatory'); } $order = new Commande($this->db); $result = $order->fetch($proposalid); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index b0fd1609f9b..150bbda74fd 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -244,7 +244,7 @@ class Thirdparties extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } // Check mandatory fields @@ -279,7 +279,7 @@ class Thirdparties extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -340,7 +340,7 @@ class Thirdparties extends DolibarrApi throw new RestException(400, 'Try to merge a thirdparty into itself'); } - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -438,11 +438,11 @@ class Thirdparties extends DolibarrApi throw new RestException(501, 'Multiprices features activation needed for this request'); } - if ($priceLevel < 1 || $priceLevel > $conf->global->PRODUIT_MULTIPRICES_LIMIT) { + if ($priceLevel < 1 || $priceLevel > getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT')) { throw new RestException(400, 'Price level must be between 1 and ' . getDolGlobalString('PRODUIT_MULTIPRICES_LIMIT')); } - if (empty(DolibarrApiAccess::$user->rights->societe->creer)) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(401, 'Access to thirdparty '.$id.' not allowed for login '.DolibarrApiAccess::$user->login); } @@ -578,7 +578,7 @@ class Thirdparties extends DolibarrApi */ public function addCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -616,7 +616,7 @@ class Thirdparties extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -693,7 +693,7 @@ class Thirdparties extends DolibarrApi */ public function addSupplierCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -731,7 +731,7 @@ class Thirdparties extends DolibarrApi */ public function deleteSupplierCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1155,7 +1155,7 @@ class Thirdparties extends DolibarrApi */ public function createCompanyBankAccount($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } if ($this->company->fetch($id) <= 0) { @@ -1206,7 +1206,7 @@ class Thirdparties extends DolibarrApi */ public function updateCompanyBankAccount($id, $bankaccount_id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } if ($this->company->fetch($id) <= 0) { @@ -1257,7 +1257,7 @@ class Thirdparties extends DolibarrApi */ public function deleteCompanyBankAccount($id, $bankaccount_id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1292,7 +1292,7 @@ class Thirdparties extends DolibarrApi throw new RestException(404, 'Thirdparty not found'); } - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1453,7 +1453,7 @@ class Thirdparties extends DolibarrApi */ public function createSocieteAccount($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1517,7 +1517,7 @@ class Thirdparties extends DolibarrApi */ public function putSocieteAccount($id, $site, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1611,7 +1611,7 @@ class Thirdparties extends DolibarrApi */ public function patchSocieteAccount($id, $site, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1670,7 +1670,7 @@ class Thirdparties extends DolibarrApi */ public function deleteSocieteAccount($id, $site) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } @@ -1704,7 +1704,7 @@ class Thirdparties extends DolibarrApi */ public function deleteSocieteAccounts($id) { - if (!DolibarrApiAccess::$user->rights->societe->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'creer')) { throw new RestException(403); } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index 8a0903e17ec..bde171e7d68 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -63,7 +63,7 @@ class SupplierProposals extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + if (!DolibarrApiAccess::$user->hasRight('supplier_proposal', 'lire')) { throw new RestException(403); } @@ -96,7 +96,7 @@ class SupplierProposals extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + if (!DolibarrApiAccess::$user->hasRight('supplier_proposal', 'lire')) { throw new RestException(403); } diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 5acf5b0f3a3..faaff5fb032 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -263,7 +263,7 @@ class Users extends DolibarrApi */ public function getInfo($includepermissions = 0) { - if (empty(DolibarrApiAccess::$user->rights->user->self->creer) && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) { + if (!DolibarrApiAccess::$user->hasRights('user', 'self', 'creer') && !DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(401, 'Not allowed'); } @@ -304,7 +304,7 @@ class Users extends DolibarrApi public function post($request_data = null) { // Check user authorization - if (empty(DolibarrApiAccess::$user->rights->user->creer) && empty(DolibarrApiAccess::$user->admin)) { + if (!DolibarrApiAccess::$user->hasRight('user', 'creer') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(401, "User creation not allowed for login ".DolibarrApiAccess::$user->login); } @@ -328,7 +328,7 @@ class Users extends DolibarrApi continue; } /*if ($field == 'pass') { - if (empty(DolibarrApiAccess::$user->rights->user->user->password)) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'password')) { throw new RestException(401, 'You are not allowed to modify/set password of other users'); continue; } @@ -381,10 +381,10 @@ class Users extends DolibarrApi continue; } if ($field == 'pass') { - if ($this->useraccount->id != DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->user->password)) { + if ($this->useraccount->id != DolibarrApiAccess::$user->id && !DolibarrApiAccess::$user->hasRight('user', 'user', 'password')) { throw new RestException(401, 'You are not allowed to modify password of other users'); } - if ($this->useraccount->id == DolibarrApiAccess::$user->id && empty(DolibarrApiAccess::$user->rights->user->self->password)) { + if ($this->useraccount->id == DolibarrApiAccess::$user->id && !DolibarrApiAccess::$user->hasRight('user', 'self', 'password')) { throw new RestException(401, 'You are not allowed to modify your own password'); } } @@ -537,8 +537,8 @@ class Users extends DolibarrApi $obj_ret = array(); - if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) || - getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) { + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin)) || + getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight('user', 'group_advance', 'read') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403, "You are not allowed to read groups"); } @@ -609,8 +609,8 @@ class Users extends DolibarrApi { global $db, $conf; - if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) || - getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty(DolibarrApiAccess::$user->rights->user->group_advance->read) && empty(DolibarrApiAccess::$user->admin)) { + if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin)) || + getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !DolibarrApiAccess::$user->hasRight('user', 'group_advance', 'read') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403, "You are not allowed to read groups"); } @@ -635,7 +635,7 @@ class Users extends DolibarrApi */ public function delete($id) { - if (empty(DolibarrApiAccess::$user->rights->user->user->supprimer) && empty(DolibarrApiAccess::$user->admin)) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'supprimer') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403, 'Not allowed'); } $result = $this->useraccount->fetch($id); @@ -708,7 +708,7 @@ class Users extends DolibarrApi unset($object->lines); unset($object->model_pdf); - $canreadsalary = ((isModEnabled('salaries') && !empty(DolibarrApiAccess::$user->rights->salaries->read)) || (empty($conf->salaries->enabled))); + $canreadsalary = ((isModEnabled('salaries') && DolibarrApiAccess::$user->hasRight('salaries', 'read')) || !isModEnabled('salaries')); if (!$canreadsalary) { unset($object->salary); From 9c7294aa8106b42c398e3a98ce021247e656dcd6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 13:20:38 +0100 Subject: [PATCH 39/90] Move rights->x->y into hasRight('x', 'y') --- .../categories/class/api_categories.class.php | 18 +++--- htdocs/commande/class/api_orders.class.php | 26 ++++---- .../facture/class/api_invoices.class.php | 40 ++++++------ .../class/api_interventions.class.php | 14 ++--- htdocs/product/class/api_products.class.php | 62 +++++++++---------- .../reception/class/api_receptions.class.php | 18 +++--- htdocs/societe/class/api_contacts.class.php | 16 ++--- 7 files changed, 97 insertions(+), 97 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index c526f4877c5..f95f2b457fd 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -320,7 +320,7 @@ class Categories extends DolibarrApi throw new RestException(403); } - if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->rights->produit->lire && !DolibarrApiAccess::$user->rights->service->lire) { + if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) { throw new RestException(403); } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { throw new RestException(403); @@ -372,7 +372,7 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) { throw new RestException(403); } $object = new Product($this->db); @@ -387,7 +387,7 @@ class Categories extends DolibarrApi } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(403); } $object = new Contact($this->db); @@ -452,7 +452,7 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) { throw new RestException(403); } $object = new Product($this->db); @@ -467,7 +467,7 @@ class Categories extends DolibarrApi } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(403); } $object = new Contact($this->db); @@ -532,7 +532,7 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) { throw new RestException(403); } $object = new Product($this->db); @@ -547,7 +547,7 @@ class Categories extends DolibarrApi } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(403); } $object = new Contact($this->db); @@ -610,7 +610,7 @@ class Categories extends DolibarrApi } if ($type === Categorie::TYPE_PRODUCT) { - if (!DolibarrApiAccess::$user->rights->produit->creer && !DolibarrApiAccess::$user->rights->service->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer') && !DolibarrApiAccess::$user->hasRight('service', 'creer')) { throw new RestException(403); } $object = new Product($this->db); @@ -625,7 +625,7 @@ class Categories extends DolibarrApi } $object = new Societe($this->db); } elseif ($type === Categorie::TYPE_CONTACT) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(403); } $object = new Contact($this->db); diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 904134acbe1..d70dab85cb7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -264,7 +264,7 @@ class Orders extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -337,7 +337,7 @@ class Orders extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -404,7 +404,7 @@ class Orders extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -472,7 +472,7 @@ class Orders extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -541,7 +541,7 @@ class Orders extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -589,7 +589,7 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -631,7 +631,7 @@ class Orders extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } @@ -726,7 +726,7 @@ class Orders extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } $result = $this->commande->fetch($id); @@ -777,7 +777,7 @@ class Orders extends DolibarrApi */ public function reopen($id) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -813,7 +813,7 @@ class Orders extends DolibarrApi */ public function setinvoiced($id) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -854,7 +854,7 @@ class Orders extends DolibarrApi */ public function close($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } $result = $this->commande->fetch($id); @@ -899,7 +899,7 @@ class Orders extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } $result = $this->commande->fetch($id); @@ -954,7 +954,7 @@ class Orders extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('propal', 'lire')) { throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (!DolibarrApiAccess::$user->hasRight('commande', 'creer')) { throw new RestException(403); } if (empty($proposalid)) { diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index f908b2532da..811d74405cf 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -282,7 +282,7 @@ class Invoices extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -335,7 +335,7 @@ class Invoices extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('commande', 'lire')) { throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($orderid)) { @@ -376,7 +376,7 @@ class Invoices extends DolibarrApi if (!DolibarrApiAccess::$user->hasRight('contrat', 'lire')) { throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($contractid)) { @@ -443,7 +443,7 @@ class Invoices extends DolibarrApi */ public function putLine($id, $lineid, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -514,7 +514,7 @@ class Invoices extends DolibarrApi */ public function postContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -562,7 +562,7 @@ class Invoices extends DolibarrApi */ public function deleteContact($id, $contactid, $type) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -607,7 +607,7 @@ class Invoices extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($lineid)) { @@ -640,7 +640,7 @@ class Invoices extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -745,7 +745,7 @@ class Invoices extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -833,7 +833,7 @@ class Invoices extends DolibarrApi */ public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } $result = $this->invoice->fetch($id); @@ -881,7 +881,7 @@ class Invoices extends DolibarrApi */ public function settodraft($id, $idwarehouse = -1) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } $result = $this->invoice->fetch($id); @@ -932,7 +932,7 @@ class Invoices extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } $result = $this->invoice->fetch($id); @@ -981,7 +981,7 @@ class Invoices extends DolibarrApi */ public function settopaid($id, $close_code = '', $close_note = '') { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } $result = $this->invoice->fetch($id); @@ -1030,7 +1030,7 @@ class Invoices extends DolibarrApi */ public function settounpaid($id) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } $result = $this->invoice->fetch($id); @@ -1118,7 +1118,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } @@ -1287,7 +1287,7 @@ class Invoices extends DolibarrApi */ public function useDiscount($id, $discountid) { - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -1334,7 +1334,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -1426,7 +1426,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -1546,7 +1546,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } foreach ($arrayofamounts as $id => $amount) { @@ -1680,7 +1680,7 @@ class Invoices extends DolibarrApi { require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; - if (!DolibarrApiAccess::$user->rights->facture->creer) { + if (!DolibarrApiAccess::$user->hasRight('facture', 'creer')) { throw new RestException(403); } if (empty($id)) { diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index d48334aeab8..cce1e0cd1f8 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -78,7 +78,7 @@ class Interventions extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->ficheinter->lire) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { throw new RestException(403); } @@ -112,7 +112,7 @@ class Interventions extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->ficheinter->lire) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { throw new RestException(403); } @@ -190,7 +190,7 @@ class Interventions extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->ficheinter->creer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -225,7 +225,7 @@ class Interventions extends DolibarrApi /* TODO public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + if(! DolibarrApiAccess::$user->hasRight('ficheinter', 'lire')) { throw new RestException(403); } @@ -258,7 +258,7 @@ class Interventions extends DolibarrApi */ public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->ficheinter->creer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -346,7 +346,7 @@ class Interventions extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->ficheinter->creer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { throw new RestException(401, "Insuffisant rights"); } $result = $this->fichinter->fetch($id); @@ -382,7 +382,7 @@ class Interventions extends DolibarrApi */ public function closeFichinter($id) { - if (!DolibarrApiAccess::$user->rights->ficheinter->creer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'creer')) { throw new RestException(401, "Insuffisant rights"); } $result = $this->fichinter->fetch($id); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 33fdcaa329f..a9318739445 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -180,7 +180,7 @@ class Products extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -306,7 +306,7 @@ class Products extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } // Check mandatory fields @@ -343,7 +343,7 @@ class Products extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -491,7 +491,7 @@ class Products extends DolibarrApi */ public function getSubproducts($id) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -529,7 +529,7 @@ class Products extends DolibarrApi */ public function addSubproducts($id, $subproduct_id, $qty, $incdec = 1) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -559,7 +559,7 @@ class Products extends DolibarrApi */ public function delSubproducts($id, $subproduct_id) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -618,7 +618,7 @@ class Products extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -660,7 +660,7 @@ class Products extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -709,7 +709,7 @@ class Products extends DolibarrApi { global $conf; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -767,7 +767,7 @@ class Products extends DolibarrApi */ public function addPurchasePrice($id, $qty, $buyprice, $price_base_type, $fourn_id, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '', $barcode = '', $fk_barcode_type = null) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -864,7 +864,7 @@ class Products extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -977,7 +977,7 @@ class Products extends DolibarrApi $id = (empty($id) ? 0 : $id); - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1025,7 +1025,7 @@ class Products extends DolibarrApi */ public function getAttributes($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1087,7 +1087,7 @@ class Products extends DolibarrApi */ public function getAttributeById($id) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1130,7 +1130,7 @@ class Products extends DolibarrApi */ public function getAttributesByRef($ref) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1180,7 +1180,7 @@ class Products extends DolibarrApi */ public function getAttributesByRefExt($ref_ext) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1232,7 +1232,7 @@ class Products extends DolibarrApi */ public function addAttributes($ref, $label, $ref_ext = '') { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1264,7 +1264,7 @@ class Products extends DolibarrApi */ public function putAttributes($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1344,7 +1344,7 @@ class Products extends DolibarrApi */ public function getAttributeValueById($id) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1385,7 +1385,7 @@ class Products extends DolibarrApi */ public function getAttributeValueByRef($id, $ref) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1471,7 +1471,7 @@ class Products extends DolibarrApi */ public function getAttributeValues($id) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1502,7 +1502,7 @@ class Products extends DolibarrApi */ public function getAttributeValuesByRef($ref) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1544,7 +1544,7 @@ class Products extends DolibarrApi */ public function addAttributeValue($id, $ref, $value) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1577,7 +1577,7 @@ class Products extends DolibarrApi */ public function putAttributeValue($id, $request_data) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1656,7 +1656,7 @@ class Products extends DolibarrApi */ public function getVariants($id, $includestock = 0) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1692,7 +1692,7 @@ class Products extends DolibarrApi */ public function getVariantsByProdRef($ref) { - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } @@ -1735,7 +1735,7 @@ class Products extends DolibarrApi */ public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features, $reference = '', $ref_ext = '') { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1796,7 +1796,7 @@ class Products extends DolibarrApi */ public function addVariantByProductRef($ref, $weight_impact, $price_impact, $price_impact_is_percent, $features) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1850,7 +1850,7 @@ class Products extends DolibarrApi */ public function putVariant($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->produit->creer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'creer')) { throw new RestException(403); } @@ -1919,7 +1919,7 @@ class Products extends DolibarrApi */ public function getStock($id, $selected_warehouse_id = null) { - if (!DolibarrApiAccess::$user->rights->produit->lire || !DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->rights->stock->lire) { throw new RestException(403); } @@ -2056,7 +2056,7 @@ class Products extends DolibarrApi $id = (empty($id) ? 0 : $id); - if (!DolibarrApiAccess::$user->rights->produit->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire')) { throw new RestException(403); } diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index ec891fd0f0a..14eb37ba777 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -179,7 +179,7 @@ class Receptions extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -255,7 +255,7 @@ class Receptions extends DolibarrApi /* public function postLine($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } @@ -323,7 +323,7 @@ class Receptions extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } @@ -388,7 +388,7 @@ class Receptions extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } @@ -425,7 +425,7 @@ class Receptions extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } @@ -510,7 +510,7 @@ class Receptions extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } $result = $this->reception->fetch($id); @@ -556,7 +556,7 @@ class Receptions extends DolibarrApi public function setinvoiced($id) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } if (empty($id)) { @@ -598,7 +598,7 @@ class Receptions extends DolibarrApi if (!DolibarrApiAccess::$user->rights->reception->lire) { throw new RestException(403); } - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } if (empty($proposalid)) { @@ -632,7 +632,7 @@ class Receptions extends DolibarrApi */ public function close($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->reception->creer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { throw new RestException(403); } diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index f9483334ce0..594f8e8463a 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -71,7 +71,7 @@ class Contacts extends DolibarrApi */ public function get($id, $includecount = 0, $includeroles = 0) { - if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) { throw new RestException(401, 'No permission to read contacts'); } @@ -119,7 +119,7 @@ class Contacts extends DolibarrApi */ public function getByEmail($email, $includecount = 0, $includeroles = 0) { - if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) { throw new RestException(401, 'No permission to read contacts'); } @@ -177,7 +177,7 @@ class Contacts extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) { throw new RestException(401, 'No permission to read contacts'); } @@ -276,7 +276,7 @@ class Contacts extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(401, 'No permission to create/update contacts'); } // Check mandatory fields @@ -315,7 +315,7 @@ class Contacts extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(401, 'No permission to create/update contacts'); } @@ -403,7 +403,7 @@ class Contacts extends DolibarrApi throw new RestException(400, "password field missing"); } - if (!DolibarrApiAccess::$user->rights->societe->contact->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'lire')) { throw new RestException(403, 'No permission to read contacts'); } if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'creer')) { @@ -479,7 +479,7 @@ class Contacts extends DolibarrApi */ public function addCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(401, 'Insufficient rights'); } @@ -519,7 +519,7 @@ class Contacts extends DolibarrApi */ public function deleteCategory($id, $category_id) { - if (!DolibarrApiAccess::$user->rights->societe->contact->creer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'creer')) { throw new RestException(401, 'Insufficient rights'); } From 8710e0b235e515ec46d4fa2f66e36305ace50b9c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 13:28:57 +0100 Subject: [PATCH 40/90] Move rights->x->y into hasRight('x', 'y') --- htdocs/categories/class/api_categories.class.php | 8 ++++---- htdocs/comm/action/class/api_agendaevents.class.php | 4 ++-- htdocs/don/class/api_donations.class.php | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index f95f2b457fd..e15571e5481 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -322,15 +322,15 @@ class Categories extends DolibarrApi if ($type == Categorie::TYPE_PRODUCT && !DolibarrApiAccess::$user->hasRight('produit', 'lire') && !DolibarrApiAccess::$user->hasRight('service', 'lire')) { throw new RestException(403); - } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->rights->contact->lire) { + } elseif ($type == Categorie::TYPE_CONTACT && !DolibarrApiAccess::$user->hasRight('contact', 'lire')) { throw new RestException(403); } elseif ($type == Categorie::TYPE_CUSTOMER && !DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(403); - } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->rights->fournisseur->lire) { + } elseif ($type == Categorie::TYPE_SUPPLIER && !DolibarrApiAccess::$user->hasRight('fournisseur', 'lire')) { throw new RestException(403); - } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->rights->adherent->lire) { + } elseif ($type == Categorie::TYPE_MEMBER && !DolibarrApiAccess::$user->hasRight('adherent', 'lire')) { throw new RestException(403); - } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->rights->projet->lire) { + } elseif ($type == Categorie::TYPE_PROJECT && !DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } elseif ($type == Categorie::TYPE_KNOWLEDGEMANAGEMENT && !DolibarrApiAccess::$user->hasRight('knowledgemanagement', 'knowledgerecord', 'read')) { throw new RestException(403); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 1c21ec62a6e..4d2021a0da1 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -63,7 +63,7 @@ class AgendaEvents extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'read')) { throw new RestException(401, "Insufficient rights to read an event"); } if ($id === 0) { @@ -109,7 +109,7 @@ class AgendaEvents extends DolibarrApi $obj_ret = array(); - if (!DolibarrApiAccess::$user->rights->agenda->myactions->read) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'read')) { throw new RestException(401, "Insufficient rights to read events"); } diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index 854e672fc84..c8e3e94527f 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -62,7 +62,7 @@ class Donations extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->don->lire) { + if (!DolibarrApiAccess::$user->hasRight('don', 'lire')) { throw new RestException(403); } @@ -101,7 +101,7 @@ class Donations extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->don->lire) { + if (!DolibarrApiAccess::$user->hasRight('don', 'lire')) { throw new RestException(403); } @@ -175,7 +175,7 @@ class Donations extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->hasRight('don', 'creer')) { throw new RestException(401, "Insuffisant rights"); } @@ -216,7 +216,7 @@ class Donations extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->hasRight('don', 'creer')) { throw new RestException(403); } @@ -256,7 +256,7 @@ class Donations extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->don->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('don', 'supprimer')) { throw new RestException(403); } @@ -305,7 +305,7 @@ class Donations extends DolibarrApi */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->don->creer) { + if (!DolibarrApiAccess::$user->hasRight('don', 'creer')) { throw new RestException(403); } From 8592db0729a1acca6eeaaee81046c8a25d204c1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 13:54:55 +0100 Subject: [PATCH 41/90] Move rights->x->y into hasRight('x', 'y') --- .../action/class/api_agendaevents.class.php | 4 +-- .../bank/class/api_bankaccounts.class.php | 16 +++++------ .../expedition/class/api_shipments.class.php | 28 +++++++++---------- .../class/api_interventions.class.php | 2 +- .../class/api_partnerships.class.php | 4 +-- htdocs/product/class/api_products.class.php | 20 ++++++------- htdocs/projet/class/api_projects.class.php | 20 ++++++------- htdocs/projet/class/api_tasks.class.php | 24 ++++++++-------- 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 4d2021a0da1..9c266c92cb6 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -191,7 +191,7 @@ class AgendaEvents extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { @@ -236,7 +236,7 @@ class AgendaEvents extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index b8f9f208e5a..eb7a0f7959c 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -67,7 +67,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -129,7 +129,7 @@ class BankAccounts extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -150,7 +150,7 @@ class BankAccounts extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } // Check mandatory fields @@ -201,7 +201,7 @@ class BankAccounts extends DolibarrApi */ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } @@ -325,7 +325,7 @@ class BankAccounts extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } @@ -363,7 +363,7 @@ class BankAccounts extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } $account = new Account($this->db); @@ -436,7 +436,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -595,7 +595,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 43165e78727..d46d7e57ea5 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -64,7 +64,7 @@ class Shipments extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -103,7 +103,7 @@ class Shipments extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -182,7 +182,7 @@ class Shipments extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -224,7 +224,7 @@ class Shipments extends DolibarrApi /* public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -258,7 +258,7 @@ class Shipments extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -326,7 +326,7 @@ class Shipments extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->expedition->creer) { + if (! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -393,7 +393,7 @@ class Shipments extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -426,7 +426,7 @@ class Shipments extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -467,7 +467,7 @@ class Shipments extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->expedition->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'supprimer')) { throw new RestException(403); } $result = $this->shipment->fetch($id); @@ -512,7 +512,7 @@ class Shipments extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } $result = $this->shipment->fetch($id); @@ -558,7 +558,7 @@ class Shipments extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } if(empty($id)) { @@ -597,10 +597,10 @@ class Shipments extends DolibarrApi require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->expedition->lire) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } if(empty($proposalid)) { @@ -634,7 +634,7 @@ class Shipments extends DolibarrApi */ public function close($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index cce1e0cd1f8..b8c5b4f187f 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -305,7 +305,7 @@ class Interventions extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'supprimer')) { throw new RestException(403); } $result = $this->fichinter->fetch($id); diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index 468bc5fb7fa..51646c97e1a 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -68,7 +68,7 @@ class Partnerships extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->partnership->read) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) { throw new RestException(403); } @@ -107,7 +107,7 @@ class Partnerships extends DolibarrApi $obj_ret = array(); $tmpobject = new Partnership($this->db); - if (!DolibarrApiAccess::$user->rights->partnership->read) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) { throw new RestException(403); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index a9318739445..82091a6a1ee 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -252,7 +252,7 @@ class Products extends DolibarrApi if (!$ids_only) { $product_static = new Product($this->db); if ($product_static->fetch($obj->rowid)) { - if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $product_static->load_stock(); if (is_array($product_static->stock_warehouse)) { @@ -446,7 +446,7 @@ class Products extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } $result = $this->product->fetch($id); @@ -825,7 +825,7 @@ class Products extends DolibarrApi */ public function deletePurchasePrice($id, $priceid) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } $result = $this->productsupplier->fetch($id); @@ -1316,7 +1316,7 @@ class Products extends DolibarrApi */ public function deleteAttributes($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1428,7 +1428,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueByRef($id, $ref) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1629,7 +1629,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueById($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1668,7 +1668,7 @@ class Products extends DolibarrApi $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); - if (!empty($includestock) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestock) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $productModel = new Product($this->db); $productModel->fetch((int) $combination->fk_product_child); $productModel->load_stock($includestock); @@ -1890,7 +1890,7 @@ class Products extends DolibarrApi */ public function deleteVariant($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1919,7 +1919,7 @@ class Products extends DolibarrApi */ public function getStock($id, $selected_warehouse_id = null) { - if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } @@ -2069,7 +2069,7 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $this->product->load_stock($includestockdata); if (is_array($this->product->stock_warehouse)) { diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 98540bdb4e6..896c1219653 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -71,7 +71,7 @@ class Projects extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -107,7 +107,7 @@ class Projects extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -193,7 +193,7 @@ class Projects extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -234,7 +234,7 @@ class Projects extends DolibarrApi */ public function getLines($id, $includetimespent = 0) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -274,7 +274,7 @@ class Projects extends DolibarrApi { global $db; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -317,7 +317,7 @@ class Projects extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -384,7 +384,7 @@ class Projects extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -445,7 +445,7 @@ class Projects extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -486,7 +486,7 @@ class Projects extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $result = $this->project->fetch($id); @@ -530,7 +530,7 @@ class Projects extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $result = $this->project->fetch($id); diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 47d96868994..28304406505 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -67,7 +67,7 @@ class Tasks extends DolibarrApi */ public function get($id, $includetimespent = 0) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -109,7 +109,7 @@ class Tasks extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -189,7 +189,7 @@ class Tasks extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -229,7 +229,7 @@ class Tasks extends DolibarrApi /* public function getLines($id, $includetimespent=0) { - if(! DolibarrApiAccess::$user->rights->projet->lire) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -274,7 +274,7 @@ class Tasks extends DolibarrApi { global $db; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -315,7 +315,7 @@ class Tasks extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -382,7 +382,7 @@ class Tasks extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -442,7 +442,7 @@ class Tasks extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -483,7 +483,7 @@ class Tasks extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $result = $this->task->fetch($id); @@ -526,7 +526,7 @@ class Tasks extends DolibarrApi */ public function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '') { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $result = $this->task->fetch($id); @@ -585,7 +585,7 @@ class Tasks extends DolibarrApi */ public function putTimeSpent($id, $timespent_id, $date, $duration, $user_id = 0, $note = '') { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $this->timespentRecordChecks($id, $timespent_id); @@ -630,7 +630,7 @@ class Tasks extends DolibarrApi */ public function deleteTimeSpent($id, $timespent_id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $this->timespentRecordChecks($id, $timespent_id); From ba1c299ab1528dad6acc4351b1452242dcf8f367 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 13:54:55 +0100 Subject: [PATCH 42/90] Move rights->x->y into hasRight('x', 'y') --- .../action/class/api_agendaevents.class.php | 4 +-- .../bank/class/api_bankaccounts.class.php | 20 ++++++------- .../expedition/class/api_shipments.class.php | 28 +++++++++---------- .../class/api_expensereports.class.php | 18 ++++++------ .../class/api_interventions.class.php | 2 +- htdocs/mrp/class/api_mos.class.php | 10 +++---- .../class/api_multicurrencies.class.php | 8 +++--- .../class/api_partnerships.class.php | 8 +++--- htdocs/product/class/api_products.class.php | 20 ++++++------- htdocs/projet/class/api_projects.class.php | 20 ++++++------- htdocs/projet/class/api_tasks.class.php | 24 ++++++++-------- .../reception/class/api_receptions.class.php | 10 +++---- htdocs/societe/class/api_contacts.class.php | 2 +- .../societe/class/api_thirdparties.class.php | 2 +- 14 files changed, 88 insertions(+), 88 deletions(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 4d2021a0da1..9c266c92cb6 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -191,7 +191,7 @@ class AgendaEvents extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { @@ -236,7 +236,7 @@ class AgendaEvents extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->agenda->myactions->create) { + if (!DolibarrApiAccess::$user->hasRight('agenda', 'myactions', 'create')) { throw new RestException(401, "Insufficient rights to create your Agenda Event"); } if (!DolibarrApiAccess::$user->hasRight('agenda', 'allactions', 'create') && DolibarrApiAccess::$user->id != $request_data['userownerid']) { diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index b8f9f208e5a..830273e2563 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -67,7 +67,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -129,7 +129,7 @@ class BankAccounts extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -150,7 +150,7 @@ class BankAccounts extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } // Check mandatory fields @@ -201,7 +201,7 @@ class BankAccounts extends DolibarrApi */ public function transfer($bankaccount_from_id = 0, $bankaccount_to_id = 0, $date = null, $description = "", $amount = 0.0, $amount_to = 0.0) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } @@ -325,7 +325,7 @@ class BankAccounts extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } @@ -363,7 +363,7 @@ class BankAccounts extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->banque->configurer) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'configurer')) { throw new RestException(403); } $account = new Account($this->db); @@ -436,7 +436,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } @@ -499,7 +499,7 @@ class BankAccounts extends DolibarrApi */ public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '', $accountancycode = '', $datev = null, $num_releve = '') { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) { throw new RestException(403); } @@ -552,7 +552,7 @@ class BankAccounts extends DolibarrApi */ public function addLink($id, $line_id, $url_id, $url, $label, $type) { - if (!DolibarrApiAccess::$user->rights->banque->modifier) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'modifier')) { throw new RestException(403); } @@ -595,7 +595,7 @@ class BankAccounts extends DolibarrApi { $list = array(); - if (!DolibarrApiAccess::$user->rights->banque->lire) { + if (!DolibarrApiAccess::$user->hasRight('banque', 'lire')) { throw new RestException(403); } diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 43165e78727..d46d7e57ea5 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -64,7 +64,7 @@ class Shipments extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -103,7 +103,7 @@ class Shipments extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->expedition->lire) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -182,7 +182,7 @@ class Shipments extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -224,7 +224,7 @@ class Shipments extends DolibarrApi /* public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } @@ -258,7 +258,7 @@ class Shipments extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -326,7 +326,7 @@ class Shipments extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if (! DolibarrApiAccess::$user->rights->expedition->creer) { + if (! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -393,7 +393,7 @@ class Shipments extends DolibarrApi */ public function deleteLine($id, $lineid) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -426,7 +426,7 @@ class Shipments extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } @@ -467,7 +467,7 @@ class Shipments extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->expedition->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'supprimer')) { throw new RestException(403); } $result = $this->shipment->fetch($id); @@ -512,7 +512,7 @@ class Shipments extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } $result = $this->shipment->fetch($id); @@ -558,7 +558,7 @@ class Shipments extends DolibarrApi public function setinvoiced($id) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } if(empty($id)) { @@ -597,10 +597,10 @@ class Shipments extends DolibarrApi require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->expedition->lire) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'lire')) { throw new RestException(403); } - if(! DolibarrApiAccess::$user->rights->expedition->creer) { + if(! DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } if(empty($proposalid)) { @@ -634,7 +634,7 @@ class Shipments extends DolibarrApi */ public function close($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->expedition->creer) { + if (!DolibarrApiAccess::$user->hasRight('expedition', 'creer')) { throw new RestException(403); } diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 27f7601e9ef..c2d4a373483 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -64,7 +64,7 @@ class ExpenseReports extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->expensereport->lire) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'lire')) { throw new RestException(403); } @@ -99,7 +99,7 @@ class ExpenseReports extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->expensereport->lire) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'lire')) { throw new RestException(403); } @@ -163,7 +163,7 @@ class ExpenseReports extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->expensereport->creer) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(401, "Insuffisant rights"); } @@ -205,7 +205,7 @@ class ExpenseReports extends DolibarrApi /* public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + if(! DolibarrApiAccess::$user->hasRight('expensereport', 'lire')) { throw new RestException(403); } @@ -239,7 +239,7 @@ class ExpenseReports extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + if(! DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(403); } @@ -307,7 +307,7 @@ class ExpenseReports extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + if(! DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(403); } @@ -371,7 +371,7 @@ class ExpenseReports extends DolibarrApi /* public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + if(! DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(403); } @@ -408,7 +408,7 @@ class ExpenseReports extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->expensereport->creer) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(403); } @@ -492,7 +492,7 @@ class ExpenseReports extends DolibarrApi /* public function validate($id, $idwarehouse=0) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + if(! DolibarrApiAccess::$user->hasRight('expensereport', 'creer')) { throw new RestException(403); } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index cce1e0cd1f8..b8c5b4f187f 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -305,7 +305,7 @@ class Interventions extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('ficheinter', 'supprimer')) { throw new RestException(403); } $result = $this->fichinter->fetch($id); diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index c88d0174aa7..75fa896c0dc 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -63,7 +63,7 @@ class Mos extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->mrp->read) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'read')) { throw new RestException(403); } @@ -97,7 +97,7 @@ class Mos extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->mrp->read) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'read')) { throw new RestException(403); } @@ -177,7 +177,7 @@ class Mos extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->mrp->write) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'write')) { throw new RestException(403); } // Check mandatory fields @@ -211,7 +211,7 @@ class Mos extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->mrp->write) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'write')) { throw new RestException(403); } @@ -304,7 +304,7 @@ class Mos extends DolibarrApi $error = 0; - if (!DolibarrApiAccess::$user->rights->mrp->write) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'write')) { throw new RestException(401, 'Not enough permission'); } $result = $this->mo->fetch($id); diff --git a/htdocs/multicurrency/class/api_multicurrencies.class.php b/htdocs/multicurrency/class/api_multicurrencies.class.php index 291de3868a6..1dbb9ffbec4 100644 --- a/htdocs/multicurrency/class/api_multicurrencies.class.php +++ b/htdocs/multicurrency/class/api_multicurrencies.class.php @@ -57,7 +57,7 @@ class MultiCurrencies extends DolibarrApi { global $db; - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->read) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'read')) { throw new RestException(401, "Insufficient rights to read currency"); } @@ -123,7 +123,7 @@ class MultiCurrencies extends DolibarrApi throw new RestException(404, 'Currency not found'); } - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->read) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'read')) { throw new RestException(401, "Insufficient rights to read currency"); } @@ -148,7 +148,7 @@ class MultiCurrencies extends DolibarrApi throw new RestException(404, 'Currency not found'); } - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->read) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'read')) { throw new RestException(401, "Insufficient rights to read currency"); } @@ -173,7 +173,7 @@ class MultiCurrencies extends DolibarrApi throw new RestException(404, 'Currency not found'); } - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->read) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'read')) { throw new RestException(401, "Insufficient rights to read currency rates"); } diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index 468bc5fb7fa..3e559351753 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -68,7 +68,7 @@ class Partnerships extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->partnership->read) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) { throw new RestException(403); } @@ -107,7 +107,7 @@ class Partnerships extends DolibarrApi $obj_ret = array(); $tmpobject = new Partnership($this->db); - if (!DolibarrApiAccess::$user->rights->partnership->read) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'read')) { throw new RestException(403); } @@ -188,7 +188,7 @@ class Partnerships extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->partnership->write) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'write')) { throw new RestException(403); } @@ -227,7 +227,7 @@ class Partnerships extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->partnership->write) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'write')) { throw new RestException(403); } diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index a9318739445..82091a6a1ee 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -252,7 +252,7 @@ class Products extends DolibarrApi if (!$ids_only) { $product_static = new Product($this->db); if ($product_static->fetch($obj->rowid)) { - if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $product_static->load_stock(); if (is_array($product_static->stock_warehouse)) { @@ -446,7 +446,7 @@ class Products extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } $result = $this->product->fetch($id); @@ -825,7 +825,7 @@ class Products extends DolibarrApi */ public function deletePurchasePrice($id, $priceid) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } $result = $this->productsupplier->fetch($id); @@ -1316,7 +1316,7 @@ class Products extends DolibarrApi */ public function deleteAttributes($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1428,7 +1428,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueByRef($id, $ref) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1629,7 +1629,7 @@ class Products extends DolibarrApi */ public function deleteAttributeValueById($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1668,7 +1668,7 @@ class Products extends DolibarrApi $combinations[$key]->attributes = $prodc2vp->fetchByFkCombination((int) $combination->id); $combinations[$key] = $this->_cleanObjectDatas($combinations[$key]); - if (!empty($includestock) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestock) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $productModel = new Product($this->db); $productModel->fetch((int) $combination->fk_product_child); $productModel->load_stock($includestock); @@ -1890,7 +1890,7 @@ class Products extends DolibarrApi */ public function deleteVariant($id) { - if (!DolibarrApiAccess::$user->rights->produit->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'supprimer')) { throw new RestException(403); } @@ -1919,7 +1919,7 @@ class Products extends DolibarrApi */ public function getStock($id, $selected_warehouse_id = null) { - if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->rights->stock->lire) { + if (!DolibarrApiAccess::$user->hasRight('produit', 'lire') || !DolibarrApiAccess::$user->hasRight('stock', 'lire')) { throw new RestException(403); } @@ -2069,7 +2069,7 @@ class Products extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if (!empty($includestockdata) && DolibarrApiAccess::$user->rights->stock->lire) { + if (!empty($includestockdata) && DolibarrApiAccess::$user->hasRight('stock', 'lire')) { $this->product->load_stock($includestockdata); if (is_array($this->product->stock_warehouse)) { diff --git a/htdocs/projet/class/api_projects.class.php b/htdocs/projet/class/api_projects.class.php index 98540bdb4e6..896c1219653 100644 --- a/htdocs/projet/class/api_projects.class.php +++ b/htdocs/projet/class/api_projects.class.php @@ -71,7 +71,7 @@ class Projects extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -107,7 +107,7 @@ class Projects extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $category = 0, $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -193,7 +193,7 @@ class Projects extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -234,7 +234,7 @@ class Projects extends DolibarrApi */ public function getLines($id, $includetimespent = 0) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -274,7 +274,7 @@ class Projects extends DolibarrApi { global $db; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -317,7 +317,7 @@ class Projects extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -384,7 +384,7 @@ class Projects extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -445,7 +445,7 @@ class Projects extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -486,7 +486,7 @@ class Projects extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $result = $this->project->fetch($id); @@ -530,7 +530,7 @@ class Projects extends DolibarrApi */ public function validate($id, $notrigger = 0) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $result = $this->project->fetch($id); diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index 47d96868994..28304406505 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -67,7 +67,7 @@ class Tasks extends DolibarrApi */ public function get($id, $includetimespent = 0) { - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -109,7 +109,7 @@ class Tasks extends DolibarrApi { global $db, $conf; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -189,7 +189,7 @@ class Tasks extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields @@ -229,7 +229,7 @@ class Tasks extends DolibarrApi /* public function getLines($id, $includetimespent=0) { - if(! DolibarrApiAccess::$user->rights->projet->lire) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -274,7 +274,7 @@ class Tasks extends DolibarrApi { global $db; - if (!DolibarrApiAccess::$user->rights->projet->lire) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'lire')) { throw new RestException(403); } @@ -315,7 +315,7 @@ class Tasks extends DolibarrApi /* public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -382,7 +382,7 @@ class Tasks extends DolibarrApi /* public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->projet->creer) { + if(! DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -442,7 +442,7 @@ class Tasks extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } @@ -483,7 +483,7 @@ class Tasks extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $result = $this->task->fetch($id); @@ -526,7 +526,7 @@ class Tasks extends DolibarrApi */ public function addTimeSpent($id, $date, $duration, $user_id = 0, $note = '') { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $result = $this->task->fetch($id); @@ -585,7 +585,7 @@ class Tasks extends DolibarrApi */ public function putTimeSpent($id, $timespent_id, $date, $duration, $user_id = 0, $note = '') { - if (!DolibarrApiAccess::$user->rights->projet->creer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'creer')) { throw new RestException(403); } $this->timespentRecordChecks($id, $timespent_id); @@ -630,7 +630,7 @@ class Tasks extends DolibarrApi */ public function deleteTimeSpent($id, $timespent_id) { - if (!DolibarrApiAccess::$user->rights->projet->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('projet', 'supprimer')) { throw new RestException(403); } $this->timespentRecordChecks($id, $timespent_id); diff --git a/htdocs/reception/class/api_receptions.class.php b/htdocs/reception/class/api_receptions.class.php index 14eb37ba777..e8a035c4049 100644 --- a/htdocs/reception/class/api_receptions.class.php +++ b/htdocs/reception/class/api_receptions.class.php @@ -63,7 +63,7 @@ class Receptions extends DolibarrApi */ public function get($id) { - if (!DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) { throw new RestException(403); } @@ -100,7 +100,7 @@ class Receptions extends DolibarrApi */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '', $properties = '') { - if (!DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) { throw new RestException(403); } @@ -221,7 +221,7 @@ class Receptions extends DolibarrApi /* public function getLines($id) { - if (!DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) { throw new RestException(403); } @@ -465,7 +465,7 @@ class Receptions extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->reception->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'supprimer')) { throw new RestException(403); } $result = $this->reception->fetch($id); @@ -595,7 +595,7 @@ class Receptions extends DolibarrApi require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if (!DolibarrApiAccess::$user->rights->reception->lire) { + if (!DolibarrApiAccess::$user->hasRight('reception', 'lire')) { throw new RestException(403); } if (!DolibarrApiAccess::$user->hasRight('reception', 'creer')) { diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 594f8e8463a..eda54cd3d41 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -366,7 +366,7 @@ class Contacts extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->societe->contact->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'contact', 'supprimer')) { throw new RestException(401, 'No permission to delete contacts'); } $result = $this->contact->fetch($id); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 150bbda74fd..b0c101796f0 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1080,7 +1080,7 @@ class Thirdparties extends DolibarrApi */ public function getCompanyBankAccount($id) { - if (!DolibarrApiAccess::$user->rights->societe->lire) { + if (!DolibarrApiAccess::$user->hasRight('societe', 'lire')) { throw new RestException(403); } if (empty($id)) { From 5d1874cecbc02d731d8d273162a80a3c6acb07d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 14:04:31 +0100 Subject: [PATCH 43/90] Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop --- htdocs/expensereport/class/api_expensereports.class.php | 4 ++-- htdocs/mrp/class/api_mos.class.php | 4 ++-- htdocs/multicurrency/class/api_multicurrencies.class.php | 8 ++++---- htdocs/partnership/class/api_partnerships.class.php | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index c2d4a373483..a16d6646eb9 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -449,7 +449,7 @@ class ExpenseReports extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->expensereport->supprimer) { + if (!DolibarrApiAccess::$user->hasRight('expensereport', 'supprimer')) { throw new RestException(403); } @@ -459,7 +459,7 @@ class ExpenseReports extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } if (!$this->expensereport->delete(DolibarrApiAccess::$user)) { diff --git a/htdocs/mrp/class/api_mos.class.php b/htdocs/mrp/class/api_mos.class.php index 75fa896c0dc..d11b66915c4 100644 --- a/htdocs/mrp/class/api_mos.class.php +++ b/htdocs/mrp/class/api_mos.class.php @@ -254,7 +254,7 @@ class Mos extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->mrp->delete) { + if (!DolibarrApiAccess::$user->hasRight('mrp', 'delete')) { throw new RestException(403); } $result = $this->mo->fetch($id); @@ -263,7 +263,7 @@ class Mos extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('mrp', $this->mo->id, 'mrp_mo')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } if (!$this->mo->delete(DolibarrApiAccess::$user)) { diff --git a/htdocs/multicurrency/class/api_multicurrencies.class.php b/htdocs/multicurrency/class/api_multicurrencies.class.php index 1dbb9ffbec4..7ad88dbee12 100644 --- a/htdocs/multicurrency/class/api_multicurrencies.class.php +++ b/htdocs/multicurrency/class/api_multicurrencies.class.php @@ -199,7 +199,7 @@ class MultiCurrencies extends DolibarrApi */ public function post($request_data = null) { - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->create) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'create')) { throw new RestException(401, "Insufficient rights to create currency"); } @@ -243,7 +243,7 @@ class MultiCurrencies extends DolibarrApi */ public function put($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->create) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'create')) { throw new RestException(401, "Insufficient rights to update currency"); } @@ -282,7 +282,7 @@ class MultiCurrencies extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->delete) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'delete')) { throw new RestException(401, "Insufficient rights to delete currency"); } @@ -316,7 +316,7 @@ class MultiCurrencies extends DolibarrApi */ public function updateRate($id, $request_data = null) { - if (!DolibarrApiAccess::$user->rights->multicurrency->currency->create) { + if (!DolibarrApiAccess::$user->hasRight('multicurrency', 'currency', 'create')) { throw new RestException(401, "Insufficient rights to update currency rate"); } diff --git a/htdocs/partnership/class/api_partnerships.class.php b/htdocs/partnership/class/api_partnerships.class.php index 3e559351753..b1b23066143 100644 --- a/htdocs/partnership/class/api_partnerships.class.php +++ b/htdocs/partnership/class/api_partnerships.class.php @@ -275,7 +275,7 @@ class Partnerships extends DolibarrApi */ public function delete($id) { - if (!DolibarrApiAccess::$user->rights->partnership->delete) { + if (!DolibarrApiAccess::$user->hasRight('partnership', 'delete')) { throw new RestException(403); } $result = $this->partnership->fetch($id); @@ -284,7 +284,7 @@ class Partnerships extends DolibarrApi } if (!DolibarrApi::_checkAccessToResource('partnership', $this->partnership->id, 'partnership')) { - throw new RestException(401, 'Access to instance id='.$this->partnership->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(403, 'Access to instance id='.$this->partnership->id.' of object not allowed for login '.DolibarrApiAccess::$user->login); } if (!$this->partnership->delete(DolibarrApiAccess::$user)) { From 5b35250b0de85382f10c5dc752cf9219a1b35e62 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 15:24:35 +0100 Subject: [PATCH 44/90] Enhance rector to fix empty($user->rights->modulex->perm1) --- dev/tools/rector/rector.php | 3 +- .../src/Renaming/EmptyGlobalToFunction.php | 22 +- .../Renaming/EmptyUserRightsToFunction.php | 281 ++++++++++++++++++ htdocs/.gitignore | 1 + 4 files changed, 295 insertions(+), 12 deletions(-) create mode 100644 dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index 5b07d1da6cc..1c5649ea0dc 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -49,12 +49,13 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class); - //$rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); + //Not yet ready: $rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); + $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyUserRightsToFunction::class); // Add all predefined rules to migrate to up to php 71. // Warning this break tab spacing of arrays on several lines diff --git a/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php b/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php index 0bd1575adcd..36260563908 100644 --- a/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php @@ -52,10 +52,10 @@ class EmptyGlobalToFunction extends AbstractRector public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( - 'Change $conf->global to getDolGlobal', + 'Change empty($conf->global->...) to getDolGlobal', [new CodeSample( - '$conf->global->CONSTANT', - 'getDolGlobalInt(\'CONSTANT\')' + 'empty($conf->global->CONSTANT)', + '!getDolGlobalInt(\'CONSTANT\')' )] ); } @@ -82,10 +82,10 @@ class EmptyGlobalToFunction extends AbstractRector if (!$node->expr instanceof Node\Expr\Empty_) { return null; } - // node is !empty(...) so we set node to ... - $newnode = $node->expr->expr; + // node is !empty(...) so we set newnode to ... + $newnode = $node->expr->expr; // newnode is conf->global->... - $tmpglobal = $newnode->var; + $tmpglobal = $newnode->var; // tmpglobal is global->... if (is_null($tmpglobal)) { return null; } @@ -93,7 +93,7 @@ class EmptyGlobalToFunction extends AbstractRector return null; } - $tmpconf = $tmpglobal->var; + $tmpconf = $tmpglobal->var; // tmpconf is conf-> if (!$this->isName($tmpconf, 'conf')) { return null; } @@ -113,10 +113,10 @@ class EmptyGlobalToFunction extends AbstractRector if ($node instanceof Node\Expr\Empty_) { - // node is empty(...) so we set node to ... - $newnode = $node->expr; + // node is empty(...) so we set newnode to ... + $newnode = $node->expr; // newnode is conf->global->... - $tmpglobal = $newnode->var; + $tmpglobal = $newnode->var; // tmpglobal is global->... if (is_null($tmpglobal)) { return null; } @@ -124,7 +124,7 @@ class EmptyGlobalToFunction extends AbstractRector return null; } - $tmpconf = $tmpglobal->var; + $tmpconf = $tmpglobal->var; // tmpconf is conf-> if (!$this->isName($tmpconf, 'conf')) { return null; } diff --git a/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php b/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php new file mode 100644 index 00000000000..3a161e21630 --- /dev/null +++ b/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php @@ -0,0 +1,281 @@ +binaryOpManipulator = $binaryOpManipulator; + } + + /** + * getRuleDefinition + * + * @return RuleDefinition + * @throws PoorDocumentationException + */ + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition( + 'Change empty(\$user->rights->module->permission) to !\$user->hasRight(\'module\', \'permission\')', + [new CodeSample( + 'empty($user->rights->module->permission)', + '!$user->hasRight(\'module\', \'permission\')' + )] + ); + } + + /** + * Return a node type from https://github.com/rectorphp/php-parser-nodes-docs/ + * + * @return string[] + */ + public function getNodeTypes(): array + { + return [Node\Expr\BooleanNot::class, Node\Expr\Empty_::class]; + } + + /** + * refactor + * + * @param Node $node A node + * @return FuncCall|BooleanNot + */ + public function refactor(Node $node) + { + if ($node instanceof Node\Expr\BooleanNot) { + if (!$node->expr instanceof Node\Expr\Empty_) { + return null; + } + // node is !empty(...) so we set newnode to ... + $newnode = $node->expr->expr; + + $tmpperm = $newnode->var; //name of tmpperm is modulex + if (is_null($tmpperm)) { + return null; + } + + $tmprights = $tmpperm->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + $tmprights = $tmprights->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + return null; + } + } + + $tmpuser = $tmprights->var; // name of tmpuser is 'user' + if (!$this->isName($tmpuser, 'user')) { + return null; + } + + $data = $this->getRights($newnode); + if (!isset($data)) { + return; + } + + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + + return $method; + } + + if ($node instanceof Node\Expr\Empty_) { + // node is empty(...) so we set newnode to ... + $newnode = $node->expr; // name of node is perm + + $tmpperm = $newnode->var; //name of tmpperm is modulex + if (is_null($tmpperm)) { + return null; + } + + $tmprights = $tmpperm->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + $tmprights = $tmprights->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + return null; + } + } + + $tmpuser = $tmprights->var; // name of tmpuser is 'user' + if (!$this->isName($tmpuser, 'user')) { + return null; + } + + $data = $this->getRights($newnode); + if (!isset($data)) { + return; + } + + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + + return new Node\Expr\BooleanNot($method); + } + + return null; + } + + /** + * Get nodes with check empty + * + * @param BooleanAnd $booleanAnd A BooleandAnd + * @return TwoNodeMatch|null + */ + private function resolveTwoNodeMatch(BooleanAnd $booleanAnd): ?TwoNodeMatch + { + return $this->binaryOpManipulator->matchFirstAndSecondConditionNode( + $booleanAnd, + // $conf->global == $value + function (Node $node): bool { + if (!$node instanceof Equal) { + return \false; + } + return $this->isGlobalVar($node->left); + }, + // !empty(...) || isset(...) + function (Node $node): bool { + if ($node instanceof BooleanNot && $node->expr instanceof Empty_) { + return $this->isGlobalVar($node->expr->expr); + } + if (!$node instanceof Isset_) { + return $this->isGlobalVar($node); + } + return \true; + } + ); + } + + /** + * Check if node is a global access with format conf->global->XXX + * + * @param Node $node A node + * @return bool Return true if noe is conf->global->XXX + */ + private function isGlobalVar($node) + { + if (!$node instanceof PropertyFetch) { + return false; + } + if (!$this->isName($node->var, 'global')) { + return false; + } + $global = $node->var; + if (!$global instanceof PropertyFetch) { + return false; + } + if (!$this->isName($global->var, 'conf')) { + return false; + } + return true; + } + + /** + * @param Node $node Node to be parsed + * @return Node|void Return the name of the constant + */ + private function getConstName($node) + { + if ($node instanceof PropertyFetch && $node->name instanceof Node\Expr) { + return $node->name; + } + $name = $this->getName($node); + if (empty($name)) { + return; + } + return new String_($name); + } + + /** + * @param \PhpParser\Node\Expr\PropertyFetch $node node + * @return array|null + */ + private function getRights(Node\Expr\PropertyFetch $node) + { + $perm2 = ''; + if (!$node->var instanceof Node\Expr\PropertyFetch) { + return null; + } + // Add a test to avoid rector error on html.formsetup.class.php + if (!$node->name instanceof Node\Expr\Variable && is_null($this->getName($node))) { + //var_dump($node); + return null; + //exit; + } + $perm1 = $node->name instanceof Node\Expr\Variable ? $node->name : new String_($this->getName($node)); + $moduleNode = $node->var; + if (!$moduleNode instanceof Node\Expr\PropertyFetch) { + return null; + } + if (!$moduleNode->var instanceof Node\Expr\PropertyFetch) { + return null; + } + if (!$this->isName($moduleNode->var, 'rights')) { + $perm2 = $perm1; + $perm1 = $moduleNode->name instanceof Node\Expr\Variable ? $moduleNode->name : new String_($this->getName($moduleNode)); + $moduleNode = $moduleNode->var; + } + $module = $moduleNode->name instanceof Node\Expr\Variable ? $moduleNode->name : new String_($this->getName($moduleNode)); + $rights = $moduleNode->var; + if (!$this->isName($rights, 'rights') || !isset($perm1) || !isset($module)) { + return null; + } + if (!$rights->var instanceof Node\Expr\Variable) { + return null; + } + $user = $rights->var; + return compact('user', 'module', 'perm1', 'perm2'); + } +} diff --git a/htdocs/.gitignore b/htdocs/.gitignore index 0749df8a2bb..d0fe62f2e73 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -1,3 +1,4 @@ +/aaa* /allscreens* /ancot* /bootstrap* From 885909a6a3ae3e28effe389806f4f1bdee0bcf1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 15:24:35 +0100 Subject: [PATCH 45/90] Enhance rector to fix empty($user->rights->modulex->perm1) --- dev/tools/rector/rector.php | 5 +- .../src/Renaming/EmptyGlobalToFunction.php | 22 +- .../Renaming/EmptyUserRightsToFunction.php | 283 ++++++++++++++++++ htdocs/.gitignore | 1 + .../html.formadvtargetemailing.class.php | 4 +- htdocs/comm/propal/card.php | 8 +- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 4 +- htdocs/compta/accounting-files.php | 14 +- htdocs/compta/bank/bankentries_list.php | 2 +- .../compta/cashcontrol/cashcontrol_list.php | 6 +- htdocs/compta/facture/card-rec.php | 6 +- htdocs/compta/facture/card.php | 16 +- htdocs/compta/facture/list.php | 8 +- htdocs/core/boxes/box_boms.php | 2 +- htdocs/core/boxes/box_bookmarks.php | 2 +- htdocs/core/boxes/box_commandes.php | 2 +- htdocs/core/boxes/box_comptes.php | 2 +- .../core/boxes/box_funnel_of_prospection.php | 2 +- .../box_graph_invoices_supplier_permonth.php | 2 +- .../core/boxes/box_graph_orders_permonth.php | 2 +- .../box_graph_orders_supplier_permonth.php | 2 +- .../boxes/box_graph_propales_permonth.php | 2 +- htdocs/core/boxes/box_mos.php | 2 +- .../core/boxes/box_produits_alerte_stock.php | 2 +- htdocs/core/boxes/box_project.php | 2 +- htdocs/core/boxes/box_shipments.php | 2 +- htdocs/core/boxes/box_task.php | 2 +- htdocs/core/boxes/box_validated_projects.php | 2 +- htdocs/core/class/html.form.class.php | 4 +- htdocs/core/class/html.formfile.class.php | 2 +- htdocs/core/class/html.formother.class.php | 6 +- htdocs/core/tpl/contacts.tpl.php | 6 +- 33 files changed, 357 insertions(+), 72 deletions(-) create mode 100644 dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php diff --git a/dev/tools/rector/rector.php b/dev/tools/rector/rector.php index 5b07d1da6cc..dceb00bfb4b 100644 --- a/dev/tools/rector/rector.php +++ b/dev/tools/rector/rector.php @@ -49,12 +49,13 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\FloatvalToTypeCastRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\FuncCall\BoolvalToTypeCastRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class); - //$rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); + //Not yet ready: $rectorconfig->rule(Rector\CodeQuality\Rector\If_\CompleteMissingIfElseBracketRector::class); $rectorConfig->rule(Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class); + $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); + $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyUserRightsToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\GlobalToFunction::class); $rectorConfig->rule(Dolibarr\Rector\Renaming\UserRightsToFunction::class); - $rectorConfig->rule(Dolibarr\Rector\Renaming\EmptyGlobalToFunction::class); // Add all predefined rules to migrate to up to php 71. // Warning this break tab spacing of arrays on several lines diff --git a/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php b/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php index 0bd1575adcd..36260563908 100644 --- a/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php +++ b/dev/tools/rector/src/Renaming/EmptyGlobalToFunction.php @@ -52,10 +52,10 @@ class EmptyGlobalToFunction extends AbstractRector public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( - 'Change $conf->global to getDolGlobal', + 'Change empty($conf->global->...) to getDolGlobal', [new CodeSample( - '$conf->global->CONSTANT', - 'getDolGlobalInt(\'CONSTANT\')' + 'empty($conf->global->CONSTANT)', + '!getDolGlobalInt(\'CONSTANT\')' )] ); } @@ -82,10 +82,10 @@ class EmptyGlobalToFunction extends AbstractRector if (!$node->expr instanceof Node\Expr\Empty_) { return null; } - // node is !empty(...) so we set node to ... - $newnode = $node->expr->expr; + // node is !empty(...) so we set newnode to ... + $newnode = $node->expr->expr; // newnode is conf->global->... - $tmpglobal = $newnode->var; + $tmpglobal = $newnode->var; // tmpglobal is global->... if (is_null($tmpglobal)) { return null; } @@ -93,7 +93,7 @@ class EmptyGlobalToFunction extends AbstractRector return null; } - $tmpconf = $tmpglobal->var; + $tmpconf = $tmpglobal->var; // tmpconf is conf-> if (!$this->isName($tmpconf, 'conf')) { return null; } @@ -113,10 +113,10 @@ class EmptyGlobalToFunction extends AbstractRector if ($node instanceof Node\Expr\Empty_) { - // node is empty(...) so we set node to ... - $newnode = $node->expr; + // node is empty(...) so we set newnode to ... + $newnode = $node->expr; // newnode is conf->global->... - $tmpglobal = $newnode->var; + $tmpglobal = $newnode->var; // tmpglobal is global->... if (is_null($tmpglobal)) { return null; } @@ -124,7 +124,7 @@ class EmptyGlobalToFunction extends AbstractRector return null; } - $tmpconf = $tmpglobal->var; + $tmpconf = $tmpglobal->var; // tmpconf is conf-> if (!$this->isName($tmpconf, 'conf')) { return null; } diff --git a/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php b/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php new file mode 100644 index 00000000000..a1b4f2f56de --- /dev/null +++ b/dev/tools/rector/src/Renaming/EmptyUserRightsToFunction.php @@ -0,0 +1,283 @@ +binaryOpManipulator = $binaryOpManipulator; + } + + /** + * getRuleDefinition + * + * @return RuleDefinition + * @throws PoorDocumentationException + */ + public function getRuleDefinition(): RuleDefinition + { + return new RuleDefinition( + 'Change empty(\$user->rights->module->permission) to !\$user->hasRight(\'module\', \'permission\')', + [new CodeSample( + 'empty($user->rights->module->permission)', + '!$user->hasRight(\'module\', \'permission\')' + )] + ); + } + + /** + * Return a node type from https://github.com/rectorphp/php-parser-nodes-docs/ + * + * @return string[] + */ + public function getNodeTypes(): array + { + return [Node\Expr\BooleanNot::class, Node\Expr\Empty_::class]; + } + + /** + * refactor + * + * @param Node $node A node + * @return FuncCall|BooleanNot + */ + public function refactor(Node $node) + { + if ($node instanceof Node\Expr\BooleanNot) { + if (!$node->expr instanceof Node\Expr\Empty_) { + return null; + } + // node is !empty(...) so we set newnode to ... + $newnode = $node->expr->expr; + + $tmpperm = $newnode->var; //name of tmpperm is modulex + if (is_null($tmpperm)) { + return null; + } + + $tmprights = $tmpperm->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + $tmprights2 = $tmprights->var; // name of tmprights is 'rights' + if (is_null($tmprights2)) { + return null; + } + if (!$this->isName($tmprights2, 'rights')) { + return null; + } + $tmprights = $tmprights2; + } + + $tmpuser = $tmprights->var; // name of tmpuser is 'user' + if (!$this->isName($tmpuser, 'user')) { + return null; + } + + $data = $this->getRights($newnode); + if (!isset($data)) { + return; + } + + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + + return $method; + } + + if ($node instanceof Node\Expr\Empty_) { + // node is empty(...) so we set newnode to ... + $newnode = $node->expr; // name of node is perm + + $tmpperm = $newnode->var; //name of tmpperm is modulex + if (is_null($tmpperm)) { + return null; + } + + $tmprights = $tmpperm->var; // name of tmprights is 'rights' + if (is_null($tmprights)) { + return null; + } + if (!$this->isName($tmprights, 'rights')) { + $tmprights2 = $tmprights->var; // name of tmprights is 'rights' + if (is_null($tmprights2)) { + return null; + } + if (!$this->isName($tmprights2, 'rights')) { + return null; + } + $tmprights = $tmprights2; + } + + $tmpuser = $tmprights->var; // name of tmpuser is 'user' + if (!$this->isName($tmpuser, 'user')) { + return null; + } + + $data = $this->getRights($newnode); + if (!isset($data)) { + return; + } + + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + + return new Node\Expr\BooleanNot($method); + } + + return null; + } + + /** + * Get nodes with check empty + * + * @param BooleanAnd $booleanAnd A BooleandAnd + * @return TwoNodeMatch|null + */ + private function resolveTwoNodeMatch(BooleanAnd $booleanAnd): ?TwoNodeMatch + { + return $this->binaryOpManipulator->matchFirstAndSecondConditionNode( + $booleanAnd, + // $conf->global == $value + function (Node $node): bool { + if (!$node instanceof Equal) { + return \false; + } + return $this->isGlobalVar($node->left); + }, + // !empty(...) || isset(...) + function (Node $node): bool { + if ($node instanceof BooleanNot && $node->expr instanceof Empty_) { + return $this->isGlobalVar($node->expr->expr); + } + if (!$node instanceof Isset_) { + return $this->isGlobalVar($node); + } + return \true; + } + ); + } + + /** + * Check if node is a global access with format conf->global->XXX + * + * @param Node $node A node + * @return bool Return true if noe is conf->global->XXX + */ + private function isGlobalVar($node) + { + if (!$node instanceof PropertyFetch) { + return false; + } + if (!$this->isName($node->var, 'global')) { + return false; + } + $global = $node->var; + if (!$global instanceof PropertyFetch) { + return false; + } + if (!$this->isName($global->var, 'conf')) { + return false; + } + return true; + } + + /** + * @param Node $node Node to be parsed + * @return Node|void Return the name of the constant + */ + private function getConstName($node) + { + if ($node instanceof PropertyFetch && $node->name instanceof Node\Expr) { + return $node->name; + } + $name = $this->getName($node); + if (empty($name)) { + return; + } + return new String_($name); + } + + /** + * @param \PhpParser\Node\Expr\PropertyFetch $node node + * @return array|null + */ + private function getRights(Node\Expr\PropertyFetch $node) + { + $perm2 = ''; + if (!$node->var instanceof Node\Expr\PropertyFetch) { + return null; + } + // Add a test to avoid rector error on html.formsetup.class.php + if (!$node->name instanceof Node\Expr\Variable && is_null($this->getName($node))) { + //var_dump($node); + return null; + //exit; + } + $perm1 = $node->name instanceof Node\Expr\Variable ? $node->name : new String_($this->getName($node)); + $moduleNode = $node->var; + if (!$moduleNode instanceof Node\Expr\PropertyFetch) { + return null; + } + if (!$moduleNode->var instanceof Node\Expr\PropertyFetch) { + return null; + } + if (!$this->isName($moduleNode->var, 'rights')) { + $perm2 = $perm1; + $perm1 = $moduleNode->name instanceof Node\Expr\Variable ? $moduleNode->name : new String_($this->getName($moduleNode)); + $moduleNode = $moduleNode->var; + } + $module = $moduleNode->name instanceof Node\Expr\Variable ? $moduleNode->name : new String_($this->getName($moduleNode)); + $rights = $moduleNode->var; + if (!$this->isName($rights, 'rights') || !isset($perm1) || !isset($module)) { + return null; + } + if (!$rights->var instanceof Node\Expr\Variable) { + return null; + } + $user = $rights->var; + return compact('user', 'module', 'perm1', 'perm2'); + } +} diff --git a/htdocs/.gitignore b/htdocs/.gitignore index 0749df8a2bb..d0fe62f2e73 100644 --- a/htdocs/.gitignore +++ b/htdocs/.gitignore @@ -1,3 +1,4 @@ +/aaa* /allscreens* /ancot* /bootstrap* diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 0cf26f4820b..70f7c9ba975 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -169,10 +169,10 @@ class FormAdvTargetEmailing extends Form if (getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX')) { $sql_usr .= " AND u2.statut <> 0"; } - if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { + if (getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX')) { $sql_usr .= " AND u2.employee<>0 "; } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + if (getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX')) { $sql_usr .= " AND u2.fk_soc IS NULL "; } $sql_usr .= " ORDER BY name ASC"; diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 408d13837ab..cfc18095d6d 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -119,11 +119,11 @@ $usercanread = $user->hasRight("propal", "lire"); $usercancreate = $user->hasRight("propal", "creer"); $usercandelete = $user->hasRight("propal", "supprimer"); -$usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->propal->propal_advance->close))); -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->propal->propal_advance->validate))); -$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->propal->propal_advance->send))); +$usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('propal', 'propal_advance', 'close'))); +$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('propal', 'propal_advance', 'validate'))); +$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('propal', 'propal_advance', 'send'))); -$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); +$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); $usercancreateorder = $user->hasRight('commande', 'creer'); $usercancreateinvoice = $user->hasRight('facture', 'creer'); $usercancreatecontract = $user->hasRight('contrat', 'creer'); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index f3881a10aff..236a4675187 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -129,7 +129,7 @@ $usercancancel = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user $usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('commande', 'order_advance', 'send')); $usercangeneretedoc = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->hasRight('commande', 'order_advance', 'generetedoc')); -$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); +$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); $usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index dc4df918c7b..a5b1446524c 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -776,8 +776,8 @@ class Commande extends CommonOrder $error = 0; - $usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->commande->creer)) - || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->commande->order_advance->close))); + $usercanclose = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'creer')) + || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('commande', 'order_advance', 'close'))); if ($usercanclose) { if ($this->statut == self::STATUS_CLOSED) { diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 6bd2223a627..0d9b4912dd5 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -136,13 +136,13 @@ $error = 0; $listofchoices = array( 'selectinvoices'=>array('label'=>'Invoices', 'picto'=>'bill', 'lang'=>'bills', 'enabled' => isModEnabled('facture'), 'perms' => $user->hasRight('facture', 'lire')), - 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => !empty($user->rights->fournisseur->facture->lire)), - 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => !empty($user->rights->expensereport->lire)), - 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->don->lire)), - 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => !empty($user->rights->tax->charges->lire)), - 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => !empty($user->rights->salaries->read)), - 'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('banque'), 'perms' => !empty($user->rights->banque->lire)), - 'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => !empty($user->rights->loan->read)), + 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'picto'=>'supplier_invoice', 'lang'=>'bills', 'enabled' => isModEnabled('supplier_invoice'), 'perms' => $user->hasRight('fournisseur', 'facture', 'lire')), + 'selectexpensereports'=>array('label'=>'ExpenseReports', 'picto'=>'expensereport', 'lang'=>'trips', 'enabled' => isModEnabled('expensereport'), 'perms' => $user->hasRight('expensereport', 'lire')), + 'selectdonations'=>array('label'=>'Donations', 'picto'=>'donation', 'lang'=>'donation', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('don', 'lire')), + 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'picto'=>'bill', 'enabled' => isModEnabled('tax'), 'perms' => $user->hasRight('tax', 'charges', 'lire')), + 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'picto'=>'salary', 'lang'=>'salaries', 'enabled' => isModEnabled('salaries'), 'perms' => $user->hasRight('salaries', 'read')), + 'selectvariouspayment'=>array('label'=>'VariousPayment', 'picto'=>'payment', 'enabled' => isModEnabled('banque'), 'perms' => $user->hasRight('banque', 'lire')), + 'selectloanspayment'=>array('label'=>'PaymentLoan','picto'=>'loan', 'enabled' => isModEnabled('don'), 'perms' => $user->hasRight('loan', 'read')), ); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index c12b7801f43..4f98aa5ede5 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -235,7 +235,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (empty($reshook)) { $objectclass = 'Account'; $objectlabel = 'BankTransaction'; - $permissiontoread = !empty($user->rights->banque->lire); + $permissiontoread = $user->hasRight('banque', 'lire'); $permissiontodelete = $user->hasRight('banque', 'modifier'); $uploaddir = $conf->bank->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 95e39c12eb0..cecb69e37ac 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -122,9 +122,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); -$permissiontoadd = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); -$permissiontodelete = (!empty($user->rights->cashdesk->run) || !empty($user->rights->takepos->run)); +$permissiontoread = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run')); +$permissiontoadd = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run')); +$permissiontodelete = ($user->hasRight('cashdesk', 'run') || $user->hasRight('takepos', 'run')); // Security check if ($user->socid > 0) { // Protection if external user diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index b2aff1082f2..60c24419459 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -115,12 +115,12 @@ $usercanread = $user->hasRight('facture', 'lire'); $usercancreate = $user->hasRight('facture', 'creer'); $usercanissuepayment = $user->hasRight('facture', 'paiement'); $usercandelete = $user->hasRight('facture', 'supprimer'); -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->validate))); +$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'validate'))); $usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->send); $usercanreopen = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->rights->facture->invoice_advance->reopen); -$usercanunvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'unvalidate'))); -$usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); +$usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); $usercancreatemargin = $user->hasRight("margins", "creer"); $usercanreadallmargin = $user->hasRight("margins", "liretous"); $usercancreatewithdrarequest = $user->hasRight("prelevement", "bons", "creer"); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index bdd079d5163..0dda399bbd0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -144,18 +144,18 @@ $usercandelete = $user->hasRight("facture", "supprimer"); $usercancreatecontract = $user->hasRight("contrat", "creer"); // Advanced Permissions -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->validate))); -$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->send))); -$usercanreopen = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->reopen))); +$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'validate'))); +$usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'send'))); +$usercanreopen = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'reopen'))); if (getDolGlobalString('INVOICE_DISALLOW_REOPEN')) { $usercanreopen = false; } -$usercanunvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->facture->invoice_advance->unvalidate))); +$usercanunvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'unvalidate'))); -$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); -$usercancreatemargin = (!empty($user->rights->margins->creer) ? $user->rights->margins->creer : 0); -$usercanreadallmargin = (!empty($user->rights->margins->liretous) ? $user->rights->margins->liretous : 0); -$usercancreatewithdrarequest = (!empty($user->rights->prelevement->bons->creer) ? $user->rights->prelevement->bons->creer : 0); +$usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); +$usercancreatemargin = ($user->hasRight('margins', 'creer') ? $user->rights->margins->creer : 0); +$usercanreadallmargin = ($user->hasRight('margins', 'liretous') ? $user->rights->margins->liretous : 0); +$usercancreatewithdrarequest = ($user->hasRight('prelevement', 'bons', 'creer') ? $user->rights->prelevement->bons->creer : 0); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index cefddec879a..c2f9de79313 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -243,10 +243,10 @@ $arrayfields = array( 'f.multicurrency_total_ttc'=>array('label'=>'MulticurrencyAmountTTC', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>292), 'multicurrency_dynamount_payed'=>array('label'=>'MulticurrencyAlreadyPaid', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>295), 'multicurrency_rtp'=>array('label'=>'MulticurrencyRemainderToPay', 'checked'=>0, 'enabled'=>(!isModEnabled('multicurrency') ? 0 : 1), 'position'=>296), // Not enabled by default because slow - 'total_pa' => array('label' => ((getDolGlobalString('MARGIN_TYPE') == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) ? 0 : 1)), - 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)), - 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || empty($user->rights->margins->liretous) || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)), + 'total_pa' => array('label' => ((getDolGlobalString('MARGIN_TYPE') == '1') ? 'BuyingPrice' : 'CostPrice'), 'checked' => 0, 'position' => 300, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), + 'total_margin' => array('label' => 'Margin', 'checked' => 0, 'position' => 301, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') ? 0 : 1)), + 'total_margin_rate' => array('label' => 'MarginRate', 'checked' => 0, 'position' => 302, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARGIN_RATES') ? 0 : 1)), + 'total_mark_rate' => array('label' => 'MarkRate', 'checked' => 0, 'position' => 303, 'enabled' => (!isModEnabled('margin') || !$user->hasRight('margins', 'liretous') || !getDolGlobalString('DISPLAY_MARK_RATES') ? 0 : 1)), 'f.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500), 'f.tms' =>array('type'=>'timestamp', 'label'=>'DateModificationShort', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>502), 'u.login'=>array('label'=>"UserAuthor", 'checked'=>1, 'position'=>504), diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php index 4f2042f6d2e..351d9372869 100644 --- a/htdocs/core/boxes/box_boms.php +++ b/htdocs/core/boxes/box_boms.php @@ -49,7 +49,7 @@ class box_boms extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->bom->read); + $this->hidden = !$user->hasRight('bom', 'read'); } /** diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 0d842ebca8c..8fbdfbabda6 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -45,7 +45,7 @@ class box_bookmarks extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->bookmark->lire); + $this->hidden = !$user->hasRight('bookmark', 'lire'); } /** diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index c3f1956729d..986d4560c32 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -49,7 +49,7 @@ class box_commandes extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->commande->lire); + $this->hidden = !$user->hasRight('commande', 'lire'); } /** diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 5f53fb46e26..045ffec244b 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -58,7 +58,7 @@ class box_comptes extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = empty($user->rights->banque->lire); + $this->hidden = !$user->hasRight('banque', 'lire'); } /** diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 7971a47eed2..18685e0d192 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -57,7 +57,7 @@ class box_funnel_of_prospection extends ModeleBoxes $this->enabled = (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 1 ? 1 : 0); // Not enabled by default, still need some work //$this->enabled = 1; - $this->hidden = empty($user->rights->projet->lire); + $this->hidden = !$user->hasRight('projet', 'lire'); } /** diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index f2ec9eb705a..97fa847f897 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -47,7 +47,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->fournisseur->facture->lire); + $this->hidden = !$user->hasRight('fournisseur', 'facture', 'lire'); } /** diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 91da3ff4141..f0021fe403a 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -47,7 +47,7 @@ class box_graph_orders_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->commande->lire); + $this->hidden = !$user->hasRight('commande', 'lire'); } /** diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index e4b61c93068..ca1da74b1bc 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -47,7 +47,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->fournisseur->commande->lire); + $this->hidden = !$user->hasRight('fournisseur', 'commande', 'lire'); } /** diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index 80f67b9b54d..796ba81a306 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -47,7 +47,7 @@ class box_graph_propales_permonth extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->propal->lire); + $this->hidden = !$user->hasRight('propal', 'lire'); } /** diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php index f7ef09fe632..c29cb773c33 100644 --- a/htdocs/core/boxes/box_mos.php +++ b/htdocs/core/boxes/box_mos.php @@ -49,7 +49,7 @@ class box_mos extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->bom->read); + $this->hidden = !$user->hasRight('bom', 'read'); } /** diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index 3e0b56acc6e..2fd1d9f2525 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -53,7 +53,7 @@ class box_produits_alerte_stock extends ModeleBoxes $this->db = $db; $listofmodulesforexternal = explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')); - $tmpentry = array('enabled'=>((isModEnabled("product") || isModEnabled("service")) && isModEnabled('stock')), 'perms'=>!empty($user->rights->stock->lire), 'module'=>'product|service|stock'); + $tmpentry = array('enabled'=>((isModEnabled("product") || isModEnabled("service")) && isModEnabled('stock')), 'perms'=>$user->hasRight('stock', 'lire'), 'module'=>'product|service|stock'); $showmode = isVisibleToUserType(($user->socid > 0 ? 1 : 0), $tmpentry, $listofmodulesforexternal); $this->hidden = ($showmode != 1); } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 95377278a45..974e869b1a7 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -52,7 +52,7 @@ class box_project extends ModeleBoxes $this->db = $db; $this->boxlabel = "OpenedProjects"; - $this->hidden = empty($user->rights->projet->lire); + $this->hidden = !$user->hasRight('projet', 'lire'); } /** diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php index b37dd0f74b6..e338b5782a1 100644 --- a/htdocs/core/boxes/box_shipments.php +++ b/htdocs/core/boxes/box_shipments.php @@ -49,7 +49,7 @@ class box_shipments extends ModeleBoxes $this->db = $db; - $this->hidden = empty($user->rights->expedition->lire); + $this->hidden = !$user->hasRight('expedition', 'lire'); } /** diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 8bbedfa38f5..170dd59e4b1 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -54,7 +54,7 @@ class box_task extends ModeleBoxes $this->boxlabel = "Tasks"; $this->db = $db; - $this->hidden = (getDolGlobalString('PROJECT_HIDE_TASKS') || empty($user->rights->projet->lire)); + $this->hidden = (getDolGlobalString('PROJECT_HIDE_TASKS') || !$user->hasRight('projet', 'lire')); } /** diff --git a/htdocs/core/boxes/box_validated_projects.php b/htdocs/core/boxes/box_validated_projects.php index ff020b312d6..8732e7d49f0 100644 --- a/htdocs/core/boxes/box_validated_projects.php +++ b/htdocs/core/boxes/box_validated_projects.php @@ -56,7 +56,7 @@ class box_validated_projects extends ModeleBoxes $this->db = $db; $this->boxlabel = "ProjectTasksWithoutTimeSpent"; - $this->hidden = empty($user->rights->projet->lire); + $this->hidden = !$user->hasRight('projet', 'lire'); if (getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) { $this->enabled = 0; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 77c64a9bf05..59c89d462c6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2081,10 +2081,10 @@ class Form if (getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX') || $notdisabled) { $sql .= " AND u.statut <> 0"; } - if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX) || $notdisabled) { + if (getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX') || $notdisabled) { $sql .= " AND u.employee <> 0"; } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX) || $notdisabled) { + if (getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX') || $notdisabled) { $sql .= " AND u.fk_soc IS NULL"; } if (!empty($morefilter)) { diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5ca638470c4..a1dd2402392 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -397,7 +397,7 @@ class FormFile $printer = 0; // The direct print feature is implemented only for such elements if (in_array($modulepart, array('contract', 'facture', 'supplier_proposal', 'propal', 'proposal', 'order', 'commande', 'expedition', 'commande_fournisseur', 'expensereport', 'delivery', 'ticket'))) { - $printer = (!empty($user->rights->printing->read) && !empty($conf->printing->enabled)) ? true : false; + $printer = ($user->hasRight('printing', 'read') && !empty($conf->printing->enabled)) ? true : false; } $hookmanager->initHooks(array('formfile')); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 5f4eb854b31..c0758ca9661 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -522,13 +522,13 @@ class FormOther if (!empty($user->socid)) { $sql_usr .= " AND u.fk_soc = ".((int) $user->socid); } - if (!empty($conf->global->USER_HIDE_NONEMPLOYEE_IN_COMBOBOX)) { + if (getDolGlobalString('USER_HIDE_NONEMPLOYEE_IN_COMBOBOX')) { $sql_usr .= " AND u.employee <> 0"; } - if (!empty($conf->global->USER_HIDE_EXTERNAL_IN_COMBOBOX)) { + if (getDolGlobalString('USER_HIDE_EXTERNAL_IN_COMBOBOX')) { $sql_usr .= " AND u.fk_soc IS NULL"; } - if (!empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { + if (getDolGlobalString('USER_HIDE_INACTIVE_IN_COMBOBOX')) { $sql_usr .= " AND u.statut <> 0"; } diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 85b904d53c3..199118ddb75 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -296,9 +296,9 @@ $arrayfields = array( $param = 'id='.$object->id.'&mainmenu=home'; -/** - * Show list - */ + +// Show list of contact links + print '
'; print ''; print ''; From 334563d282d294a245081c915afd51008df28915 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 16:03:59 +0100 Subject: [PATCH 46/90] Fix template to use v19 dev rules --- htdocs/modulebuilder/template/class/myobject.class.php | 4 ++-- .../template/core/modules/modMyModule.class.php | 6 +++--- htdocs/modulebuilder/template/mymoduleindex.php | 10 ++-------- htdocs/modulebuilder/template/myobject_agenda.php | 4 ++-- htdocs/modulebuilder/template/myobject_contact.php | 4 ++-- htdocs/modulebuilder/template/myobject_document.php | 8 ++++---- htdocs/modulebuilder/template/myobject_note.php | 6 +++--- 7 files changed, 18 insertions(+), 24 deletions(-) diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 47388ead754..de25cdc5fbc 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -617,8 +617,8 @@ class MyObject extends CommonObject return 0; } - /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write')) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->mymodule->myobject->myobject_advance->validate)))) + /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject', 'write')) + || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject_advance', 'validate'))) { $this->error='NotEnoughPermissions'; dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 17c832df13b..889804e87db 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -177,8 +177,8 @@ class modMyModule extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 - // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->hasRight('mymodule', 'read'):/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->hasRight('othermodule', 'read'):/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be @@ -290,7 +290,7 @@ class modMyModule extends DolibarrModules $this->rights[$r][0] = $this->numero . sprintf("%02d", ($o * 10) + 3); // Permission id (must not be already used) $this->rights[$r][1] = 'Delete objects of MyModule'; // Permission label $this->rights[$r][4] = 'myobject'; - $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->myobject->delete) + $this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->hasRight('mymodule', 'myobject', 'delete')) $r++; */ /* END MODULEBUILDER PERMISSIONS */ diff --git a/htdocs/modulebuilder/template/mymoduleindex.php b/htdocs/modulebuilder/template/mymoduleindex.php index 59dbe92439d..f11670f0906 100644 --- a/htdocs/modulebuilder/template/mymoduleindex.php +++ b/htdocs/modulebuilder/template/mymoduleindex.php @@ -111,19 +111,16 @@ print '
'; /* BEGIN MODULEBUILDER DRAFT MYOBJECT // Draft MyObject -if (isModEnabled('mymodule') && $user->rights->mymodule->read) -{ +if (isModEnabled('mymodule') && $user->hasRight('mymodule', 'read')) { $langs->load("orders"); $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; $sql.= ", ".MAIN_DB_PREFIX."societe as s"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.fk_statut = 0"; $sql.= " AND c.entity IN (".getEntity('commande').")"; - if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid); $resql = $db->query($sql); @@ -192,13 +189,10 @@ $max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT'); /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT // Last modified myobject -if (isModEnabled('mymodule') && $user->rights->mymodule->read) -{ +if (isModEnabled('mymodule') && $user->hasRight('mymodule', 'read')) { $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject as s"; - //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")"; - //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); //if ($socid) $sql.= " AND s.rowid = $socid"; $sql .= " ORDER BY s.tms DESC"; $sql .= $db->plimit($max, 0); diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 646a8406d06..074fc8cb44b 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -136,8 +136,8 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; + $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read'); + $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); } else { $permissiontoread = 1; $permissiontoadd = 1; diff --git a/htdocs/modulebuilder/template/myobject_contact.php b/htdocs/modulebuilder/template/myobject_contact.php index 93bd0cee267..f7669ae118d 100644 --- a/htdocs/modulebuilder/template/myobject_contact.php +++ b/htdocs/modulebuilder/template/myobject_contact.php @@ -83,8 +83,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; + $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read'); + $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); } else { $permissiontoread = 1; $permissiontoadd = 1; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 19b1a7ceed3..6a891511801 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -130,8 +130,8 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php + $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read'); + $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php } else { $permissiontoread = 1; $permissiontoadd = 1; @@ -251,9 +251,9 @@ print '
'; print dol_get_fiche_end(); $modulepart = 'mymodule'; -//$permissiontoadd = $user->rights->mymodule->myobject->write; +//$permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); $permissiontoadd = 1; -//$permtoedit = $user->rights->mymodule->myobject->write; +//$permtoedit = $user->hasRight('mymodule', 'myobject', 'write'); $permtoedit = 1; $param = '&id='.$object->id; diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index ef4bde7ecf9..c0edbbeffae 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -108,9 +108,9 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->mymodule->myobject->read; - $permissiontoadd = $user->rights->mymodule->myobject->write; - $permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php + $permissiontoread = $user->hasRight('mymodule', 'myobject', 'read'); + $permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); + $permissionnote = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_setnotes.inc.php } else { $permissiontoread = 1; $permissiontoadd = 1; From 52e8d71d65f901804c1681d418589f8be8eb19a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 16:04:32 +0100 Subject: [PATCH 47/90] Fix use v19 dev rules --- htdocs/bom/bom_agenda.php | 3 +-- htdocs/bom/bom_card.php | 22 +++++++++------------- htdocs/bom/class/bom.class.php | 29 ----------------------------- 3 files changed, 10 insertions(+), 44 deletions(-) diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 794622791a0..d4fb24d6daa 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -159,8 +159,7 @@ if ($object->id > 0) { { $langs->load("projects"); $morehtmlref.='
'.$langs->trans('Project') . ' '; - if ($user->rights->bom->creer) - { + if ($user->hasRight('bom', 'creer')) { if ($action != 'classify') //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 5b105fda2cf..5dda67de5a3 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -513,8 +513,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $morehtmlref = '
'; /* // Ref bis - $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', 0, 1); - $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->bom->creer, 'string', '', null, null, '', 1); + $morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->hasRight('bom', 'creer'), 'string', '', 0, 1); + $morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->hasRight('bom', 'creer'), 'string', '', null, null, '', 1); // Thirdparty $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1); // Project @@ -759,18 +759,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } /* - if ($user->rights->bom->write) - { - if ($object->status == 1) - { - print ''.$langs->trans("Disable").''."\n"; + if ($user->hasRight('bom', 'write')) { + if ($object->status == 1) { + print ''.$langs->trans("Disable").''."\n"; + } else { + print ''.$langs->trans("Enable").''."\n"; + } } - else - { - print ''.$langs->trans("Enable").''."\n"; - } - } - */ + */ // Delete print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 94e93d1d631..4e50f993090 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -931,14 +931,6 @@ class BOM extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->create)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - $now = dol_now(); $this->db->begin(); @@ -1051,13 +1043,6 @@ class BOM extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'BOM_UNVALIDATE'); } @@ -1075,13 +1060,6 @@ class BOM extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'BOM_CLOSE'); } @@ -1099,13 +1077,6 @@ class BOM extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'BOM_REOPEN'); } From 24a8c2e66a569c2c21f3ad2dda85cc329494f521 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 16:23:09 +0100 Subject: [PATCH 48/90] Fix phpunit --- .../src/Renaming/UserRightsToFunction.php | 23 ++++++++++++++++++- htdocs/bom/tpl/objectline_title.tpl.php | 4 ++-- htdocs/bom/tpl/objectline_view.tpl.php | 4 ++-- htdocs/user/class/api_users.class.php | 8 +++---- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index 5a141ddad5b..5d732c6ffa3 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -74,9 +74,30 @@ class UserRightsToFunction extends AbstractRector } } } + if ($node instanceof Node\Expr\Assign) { - return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN; + // var is left of = and expr is right + if (!isset($node->var)) { + return; + } + + if (!$node->expr instanceof Node\Expr\PropertyFetch) { + return; + } + + $data = $this->getRights($node->expr); + if (!isset($data)) { + return; + } + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $node->expr = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + + return $node; } + $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { if (!$node->expr instanceof Node\Expr\Empty_) { diff --git a/htdocs/bom/tpl/objectline_title.tpl.php b/htdocs/bom/tpl/objectline_title.tpl.php index 703feaccf14..680ac6d1079 100644 --- a/htdocs/bom/tpl/objectline_title.tpl.php +++ b/htdocs/bom/tpl/objectline_title.tpl.php @@ -24,8 +24,8 @@ * $object (invoice, order, ...) * $conf * $langs - * $element (used to test $user->rights->$element->creer) - * $permtoedit (used to replace test $user->rights->$element->creer) + * $element (used to test $user->hasRight($element, 'creer')) + * $permtoedit (used to replace test $user->hasRight($element, 'creer')) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $outputalsopricetotalwithtax * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 32e976b9848..f01a7600c18 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -25,8 +25,8 @@ * $conf * $langs * $forceall (0 by default, 1 for supplier invoices/orders) - * $element (used to test $user->rights->$element->creer) - * $permtoedit (used to replace test $user->rights->$element->creer) + * $element (used to test $user->hasRight($element, 'creer')) + * $permtoedit (used to replace test $user->hasRight($element, 'creer')) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $object_rights->creer initialized from = $object->getRights() * $disableedit, $disablemove, $disableremove diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index faaff5fb032..d2f406442b2 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -148,7 +148,7 @@ class Users extends DolibarrApi */ public function get($id, $includepermissions = 0) { - if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && $id != 0 && DolibarrApiAccess::$user->id != $id) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin) && $id != 0 && DolibarrApiAccess::$user->id != $id) { throw new RestException(401, 'Not allowed'); } @@ -191,7 +191,7 @@ class Users extends DolibarrApi throw new RestException(400, 'Bad parameters'); } - if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->login != $login) { throw new RestException(401, 'Not allowed'); } @@ -230,7 +230,7 @@ class Users extends DolibarrApi throw new RestException(400, 'Bad parameters'); } - if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->email != $email) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin) && DolibarrApiAccess::$user->email != $email) { throw new RestException(401, 'Not allowed'); } @@ -442,7 +442,7 @@ class Users extends DolibarrApi */ public function getGroups($id) { - if (empty(DolibarrApiAccess::$user->hasRight('user', 'user', 'lire')) && empty(DolibarrApiAccess::$user->admin)) { + if (!DolibarrApiAccess::$user->hasRight('user', 'user', 'lire') && empty(DolibarrApiAccess::$user->admin)) { throw new RestException(403); } From 6b73cdeac72c3eb3249a71052e8ebaabfed7885b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 16:28:57 +0100 Subject: [PATCH 49/90] Debug v19 --- htdocs/modulebuilder/template/myobject_document.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 6a891511801..5c36a559723 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -251,12 +251,7 @@ print '
'; print dol_get_fiche_end(); $modulepart = 'mymodule'; -//$permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); -$permissiontoadd = 1; -//$permtoedit = $user->hasRight('mymodule', 'myobject', 'write'); -$permtoedit = 1; $param = '&id='.$object->id; - //$relativepathwithnofile='myobject/' . dol_sanitizeFileName($object->id).'/'; $relativepathwithnofile = 'myobject/'.dol_sanitizeFileName($object->ref).'/'; From 8e6109c89701589c604d0aaf43dd1cf91f8ff859 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 16:29:10 +0100 Subject: [PATCH 50/90] Clean code --- htdocs/workstation/workstation_document.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/workstation/workstation_document.php b/htdocs/workstation/workstation_document.php index 4510cd39023..5dba65f6776 100644 --- a/htdocs/workstation/workstation_document.php +++ b/htdocs/workstation/workstation_document.php @@ -184,12 +184,7 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'workstation'; - //$permission = $user->rights->workstation->workstation->write; - $permission = 1; - //$permtoedit = $user->rights->workstation->workstation->write; - $permtoedit = 1; $param = '&id='.$object->id; - //$relativepathwithnofile='workstation/' . dol_sanitizeFileName($object->id).'/'; $relativepathwithnofile = 'workstation/'.dol_sanitizeFileName($object->ref).'/'; From 758ccb0c5b523eca466584a2fdf30d878cd0382d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 4 Feb 2024 17:27:57 +0100 Subject: [PATCH 51/90] Use rector to convert user->rights into user->hasRight --- .../src/Renaming/UserRightsToFunction.php | 36 ++++++++++++------- htdocs/bookcal/calendar_agenda.php | 4 +-- htdocs/bookcal/calendar_contact.php | 4 +-- htdocs/bookcal/calendar_document.php | 4 +-- htdocs/bookcal/calendar_note.php | 6 ++-- htdocs/categories/viewcat.php | 2 +- htdocs/comm/action/list.php | 2 +- htdocs/comm/propal/document.php | 6 ++-- htdocs/comm/propal/note.php | 2 +- htdocs/commande/document.php | 4 +-- htdocs/commande/note.php | 2 +- .../bank/account_statement_document.php | 6 ++-- htdocs/compta/bank/document.php | 6 ++-- htdocs/compta/bank/list.php | 4 +-- .../compta/bank/various_payment/document.php | 4 +-- htdocs/compta/deplacement/card.php | 4 +-- htdocs/compta/deplacement/document.php | 4 +-- htdocs/compta/paiement/cheque/card.php | 8 ++--- htdocs/compta/paymentbybanktransfer/index.php | 2 +- htdocs/compta/prelevement/index.php | 2 +- htdocs/compta/prelevement/orders_list.php | 4 +-- htdocs/compta/sociales/card.php | 10 +++--- htdocs/compta/sociales/document.php | 6 ++-- htdocs/compta/sociales/note.php | 6 ++-- htdocs/compta/tva/card.php | 10 +++--- htdocs/compta/tva/document.php | 6 ++-- htdocs/contrat/messaging.php | 6 ++-- htdocs/core/ajax/ajaxdirpreview.php | 2 +- htdocs/core/lib/files.lib.php | 4 +-- htdocs/core/tpl/notes.tpl.php | 2 +- htdocs/cron/list.php | 6 ++-- htdocs/delivery/card.php | 8 ++--- htdocs/don/card.php | 4 +-- htdocs/don/document.php | 6 ++-- htdocs/don/note.php | 2 +- htdocs/ecm/dir_add_card.php | 6 ++-- htdocs/ecm/file_card.php | 6 ++-- htdocs/ecm/file_note.php | 4 +-- htdocs/ecm/search.php | 2 +- .../class/emailcollector.class.php | 2 +- .../conferenceorbooth_card.php | 12 +++---- .../conferenceorbooth_contact.php | 8 ++--- .../conferenceorbooth_document.php | 8 ++--- .../conferenceorbooth_list.php | 6 ++-- .../conferenceorboothattendee_card.php | 12 +++---- .../conferenceorboothattendee_list.php | 6 ++-- .../conferenceorboothattendee_note.php | 4 +-- htdocs/expedition/card.php | 8 ++--- htdocs/expedition/document.php | 6 ++-- htdocs/expedition/list.php | 10 +++--- htdocs/expedition/note.php | 2 +- htdocs/expensereport/card.php | 12 +++---- htdocs/expensereport/document.php | 6 ++-- htdocs/expensereport/list.php | 8 ++--- htdocs/expensereport/note.php | 2 +- .../tpl/expensereport_addfile.tpl.php | 2 +- htdocs/fichinter/card.php | 6 ++-- htdocs/fichinter/document.php | 4 +-- htdocs/fichinter/list.php | 6 ++-- htdocs/fichinter/note.php | 2 +- htdocs/holiday/card.php | 4 +-- htdocs/holiday/document.php | 6 ++-- htdocs/hrm/evaluation_agenda.php | 4 +-- htdocs/hrm/evaluation_card.php | 14 ++++---- htdocs/hrm/evaluation_contact.php | 2 +- htdocs/hrm/evaluation_document.php | 4 +-- htdocs/hrm/evaluation_note.php | 4 +-- htdocs/hrm/job_agenda.php | 4 +-- htdocs/hrm/job_card.php | 10 +++--- htdocs/hrm/job_document.php | 4 +-- htdocs/hrm/job_list.php | 6 ++-- htdocs/hrm/job_note.php | 4 +-- htdocs/hrm/position.php | 6 ++-- htdocs/hrm/position_agenda.php | 4 +-- htdocs/hrm/position_card.php | 8 ++--- htdocs/hrm/position_document.php | 4 +-- htdocs/hrm/position_list.php | 6 ++-- htdocs/hrm/position_note.php | 4 +-- htdocs/hrm/skill_agenda.php | 4 +-- htdocs/hrm/skill_card.php | 6 ++-- htdocs/hrm/skill_document.php | 4 +-- htdocs/hrm/skill_note.php | 4 +-- htdocs/imports/class/import.class.php | 2 +- htdocs/intracommreport/card.php | 6 ++-- htdocs/intracommreport/list.php | 4 +-- htdocs/loan/document.php | 6 ++-- htdocs/loan/note.php | 4 +-- htdocs/main.inc.php | 14 ++++---- htdocs/mrp/ajax/interface.php | 2 +- htdocs/mrp/mo_card.php | 8 ++--- htdocs/mrp/mo_document.php | 6 ++-- htdocs/mrp/mo_list.php | 6 ++-- htdocs/mrp/mo_movements.php | 6 ++-- htdocs/mrp/mo_note.php | 2 +- htdocs/mrp/mo_production.php | 6 ++-- htdocs/opensurvey/card.php | 6 ++-- htdocs/opensurvey/list.php | 6 ++-- htdocs/partnership/partnership_agenda.php | 4 +-- htdocs/partnership/partnership_contact.php | 4 +-- htdocs/partnership/partnership_document.php | 4 +-- htdocs/partnership/partnership_list.php | 6 ++-- htdocs/partnership/partnership_note.php | 6 ++-- htdocs/product/inventory/card.php | 24 ++++++------- htdocs/product/inventory/inventory.php | 8 ++--- htdocs/product/inventory/list.php | 6 ++-- htdocs/product/list.php | 8 ++--- htdocs/product/stock/card.php | 8 ++--- htdocs/product/stock/info.php | 2 +- htdocs/product/stock/list.php | 10 +++--- htdocs/product/stock/movement_card.php | 16 ++++----- htdocs/product/stock/movement_list.php | 12 +++---- htdocs/product/stock/productlot_document.php | 2 +- htdocs/product/stock/productlot_list.php | 6 ++-- htdocs/product/stock/productlot_note.php | 2 +- .../stocktransfer/stocktransfer_agenda.php | 2 +- .../stocktransfer/stocktransfer_card.php | 8 ++--- .../stocktransfer/stocktransfer_contact.php | 2 +- .../stocktransfer/stocktransfer_document.php | 2 +- .../stocktransfer/stocktransfer_note.php | 4 +-- htdocs/projet/card.php | 2 +- htdocs/projet/index.php | 2 +- htdocs/projet/tasks/task.php | 2 +- htdocs/public/webportal/tpl/menu.tpl.php | 2 +- .../public/webportal/webportal.main.inc.php | 4 +-- htdocs/reception/card.php | 24 ++++++------- htdocs/reception/contact.php | 20 +++++------ htdocs/reception/dispatch.php | 8 ++--- htdocs/reception/document.php | 24 ++++++------- htdocs/reception/list.php | 6 ++-- htdocs/reception/note.php | 22 ++++++------ htdocs/resource/card.php | 6 ++-- .../class/html.formresource.class.php | 2 +- htdocs/resource/document.php | 4 +-- htdocs/resource/note.php | 4 +-- htdocs/salaries/list.php | 6 ++-- htdocs/salaries/payments.php | 6 ++-- htdocs/salaries/virement_request.php | 4 +-- htdocs/societe/card.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- htdocs/societe/paymentmodes.php | 2 +- htdocs/societe/website.php | 4 +-- htdocs/supplier_proposal/card.php | 10 +++--- htdocs/supplier_proposal/document.php | 6 ++-- htdocs/supplier_proposal/list.php | 8 ++--- htdocs/supplier_proposal/note.php | 2 +- htdocs/takepos/invoice.php | 4 +-- htdocs/ticket/agenda.php | 2 +- htdocs/ticket/contact.php | 4 +-- htdocs/ticket/document.php | 6 ++-- htdocs/ticket/list.php | 6 ++-- htdocs/ticket/messaging.php | 2 +- htdocs/user/bank.php | 2 +- htdocs/user/group/ldap.php | 2 +- htdocs/user/notify/card.php | 2 +- htdocs/variants/card.php | 8 ++--- htdocs/webportal/class/context.class.php | 4 +-- .../class/html.formwebportal.class.php | 2 +- .../webportal/class/webPortalTheme.class.php | 6 ++-- .../webportal/class/webportalmember.class.php | 18 +++++----- .../class/webportalpartnership.class.php | 2 +- .../controllers/document.controller.class.php | 2 +- htdocs/website/index.php | 4 +-- htdocs/workstation/workstation_note.php | 4 +-- 163 files changed, 482 insertions(+), 472 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index 5d732c6ffa3..af9a4d6e3e3 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -75,6 +75,7 @@ class UserRightsToFunction extends AbstractRector } } + if ($node instanceof Node\Expr\Assign) { // var is left of = and expr is right if (!isset($node->var)) { @@ -98,37 +99,46 @@ class UserRightsToFunction extends AbstractRector return $node; } + $caseok = false; // Will be tru if we can make the replacement. We must not do it for assignement like when $user->right->aaa->bbb = ... $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { if (!$node->expr instanceof Node\Expr\Empty_) { return null; } $node = $node->expr->expr; + $caseok = true; } if ($node instanceof Node\Expr\Empty_) { $node = $node->expr; $isInverse = true; + $caseok = true; } if ($node instanceof Node\Expr\Isset_) { // Take first arg for isset (No code found with multiple isset). $node = $node->vars[0]; + $caseok = true; } if (!$node instanceof Node\Expr\PropertyFetch) { - return; + return null; } - $data = $this->getRights($node); - if (!isset($data)) { - return; + + if ($caseok) { + $data = $this->getRights($node); + if (!isset($data)) { + return; + } + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + if ($isInverse) { + return new Node\Expr\BooleanNot($method); + } + return $method; + } else { + return null; } - $args = [new Arg($data['module']), new Arg($data['perm1'])]; - if (!empty($data['perm2'])) { - $args[] = new Arg($data['perm2']); - } - $method = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); - if ($isInverse) { - return new Node\Expr\BooleanNot($method); - } - return $method; } /** diff --git a/htdocs/bookcal/calendar_agenda.php b/htdocs/bookcal/calendar_agenda.php index e882d054f45..deb1f993471 100644 --- a/htdocs/bookcal/calendar_agenda.php +++ b/htdocs/bookcal/calendar_agenda.php @@ -88,8 +88,8 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->calendar->read; - $permissiontoadd = $user->rights->bookcal->calendar->write; + $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read'); + $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); } else { $permissiontoread = 1; $permissiontoadd = 1; diff --git a/htdocs/bookcal/calendar_contact.php b/htdocs/bookcal/calendar_contact.php index a102542f5ca..8247fa2ca74 100644 --- a/htdocs/bookcal/calendar_contact.php +++ b/htdocs/bookcal/calendar_contact.php @@ -83,8 +83,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->calendar->read; - $permission = $user->rights->bookcal->calendar->write; + $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read'); + $permission = $user->hasRight('bookcal', 'calendar', 'write'); } else { $permissiontoread = 1; $permission = 1; diff --git a/htdocs/bookcal/calendar_document.php b/htdocs/bookcal/calendar_document.php index 07df7276c3a..b45c082c6ae 100644 --- a/htdocs/bookcal/calendar_document.php +++ b/htdocs/bookcal/calendar_document.php @@ -127,8 +127,8 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->calendar->read; - $permissiontoadd = $user->rights->bookcal->calendar->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php + $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read'); + $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php } else { $permissiontoread = 1; $permissiontoadd = 1; diff --git a/htdocs/bookcal/calendar_note.php b/htdocs/bookcal/calendar_note.php index 69c30f892bb..31f47504264 100644 --- a/htdocs/bookcal/calendar_note.php +++ b/htdocs/bookcal/calendar_note.php @@ -105,9 +105,9 @@ if ($id > 0 || !empty($ref)) { // Set $enablepermissioncheck to 1 to enable a minimum low level of checks $enablepermissioncheck = 0; if ($enablepermissioncheck) { - $permissiontoread = $user->rights->bookcal->calendar->read; - $permissiontoadd = $user->rights->bookcal->calendar->write; - $permissionnote = $user->rights->bookcal->calendar->write; // Used by the include of actions_setnotes.inc.php + $permissiontoread = $user->hasRight('bookcal', 'calendar', 'read'); + $permissiontoadd = $user->hasRight('bookcal', 'calendar', 'write'); + $permissionnote = $user->hasRight('bookcal', 'calendar', 'write'); // Used by the include of actions_setnotes.inc.php } else { $permissiontoread = 1; $permissiontoadd = 1; diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 75fcab83c19..a7a13ff64d1 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1025,7 +1025,7 @@ if ($type == Categorie::TYPE_PROJECT) { if ($user->hasRight("project", "read")) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $permission = $user->rights->projet->creer; + $permission = $user->hasRight('projet', 'creer'); $objects = $object->getObjectsInCateg($type, 0, $limit, $offset); if ($objects < 0) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 9e7faf0f372..301216c6567 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -267,7 +267,7 @@ if (empty($reshook)) { $objectlabel = 'Events'; $uploaddir = true; // Only users that can delete any event can remove records. - $permissiontodelete = $user->rights->agenda->allactions->delete; + $permissiontodelete = $user->hasRight('agenda', 'allactions', 'delete'); $permissiontoadd = $user->hasRight('agenda', 'myactions', 'create'); include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 9c83eafad02..00ec2367c8a 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -74,7 +74,7 @@ if (!$sortfield) { $object = new Propal($db); $object->fetch($id, $ref); -$permissiontoadd = $user->rights->propal->creer; +$permissiontoadd = $user->hasRight('propal', 'creer'); // Security check $socid = ''; @@ -174,8 +174,8 @@ if ($object->id > 0) { print dol_get_fiche_end(); $modulepart = 'propal'; - $permissiontoadd = $user->rights->propal->creer; - $permtoedit = $user->rights->propal->creer; + $permissiontoadd = $user->hasRight('propal', 'creer'); + $permtoedit = $user->hasRight('propal', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 36eb458f252..bc408a1c6de 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -66,7 +66,7 @@ $usercancreate = $user->hasRight("propal", "creer"); * Actions */ -$permissionnote = $user->rights->propal->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('propal', 'creer'); // Used by the include of actions_setnotes.inc.php $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index c529cade054..864375fbf5d 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -179,8 +179,8 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); $modulepart = 'commande'; - $permissiontoadd = $user->rights->commande->creer; - $permtoedit = $user->rights->commande->creer; + $permissiontoadd = $user->hasRight('commande', 'creer'); + $permtoedit = $user->hasRight('commande', 'creer'); $param = '&id='.$object->id.'&entity='.(empty($object->entity) ? $conf->entity : $object->entity); include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 368a8333317..33fd5fd60e3 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -54,7 +54,7 @@ $result = restrictedArea($user, 'commande', $id, ''); $usercancreate = $user->hasRight("commande", "creer"); -$permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('commande', 'creer'); // Used by the include of actions_setnotes.inc.php $object = new Commande($db); diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index a07759ad504..bd210826e37 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -119,7 +119,7 @@ if (GETPOST("rel") == 'prev') { $found = true; } -$permissiontoadd = $user->rights->banque->modifier; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('banque', 'modifier'); // Used by the include of actions_dellink.inc.php /* @@ -184,8 +184,8 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; - $permissiontoadd = $user->rights->banque->modifier; - $permtoedit = $user->rights->banque->modifier; + $permissiontoadd = $user->hasRight('banque', 'modifier'); + $permtoedit = $user->hasRight('banque', 'modifier'); $param = '&id='.$object->id.'&num='.urlencode($numref); $moreparam = '&num='.urlencode($numref); $relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($numref)."/"; diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 522b2d56939..5e3eef6e06e 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -76,7 +76,7 @@ if ($id > 0 || !empty($ref)) { $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', ''); -$permissiontoadd = $user->rights->banque->modifier; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('banque', 'modifier'); // Used by the include of actions_dellink.inc.php /* @@ -139,8 +139,8 @@ if ($id > 0 || !empty($ref)) { $modulepart = 'bank'; - $permissiontoadd = $user->rights->banque->modifier; - $permtoedit = $user->rights->banque->modifier; + $permissiontoadd = $user->hasRight('banque', 'modifier'); + $permtoedit = $user->hasRight('banque', 'modifier'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index cc4c0216a1b..46ab79f2291 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -126,8 +126,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoadd = $user->rights->banque->modifier; -$permissiontodelete = $user->rights->banque->configurer; +$permissiontoadd = $user->hasRight('banque', 'modifier'); +$permissiontodelete = $user->hasRight('banque', 'configurer'); $allowed = 0; if ($user->hasRight('accounting', 'chartofaccount')) { diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 42a735086c5..a88c71d535e 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -70,7 +70,7 @@ $object->fetch($id, $ref); $upload_dir = $conf->bank->dir_output.'/'.dol_sanitizeFileName($object->id); $modulepart = 'banque'; -$permissiontoadd = $user->rights->banque->modifier; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('banque', 'modifier'); // Used by the include of actions_dellink.inc.php @@ -153,7 +153,7 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'banque'; - $permissiontoadd = $user->rights->banque->modifier; + $permissiontoadd = $user->hasRight('banque', 'modifier'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php index 7d645466d7c..ab24151539f 100644 --- a/htdocs/compta/deplacement/card.php +++ b/htdocs/compta/deplacement/card.php @@ -53,7 +53,7 @@ $object = new Deplacement($db); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('tripsandexpensescard', 'globalcard')); -$permissionnote = $user->rights->deplacement->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_setnotes.inc.php /* @@ -492,7 +492,7 @@ if ($action == 'create') { } } - $permissiontodelete = $user->rights->deplacement->supprimer; + $permissiontodelete = $user->hasRight('deplacement', 'supprimer'); print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); print '
'; diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index b33692eb454..003418d2ab8 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -75,7 +75,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'deplacement', $id, ''); -$permissiontoadd = $user->rights->deplacement->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -129,7 +129,7 @@ if ($object->id) { print ''; $modulepart = 'deplacement'; - $permissiontoadd = $user->rights->deplacement->creer; + $permissiontoadd = $user->hasRight('deplacement', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index e4cc36e0736..898320fdb1c 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -84,11 +84,11 @@ if ($user->socid) { } $result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque', '', 'fk_user_author', $fieldname); -$usercanread = $user->rights->banque->cheque; -$usercancreate = $user->rights->banque->cheque; -$usercandelete = $user->rights->banque->cheque; +$usercanread = $user->hasRight('banque', 'cheque'); +$usercancreate = $user->hasRight('banque', 'cheque'); +$usercandelete = $user->hasRight('banque', 'cheque'); -$permissiontodelete = $user->rights->banque->cheque; +$permissiontodelete = $user->hasRight('banque', 'cheque'); // List of payment mode to support // Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' diff --git a/htdocs/compta/paymentbybanktransfer/index.php b/htdocs/compta/paymentbybanktransfer/index.php index ae9dca4e1a9..5f808e03e2e 100644 --- a/htdocs/compta/paymentbybanktransfer/index.php +++ b/htdocs/compta/paymentbybanktransfer/index.php @@ -45,7 +45,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'paymentbybanktransfer', '', ''); -$usercancreate = $user->rights->paymentbybanktransfer->create; +$usercancreate = $user->hasRight('paymentbybanktransfer', 'create'); /* diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php index ead17605ff1..341b378cc05 100644 --- a/htdocs/compta/prelevement/index.php +++ b/htdocs/compta/prelevement/index.php @@ -44,7 +44,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'prelevement', '', 'bons'); -$usercancreate = $user->rights->prelevement->bons->creer; +$usercancreate = $user->hasRight('prelevement', 'bons', 'creer'); /* diff --git a/htdocs/compta/prelevement/orders_list.php b/htdocs/compta/prelevement/orders_list.php index b1347f9738e..0adc9dac87f 100644 --- a/htdocs/compta/prelevement/orders_list.php +++ b/htdocs/compta/prelevement/orders_list.php @@ -71,10 +71,10 @@ $search_amount = GETPOST('search_amount', 'alpha'); $bon = new BonPrelevement($db); $hookmanager->initHooks(array('withdrawalsreceiptslist')); -$usercancreate = $user->rights->prelevement->bons->creer; +$usercancreate = $user->hasRight('prelevement', 'bons', 'creer'); $permissiontodelete = $user->hasRight('prelevement', 'creer'); if ($type == 'bank-transfer') { - $usercancreate = $user->rights->paymentbybanktransfer->create; + $usercancreate = $user->hasRight('paymentbybanktransfer', 'create'); $permissiontodelete = $user->hasRight('paymentbybanktransfer', 'create'); } diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 22886c531d4..ba0991ac02e 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -83,11 +83,11 @@ if ($id > 0 || $ref) { $object->fetch($id, $ref); } -$permissiontoread = $user->rights->tax->charges->lire; -$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('tax', 'charges', 'lire'); +$permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID); -$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check @@ -845,7 +845,7 @@ if ($id > 0) { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content $genallowed = 0; - $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + $delallowed = $user->hasRight('tax', 'charges', 'creer'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 34e64e13287..ef68f325cc4 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -79,7 +79,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges'); -$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -170,8 +170,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'tax'; - $permissiontoadd = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->tax->charges->creer; + $permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); + $permtoedit = $user->hasRight('tax', 'charges', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/compta/sociales/note.php b/htdocs/compta/sociales/note.php index 86f82ea270c..cdabc0cede5 100644 --- a/htdocs/compta/sociales/note.php +++ b/htdocs/compta/sociales/note.php @@ -53,9 +53,9 @@ if ($user->socid) { } $result = restrictedArea($user, 'tax', $object->id, 'chargesociales', 'charges'); -$permissiontoread = $user->rights->tax->charges->lire; -$permissiontoadd = $user->rights->tax->charges->creer; -$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php +$permissiontoread = $user->hasRight('tax', 'charges', 'lire'); +$permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); +$permissionnote = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_setnotes.inc.php /* diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 695f3ee45bb..3991d6ae100 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -82,11 +82,11 @@ if (empty($action) && empty($id) && empty($ref)) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->tax->charges->lire; -$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('tax', 'charges', 'lire'); +$permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->tax->charges->supprimer || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID); -$permissionnote = $user->rights->tax->charges->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->tax->multidir_output[isset($object->entity) ? $object->entity : 1].'/vat'; // Security check @@ -843,7 +843,7 @@ if ($id > 0) { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content $genallowed = 0; - $delallowed = $user->rights->tax->charges->creer; // If you can create/edit, you can remove a file on card + $delallowed = $user->hasRight('tax', 'charges', 'creer'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('tax-vat', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/compta/tva/document.php b/htdocs/compta/tva/document.php index 8a636af3ae1..c7b9f2dcc61 100644 --- a/htdocs/compta/tva/document.php +++ b/htdocs/compta/tva/document.php @@ -80,7 +80,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'tax', '', 'tva', 'charges'); -$permissiontoadd = $user->rights->tax->charges->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -152,8 +152,8 @@ if ($object->id) { print dol_get_fiche_end(); - $permissiontoadd = $user->rights->tax->charges->creer; - $permtoedit = $user->rights->tax->charges->creer; + $permissiontoadd = $user->hasRight('tax', 'charges', 'creer'); + $permtoedit = $user->hasRight('tax', 'charges', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/contrat/messaging.php b/htdocs/contrat/messaging.php index 89612f4094a..5eaaac8d51f 100644 --- a/htdocs/contrat/messaging.php +++ b/htdocs/contrat/messaging.php @@ -130,7 +130,7 @@ if (empty($reshook)) { $form = new Form($db); // Load object modContract -$module = (!empty($conf->global->CONTRACT_ADDON) ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); +$module = (getDolGlobalString('CONTRACT_ADDON') ? $conf->global->CONTRACT_ADDON : 'mod_contract_serpis'); if (substr($module, 0, 13) == 'mod_contract_' && substr($module, -3) == 'php') { $module = substr($module, 0, dol_strlen($module) - 4); } @@ -145,7 +145,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $object->fetch_thirdparty(); $title = $langs->trans("Agenda"); -if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) { +if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/contractrefonly/', $conf->global->MAIN_HTML_TITLE) && $object->ref) { $title = $object->ref." - ".$title; } $help_url = 'EN:Module_Contracts|FR:Module_Contrat'; @@ -181,7 +181,7 @@ $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_ $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $permtoedit, 'string', '', null, null, '', 1, 'getFormatedSupplierRef'); // Thirdparty $morehtmlref .= '
'.$object->thirdparty->getNomUrl(1); -if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { +if (!getDolGlobalString('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) { $morehtmlref .= ' ('.$langs->trans("OtherContracts").')'; } // Project diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index d85fa7dd8f2..f5ea99e4b36 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -293,7 +293,7 @@ if ($type == 'directory') { $filter = preg_quote($search_doc_ref, '/'); $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1); - $perm = $user->rights->ecm->upload; + $perm = $user->hasRight('ecm', 'upload'); $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1); } else { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 1be900fa9de..dce5639875d 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3201,11 +3201,11 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } elseif ($modulepart == 'export' && !empty($conf->export->dir_temp)) { // Wrapping for export module // Note that a test may not be required because we force the dir of download on the directory of the user that export - $accessallowed = $user->rights->export->lire; + $accessallowed = $user->hasRight('export', 'lire'); $original_file = $conf->export->dir_temp.'/'.$fuser->id.'/'.$original_file; } elseif ($modulepart == 'import' && !empty($conf->import->dir_temp)) { // Wrapping for import module - $accessallowed = $user->rights->import->run; + $accessallowed = $user->hasRight('import', 'run'); $original_file = $conf->import->dir_temp.'/'.$original_file; } elseif ($modulepart == 'recruitment' && !empty($conf->recruitment->dir_output)) { // Wrapping for recruitment module diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index b4df3e4311e..8ca0cc44990 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -34,7 +34,7 @@ if ($module == "product") { } $colwidth = (isset($colwidth) ? $colwidth : (empty($cssclass) ? '25' : '')); // Set $permission from the $permissionnote var defined on calling page -$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : (isset($user->rights->$module->create) ? $user->rights->$module->create : (isset($user->rights->$module->creer) ? $user->rights->$module->creer : 0)))); +$permission = (isset($permissionnote) ? $permissionnote : (isset($permission) ? $permission : ($user->hasRight($module, 'create') ? $user->rights->$module->create : ($user->hasRight($module, 'creer') ? $user->rights->$module->creer : 0)))); $moreparam = (isset($moreparam) ? $moreparam : ''); $value_public = $object->note_public; $value_private = $object->note_private; diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index d93b8e445ac..e78006d9e3f 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -90,10 +90,10 @@ if (!$user->hasRight('cron', 'read')) { accessforbidden(); } -$permissiontoread = $user->rights->cron->read; +$permissiontoread = $user->hasRight('cron', 'read'); $permissiontoadd = $user->rights->cron->create ? $user->rights->cron->create : $user->rights->cron->write; -$permissiontodelete = $user->rights->cron->delete; -$permissiontoexecute = $user->rights->cron->execute; +$permissiontodelete = $user->hasRight('cron', 'delete'); +$permissiontoexecute = $user->hasRight('cron', 'execute'); /* diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index f87ac1bada3..eaa0525458c 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -92,7 +92,7 @@ $error = 0; $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Delete Link -$permissiondellink = $user->rights->expedition->delivery->supprimer; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->hasRight('expedition', 'delivery', 'supprimer'); // Used by the include of actions_dellink.inc.php include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once if ($action == 'add') { @@ -244,7 +244,7 @@ if ($action == 'update_extras_line') { // Actions to build doc $upload_dir = $conf->expedition->dir_output.'/receipt'; -$permissiontoadd = $user->rights->expedition->creer; +$permissiontoadd = $user->hasRight('expedition', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; @@ -671,8 +671,8 @@ if ($action == 'create') { $filedir = $conf->expedition->dir_output."/receipt/".$objectref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->expedition->delivery->lire; - $delallowed = $user->rights->expedition->delivery->creer; + $genallowed = $user->hasRight('expedition', 'delivery', 'lire'); + $delallowed = $user->hasRight('expedition', 'delivery', 'creer'); print $formfile->showdocuments('delivery', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 4d352e6b65f..cb012a3999d 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -86,7 +86,7 @@ $upload_dir = $conf->don->dir_output; // Security check $result = restrictedArea($user, 'don', $object->id); -$permissiontoadd = $user->rights->don->creer; +$permissiontoadd = $user->hasRight('don', 'creer'); /* @@ -963,7 +963,7 @@ if (!empty($id) && $action != 'edit') { $filedir = $conf->don->dir_output."/".dol_sanitizeFileName($object->id); $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id; $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); - $delallowed = $user->rights->don->creer; + $delallowed = $user->hasRight('don', 'creer'); print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 6931f12d744..445d38a28b7 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -84,7 +84,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'don', $object->id); -$permissiontoadd = $user->rights->don->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('don', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -195,8 +195,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'don'; - $permissiontoadd = $user->rights->don->creer; - $permtoedit = $user->rights->don->creer; + $permissiontoadd = $user->hasRight('don', 'creer'); + $permtoedit = $user->hasRight('don', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/don/note.php b/htdocs/don/note.php index b3641446c93..e60b9b71054 100644 --- a/htdocs/don/note.php +++ b/htdocs/don/note.php @@ -57,7 +57,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'don', $object->id, ''); -$permissionnote = $user->rights->don->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('don', 'creer'); // Used by the include of actions_setnotes.inc.php /* diff --git a/htdocs/ecm/dir_add_card.php b/htdocs/ecm/dir_add_card.php index f12f4bfb0a4..7900949b179 100644 --- a/htdocs/ecm/dir_add_card.php +++ b/htdocs/ecm/dir_add_card.php @@ -98,9 +98,9 @@ $permissiontoadd = 0; $permissiontodelete = 0; $permissiontoupload = 0; if ($module == 'ecm') { - $permissiontoadd = $user->rights->ecm->setup; - $permissiontodelete = $user->rights->ecm->setup; - $permissiontoupload = $user->rights->ecm->upload; + $permissiontoadd = $user->hasRight('ecm', 'setup'); + $permissiontodelete = $user->hasRight('ecm', 'setup'); + $permissiontoupload = $user->hasRight('ecm', 'upload'); } if ($module == 'medias') { $permissiontoadd = ($user->rights->mailing->creer || $user->rights->website->write); diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index c580bd97f22..fe6ada5a160 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -103,9 +103,9 @@ if ($result < 0) { } // Permissions -$permissiontoread = $user->rights->ecm->read; -$permissiontoadd = $user->rights->ecm->setup; -$permissiontoupload = $user->rights->ecm->upload; +$permissiontoread = $user->hasRight('ecm', 'read'); +$permissiontoadd = $user->hasRight('ecm', 'setup'); +$permissiontoupload = $user->hasRight('ecm', 'upload'); if (!$permissiontoread) { accessforbidden(); diff --git a/htdocs/ecm/file_note.php b/htdocs/ecm/file_note.php index 4b4df1321ea..6624936141b 100644 --- a/htdocs/ecm/file_note.php +++ b/htdocs/ecm/file_note.php @@ -106,9 +106,9 @@ if ($result < 0) { exit; } -$permissionnote = $user->rights->ecm->setup; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('ecm', 'setup'); // Used by the include of actions_setnotes.inc.php -$permissiontoread = $user->rights->ecm->read; +$permissiontoread = $user->hasRight('ecm', 'read'); if (!$permissiontoread) { accessforbidden(); diff --git a/htdocs/ecm/search.php b/htdocs/ecm/search.php index 889d205cf74..ca847e61fee 100644 --- a/htdocs/ecm/search.php +++ b/htdocs/ecm/search.php @@ -85,7 +85,7 @@ if (!empty($section)) { } } -$permissiontoread = $user->rights->ecm->read; +$permissiontoread = $user->hasRight('ecm', 'read'); if (!$permissiontoread) { accessforbidden(); diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index b457da8181a..2329b7584ce 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2669,7 +2669,7 @@ class EmailCollector extends CommonObject if (!dol_is_dir($destdir)) { dol_mkdir($destdir); } - if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { + if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP')) { foreach ($attachments as $attachment) { $attachment->save($destdir.'/'); } diff --git a/htdocs/eventorganization/conferenceorbooth_card.php b/htdocs/eventorganization/conferenceorbooth_card.php index 21d38f947b6..9364a637788 100644 --- a/htdocs/eventorganization/conferenceorbooth_card.php +++ b/htdocs/eventorganization/conferenceorbooth_card.php @@ -86,11 +86,11 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check @@ -632,8 +632,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->eventorganization->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->eventorganization->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('eventorganization', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('eventorganization', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('eventorganization', $object->element.'/'.$objref, $filedir, $urlsource, 0, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/eventorganization/conferenceorbooth_contact.php b/htdocs/eventorganization/conferenceorbooth_contact.php index b02996ebff8..b365fc7aec8 100644 --- a/htdocs/eventorganization/conferenceorbooth_contact.php +++ b/htdocs/eventorganization/conferenceorbooth_contact.php @@ -77,11 +77,11 @@ if ($user->socid > 0) { $isdraft = (($object->status== $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'eventorganization', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index b341e6a2134..3ca9ead5d8b 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -91,11 +91,11 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check diff --git a/htdocs/eventorganization/conferenceorbooth_list.php b/htdocs/eventorganization/conferenceorbooth_list.php index 39f88d01a66..6c9f2b0525a 100644 --- a/htdocs/eventorganization/conferenceorbooth_list.php +++ b/htdocs/eventorganization/conferenceorbooth_list.php @@ -134,9 +134,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; -$permissiontodelete = $user->rights->eventorganization->delete; +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); +$permissiontodelete = $user->hasRight('eventorganization', 'delete'); // Security check if (!isModEnabled('eventorganization')) { diff --git a/htdocs/eventorganization/conferenceorboothattendee_card.php b/htdocs/eventorganization/conferenceorboothattendee_card.php index d0cc03cde79..a80dfe8075e 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_card.php +++ b/htdocs/eventorganization/conferenceorboothattendee_card.php @@ -113,11 +113,11 @@ if ($object->fk_project > 0) { } // Permissions -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->eventorganization->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->eventorganization->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->eventorganization->write; // Used by the include of actions_dellink.inc.php +$permissionnote = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('eventorganization', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->eventorganization->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -637,8 +637,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->eventorganization->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->eventorganization->conferenceorboothattendee->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->eventorganization->conferenceorboothattendee->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('eventorganization:ConferenceOrBoothAttendee', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/eventorganization/conferenceorboothattendee_list.php b/htdocs/eventorganization/conferenceorboothattendee_list.php index 006b870fd93..5164436088f 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_list.php +++ b/htdocs/eventorganization/conferenceorboothattendee_list.php @@ -143,9 +143,9 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->eventorganization->read; -$permissiontoadd = $user->rights->eventorganization->write; -$permissiontodelete = $user->rights->eventorganization->delete; +$permissiontoread = $user->hasRight('eventorganization', 'read'); +$permissiontoadd = $user->hasRight('eventorganization', 'write'); +$permissiontodelete = $user->hasRight('eventorganization', 'delete'); // Security check if (empty($conf->eventorganization->enabled)) { diff --git a/htdocs/eventorganization/conferenceorboothattendee_note.php b/htdocs/eventorganization/conferenceorboothattendee_note.php index 8dba83ebadf..0ca03d3bcc4 100644 --- a/htdocs/eventorganization/conferenceorboothattendee_note.php +++ b/htdocs/eventorganization/conferenceorboothattendee_note.php @@ -106,8 +106,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissionnote = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->eventorganization->conferenceorboothattendee->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('eventorganization', 'conferenceorboothattendee', 'write'); // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 6bf40733ed9..6826801e965 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -125,8 +125,8 @@ if ($user->socid) { $result = restrictedArea($user, 'expedition', $object->id, ''); -$permissiondellink = $user->rights->expedition->delivery->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->expedition->creer; +$permissiondellink = $user->hasRight('expedition', 'delivery', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('expedition', 'creer'); /* @@ -2730,8 +2730,8 @@ if ($action == 'create') { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->expedition->lire; - $delallowed = $user->rights->expedition->creer; + $genallowed = $user->hasRight('expedition', 'lire'); + $delallowed = $user->hasRight('expedition', 'creer'); print $formfile->showdocuments('expedition', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); diff --git a/htdocs/expedition/document.php b/htdocs/expedition/document.php index f8aef745d16..fdc58396d3d 100644 --- a/htdocs/expedition/document.php +++ b/htdocs/expedition/document.php @@ -95,7 +95,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'expedition', $object->id, ''); -$permissiontoadd = $user->rights->expedition->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('expedition', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -185,8 +185,8 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); $modulepart = 'expedition'; - $permissiontoadd = $user->rights->expedition->creer; - $permtoedit = $user->rights->expedition->creer; + $permissiontoadd = $user->hasRight('expedition', 'creer'); + $permtoedit = $user->hasRight('expedition', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index 2f58d6cd36a..a3e117c8662 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -207,9 +207,9 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' if (empty($reshook)) { $objectclass = 'Expedition'; $objectlabel = 'Sendings'; - $permissiontoread = $user->rights->expedition->lire; - $permissiontoadd = $user->rights->expedition->creer; - $permissiontodelete = $user->rights->expedition->supprimer; + $permissiontoread = $user->hasRight('expedition', 'lire'); + $permissiontoadd = $user->hasRight('expedition', 'creer'); + $permissiontodelete = $user->hasRight('expedition', 'supprimer'); $uploaddir = $conf->expedition->dir_output.'/sending'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -1224,8 +1224,8 @@ $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sorto $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; -$genallowed = $user->rights->expedition->lire; -$delallowed = $user->rights->expedition->creer; +$genallowed = $user->hasRight('expedition', 'lire'); +$delallowed = $user->hasRight('expedition', 'creer'); $title = ''; print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 78fbcc8685b..b2e6db874ba 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -64,7 +64,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref); } -$permissionnote = $user->rights->expedition->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('expedition', 'creer'); // Used by the include of actions_setnotes.inc.php // Security check if ($user->socid) { diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php index 86a661d59c2..1b4a82db1b4 100644 --- a/htdocs/expensereport/card.php +++ b/htdocs/expensereport/card.php @@ -113,9 +113,9 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('expensereportcard', 'globalcard')); -$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $upload_dir = $conf->expensereport->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -150,7 +150,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'expensereport', $object->id, 'expensereport'); -$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -2853,8 +2853,8 @@ if ($action != 'presend') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->expensereport->dir_output."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->expensereport->creer; - $delallowed = $user->rights->expensereport->creer; + $genallowed = $user->hasRight('expensereport', 'creer'); + $delallowed = $user->hasRight('expensereport', 'creer'); $var = true; print $formfile->showdocuments('expensereport', $filename, $filedir, $urlsource, $genallowed, $delallowed); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/expensereport/document.php b/htdocs/expensereport/document.php index cdc82a205e3..d801b93b484 100644 --- a/htdocs/expensereport/document.php +++ b/htdocs/expensereport/document.php @@ -95,7 +95,7 @@ if ($object->id > 0) { } } -$permissiontoadd = $user->rights->expensereport->creer; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_dellink.inc.php /* @@ -156,8 +156,8 @@ if ($object->id) { $modulepart = 'expensereport'; - $permissiontoadd = $user->rights->expensereport->creer; - $permtoedit = $user->rights->expensereport->creer; + $permissiontoadd = $user->hasRight('expensereport', 'creer'); + $permtoedit = $user->hasRight('expensereport', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 0d371731c90..03d1106177c 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -238,8 +238,8 @@ if (empty($reshook)) { // Mass actions $objectclass = 'ExpenseReport'; $objectlabel = 'ExpenseReport'; - $permissiontoread = $user->rights->expensereport->lire; - $permissiontodelete = $user->rights->expensereport->supprimer; + $permissiontoread = $user->hasRight('expensereport', 'lire'); + $permissiontodelete = $user->hasRight('expensereport', 'supprimer'); $uploaddir = $conf->expensereport->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -1010,8 +1010,8 @@ if ($resql) { $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->expensereport->lire; - $delallowed = $user->rights->expensereport->creer; + $genallowed = $user->hasRight('expensereport', 'lire'); + $delallowed = $user->hasRight('expensereport', 'creer'); print $formfile->showdocuments('massfilesarea_expensereport', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/expensereport/note.php b/htdocs/expensereport/note.php index 3b10af46bc5..b13291998df 100644 --- a/htdocs/expensereport/note.php +++ b/htdocs/expensereport/note.php @@ -55,7 +55,7 @@ if (!$object->fetch($id, $ref) > 0) { dol_print_error($db); } -$permissionnote = $user->rights->expensereport->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('expensereport', 'creer'); // Used by the include of actions_setnotes.inc.php if ($object->id > 0) { // Check current user can read this expense report diff --git a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php index 6aea588a506..ff2fd3d4285 100644 --- a/htdocs/expensereport/tpl/expensereport_addfile.tpl.php +++ b/htdocs/expensereport/tpl/expensereport_addfile.tpl.php @@ -13,7 +13,7 @@ if ($action == 'editline') { print '
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; - if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->statut == 1 || ($object->statut == 2 && $nbtry < $nbemail))) { + if ((getDolGlobalString('MAILING_LIMIT_SENDBYWEB') && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) && ($object->status == 1 || ($object->status == 2 && $nbtry < $nbemail))) { if (getDolGlobalInt('MAILING_LIMIT_SENDBYWEB') > 0) { $text .= $langs->trans('LimitSendingEmailing', getDolGlobalString('MAILING_LIMIT_SENDBYWEB')); } else { @@ -398,7 +400,7 @@ if ($object->fetch($id) >= 0) { print '
'; - $allowaddtarget = ($object->statut == $object::STATUS_DRAFT); + $allowaddtarget = ($object->status == $object::STATUS_DRAFT); // Show email selectors if ($allowaddtarget && $user->hasRight('mailing', 'creer')) { @@ -410,11 +412,19 @@ if ($object->fetch($id) >= 0) { print '
'; print '
'; print '
'.$langs->trans("RecipientSelectionModules").'
'; - print '
'.$langs->trans("NbOfUniqueEMails").'
'; - print '
'.$langs->trans("Filters").'
'; - print '              
'.$langs->trans("EvenUnsubscribe").' '; - print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1); + print '
'; + if ($object->messtype != 'sms') { + print $langs->trans("NbOfUniqueEMails"); + } else { + print $langs->trans("NbOfUniquePhones"); + } print '
'; + print '
'.$langs->trans("Filters").'
'; + if ($object->messtype != 'sms') { + print '              
'.$langs->trans("EvenUnsubscribe").' '; + print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1); + print '
'; + } print '
'; print '
 
'; print '
'; // End tr @@ -776,12 +786,12 @@ if ($object->fetch($id) >= 0) { if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print '
'; print ''; - if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet if ($user->hasRight('mailing', 'creer')) { print ''.img_delete($langs->trans("RemoveRecipient")).''; } } - /*if ($obj->statut == -1) // Sent with error + /*if ($obj->status == -1) // Sent with error { print ''.$langs->trans("Retry").''; }*/ @@ -834,7 +844,7 @@ if ($object->fetch($id) >= 0) { // Date sent print ''; - if ($obj->statut != $object::STATUS_DRAFT) { + if ($obj->status != $object::STATUS_DRAFT) { // Date sent print $obj->date_envoi; } @@ -842,10 +852,10 @@ if ($object->fetch($id) >= 0) { // Status of recipient sending email (Warning != status of emailing) print ''; - if ($obj->statut == $object::STATUS_DRAFT) { - print $object::libStatutDest($obj->statut, 2, ''); + if ($obj->status == $object::STATUS_DRAFT) { + print $object::libStatutDest($obj->status, 2, ''); } else { - print $object::libStatutDest($obj->statut, 2, $obj->error_text); + print $object::libStatutDest($obj->status, 2, $obj->error_text); } print ''; print ''; - if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if ($obj->status == $object::STATUS_DRAFT) { // Not sent yet if ($user->hasRight('mailing', 'creer')) { print ''.img_delete($langs->trans("RemoveRecipient")).''; } } - /*if ($obj->statut == -1) // Sent with error + /*if ($obj->status == -1) // Sent with error { print ''.$langs->trans("Retry").''; }*/ @@ -869,7 +879,7 @@ if ($object->fetch($id) >= 0) { $i++; } } else { - if ($object->statut < $object::STATUS_SENTPARTIALY) { + if ($object->status < $object::STATUS_SENTPARTIALY) { print '
'; print ''.$langs->trans("NoTargetYet").''; print '
'; print ''; print ''; + print ''; + print ''; print ''; @@ -415,19 +439,28 @@ if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { } print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "m.rowid", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; +// Message type +if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "m.messtype", $param, "", "", $sortfield, $sortorder); + $totalarray['nbfield']++; +} print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "m.titre", $param, "", "", $sortfield, $sortorder); $totalarray['nbfield']++; -print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", 'align="center"', $sortfield, $sortorder); +print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "m.date_creat", $param, "", '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; if (!$filteremail) { - print_liste_field_titre("NbOfEMails", $_SERVER["PHP_SELF"], "m.nbemail", $param, "", 'align="center"', $sortfield, $sortorder); + $title = $langs->trans("NbOfEMails"); + if (getDolGlobalInt('EMAILINGS_SUPPORT_ALSO_SMS')) { + $title .= ' | '.$langs->trans("SMS"); + } + print_liste_field_titre($title, $_SERVER["PHP_SELF"], "m.nbemail", $param, "", '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } if (!$filteremail) { - print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("DateLastSend", $_SERVER["PHP_SELF"], "m.date_envoi", $param, "", '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } else { - print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, "", '', $sortfield, $sortorder, 'center '); $totalarray['nbfield']++; } // Extra fields @@ -484,10 +517,18 @@ while ($i < $imaxinloop) { } } + // Ref print ''; print $object->getNomUrl(1); print ''; + print dol_escape_htmltag($obj->messtype); + print ''.dol_escape_htmltag($obj->title).''; $nbemail = $obj->nbemail; - /*if ($obj->statut != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) + /*if ($obj->status != 3 && !empty($conf->global->MAILING_LIMIT_SENDBYWEB) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); print $form->textwithpicto($nbemail,$text,1,'warning'); @@ -514,7 +555,7 @@ while ($i < $imaxinloop) { } // Last send - print ''.dol_print_date($db->jdate($obj->date_envoi), 'day').''.dol_print_date($db->jdate($obj->date_envoi), 'day').'
'.$langs->trans('BindingOptions').'
'; $htmltext = $langs->trans("ID").': '.$obj->id; - $htmltext .= '
'.$langs->trans("Permission").': user->rights->'.$obj->module.'->'.$obj->perms.($obj->subperms ? '->'.$obj->subperms : ''); + $htmltext .= '
'.$langs->trans("Permission").': user->hasRight(\''.$obj->module.'\', \''.$obj->perms.'\''.($obj->subperms ? ', \''.$obj->subperms.'\'' : '').')'; print $form->textwithpicto('', $htmltext); //print ''.$obj->id.''; print '
'; $modulepart = 'expensereport'; -$permission = $user->rights->expensereport->creer; +$permission = $user->hasRight('expensereport', 'creer'); // We define var to enable the feature to add prefix of uploaded files $savingdocmask = ''; diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 971eea5a1eb..c069e2d15b2 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -744,7 +744,7 @@ if (empty($reshook)) { // Actions to build doc $upload_dir = $conf->ficheinter->dir_output; - $permissiontoadd = $user->rights->ficheinter->creer; + $permissiontoadd = $user->hasRight('ficheinter', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if ($action == 'update_extras') { @@ -1747,8 +1747,8 @@ if ($action == 'create') { $filename = dol_sanitizeFileName($object->ref); $filedir = $conf->ficheinter->dir_output."/".$filename; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->ficheinter->lire; - $delallowed = $user->rights->ficheinter->creer; + $genallowed = $user->hasRight('ficheinter', 'lire'); + $delallowed = $user->hasRight('ficheinter', 'creer'); print $formfile->showdocuments('ficheinter', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); // Show links to link elements diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 98f2e077395..c6b12144a5b 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -79,7 +79,7 @@ $object->fetch($id, $ref); $upload_dir = $conf->ficheinter->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart = 'fichinter'; -$permissiontoadd = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_setnotes.inc.php /* @@ -164,7 +164,7 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'ficheinter'; - $permtoedit = $user->rights->ficheinter->creer; + $permtoedit = $user->hasRight('ficheinter', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 20eb6c8e26c..12752dc3c59 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -156,9 +156,9 @@ if ($user->socid) { } $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); -$permissiontoread = $user->rights->ficheinter->lire; -$permissiontoadd = $user->rights->ficheinter->creer; -$permissiontodelete = $user->rights->ficheinter->supprimer; +$permissiontoread = $user->hasRight('ficheinter', 'lire'); +$permissiontoadd = $user->hasRight('ficheinter', 'creer'); +$permissiontodelete = $user->hasRight('ficheinter', 'supprimer'); /* diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 471c5c64485..584feadd2fb 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -49,7 +49,7 @@ $result = restrictedArea($user, 'ficheinter', $id, 'fichinter'); $object = new Fichinter($db); $object->fetch($id, $ref); -$permissionnote = $user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('ficheinter', 'creer'); // Used by the include of actions_setnotes.inc.php /* * Actions diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 5b9c527a019..2d76c1b0cbb 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1623,8 +1623,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->holiday->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->holiday->read && $object->fk_user == $user->id) || !empty($user->rights->holiday->readall); // If you can read, you can build the PDF to read content - $delallowed = ($user->rights->holiday->write && $object->fk_user == $user->id) || !empty($user->rights->holiday->writeall_advance); // If you can create/edit, you can remove a file on card + $genallowed = ($user->rights->holiday->read && $object->fk_user == $user->id) || $user->hasRight('holiday', 'readall'); // If you can read, you can build the PDF to read content + $delallowed = ($user->rights->holiday->write && $object->fk_user == $user->id) || $user->hasRight('holiday', 'writeall_advance'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('holiday:Holiday', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php index 69615a2b9af..c72a42e5631 100644 --- a/htdocs/holiday/document.php +++ b/htdocs/holiday/document.php @@ -104,7 +104,7 @@ if ($user->socid) { } $result = restrictedArea($user, 'holiday', $object->id, 'holiday'); -$permissiontoadd = $user->rights->holiday->write; // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('holiday', 'write'); // Used by the include of actions_setnotes.inc.php /* @@ -286,8 +286,8 @@ if ($object->id) { print dol_get_fiche_end(); - $permissiontoadd = $user->rights->holiday->write; - $permtoedit = $user->rights->holiday->write; + $permissiontoadd = $user->hasRight('holiday', 'write'); + $permtoedit = $user->hasRight('holiday', 'write'); $param = '&id='.$object->id; $relativepathwithnofile = dol_sanitizeFileName($object->ref).'/'; $savingdocmask = dol_sanitizeFileName($object->ref).'-__file__'; diff --git a/htdocs/hrm/evaluation_agenda.php b/htdocs/hrm/evaluation_agenda.php index 44437c1a6fa..6a51a67396a 100644 --- a/htdocs/hrm/evaluation_agenda.php +++ b/htdocs/hrm/evaluation_agenda.php @@ -90,8 +90,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoadd = $user->rights->hrm->evaluation->write; // Used by the include of actions_addupdatedelete.inc.php -$permissiontoread = $user->rights->hrm->evaluation->read; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index e7681e75b6c..b924a6f18f9 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -81,12 +81,12 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->hrm->evaluation->read; -$permissiontoadd = $user->rights->hrm->evaluation->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontovalidate = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->rights->hrm->evaluation_advance->validate) || (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd); -$permissiontoClose = $user->rights->hrm->evaluation->write; -$permissiontodelete = $user->rights->hrm->evaluation->delete/* || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT)*/; -$permissiondellink = $user->rights->hrm->evaluation->write; // Used by the include of actions_dellink.inc.php +$permissiontoClose = $user->hasRight('hrm', 'evaluation', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'evaluation', 'delete')/* || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT)*/; +$permissiondellink = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1].'/evaluation'; // Security check (enable the most restrictive one) @@ -691,8 +691,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->hrm->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->hrm->evaluation->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->hrm->evaluation->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('hrm', 'evaluation', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('hrm', 'evaluation', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('hrm:Evaluation', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang, '', $object, 0, 'remove_file_comfirm'); } diff --git a/htdocs/hrm/evaluation_contact.php b/htdocs/hrm/evaluation_contact.php index 60fa5223d07..d99f76d4588 100644 --- a/htdocs/hrm/evaluation_contact.php +++ b/htdocs/hrm/evaluation_contact.php @@ -57,7 +57,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals // Permissions -$permission = $user->rights->hrm->evaluation->write; +$permission = $user->hasRight('hrm', 'evaluation', 'write'); // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/evaluation_document.php b/htdocs/hrm/evaluation_document.php index 51262f6edf2..4ec3fc93b2e 100644 --- a/htdocs/hrm/evaluation_document.php +++ b/htdocs/hrm/evaluation_document.php @@ -81,8 +81,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoadd = $user->rights->hrm->evaluation->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php -$permissiontoread = $user->rights->hrm->evaluation->read; +$permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/evaluation_note.php b/htdocs/hrm/evaluation_note.php index ba0ec02d616..37a8a479af7 100644 --- a/htdocs/hrm/evaluation_note.php +++ b/htdocs/hrm/evaluation_note.php @@ -60,8 +60,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissionnote = $user->rights->hrm->evaluation->write; // Used by the include of actions_setnotes.inc.php -$permissiontoread = $user->rights->hrm->evaluation->read; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/job_agenda.php b/htdocs/hrm/job_agenda.php index 671d10c8a74..f13d0e88d8b 100644 --- a/htdocs/hrm/job_agenda.php +++ b/htdocs/hrm/job_agenda.php @@ -88,8 +88,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/job_card.php b/htdocs/hrm/job_card.php index 3ca13ca1b77..1cfbc38a80e 100644 --- a/htdocs/hrm/job_card.php +++ b/htdocs/hrm/job_card.php @@ -78,9 +78,9 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/job'; // Security check (enable the most restrictive one) @@ -504,8 +504,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref . '/' . $objref . '.pdf'; $filedir = $conf->hrm->dir_output . '/' . $object->element . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->hrm->job->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->hrm->job->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('hrm', 'job', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('hrm', 'job', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('hrm:Job', $object->element . '/' . $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/hrm/job_document.php b/htdocs/hrm/job_document.php index b6b1e19412a..08784d007ef 100644 --- a/htdocs/hrm/job_document.php +++ b/htdocs/hrm/job_document.php @@ -80,8 +80,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/job_list.php b/htdocs/hrm/job_list.php index aa66d55dd4a..182c6030f76 100644 --- a/htdocs/hrm/job_list.php +++ b/htdocs/hrm/job_list.php @@ -133,9 +133,9 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); // Security check (enable the most restrictive one) if ($user->socid > 0) { diff --git a/htdocs/hrm/job_note.php b/htdocs/hrm/job_note.php index 2d2b340fee5..61d82ec2781 100644 --- a/htdocs/hrm/job_note.php +++ b/htdocs/hrm/job_note.php @@ -59,8 +59,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissionnote = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissionnote = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/position.php b/htdocs/hrm/position.php index 7ef6bf1c24c..7b3617c5778 100644 --- a/htdocs/hrm/position.php +++ b/htdocs/hrm/position.php @@ -146,9 +146,9 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/position'; // Security check (enable the most restrictive one) diff --git a/htdocs/hrm/position_agenda.php b/htdocs/hrm/position_agenda.php index b1534dc9787..232acae98c3 100644 --- a/htdocs/hrm/position_agenda.php +++ b/htdocs/hrm/position_agenda.php @@ -91,8 +91,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/position_card.php b/htdocs/hrm/position_card.php index 0dda7f0bea1..dc83d41e0d5 100644 --- a/htdocs/hrm/position_card.php +++ b/htdocs/hrm/position_card.php @@ -52,10 +52,10 @@ if ($res < 0) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->hrm->all->delete; -$permissiondellink = $user->rights->hrm->all->write; // Used by the include of actions_dellink.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); +$permissiondellink = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/position'; // Security check (enable the most restrictive one) diff --git a/htdocs/hrm/position_document.php b/htdocs/hrm/position_document.php index 5de8d3f0e33..d32e56ee93b 100644 --- a/htdocs/hrm/position_document.php +++ b/htdocs/hrm/position_document.php @@ -80,8 +80,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/position_list.php b/htdocs/hrm/position_list.php index bb9c888f93a..fd45a8c6f2b 100644 --- a/htdocs/hrm/position_list.php +++ b/htdocs/hrm/position_list.php @@ -134,9 +134,9 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); // Security check (enable the most restrictive one) if ($user->socid > 0) { diff --git a/htdocs/hrm/position_note.php b/htdocs/hrm/position_note.php index 7a23d7d7b7d..d7a9efa6cba 100644 --- a/htdocs/hrm/position_note.php +++ b/htdocs/hrm/position_note.php @@ -57,8 +57,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissionnote = $user->rights->hrm->all->write; -$permissiontoread = $user->rights->hrm->all->read; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('hrm', 'all', 'write'); +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/skill_agenda.php b/htdocs/hrm/skill_agenda.php index a2899731f8d..e6b5368a782 100644 --- a/htdocs/hrm/skill_agenda.php +++ b/htdocs/hrm/skill_agenda.php @@ -90,8 +90,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/skill_card.php b/htdocs/hrm/skill_card.php index 434b6b49979..bd2070a4f71 100644 --- a/htdocs/hrm/skill_card.php +++ b/htdocs/hrm/skill_card.php @@ -79,9 +79,9 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->hrm->all->delete; +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('hrm', 'all', 'delete'); $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1] . '/skill'; // Security check (enable the most restrictive one) diff --git a/htdocs/hrm/skill_document.php b/htdocs/hrm/skill_document.php index 4cd88ca4578..6c898faced2 100644 --- a/htdocs/hrm/skill_document.php +++ b/htdocs/hrm/skill_document.php @@ -80,8 +80,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissiontoread = $user->rights->hrm->all->read; -$permissiontoadd = $user->rights->hrm->all->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); +$permissiontoadd = $user->hasRight('hrm', 'all', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/hrm/skill_note.php b/htdocs/hrm/skill_note.php index 85822772375..645180ec4ec 100644 --- a/htdocs/hrm/skill_note.php +++ b/htdocs/hrm/skill_note.php @@ -57,8 +57,8 @@ if ($id > 0 || !empty($ref)) { } // Permissions -$permissionnote = $user->rights->hrm->all->write; -$permissiontoread = $user->rights->hrm->all->read; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('hrm', 'all', 'write'); +$permissiontoread = $user->hasRight('hrm', 'all', 'read'); // Used by the include of actions_addupdatedelete.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 0687650ce8a..05d8b4bb54b 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -171,7 +171,7 @@ class Import } // Permission - $this->array_import_perms[$i] = $user->rights->import->run; + $this->array_import_perms[$i] = $user->hasRight('import', 'run'); // Icon $this->array_import_icon[$i] = (isset($module->import_icon[$r]) ? $module->import_icon[$r] : $module->picto); // Code of dataset export diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index c234f22c7e4..358385af8f7 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -78,9 +78,9 @@ $hookmanager->initHooks(array('intracommcard', 'globalcard')); $error = 0; // Permissions -$permissiontoread = $user->rights->intracommreport->read; -$permissiontoadd = $user->rights->intracommreport->write; -$permissiontodelete = $user->rights->intracommreport->delete; +$permissiontoread = $user->hasRight('intracommreport', 'read'); +$permissiontoadd = $user->hasRight('intracommreport', 'write'); +$permissiontodelete = $user->hasRight('intracommreport', 'delete'); // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/intracommreport/list.php b/htdocs/intracommreport/list.php index ecf2ed66019..a3947ba03bc 100644 --- a/htdocs/intracommreport/list.php +++ b/htdocs/intracommreport/list.php @@ -153,8 +153,8 @@ if ($search_type == '0') { $result = restrictedArea($user, 'produit|service', '', '', '', '', '', 0); } -$permissiontoread = $user->rights->intracommreport->read; -$permissiontodelete = $user->rights->intracommreport->delete; +$permissiontoread = $user->hasRight('intracommreport', 'read'); +$permissiontodelete = $user->hasRight('intracommreport', 'delete'); /* diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php index 6aa24247afe..56bf59b10cc 100644 --- a/htdocs/loan/document.php +++ b/htdocs/loan/document.php @@ -72,7 +72,7 @@ if ($id > 0) { $upload_dir = $conf->loan->dir_output.'/'.dol_sanitizeFileName($object->ref); $modulepart = 'loan'; -$permissiontoadd = $user->rights->loan->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->hasRight('loan', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php /* @@ -164,8 +164,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'loan'; - $permissiontoadd = $user->rights->loan->write; - $permtoedit = $user->rights->loan->write; + $permissiontoadd = $user->hasRight('loan', 'write'); + $permtoedit = $user->hasRight('loan', 'write'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/loan/note.php b/htdocs/loan/note.php index 09a85f6aab0..ff5938a63c7 100644 --- a/htdocs/loan/note.php +++ b/htdocs/loan/note.php @@ -51,7 +51,7 @@ if ($id > 0) { $object->fetch($id); } -$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('loan', 'write'); // Used by the include of actions_setnotes.inc.php /* @@ -135,7 +135,7 @@ if ($id > 0) { print '
'; $cssclass = 'titlefield'; - $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php + $permission = $user->hasRight('loan', 'write'); // Used by the include of notes.tpl.php include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; print dol_get_fiche_end(); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 552310bb7b6..2be1db14f83 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1780,7 +1780,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr // Displays title $appli = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; + $appli = getDolGlobalString('MAIN_APPLICATION_TITLE'); } print ''; @@ -1848,7 +1848,7 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr print '<!-- Includes CSS for JQuery (Ajax library) -->'."\n"; $jquerytheme = 'base'; if (getDolGlobalString('MAIN_USE_JQUERY_THEME')) { - $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; + $jquerytheme = getDolGlobalString('MAIN_USE_JQUERY_THEME'); } if (constant('JS_JQUERY_UI')) { print '<link rel="stylesheet" type="text/css" href="'.JS_JQUERY_UI.'css/'.$jquerytheme.'/jquery-ui.min.css'.($ext ? '?'.$ext : '').'">'."\n"; // Forced JQuery @@ -2158,7 +2158,7 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Define link to login card $appli = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; + $appli = getDolGlobalString('MAIN_APPLICATION_TITLE'); if (preg_match('/\d\.\d/', $appli)) { if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core @@ -2515,7 +2515,7 @@ function top_menu_user($hideloginname = 0, $urllogout = '') // Define version to show $appli = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; + $appli = getDolGlobalString('MAIN_APPLICATION_TITLE'); if (preg_match('/\d\.\d/', $appli)) { if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core @@ -3271,7 +3271,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ $appli = constant('DOL_APPLICATION_TITLE'); if (getDolGlobalString('MAIN_APPLICATION_TITLE')) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; $doliurl = ''; + $appli = getDolGlobalString('MAIN_APPLICATION_TITLE'); $doliurl = ''; if (preg_match('/\d\.\d/', $appli)) { if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core @@ -3337,7 +3337,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ $bugbaseurl .= urlencode("\n"); $bugbaseurl .= urlencode("## Report\n"); } elseif (getDolGlobalString('MAIN_BUGTRACK_ENABLELINK')) { - $bugbaseurl = $conf->global->MAIN_BUGTRACK_ENABLELINK; + $bugbaseurl = getDolGlobalString('MAIN_BUGTRACK_ENABLELINK'); } else { $bugbaseurl = ""; } @@ -3405,7 +3405,7 @@ function main_area($title = '') print $hookmanager->resPrint; if (getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')) { - print info_admin($langs->trans("WarningYouAreInMaintenanceMode", $conf->global->MAIN_ONLY_LOGIN_ALLOWED), 0, 0, 1, 'warning maintenancemode'); + print info_admin($langs->trans("WarningYouAreInMaintenanceMode", getDolGlobalString('MAIN_ONLY_LOGIN_ALLOWED')), 0, 0, 1, 'warning maintenancemode'); } // Permit to add user company information on each printed document by setting SHOW_SOCINFO_ON_PRINT diff --git a/htdocs/mrp/ajax/interface.php b/htdocs/mrp/ajax/interface.php index 5d9501d13c2..83735a14dc2 100644 --- a/htdocs/mrp/ajax/interface.php +++ b/htdocs/mrp/ajax/interface.php @@ -32,7 +32,7 @@ $action = GETPOST('action', 'alphanohtml'); $result = restrictedArea($user, 'mrp'); -$permissiontoproduce = $user->rights->mrp->write; +$permissiontoproduce = $user->hasRight('mrp', 'write'); diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 92e1838cad4..39ae023c7c3 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -105,9 +105,9 @@ $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft); // Permissions -$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('mrp', 'write'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; @@ -837,7 +837,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->mrp->dir_output.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->mrp->read; // If you can read, you can build the PDF to read content + $genallowed = $user->hasRight('mrp', 'read'); // If you can read, you can build the PDF to read content $delallowed = $user->hasRight("mrp", "creer"); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mrp:mo', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang); diff --git a/htdocs/mrp/mo_document.php b/htdocs/mrp/mo_document.php index 505e598c4df..0c7ef6da4e8 100644 --- a/htdocs/mrp/mo_document.php +++ b/htdocs/mrp/mo_document.php @@ -83,7 +83,7 @@ if ($id > 0 || !empty($ref)) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft); -$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php +$permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php /* @@ -180,8 +180,8 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'mrp'; - $permissiontoadd = $user->rights->mrp->write; - $permtoedit = $user->rights->mrp->write; + $permissiontoadd = $user->hasRight('mrp', 'write'); + $permtoedit = $user->hasRight('mrp', 'write'); $param = '&id='.$object->id; //$relativepathwithnofile='mo/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index 136345b7c87..f73413914b8 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -139,9 +139,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->mrp->read; -$permissiontoadd = $user->rights->mrp->write; -$permissiontodelete = $user->rights->mrp->delete; +$permissiontoread = $user->hasRight('mrp', 'read'); +$permissiontoadd = $user->hasRight('mrp', 'write'); +$permissiontodelete = $user->hasRight('mrp', 'delete'); // Security check if ($user->socid > 0) { diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index fdb3a0a8366..ca9e1080733 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -147,9 +147,9 @@ $objectlist->fields = dol_sort_array($objectlist->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); // Permissions -$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('mrp', 'write'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->entity : 1]; diff --git a/htdocs/mrp/mo_note.php b/htdocs/mrp/mo_note.php index acdcf02f3bf..32d15e522b0 100644 --- a/htdocs/mrp/mo_note.php +++ b/htdocs/mrp/mo_note.php @@ -60,7 +60,7 @@ if ($id > 0 || !empty($ref)) { $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php index a0730b6078e..a05ad446a6d 100644 --- a/htdocs/mrp/mo_production.php +++ b/htdocs/mrp/mo_production.php @@ -93,9 +93,9 @@ $isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0); $result = restrictedArea($user, 'mrp', $object->id, 'mrp_mo', '', 'fk_soc', 'rowid', $isdraft); // Permissions -$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('mrp', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->hasRight('mrp', 'write'); // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->hasRight('mrp', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); $permissiontoproduce = $permissiontoadd; diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 68c9c87a707..306a3b590eb 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -61,10 +61,10 @@ $hookmanager->initHooks(array('surveycard', 'globalcard')); $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); -$permissiontoread = $user->rights->opensurvey->read; -$permissiontoadd = $user->rights->opensurvey->write; +$permissiontoread = $user->hasRight('opensurvey', 'read'); +$permissiontoadd = $user->hasRight('opensurvey', 'write'); // permission delete doesn't exists -$permissiontodelete = $user->rights->opensurvey->write; +$permissiontodelete = $user->hasRight('opensurvey', 'write'); /* diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index ed95a60d577..c9c736840e1 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -107,10 +107,10 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->opensurvey->read; -$permissiontoadd = $user->rights->opensurvey->write; +$permissiontoread = $user->hasRight('opensurvey', 'read'); +$permissiontoadd = $user->hasRight('opensurvey', 'write'); // permission delete doesn't exists -$permissiontodelete = $user->rights->opensurvey->write; +$permissiontodelete = $user->hasRight('opensurvey', 'write'); /* diff --git a/htdocs/partnership/partnership_agenda.php b/htdocs/partnership/partnership_agenda.php index e21f9e8b10b..ede3011d778 100644 --- a/htdocs/partnership/partnership_agenda.php +++ b/htdocs/partnership/partnership_agenda.php @@ -85,8 +85,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->partnership->multidir_output[$object->entity]."/".$object->id; } -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); // Security check - Protection if external user diff --git a/htdocs/partnership/partnership_contact.php b/htdocs/partnership/partnership_contact.php index 410a39dcb0a..d1f4d64527c 100644 --- a/htdocs/partnership/partnership_contact.php +++ b/htdocs/partnership/partnership_contact.php @@ -51,8 +51,8 @@ $extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals -$permissiontoread = $user->rights->partnership->read; -$permission = $user->rights->partnership->write; +$permissiontoread = $user->hasRight('partnership', 'read'); +$permission = $user->hasRight('partnership', 'write'); $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); // Security check - Protection if external user diff --git a/htdocs/partnership/partnership_document.php b/htdocs/partnership/partnership_document.php index 83e226a780b..c115151d4e7 100644 --- a/htdocs/partnership/partnership_document.php +++ b/htdocs/partnership/partnership_document.php @@ -75,8 +75,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->partnership->multidir_output[$object->entity ? $object->entity : $conf->entity]."/partnership/".get_exdir(0, 0, 0, 1, $object); } -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); // Security check - Protection if external user diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index cbd2c7aee69..6d97e6cf5f6 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -150,9 +150,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; -$permissiontodelete = $user->rights->partnership->delete; +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissiontoadd = $user->hasRight('partnership', 'write'); +$permissiontodelete = $user->hasRight('partnership', 'delete'); // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/partnership/partnership_note.php b/htdocs/partnership/partnership_note.php index dec2b76ccb1..7c370057e98 100644 --- a/htdocs/partnership/partnership_note.php +++ b/htdocs/partnership/partnership_note.php @@ -57,9 +57,9 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->partnership->multidir_output[$object->entity]."/".$object->id; } -$permissiontoread = $user->rights->partnership->read; -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoread = $user->hasRight('partnership', 'read'); +$permissionnote = $user->hasRight('partnership', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('partnership', 'write'); // Used by the include of actions_addupdatedelete.inc.php $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); // Security check - Protection if external user diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index b0f66bf3e59..5c2148913ae 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -84,18 +84,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ //$result = restrictedArea($user, 'mymodule', $id); if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $permissiontoread = $user->rights->stock->lire; - $permissiontoadd = $user->rights->stock->creer; - $permissiontodelete = $user->rights->stock->supprimer; - $permissionnote = $user->rights->stock->creer; // Used by the include of actions_setnotes.inc.php - $permissiondellink = $user->rights->stock->creer; // Used by the include of actions_dellink.inc.php + $permissiontoread = $user->hasRight('stock', 'lire'); + $permissiontoadd = $user->hasRight('stock', 'creer'); + $permissiontodelete = $user->hasRight('stock', 'supprimer'); + $permissionnote = $user->hasRight('stock', 'creer'); // Used by the include of actions_setnotes.inc.php + $permissiondellink = $user->hasRight('stock', 'creer'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->stock->multidir_output[isset($object->entity) ? $object->entity : 1]; } else { - $permissiontoread = $user->rights->stock->inventory_advance->read; - $permissiontoadd = $user->rights->stock->inventory_advance->write; - $permissiontodelete = $user->rights->stock->inventory_advance->delete; - $permissionnote = $user->rights->stock->inventory_advance->write; // Used by the include of actions_setnotes.inc.php - $permissiondellink = $user->rights->stock->inventory_advance->write; // Used by the include of actions_dellink.inc.php + $permissiontoread = $user->hasRight('stock', 'inventory_advance', 'read'); + $permissiontoadd = $user->hasRight('stock', 'inventory_advance', 'write'); + $permissiontodelete = $user->hasRight('stock', 'inventory_advance', 'delete'); + $permissionnote = $user->hasRight('stock', 'inventory_advance', 'write'); // Used by the include of actions_setnotes.inc.php + $permissiondellink = $user->hasRight('stock', 'inventory_advance', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->stock->multidir_output[isset($object->entity) ? $object->entity : 1]; } @@ -466,8 +466,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->mymodule->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->mymodule->myobject->read; // If you can read, you can build the PDF to read content - $delallowed = $user->rights->mymodule->myobject->write; // If you can create/edit, you can remove a file on card + $genallowed = $user->hasRight('mymodule', 'myobject', 'read'); // If you can read, you can build the PDF to read content + $delallowed = $user->hasRight('mymodule', 'myobject', 'write'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('mymodule:MyObject', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 6decd5e6f4a..cd8ee975ed4 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -104,11 +104,11 @@ if ($limit > 0 && $limit != $conf->liste_limit) { if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $permissiontoadd = $user->rights->stock->creer; - $permissiontodelete = $user->rights->stock->supprimer; + $permissiontoadd = $user->hasRight('stock', 'creer'); + $permissiontodelete = $user->hasRight('stock', 'supprimer'); } else { - $permissiontoadd = $user->rights->stock->inventory_advance->write; - $permissiontodelete = $user->rights->stock->inventory_advance->write; + $permissiontoadd = $user->hasRight('stock', 'inventory_advance', 'write'); + $permissiontodelete = $user->hasRight('stock', 'inventory_advance', 'write'); } $now = dol_now(); diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 3acbf368d5f..4424024dee7 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -129,9 +129,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->stock->lire; -$permissiontoadd = $user->rights->stock->creer; -$permissiontodelete = $user->rights->stock->supprimer; +$permissiontoread = $user->hasRight('stock', 'lire'); +$permissiontoadd = $user->hasRight('stock', 'creer'); +$permissiontodelete = $user->hasRight('stock', 'supprimer'); // Security check $socid = 0; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index cd8137b4609..3ad055f1e6c 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -249,10 +249,10 @@ $arrayfields = array( 'p.fk_default_workstation'=>array('label'=>'DefaultWorkstation', 'checked'=>0, 'enabled'=>isModEnabled('workstation') && $type == 1, 'position'=>33), 'p.sellprice'=>array('label'=>"SellingPrice", 'checked'=>1, 'enabled'=>!getDolGlobalString('PRODUIT_MULTIPRICES'), 'position'=>40), 'p.tva_tx'=>array('label'=>"VATRate", 'checked'=>0, 'enabled'=>!getDolGlobalString('PRODUIT_MULTIPRICES'), 'position'=>41), - 'p.minbuyprice'=>array('label'=>"BuyingPriceMinShort", 'checked'=>1, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>42), - 'p.numbuyprice'=>array('label'=>"BuyingPriceNumShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>43), - 'p.pmp'=>array('label'=>"PMPValueShort", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>44), - 'p.cost_price'=>array('label'=>"CostPrice", 'checked'=>0, 'enabled'=>(!empty($user->rights->fournisseur->lire)), 'position'=>45), + 'p.minbuyprice'=>array('label'=>"BuyingPriceMinShort", 'checked'=>1, 'enabled'=>($user->hasRight('fournisseur', 'lire')), 'position'=>42), + 'p.numbuyprice'=>array('label'=>"BuyingPriceNumShort", 'checked'=>0, 'enabled'=>($user->hasRight('fournisseur', 'lire')), 'position'=>43), + 'p.pmp'=>array('label'=>"PMPValueShort", 'checked'=>0, 'enabled'=>($user->hasRight('fournisseur', 'lire')), 'position'=>44), + 'p.cost_price'=>array('label'=>"CostPrice", 'checked'=>0, 'enabled'=>($user->hasRight('fournisseur', 'lire')), 'position'=>45), 'p.seuil_stock_alerte'=>array('label'=>"StockLimit", 'checked'=>0, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position'=>50), 'p.desiredstock'=>array('label'=>"DesiredStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position'=>51), 'p.stock'=>array('label'=>"PhysicalStock", 'checked'=>1, 'enabled'=>(isModEnabled('stock') && $user->hasRight('stock', 'lire') && ($contextpage != 'servicelist' || getDolGlobalString('STOCK_SUPPORTS_SERVICES'))), 'position'=>52), diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 5db1a837a01..a5c32a79043 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -92,9 +92,9 @@ if ($id > 0 || !empty($ref)) { } } -$usercanread = (($user->rights->stock->lire)); -$usercancreate = (($user->rights->stock->creer)); -$usercandelete = (($user->rights->stock->supprimer)); +$usercanread = (($user->hasRight('stock', 'lire'))); +$usercancreate = (($user->hasRight('stock', 'creer'))); +$usercandelete = (($user->hasRight('stock', 'supprimer'))); /* @@ -267,7 +267,7 @@ if (empty($reshook)) { // Actions to build doc $upload_dir = $conf->stock->dir_output; - $permissiontoadd = $user->rights->stock->creer; + $permissiontoadd = $user->hasRight('stock', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; } diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index fd3c8e2e9c4..c49d7f2f208 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -36,7 +36,7 @@ $ref = GETPOST('ref', 'alpha'); // Security check //$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); $result = restrictedArea($user, 'stock'); -$usercancreate = $user->rights->stock->creer; +$usercancreate = $user->hasRight('stock', 'creer'); /* * View diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 3f9ca9d6cce..712e44f3a18 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -135,9 +135,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->stock->lire; -$permissiontodelete = $user->rights->stock->supprimer; -$permissiontoadd = $user->rights->stock->creer; +$permissiontoread = $user->hasRight('stock', 'lire'); +$permissiontodelete = $user->hasRight('stock', 'supprimer'); +$permissiontoadd = $user->hasRight('stock', 'creer'); // Security check $result = restrictedArea($user, 'stock'); @@ -927,8 +927,8 @@ if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->stock->lire; - $delallowed = $user->rights->stock->creer; + $genallowed = $user->hasRight('stock', 'lire'); + $delallowed = $user->hasRight('stock', 'creer'); print $formfile->showdocuments('massfilesarea_stock', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 11c3dc31649..974ba22666c 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -122,9 +122,9 @@ $arrayfields = array( //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); -$usercanread = (($user->rights->stock->mouvement->lire)); -$usercancreate = (($user->rights->stock->mouvement->creer)); -$usercandelete = (($user->rights->stock->mouvement->supprimer)); +$usercanread = (($user->hasRight('stock', 'mouvement', 'lire'))); +$usercancreate = (($user->hasRight('stock', 'mouvement', 'creer'))); +$usercandelete = (($user->hasRight('stock', 'mouvement', 'supprimer'))); @@ -400,15 +400,15 @@ if ($action == "transfert_stock" && !$cancel) { // The builddoc action for object of a movement must be on the movement card // Actions to build doc $upload_dir = $conf->stock->dir_output."movement/"; -$permissiontoadd = $user->rights->stock->creer; +$permissiontoadd = $user->hasRight('stock', 'creer'); include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; if (empty($reshook) && $action != 'remove_file') { $objectclass = 'MouvementStock'; $objectlabel = 'Movements'; - $permissiontoread = $user->rights->stock->lire; - $permissiontodelete = $user->rights->stock->supprimer; + $permissiontoread = $user->hasRight('stock', 'lire'); + $permissiontodelete = $user->hasRight('stock', 'supprimer'); $uploaddir = $conf->stock->dir_output."/movement/"; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -1199,8 +1199,8 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id > 0) $genallowed = $usercanread; $delallowed = $usercancreate; - $genallowed = $user->rights->stock->lire; - $delallowed = $user->rights->stock->creer; + $genallowed = $user->hasRight('stock', 'lire'); + $delallowed = $user->hasRight('stock', 'creer'); print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown = $formfile->numoffiles; diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index d8cb47f17fe..1e07e1970a4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -173,13 +173,13 @@ if (!$user->hasRight('stock', 'mouvement', 'lire')) { $uploaddir = $conf->stock->dir_output.'/movements'; -$permissiontoread = $user->rights->stock->mouvement->lire; -$permissiontoadd = $user->rights->stock->mouvement->creer; -$permissiontodelete = $user->rights->stock->mouvement->creer; // There is no deletion permission for stock movement as we should never delete +$permissiontoread = $user->hasRight('stock', 'mouvement', 'lire'); +$permissiontoadd = $user->hasRight('stock', 'mouvement', 'creer'); +$permissiontodelete = $user->hasRight('stock', 'mouvement', 'creer'); // There is no deletion permission for stock movement as we should never delete -$usercanread = $user->rights->stock->mouvement->lire; -$usercancreate = $user->rights->stock->mouvement->creer; -$usercandelete = $user->rights->stock->mouvement->creer; +$usercanread = $user->hasRight('stock', 'mouvement', 'lire'); +$usercancreate = $user->hasRight('stock', 'mouvement', 'creer'); +$usercandelete = $user->hasRight('stock', 'mouvement', 'creer'); $error = 0; diff --git a/htdocs/product/stock/productlot_document.php b/htdocs/product/stock/productlot_document.php index 9c04f0e0447..8cc4343ea63 100644 --- a/htdocs/product/stock/productlot_document.php +++ b/htdocs/product/stock/productlot_document.php @@ -109,7 +109,7 @@ if (empty($upload_dir)) { $permissiontoread = $usercanread; $permissiontoadd = $usercancreate; -$permtoedit = $user->rights->produit->creer; +$permtoedit = $user->hasRight('produit', 'creer'); //$permissiontodelete = $usercandelete; // Security check diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 5d29e2bcd5b..c5734003b85 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -127,9 +127,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$usercanread = $user->rights->produit->lire; -$usercancreate = $user->rights->produit->creer; -$usercandelete = $user->rights->produit->supprimer; +$usercanread = $user->hasRight('produit', 'lire'); +$usercancreate = $user->hasRight('produit', 'creer'); +$usercandelete = $user->hasRight('produit', 'supprimer'); $upload_dir = $conf->productbatch->multidir_output[$conf->entity]; diff --git a/htdocs/product/stock/productlot_note.php b/htdocs/product/stock/productlot_note.php index e0e274f05bd..ee5c23ad162 100644 --- a/htdocs/product/stock/productlot_note.php +++ b/htdocs/product/stock/productlot_note.php @@ -50,7 +50,7 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->productlot->multidir_output[!empty($object->entity) ? $object->entity : $conf->entity]."/".$object->id; } -$permissionnote = $user->rights->produit->lire; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('produit', 'lire'); // Used by the include of actions_setnotes.inc.php // Security check (enable the most restrictive one) //if ($user->socid > 0) accessforbidden(); diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php index 4069721ba36..ada61f4f791 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_agenda.php @@ -88,7 +88,7 @@ if ($id > 0 || !empty($ref)) { //if ($user->socid > 0) $socid = $user->socid; $result = restrictedArea($user, 'stocktransfer', $object->id, '', 'stocktransfer'); -$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php /* diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php index 5e66bba6ed2..7a3779036e5 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php @@ -87,11 +87,11 @@ if (empty($action) && empty($id) && empty($ref)) { include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->stocktransfer->stocktransfer->read; -$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissionnote = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_setnotes.inc.php +$permissiontoread = $user->hasRight('stocktransfer', 'stocktransfer', 'read'); +$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_setnotes.inc.php $permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED); -$permissiondellink = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_dellink.inc.php +$permissiondellink = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_dellink.inc.php $upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1]; // Security check - Protection if external user diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php index 1da1be0ca9c..95fae85acb2 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_contact.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_contact.php @@ -159,7 +159,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); - $user->rights->stocktransfer->write = $user->rights->stocktransfer->stocktransfer->write; + $user->rights->stocktransfer->write = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); foreach ($dirtpls as $reldir) { diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_document.php b/htdocs/product/stock/stocktransfer/stocktransfer_document.php index 3ed8d1280ce..5c6a3b77355 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_document.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_document.php @@ -80,7 +80,7 @@ if ($id > 0 || !empty($ref)) { //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'stocktransfer', $object->id); -$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_addupdatedelete.inc.php +$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_note.php b/htdocs/product/stock/stocktransfer/stocktransfer_note.php index d3ca1b2bbbc..cef7273128d 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_note.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_note.php @@ -56,8 +56,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->stocktransfer->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->stocktransfer->stocktransfer->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index fac60bca8f5..fc3c8450691 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -413,7 +413,7 @@ if (empty($reshook)) { $object->opp_percent = $opp_percent; } - if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { + if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { if ($object->opp_amount && ($object->opp_status <= 0)) { $error++; setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 959cc1e84b3..b1759b48a43 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -92,7 +92,7 @@ $projectstatic = new Project($db); $form = new Form($db); $formfile = new FormFile($db); -$projectset = ($mine ? $mine : (empty($user->rights->projet->all->lire) ? 0 : 2)); +$projectset = ($mine ? $mine : (!$user->hasRight('projet', 'all', 'lire') ? 0 : 2)); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, $projectset, 1); //var_dump($projectsListId); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index f71b0fbfeb2..17bf7541798 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -695,7 +695,7 @@ if ($id > 0 || !empty($ref)) { $filename = dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $filedir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref); $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->projet->lire); + $genallowed = ($user->hasRight('projet', 'lire')); $delallowed = ($user->hasRight('projet', 'creer')); print $formfile->showdocuments('project_task', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); diff --git a/htdocs/public/webportal/tpl/menu.tpl.php b/htdocs/public/webportal/tpl/menu.tpl.php index a3226003109..bb615c24135 100644 --- a/htdocs/public/webportal/tpl/menu.tpl.php +++ b/htdocs/public/webportal/tpl/menu.tpl.php @@ -167,7 +167,7 @@ if (empty($reshook)) { <ul> <li class="brand"> <?php - $brandTitle = !empty($conf->global->WEBPORTAL_TITLE) ? getDolGlobalString('WEBPORTAL_TITLE') : getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); + $brandTitle = getDolGlobalString('WEBPORTAL_TITLE') ? getDolGlobalString('WEBPORTAL_TITLE') : getDolGlobalString('MAIN_INFO_SOCIETE_NOM'); print '<a class="brand__logo-link" href="'.$context->getControllerUrl().'" >'; if (!empty($context->theme->menuLogoUrl)) { print '<img class="brand__logo-img" src="' . dol_escape_htmltag($context->theme->menuLogoUrl) . '" alt="' . dol_escape_htmltag($brandTitle) . '" >'; diff --git a/htdocs/public/webportal/webportal.main.inc.php b/htdocs/public/webportal/webportal.main.inc.php index 667c8f340eb..f72337314c1 100644 --- a/htdocs/public/webportal/webportal.main.inc.php +++ b/htdocs/public/webportal/webportal.main.inc.php @@ -79,7 +79,7 @@ if (!defined('WEBPORTAL_NOREQUIRETRAN') || (!defined('WEBPORTAL_NOLOGIN') && !em if (!is_object($langs)) { // This can occurs when calling page with NOREQUIRETRAN defined, however we need langs for error messages. include_once DOL_DOCUMENT_ROOT . '/core/class/translate.class.php'; $langs = new Translate("", $conf); - $langcode = (GETPOST('lang', 'aZ09', 1) ? GETPOST('lang', 'aZ09', 1) : (empty($logged_user->conf->MAIN_LANG_DEFAULT) ? (empty($conf->global->MAIN_LANG_DEFAULT) ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $logged_user->conf->MAIN_LANG_DEFAULT)); + $langcode = (GETPOST('lang', 'aZ09', 1) ? GETPOST('lang', 'aZ09', 1) : (empty($logged_user->conf->MAIN_LANG_DEFAULT) ? (!getDolGlobalString('MAIN_LANG_DEFAULT') ? 'auto' : $conf->global->MAIN_LANG_DEFAULT) : $logged_user->conf->MAIN_LANG_DEFAULT)); if (defined('MAIN_LANG_DEFAULT')) { $langcode = constant('MAIN_LANG_DEFAULT'); } @@ -143,7 +143,7 @@ if (!defined('WEBPORTAL_NOLOGIN') && !empty($context->controllerInstance->access if (empty($webportal_logged_thirdparty_account_id)) { // Set cookie for timeout management - if (!empty($conf->global->MAIN_SESSION_TIMEOUT)) { + if (getDolGlobalString('MAIN_SESSION_TIMEOUT')) { setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", null, (empty($dolibarr_main_force_https) ? false : true), true); } diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index a4d4c666377..a0df3a17284 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -156,17 +156,17 @@ if (isModEnabled("reception") || $origin == 'reception' || empty($origin)) { } if (isModEnabled("reception")) { - $permissiontoread = $user->rights->reception->lire; - $permissiontoadd = $user->rights->reception->creer; - $permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate))); - $permissiontodelete = $user->rights->reception->supprimer; + $permissiontoread = $user->hasRight('reception', 'lire'); + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); + $permissiontodelete = $user->hasRight('reception', 'supprimer'); } else { - $permissiontoread = $user->rights->fournisseur->commande->receptionner; - $permissiontoadd = $user->rights->fournisseur->commande->receptionner; - $permissiondellink = $user->rights->fournisseur->commande->receptionner; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check))); - $permissiontodelete = $user->rights->fournisseur->commande->receptionner; + $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); + $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner'); } @@ -2208,8 +2208,8 @@ if ($action == 'create') { $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = $user->rights->reception->lire; - $delallowed = $user->rights->reception->creer; + $genallowed = $user->hasRight('reception', 'lire'); + $delallowed = $user->hasRight('reception', 'creer'); print $formfile->showdocuments('reception', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 7bd468463bb..c0f2fd18685 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -80,17 +80,17 @@ if ($origin == 'reception') { } if (isModEnabled("reception")) { - $permissiontoread = $user->rights->reception->lire; - $permissiontoadd = $user->rights->reception->creer; - $permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate))); - $permissiontodelete = $user->rights->reception->supprimer; + $permissiontoread = $user->hasRight('reception', 'lire'); + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); + $permissiontodelete = $user->hasRight('reception', 'supprimer'); } else { - $permissiontoread = $user->rights->fournisseur->commande->receptionner; - $permissiontoadd = $user->rights->fournisseur->commande->receptionner; - $permissiondellink = $user->rights->fournisseur->commande->receptionner; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check))); - $permissiontodelete = $user->rights->fournisseur->commande->receptionner; + $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); + $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner'); } diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index 2e895150463..fdd5135eb75 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -98,11 +98,11 @@ if ($id > 0 || !empty($ref)) { } if (empty($conf->reception->enabled)) { - $permissiontoreceive = $user->rights->fournisseur->commande->receptionner; - $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check))); + $permissiontoreceive = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); } else { - $permissiontoreceive = $user->rights->reception->creer; - $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate))); + $permissiontoreceive = $user->hasRight('reception', 'creer'); + $permissiontocontrol = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); } // $id is id of a reception diff --git a/htdocs/reception/document.php b/htdocs/reception/document.php index b5e4eafc0c6..30bb01e2d76 100644 --- a/htdocs/reception/document.php +++ b/htdocs/reception/document.php @@ -97,17 +97,17 @@ if ($user->socid > 0) { $result = restrictedArea($user, 'reception', $object->id, ''); if (isModEnabled("reception")) { - $permissiontoread = $user->rights->reception->lire; - $permissiontoadd = $user->rights->reception->creer; - $permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate))); - $permissiontodelete = $user->rights->reception->supprimer; + $permissiontoread = $user->hasRight('reception', 'lire'); + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); + $permissiontodelete = $user->hasRight('reception', 'supprimer'); } else { - $permissiontoread = $user->rights->fournisseur->commande->receptionner; - $permissiontoadd = $user->rights->fournisseur->commande->receptionner; - $permissiondellink = $user->rights->fournisseur->commande->receptionner; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check))); - $permissiontodelete = $user->rights->fournisseur->commande->receptionner; + $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); + $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner'); } @@ -198,8 +198,8 @@ if ($id > 0 || !empty($ref)) { print dol_get_fiche_end(); $modulepart = 'reception'; - $permissiontoadd = $user->rights->reception->creer; - $permtoedit = $user->rights->reception->creer; + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permtoedit = $user->hasRight('reception', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index ef28514f1fd..b89e8e46797 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -207,9 +207,9 @@ if (empty($reshook)) { // Mass actions $objectclass = 'Reception'; $objectlabel = 'Receptions'; - $permissiontoread = $user->rights->reception->lire; - $permissiontoadd = $user->rights->reception->creer; - $permissiontodelete = $user->rights->reception->supprimer; + $permissiontoread = $user->hasRight('reception', 'lire'); + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permissiontodelete = $user->hasRight('reception', 'supprimer'); $uploaddir = $conf->reception->multidir_output[$conf->entity]; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index 2d9ae567c02..304f122ce8e 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -69,19 +69,19 @@ if ($user->socid > 0) { } if (isModEnabled("reception")) { - $permissiontoread = $user->rights->reception->lire; - $permissiontoadd = $user->rights->reception->creer; - $permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->creer)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->reception->reception_advance->validate))); - $permissiontodelete = $user->rights->reception->supprimer; + $permissiontoread = $user->hasRight('reception', 'lire'); + $permissiontoadd = $user->hasRight('reception', 'creer'); + $permissiondellink = $user->hasRight('reception', 'creer'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('reception', 'reception_advance', 'validate'))); + $permissiontodelete = $user->hasRight('reception', 'supprimer'); } else { - $permissiontoread = $user->rights->fournisseur->commande->receptionner; - $permissiontoadd = $user->rights->fournisseur->commande->receptionner; - $permissiondellink = $user->rights->fournisseur->commande->receptionner; // Used by the include of actions_dellink.inc.php - $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande->receptionner)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->fournisseur->commande_advance->check))); - $permissiontodelete = $user->rights->fournisseur->commande->receptionner; + $permissiontoread = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiontoadd = $user->hasRight('fournisseur', 'commande', 'receptionner'); + $permissiondellink = $user->hasRight('fournisseur', 'commande', 'receptionner'); // Used by the include of actions_dellink.inc.php + $permissiontovalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande', 'receptionner')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('fournisseur', 'commande_advance', 'check'))); + $permissiontodelete = $user->hasRight('fournisseur', 'commande', 'receptionner'); } -$permissionnote = $user->rights->reception->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('reception', 'creer'); // Used by the include of actions_setnotes.inc.php // TODO Test on reception module on only if ($origin == 'reception') { diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 1fd68eeec63..d44427bc1da 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -66,8 +66,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $result = restrictedArea($user, 'resource', $object->id, 'resource'); -$permissiontoadd = $user->rights->resource->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->resource->delete; +$permissiontoadd = $user->hasRight('resource', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('resource', 'delete'); /* @@ -264,7 +264,7 @@ if ($action == 'create' || $object->fetch($id, $ref) > 0) { print '</td></tr>'; // State - if (empty($conf->global->SOCIETE_DISABLE_STATE)) { + if (!getDolGlobalString('SOCIETE_DISABLE_STATE')) { if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) { print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'; } else { diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 888e3aa91c7..2e195026761 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -347,7 +347,7 @@ class FormResource // If translation exists use it, otherwise use default name if ( - !empty($conf->global->MAIN_SHOW_STATE_CODE) && + getDolGlobalString('MAIN_SHOW_STATE_CODE') && (getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 1 || getDolGlobalInt('MAIN_SHOW_STATE_CODE') == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all') ) { if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1) { diff --git a/htdocs/resource/document.php b/htdocs/resource/document.php index 7bb60594336..21d21e0901c 100644 --- a/htdocs/resource/document.php +++ b/htdocs/resource/document.php @@ -80,7 +80,7 @@ $modulepart = 'resource'; $result = restrictedArea($user, 'resource', $object->id, 'resource'); -$permissiontoadd = $user->rights->resource->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles +$permissiontoadd = $user->hasRight('resource', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles /* @@ -146,7 +146,7 @@ if ($object->id > 0) { print dol_get_fiche_end(); $modulepart = 'dolresource'; - $permissiontoadd = $user->rights->resource->write; + $permissiontoadd = $user->hasRight('resource', 'write'); include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index e5cc1819ead..f40c7adbd03 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -51,7 +51,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ $result = restrictedArea($user, 'resource', $object->id, 'resource'); -$permissionnote = $user->rights->resource->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('resource', 'write'); // Used by the include of actions_setnotes.inc.php /* @@ -107,7 +107,7 @@ if ($id > 0 || !empty($ref)) { print '</div>'; - $permission = $user->rights->resource->write; + $permission = $user->hasRight('resource', 'write'); $cssclass = 'titlefield'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php index f1e58537c7f..f7d20471545 100644 --- a/htdocs/salaries/list.php +++ b/htdocs/salaries/list.php @@ -142,9 +142,9 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->salaries->read; -$permissiontoadd = $user->rights->salaries->write; -$permissiontodelete = $user->rights->salaries->delete; +$permissiontoread = $user->hasRight('salaries', 'read'); +$permissiontoadd = $user->hasRight('salaries', 'write'); +$permissiontodelete = $user->hasRight('salaries', 'delete'); // Security check $socid = GETPOST("socid", "int"); diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index c80070c78dd..68d9dd23056 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -148,9 +148,9 @@ foreach ($object->fields as $key => $val) { } } -$permissiontoread = $user->rights->salaries->read; -$permissiontoadd = $user->rights->salaries->write; -$permissiontodelete = $user->rights->salaries->delete; +$permissiontoread = $user->hasRight('salaries', 'read'); +$permissiontoadd = $user->hasRight('salaries', 'write'); +$permissiontodelete = $user->hasRight('salaries', 'delete'); // Security check $socid = GETPOST("socid", "int"); diff --git a/htdocs/salaries/virement_request.php b/htdocs/salaries/virement_request.php index e787a889e46..a17bf6e3dd2 100644 --- a/htdocs/salaries/virement_request.php +++ b/htdocs/salaries/virement_request.php @@ -102,8 +102,8 @@ if ($id > 0 || !empty($ref)) { } } -$permissiontoread = $user->rights->salaries->read; -$permissiontoadd = $user->rights->salaries->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles +$permissiontoread = $user->hasRight('salaries', 'read'); +$permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles $permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID); $moreparam = ''; diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 2cbf22d296d..91966522a21 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -1741,7 +1741,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayactio print '<td colspan="3" class="maxwidthonsmartphone">'; $userlist = $form->select_dolusers('', '', 0, null, 0, '', '', '0', 0, 0, 'AND u.statut = 1', 0, '', '', 0, 2); // Note: If user has no right to "see all thirdparties", we force selection of sale representative to him, so after creation he can see the record. - $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (empty($user->rights->societe->client->voir) ? array($user->id) : array()))); + $selected = (count(GETPOST('commercial', 'array')) > 0 ? GETPOST('commercial', 'array') : (GETPOST('commercial', 'int') > 0 ? array(GETPOST('commercial', 'int')) : (!$user->hasRight('societe', 'client', 'voir') ? array($user->id) : array()))); print img_picto('', 'user').$form->multiselectarray('commercial', $userlist, $selected, null, null, 'quatrevingtpercent widthcentpercentminusx', 0, 0); print '</td></tr>'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 9a668024981..64eb928edf8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4039,7 +4039,7 @@ class Societe extends CommonObject $isACompany = 1; } } - return boolval($isACompany); + return (bool) $isACompany; } /** diff --git a/htdocs/societe/paymentmodes.php b/htdocs/societe/paymentmodes.php index 5c7e2e58749..5f15d0e031d 100644 --- a/htdocs/societe/paymentmodes.php +++ b/htdocs/societe/paymentmodes.php @@ -82,7 +82,7 @@ $hookmanager->initHooks(array('thirdpartybancard', 'globalcard')); $permissiontoread = $user->hasRight('societe', 'lire'); $permissiontoadd = $user->hasRight('societe', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_builddoc.inc.php -$permissiontoaddupdatepaymentinformation = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->societe->thirdparty_paymentinformation_advance->write))); +$permissiontoaddupdatepaymentinformation = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('societe', 'thirdparty_paymentinformation_advance', 'write'))); // Check permission on company diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php index 9b1bb4c14c2..9b7d0d44087 100644 --- a/htdocs/societe/website.php +++ b/htdocs/societe/website.php @@ -664,8 +664,8 @@ if (in_array('builddoc', array_keys($arrayofmassactions)) && ($nbtotalofrecords $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->mymodule->read; - $delallowed = $user->rights->mymodule->create; + $genallowed = $user->hasRight('mymodule', 'read'); + $delallowed = $user->hasRight('mymodule', 'create'); print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 4567e6b823f..1127a921131 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -104,16 +104,16 @@ if ($id > 0 || !empty($ref)) { } // Common permissions -$usercanread = $user->rights->supplier_proposal->lire; -$usercancreate = $user->rights->supplier_proposal->creer; -$usercandelete = $user->rights->supplier_proposal->supprimer; +$usercanread = $user->hasRight('supplier_proposal', 'lire'); +$usercancreate = $user->hasRight('supplier_proposal', 'creer'); +$usercandelete = $user->hasRight('supplier_proposal', 'supprimer'); // Advanced permissions -$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->supplier_proposal->validate_advance))); +$usercanvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('supplier_proposal', 'validate_advance'))); $usercansend = (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') || $user->rights->supplier_proposal->send_advance); // Additional area permissions -$usercanclose = $user->rights->supplier_proposal->cloturer; +$usercanclose = $user->hasRight('supplier_proposal', 'cloturer'); $usercancreateorder = ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer); // Permissions for includes diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index 6ac79342692..70c70a9bfe9 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -76,7 +76,7 @@ if ($object->id > 0) { $upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref); } -$permissiontoadd = $user->rights->supplier_proposal->creer; +$permissiontoadd = $user->hasRight('supplier_proposal', 'creer'); $usercancreate = $permissiontoadd; /* @@ -164,8 +164,8 @@ if ($object->id > 0) { print dol_get_fiche_end(); $modulepart = 'supplier_proposal'; - $permissiontoadd = $user->rights->supplier_proposal->creer; - $permtoedit = $user->rights->supplier_proposal->creer; + $permissiontoadd = $user->hasRight('supplier_proposal', 'creer'); + $permtoedit = $user->hasRight('supplier_proposal', 'creer'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; } else { diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index c5b95580701..b15417f1868 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -204,8 +204,8 @@ if (!$user->hasRight('societe', 'client', 'voir')) { $result = restrictedArea($user, $module, $objectid, $dbtable); -$permissiontoread = $user->rights->supplier_proposal->lire; -$permissiontodelete = $user->rights->supplier_proposal->supprimer; +$permissiontoread = $user->hasRight('supplier_proposal', 'lire'); +$permissiontodelete = $user->hasRight('supplier_proposal', 'supprimer'); /* @@ -1358,8 +1358,8 @@ if ($resql) { $filedir = $diroutputmassaction; - $genallowed = $user->rights->supplier_proposal->lire; - $delallowed = $user->rights->supplier_proposal->creer; + $genallowed = $user->hasRight('supplier_proposal', 'lire'); + $delallowed = $user->hasRight('supplier_proposal', 'creer'); print $formfile->showdocuments('massfilesarea_supplier_proposal', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } else { diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 147b1299e22..964653459f9 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -61,7 +61,7 @@ $usercancreate = $user->hasRight("supplier_propal", "write"); * Actions */ -$permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->hasRight('supplier_proposal', 'creer'); // Used by the include of actions_setnotes.inc.php $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 35f8737168a..17b22e4e750 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -838,7 +838,7 @@ if (empty($reshook)) { $prod->fetch($line->fk_product); $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); + $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); $pu_ht = price2num($number / (1 + ($line->tva_tx / 100)), 'MU'); //Check min price if ($usercanproductignorepricemin && (!empty($price_min) && (price2num($pu_ht) * (1 - price2num($line->remise_percent) / 100) < price2num($price_min)))) { @@ -882,7 +882,7 @@ if (empty($reshook)) { $datapriceofproduct = $prod->getSellPrice($mysoc, $customer, 0); $price_min = $datapriceofproduct['price_min']; - $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && empty($user->rights->produit->ignore_price_min_advance)) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); + $usercanproductignorepricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); $pu_ht = price2num($line->subprice / (1 + ($line->tva_tx / 100)), 'MU'); diff --git a/htdocs/ticket/agenda.php b/htdocs/ticket/agenda.php index ca6150fb366..fe040dde435 100644 --- a/htdocs/ticket/agenda.php +++ b/htdocs/ticket/agenda.php @@ -105,7 +105,7 @@ if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $ accessforbidden(); } -$permissiontoadd = $user->rights->ticket->write; +$permissiontoadd = $user->hasRight('ticket', 'write'); /* diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php index b79c2501b85..a2bbe08be55 100644 --- a/htdocs/ticket/contact.php +++ b/htdocs/ticket/contact.php @@ -78,7 +78,7 @@ if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $ accessforbidden(); } -$permissiontoadd = $user->rights->ticket->write; +$permissiontoadd = $user->hasRight('ticket', 'write'); /* @@ -268,7 +268,7 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { //print '<br>'; - $permission = $user->rights->ticket->write; + $permission = $user->hasRight('ticket', 'write'); // Contacts lines (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); diff --git a/htdocs/ticket/document.php b/htdocs/ticket/document.php index 20642564918..00b848f240d 100644 --- a/htdocs/ticket/document.php +++ b/htdocs/ticket/document.php @@ -91,7 +91,7 @@ if (!$user->socid && getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $o accessforbidden(); } -$permissiontoadd = $user->rights->ticket->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles +$permissiontoadd = $user->hasRight('ticket', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles /* @@ -211,8 +211,8 @@ if ($object->id) { //$object->ref = $object->track_id; // For compatibility we use track ID for directory $modulepart = 'ticket'; - $permissiontoadd = $user->rights->ticket->write; - $permtoedit = $user->rights->ticket->write; + $permissiontoadd = $user->hasRight('ticket', 'write'); + $permtoedit = $user->hasRight('ticket', 'write'); $param = '&id='.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index 95cfbad7bc7..40d58535e49 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -177,9 +177,9 @@ if ($project_ref) { $search_fk_project = $projectid; } -$permissiontoread = $user->rights->ticket->read; -$permissiontoadd = $user->rights->ticket->write; -$permissiontodelete = $user->rights->ticket->delete; +$permissiontoread = $user->hasRight('ticket', 'read'); +$permissiontoadd = $user->hasRight('ticket', 'write'); +$permissiontodelete = $user->hasRight('ticket', 'delete'); $error = 0; diff --git a/htdocs/ticket/messaging.php b/htdocs/ticket/messaging.php index 7eed20c1f93..7daf2518b1f 100644 --- a/htdocs/ticket/messaging.php +++ b/htdocs/ticket/messaging.php @@ -102,7 +102,7 @@ if (!$user->socid && (getDolGlobalString('TICKET_LIMIT_VIEW_ASSIGNED_ONLY') && $ accessforbidden(); } -$permissiontoadd = $user->rights->ticket->write; +$permissiontoadd = $user->hasRight('ticket', 'write'); /* diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 76177649c10..613f41758ce 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -85,7 +85,7 @@ if (empty($account->userid)) { // Define value to know what current user can do on users $canadduser = (!empty($user->admin) || $user->hasRight('user', 'user', 'creer') || $user->rights->hrm->write_personal_information->write); $canreaduser = (!empty($user->admin) || $user->rights->user->user->lire || $user->rights->hrm->read_personal_information->read); -$permissiontoaddbankaccount = (!empty($user->rights->salaries->write) || !empty($user->rights->hrm->employee->write) || $user->hasRight('user', 'creer')); +$permissiontoaddbankaccount = ($user->hasRight('salaries', 'write') || $user->hasRight('hrm', 'employee', 'write') || $user->hasRight('user', 'creer')); $permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write'); $permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index 8eb400ad793..34aba0173b2 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -53,7 +53,7 @@ if (isModEnabled('multicompany') && $conf->entity > 1 && getDolGlobalString('MUL $canreadperms = true; if (getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) { - $canreadperms = (!empty($user->admin) || !empty($user->rights->user->group_advance->read)); + $canreadperms = (!empty($user->admin) || $user->hasRight('user', 'group_advance', 'read')); } diff --git a/htdocs/user/notify/card.php b/htdocs/user/notify/card.php index 37e8e780067..5e5aa095c1a 100644 --- a/htdocs/user/notify/card.php +++ b/htdocs/user/notify/card.php @@ -71,7 +71,7 @@ if ($id > 0 || !empty($ref)) { $object->getrights(); } -$permissiontoadd = (($object->id == $user->id) || (!empty($user->rights->user->user->lire))); +$permissiontoadd = (($object->id == $user->id) || ($user->hasRight('user', 'user', 'lire'))); // Security check if ($user->socid) { diff --git a/htdocs/variants/card.php b/htdocs/variants/card.php index da822702c22..501a209ad5f 100644 --- a/htdocs/variants/card.php +++ b/htdocs/variants/card.php @@ -59,10 +59,10 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('productattributecard', 'globalcard')); -$permissiontoread = $user->rights->variants->read; -$permissiontoadd = $user->rights->variants->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontoedit = $user->rights->variants->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontodelete = $user->rights->variants->delete; +$permissiontoread = $user->hasRight('variants', 'read'); +$permissiontoadd = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoedit = $user->hasRight('variants', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontodelete = $user->hasRight('variants', 'delete'); $error = 0; diff --git a/htdocs/webportal/class/context.class.php b/htdocs/webportal/class/context.class.php index 10fb12e5641..d590c4fcf6d 100644 --- a/htdocs/webportal/class/context.class.php +++ b/htdocs/webportal/class/context.class.php @@ -243,8 +243,8 @@ class Context global $conf; // Init de l'url de base - if (!empty($conf->global->WEBPORTAL_ROOT_URL)) { - $rootUrl = $conf->global->WEBPORTAL_ROOT_URL; + if (getDolGlobalString('WEBPORTAL_ROOT_URL')) { + $rootUrl = getDolGlobalString('WEBPORTAL_ROOT_URL'); if (substr($rootUrl, -1) !== '/') { $rootUrl .= '/'; } diff --git a/htdocs/webportal/class/html.formwebportal.class.php b/htdocs/webportal/class/html.formwebportal.class.php index d7f12bc735e..10d57b9591b 100644 --- a/htdocs/webportal/class/html.formwebportal.class.php +++ b/htdocs/webportal/class/html.formwebportal.class.php @@ -273,7 +273,7 @@ class FormWebPortal extends Form } // Get list of files starting with name of ref (Note: files with '^ref\.extension' are generated files, files with '^ref-...' are uploaded files) - if ($allfiles || !empty($conf->global->MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP)) { + if ($allfiles || getDolGlobalString('MAIN_SHOW_ALL_FILES_ON_DOCUMENT_TOOLTIP')) { $filterforfilesearch = '^' . preg_quote(basename($modulesubdir), '/'); } else { $filterforfilesearch = '^' . preg_quote(basename($modulesubdir), '/') . '\.'; diff --git a/htdocs/webportal/class/webPortalTheme.class.php b/htdocs/webportal/class/webPortalTheme.class.php index f4c87331dcf..4adfcb402c0 100644 --- a/htdocs/webportal/class/webPortalTheme.class.php +++ b/htdocs/webportal/class/webPortalTheme.class.php @@ -80,9 +80,9 @@ class WebPortalTheme $outColor = ''; - if (!empty($conf->global->WEBPORTAL_PRIMARY_COLOR)) { - $outColor = $conf->global->WEBPORTAL_PRIMARY_COLOR; - } elseif (!empty($conf->global->THEME_ELDY_TOPMENU_BACK1)) { + if (getDolGlobalString('WEBPORTAL_PRIMARY_COLOR')) { + $outColor = getDolGlobalString('WEBPORTAL_PRIMARY_COLOR'); + } elseif (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) { $outColor = '#' . colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1)); } diff --git a/htdocs/webportal/class/webportalmember.class.php b/htdocs/webportal/class/webportalmember.class.php index 3eaef8f7379..7ef93ac9f35 100644 --- a/htdocs/webportal/class/webportalmember.class.php +++ b/htdocs/webportal/class/webportalmember.class.php @@ -252,7 +252,7 @@ class WebPortalMember extends Adherent { global $conf, $langs, $hookmanager; - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) { + if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') && $withpictoimg) { $withpictoimg = 0; } @@ -297,7 +297,7 @@ class WebPortalMember extends Adherent $linkstart .= '<a href="' . $url . '"'; $linkclose = ""; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { $langs->load("users"); $label = $langs->trans("ShowUser"); $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; @@ -335,7 +335,7 @@ class WebPortalMember extends Adherent $result .= $picto; } if (($withpictoimg > -2 && $withpictoimg != 2) || $withpictoimg == -4) { - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { $result .= '<span class="nopadding valignmiddle' . ((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled') . ($morecss ? ' usertext' . $morecss : '') . '">'; } @@ -346,7 +346,7 @@ class WebPortalMember extends Adherent } else { $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : ($mode == 'lastname' ? 4 : -1)), $maxlen); } - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { $result .= '</span>'; } } @@ -435,8 +435,8 @@ class WebPortalMember extends Adherent // List of extra languages $arrayoflangcode = array(); - if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE)) { - $arrayoflangcode[] = $conf->global->PDF_USE_ALSO_LANGUAGE_CODE; + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { + $arrayoflangcode[] = getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'); } if (is_array($arrayoflangcode) && count($arrayoflangcode)) { @@ -466,9 +466,9 @@ class WebPortalMember extends Adherent } // If MAIN_FORCE_STATE_INTO_ADDRESS is on, state is already returned previously with getFullAddress - if (!in_array($this->country_code, $countriesusingstate) && empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS) - && empty($conf->global->SOCIETE_DISABLE_STATE) && $this->state) { - if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 && $this->region) { + if (!in_array($this->country_code, $countriesusingstate) && !getDolGlobalString('MAIN_FORCE_STATE_INTO_ADDRESS') + && !getDolGlobalString('SOCIETE_DISABLE_STATE') && $this->state) { + if (getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 && $this->region) { $out .= ($outdone ? ' - ' : '') . $this->region . ' - ' . $this->state; } else { $out .= ($outdone ? ' - ' : '') . $this->state; diff --git a/htdocs/webportal/class/webportalpartnership.class.php b/htdocs/webportal/class/webportalpartnership.class.php index 9aa428aa2fe..9a83db0bf59 100644 --- a/htdocs/webportal/class/webportalpartnership.class.php +++ b/htdocs/webportal/class/webportalpartnership.class.php @@ -265,7 +265,7 @@ class WebPortalPartnership extends Partnership $linkclose = ''; if (empty($notooltip)) { - if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { $label = $langs->trans("ShowPartnership"); $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; } diff --git a/htdocs/webportal/controllers/document.controller.class.php b/htdocs/webportal/controllers/document.controller.class.php index 0532b2fc218..ef07b55efee 100644 --- a/htdocs/webportal/controllers/document.controller.class.php +++ b/htdocs/webportal/controllers/document.controller.class.php @@ -111,7 +111,7 @@ class DocumentController extends Controller if (isset($_GET["attachment"])) { $attachment = GETPOST("attachment", 'alpha') ? true : false; } - if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) { + if (getDolGlobalString('MAIN_DISABLE_FORCE_SAVEAS')) { $attachment = false; } diff --git a/htdocs/website/index.php b/htdocs/website/index.php index ac3c6bd4c44..557eca88bc2 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -347,8 +347,8 @@ if ($action == 'replacesite' || $mode == 'replacesite') { $listofpages = getPagesFromSearchCriterias($containertype, $algo, $searchkey, 1000, $sortfield, $sortorder, $langcode, $otherfilters, -1); } -$usercanedit = $user->rights->website->write; -$permissiontoadd = $user->rights->website->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles +$usercanedit = $user->hasRight('website', 'write'); +$permissiontoadd = $user->hasRight('website', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles $permissiontodelete = $user->hasRight('website', 'delete'); diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index 59085e64cbe..8f16aca5b3f 100644 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -56,8 +56,8 @@ if ($id > 0 || !empty($ref)) { $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; } -$permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php -$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php +$permissionnote = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_setnotes.inc.php +$permissiontoadd = $user->hasRight('workstation', 'workstation', 'write'); // Used by the include of actions_addupdatedelete.inc.php // Security check $isdraft = 0; From 5b36c7c1ba047e4cccf3d3dac3aa1b747ef9f417 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 4 Feb 2024 18:21:13 +0100 Subject: [PATCH 52/90] Clean code --- htdocs/bookcal/availabilities_document.php | 4 ---- htdocs/bookcal/calendar_document.php | 4 ---- htdocs/eventorganization/conferenceorbooth_document.php | 4 ---- htdocs/hrm/job_document.php | 3 --- htdocs/knowledgemanagement/knowledgerecord_document.php | 4 ---- htdocs/partnership/partnership_document.php | 4 ---- htdocs/product/stock/stocktransfer/stocktransfer_document.php | 4 ---- 7 files changed, 27 deletions(-) diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php index 94e8fd47384..723df675ef5 100644 --- a/htdocs/bookcal/availabilities_document.php +++ b/htdocs/bookcal/availabilities_document.php @@ -196,10 +196,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'bookcal'; - //$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); - $permissiontoadd = 1; - //$permtoedit = $user->hasRight('bookcal', 'availabilities', 'write'); - $permtoedit = 1; $param = '&id='.$object->id; //$relativepathwithnofile='availabilities/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/bookcal/calendar_document.php b/htdocs/bookcal/calendar_document.php index b45c082c6ae..96b8b5b4d83 100644 --- a/htdocs/bookcal/calendar_document.php +++ b/htdocs/bookcal/calendar_document.php @@ -245,10 +245,6 @@ print '</div>'; print dol_get_fiche_end(); $modulepart = 'bookcal'; -//$permissiontoadd = $user->rights->bookcal->calendar->write; -$permissiontoadd = 1; -//$permtoedit = $user->rights->bookcal->calendar->write; -$permtoedit = 1; $param = '&id='.$object->id; //$relativepathwithnofile='calendar/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/eventorganization/conferenceorbooth_document.php b/htdocs/eventorganization/conferenceorbooth_document.php index 3ca9ead5d8b..2e759c02658 100644 --- a/htdocs/eventorganization/conferenceorbooth_document.php +++ b/htdocs/eventorganization/conferenceorbooth_document.php @@ -395,10 +395,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'eventorganization'; - //$permission = $user->rights->eventorganization->conferenceorbooth->write; - $permission = 1; - //$permtoedit = $user->rights->eventorganization->conferenceorbooth->write; - $permtoedit = 1; $param = '&id='.$object->id; //$param = ''; if ($withproject) { diff --git a/htdocs/hrm/job_document.php b/htdocs/hrm/job_document.php index 08784d007ef..3f9ff9a74dc 100644 --- a/htdocs/hrm/job_document.php +++ b/htdocs/hrm/job_document.php @@ -158,9 +158,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'hrm'; - //$permissiontoadd = $user->rights->hrm->job->write; - //$permtoedit = $user->rights->hrm->job->write; - $permtoedit = $permissiontoadd; $param = '&id='.$object->id; //$relativepathwithnofile='job/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/knowledgemanagement/knowledgerecord_document.php b/htdocs/knowledgemanagement/knowledgerecord_document.php index f83bcd883e0..75780701b36 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_document.php +++ b/htdocs/knowledgemanagement/knowledgerecord_document.php @@ -183,10 +183,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'knowledgemanagement'; - //$permission = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); - $permission = 1; - //$permtoedit = $user->hasRight('knowledgemanagement', 'knowledgerecord', 'write'); - $permtoedit = 1; $param = '&id='.$object->id; //$relativepathwithnofile='knowledgerecord/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/partnership/partnership_document.php b/htdocs/partnership/partnership_document.php index c115151d4e7..c0d83257d3a 100644 --- a/htdocs/partnership/partnership_document.php +++ b/htdocs/partnership/partnership_document.php @@ -196,10 +196,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'partnership'; - //$permission = $user->rights->partnership->write; - $permission = 1; - //$permtoedit = $user->rights->partnership->write; - $permtoedit = 1; $param = '&id='.$object->id; //$relativepathwithnofile='partnership/' . dol_sanitizeFileName($object->id).'/'; diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_document.php b/htdocs/product/stock/stocktransfer/stocktransfer_document.php index 5c6a3b77355..72b5352f740 100644 --- a/htdocs/product/stock/stocktransfer/stocktransfer_document.php +++ b/htdocs/product/stock/stocktransfer/stocktransfer_document.php @@ -182,10 +182,6 @@ if ($object->id) { print dol_get_fiche_end(); $modulepart = 'stocktransfer'; - //$permission = $user->rights->stocktransfer->stocktransfer->write; - $permission = 1; - //$permtoedit = $user->rights->stocktransfer->stocktransfer->write; - $permtoedit = 1; $param = '&id='.$object->id; //$relativepathwithnofile='stocktransfer/' . dol_sanitizeFileName($object->id).'/'; From 246fcc639bbe8fee3cdce52e739383c3369f8dce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 4 Feb 2024 18:21:17 +0100 Subject: [PATCH 53/90] Use rector to convert user->rights into user->hasRight --- .../src/Renaming/UserRightsToFunction.php | 77 ++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index af9a4d6e3e3..4c69fa52e31 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -10,6 +10,10 @@ use Rector\Core\PhpParser\Node\NodeFactory; use Rector\Core\Rector\AbstractRector; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; +use PhpParser\Node\Expr\BinaryOp\BooleanAnd; +use PhpParser\Node\Expr\BinaryOp\Concat; +use PhpParser\Node\Expr\BinaryOp\Equal; + /** * Class to refactor User rights @@ -50,6 +54,7 @@ class UserRightsToFunction extends AbstractRector Node\Expr\Assign::class, Node\Expr\PropertyFetch::class, Node\Expr\BooleanNot::class, + Node\Expr\BinaryOp\BooleanAnd::class, Node\Expr\Empty_::class, Node\Expr\Isset_::class, Node\Stmt\ClassMethod::class @@ -75,9 +80,8 @@ class UserRightsToFunction extends AbstractRector } } - if ($node instanceof Node\Expr\Assign) { - // var is left of = and expr is right + // var is left of = and expr is right of = if (!isset($node->var)) { return; } @@ -99,6 +103,45 @@ class UserRightsToFunction extends AbstractRector return $node; } + if ($node instanceof Node\Expr\BinaryOp\BooleanAnd) { + /*$nodes = $this->resolveTwoNodeMatch($node); + if (!isset($nodes)) { + return; + } + + $node = $nodes->getFirstExpr(); + */ + $mustprocesstheleft = false; + $mustprocesstheright = false; + + if ($node->left instanceof Node\Expr\PropertyFetch) { + $data = $this->getRights($node->left); + if (isset($data)) { + $mustprocesstheleft = true; + } + } + if (empty($mustprocesstheleft) && $node->right instanceof Node\Expr\PropertyFetch) { + $data = $this->getRights($node->right); + if (isset($data)) { + $mustprocesstheright = true; + } + } + + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } + + if ($mustprocesstheleft) { + $node->left = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + } + if ($mustprocesstheright) { + $node->right = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + } + + return $node; + } + $caseok = false; // Will be tru if we can make the replacement. We must not do it for assignement like when $user->right->aaa->bbb = ... $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { @@ -181,4 +224,34 @@ class UserRightsToFunction extends AbstractRector $user = $rights->var; return compact('user', 'module', 'perm1', 'perm2'); } + + /** + * Get nodes with check empty + * + * @param BooleanAnd $booleanAnd A BooleandAnd + * @return TwoNodeMatch|null + */ + private function resolveTwoNodeMatch(BooleanAnd $booleanAnd): ?TwoNodeMatch + { + return $this->binaryOpManipulator->matchFirstAndSecondConditionNode( + $booleanAnd, + // Function to check if we are in the case $conf->global->... == $value + function (Node $node): bool { + if (!$node instanceof Equal) { + return \false; + } + return $this->isGlobalVar($node->left); + }, + // !empty(...) || isset(...) + function (Node $node): bool { + if ($node instanceof BooleanNot && $node->expr instanceof Empty_) { + return $this->isGlobalVar($node->expr->expr); + } + if (!$node instanceof Isset_) { + return $this->isGlobalVar($node); + } + return \true; + } + ); + } } From 73d979515270ea8439cc0e3d29d71083298dfa1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 4 Feb 2024 18:30:53 +0100 Subject: [PATCH 54/90] Use rector to convert user->rights into user->hasRight --- .../src/Renaming/UserRightsToFunction.php | 20 +++++++++-------- htdocs/core/boxes/box_members_by_tags.php | 2 +- htdocs/core/lib/files.lib.php | 2 +- .../doc/doc_generic_project_odt.modules.php | 22 +++++++++---------- .../project/doc/pdf_beluga.modules.php | 10 ++++----- htdocs/don/card.php | 2 +- htdocs/expensereport/list.php | 4 ++-- htdocs/holiday/card.php | 4 ++-- htdocs/hrm/evaluation_card.php | 2 +- htdocs/product/composition/card.php | 6 ++--- htdocs/product/fournisseurs.php | 4 ++-- htdocs/product/stock/product.php | 4 ++-- htdocs/projet/card.php | 2 +- htdocs/ticket/card.php | 2 +- htdocs/variants/combinations.php | 6 ++--- 15 files changed, 47 insertions(+), 45 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index 4c69fa52e31..5f484264f91 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -127,16 +127,18 @@ class UserRightsToFunction extends AbstractRector } } - $args = [new Arg($data['module']), new Arg($data['perm1'])]; - if (!empty($data['perm2'])) { - $args[] = new Arg($data['perm2']); - } + if (isset($data)) { + $args = [new Arg($data['module']), new Arg($data['perm1'])]; + if (!empty($data['perm2'])) { + $args[] = new Arg($data['perm2']); + } - if ($mustprocesstheleft) { - $node->left = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); - } - if ($mustprocesstheright) { - $node->right = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + if ($mustprocesstheleft && !empty($data['module'])) { + $node->left = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + } + if ($mustprocesstheright && !empty($data['module'])) { + $node->right = $this->nodeFactory->createMethodCall($data['user'], 'hasRight', $args); + } } return $node; diff --git a/htdocs/core/boxes/box_members_by_tags.php b/htdocs/core/boxes/box_members_by_tags.php index 801c045d8d3..587d7bdcd53 100644 --- a/htdocs/core/boxes/box_members_by_tags.php +++ b/htdocs/core/boxes/box_members_by_tags.php @@ -58,7 +58,7 @@ class box_members_by_tags extends ModeleBoxes $this->enabled = 0; // disabled for external users } - $this->hidden = !(isModEnabled('adherent') && $user->rights->adherent->lire); + $this->hidden = !(isModEnabled('adherent') && $user->hasRight('adherent', 'lire')); } /** diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index dce5639875d..ff39f4b7149 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -2672,7 +2672,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, $original_file = $dolibarr_main_data_root.'/doctemplates/'.$original_file; } elseif ($modulepart == 'doctemplateswebsite' && !empty($dolibarr_main_data_root)) { // Wrapping for doctemplates of websites - $accessallowed = ($fuser->rights->website->write && preg_match('/\.jpg$/i', basename($original_file))); + $accessallowed = ($fuser->hasRight('website', 'write') && preg_match('/\.jpg$/i', basename($original_file))); $original_file = $dolibarr_main_data_root.'/doctemplates/websites/'.$original_file; } elseif ($modulepart == 'packages' && !empty($dolibarr_main_data_root)) { // To download zip of modules // Wrapping for *.zip package files, like when used with url http://.../document.php?modulepart=packages&file=module_myfile.zip diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 26911824813..48c64bdd6c3 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -964,19 +964,19 @@ class doc_generic_project_odt extends ModelePDFProjects 'title' => "ListSupplierProposalsAssociatedProject", 'class' => 'SupplierProposal', 'table' => 'supplier_proposal', - 'test' => isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire + 'test' => isModEnabled('supplier_proposal') && $user->hasRight('supplier_proposal', 'lire') ), 'order_supplier' => array( 'title' => "ListSupplierOrdersAssociatedProject", 'table' => 'commande_fournisseur', 'class' => 'CommandeFournisseur', - 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire) + 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')) ), 'invoice_supplier' => array( 'title' => "ListSupplierInvoicesAssociatedProject", 'table' => 'facture_fourn', 'class' => 'FactureFournisseur', - 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire) + 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')) ), 'contract' => array( 'title' => "ListContractAssociatedProject", @@ -996,52 +996,52 @@ class doc_generic_project_odt extends ModelePDFProjects 'class' => 'Expedition', 'table' => 'expedition', 'disableamount' => 1, - 'test' => isModEnabled('expedition') && $user->rights->expedition->lire + 'test' => isModEnabled('expedition') && $user->hasRight('expedition', 'lire') ), 'trip' => array( 'title' => "ListTripAssociatedProject", 'class' => 'Deplacement', 'table' => 'deplacement', 'disableamount' => 1, - 'test' => isModEnabled('deplacement') && $user->rights->deplacement->lire + 'test' => isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire') ), 'expensereport' => array( 'title' => "ListExpenseReportsAssociatedProject", 'class' => 'ExpenseReportLine', 'table' => 'expensereport_det', - 'test' => isModEnabled('expensereport') && $user->rights->expensereport->lire + 'test' => isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire') ), 'donation' => array( 'title' => "ListDonationsAssociatedProject", 'class' => 'Don', 'table' => 'don', - 'test' => isModEnabled('don') && $user->rights->don->lire + 'test' => isModEnabled('don') && $user->hasRight('don', 'lire') ), 'loan' => array( 'title' => "ListLoanAssociatedProject", 'class' => 'Loan', 'table' => 'loan', - 'test' => isModEnabled('loan') && $user->rights->loan->read + 'test' => isModEnabled('loan') && $user->hasRight('loan', 'read') ), 'chargesociales' => array( 'title' => "ListSocialContributionAssociatedProject", 'class' => 'ChargeSociales', 'table' => 'chargesociales', 'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id, - 'test' => isModEnabled('tax') && $user->rights->tax->charges->lire + 'test' => isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire') ), 'stock_mouvement' => array( 'title' => "ListMouvementStockProject", 'class' => 'MouvementStock', 'table' => 'stock_mouvement', - 'test' => (isModEnabled('stock') && $user->rights->stock->mouvement->lire && getDolGlobalString('STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW')) + 'test' => (isModEnabled('stock') && $user->hasRight('stock', 'mouvement', 'lire') && getDolGlobalString('STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW')) ), 'agenda' => array( 'title' => "ListActionsAssociatedProject", 'class' => 'ActionComm', 'table' => 'actioncomm', 'disableamount' => 1, - 'test' => isModEnabled('agenda') && $user->rights->agenda->allactions->lire + 'test' => isModEnabled('agenda') && $user->hasRight('agenda', 'allactions', 'lire') ), ); diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index ae340d70d44..1b72613d780 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -355,7 +355,7 @@ class pdf_beluga extends ModelePDFProjects 'class'=>'CommandeFournisseur', 'table'=>'commande_fournisseur', 'datefieldname'=>'date_commande', - 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire), + 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'commande', 'lire')) || (isModEnabled("supplier_order") && $user->hasRight('supplier_order', 'lire')), 'lang'=>'orders'), 'invoice_supplier'=>array( 'name'=>"BillsSuppliers", @@ -364,7 +364,7 @@ class pdf_beluga extends ModelePDFProjects 'margin'=>'minus', 'table'=>'facture_fourn', 'datefieldname'=>'datef', - 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire), + 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight('fournisseur', 'facture', 'lire')) || (isModEnabled("supplier_invoice") && $user->hasRight('supplier_invoice', 'lire')), 'lang'=>'bills'), 'contract'=>array( 'name'=>"Contracts", @@ -391,7 +391,7 @@ class pdf_beluga extends ModelePDFProjects 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'test'=>isModEnabled('deplacement') && $user->rights->deplacement->lire, + 'test'=>isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire'), 'lang'=>'trip'), 'expensereport'=>array( 'name'=>"ExpensesReports", @@ -401,7 +401,7 @@ class pdf_beluga extends ModelePDFProjects 'datefieldname'=>'dated', 'margin'=>'minus', 'disableamount'=>1, - 'test'=>isModEnabled('expensereport') && $user->rights->expensereport->lire, + 'test'=>isModEnabled('expensereport') && $user->hasRight('expensereport', 'lire'), 'lang'=>'trip'), 'agenda'=>array( 'name'=>"Agenda", @@ -410,7 +410,7 @@ class pdf_beluga extends ModelePDFProjects 'table'=>'actioncomm', 'datefieldname'=>'datep', 'disableamount'=>1, - 'test'=> isModEnabled('agenda') && $user->rights->agenda->allactions->read, + 'test'=> isModEnabled('agenda') && $user->hasRight('agenda', 'allactions', 'read'), 'lang'=>'agenda') ); diff --git a/htdocs/don/card.php b/htdocs/don/card.php index cb012a3999d..78f6bdb376b 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -962,7 +962,7 @@ if (!empty($id) && $action != 'edit') { $filename = dol_sanitizeFileName($object->id); $filedir = $conf->don->dir_output."/".dol_sanitizeFileName($object->id); $urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id; - $genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire); + $genallowed = (($object->paid == 0 || $user->admin) && $user->hasRight('don', 'lire')); $delallowed = $user->hasRight('don', 'creer'); print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf); diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 03d1106177c..47364111920 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -497,8 +497,8 @@ if ($resql) { $childids = $user->getAllChildIds(1); - $canedit = ((in_array($user_id, $childids) && $user->rights->expensereport->creer) - || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance)); + $canedit = ((in_array($user_id, $childids) && $user->hasRight('expensereport', 'creer')) + || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->hasRight('expensereport', 'writeall_advance'))); // Buttons for actions if ($canedit) { diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 2d76c1b0cbb..83828e91488 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -1623,8 +1623,8 @@ if ((empty($id) && empty($ref)) || $action == 'create' || $action == 'add') { $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->holiday->dir_output.'/'.$object->element.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed = ($user->rights->holiday->read && $object->fk_user == $user->id) || $user->hasRight('holiday', 'readall'); // If you can read, you can build the PDF to read content - $delallowed = ($user->rights->holiday->write && $object->fk_user == $user->id) || $user->hasRight('holiday', 'writeall_advance'); // If you can create/edit, you can remove a file on card + $genallowed = ($user->hasRight('holiday', 'read') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'readall'); // If you can read, you can build the PDF to read content + $delallowed = ($user->hasRight('holiday', 'write') && $object->fk_user == $user->id) || $user->hasRight('holiday', 'writeall_advance'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('holiday:Holiday', $object->element.'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); } diff --git a/htdocs/hrm/evaluation_card.php b/htdocs/hrm/evaluation_card.php index b924a6f18f9..742b109fc1f 100644 --- a/htdocs/hrm/evaluation_card.php +++ b/htdocs/hrm/evaluation_card.php @@ -83,7 +83,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ // Permissions $permissiontoread = $user->hasRight('hrm', 'evaluation', 'read'); $permissiontoadd = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$permissiontovalidate = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->rights->hrm->evaluation_advance->validate) || (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd); +$permissiontovalidate = (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('hrm', 'evaluation_advance', 'validate')) || (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $permissiontoadd); $permissiontoClose = $user->hasRight('hrm', 'evaluation', 'write'); $permissiontodelete = $user->hasRight('hrm', 'evaluation', 'delete')/* || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT)*/; $permissiondellink = $user->hasRight('hrm', 'evaluation', 'write'); // Used by the include of actions_dellink.inc.php diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 1e86a7bedce..0590e1f541d 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -76,9 +76,9 @@ if ($object->id > 0) { } else { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); -$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'supprimer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'supprimer'))); /* diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index aba181da8f9..735e09feead 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -108,8 +108,8 @@ if ($id > 0 || $ref) { $prod->fetch($id, $ref); } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); if ($object->id > 0) { if ($object->type == $object::TYPE_PRODUCT) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 690d1f68e01..442fa454d95 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -115,8 +115,8 @@ $hookmanager->initHooks(array('stockproductcard', 'globalcard')); $error = 0; -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'lire'); if ($object->isService()) { diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index fc3c8450691..50b82ad259d 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -404,7 +404,7 @@ if (empty($reshook)) { } } - if ($action == 'set_opp_status' && $user->rights->projet->creer) { + if ($action == 'set_opp_status' && $user->hasRight('projet', 'creer')) { $error = 0; if (GETPOSTISSET('opp_status')) { $object->opp_status = $opp_status; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 8c8441d1415..18e1305afc0 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -969,7 +969,7 @@ if ($action == 'create' || $action == 'presend') { $morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">- '.$form->textwithpicto($langs->trans("CreatedByPublicPortal"), $htmltooptip, 1, 'help', '', 0, 3, 'tooltip').'</small>'; } - $permissiontoedit = $object->status < 8 && !$user->socid && $user->rights->ticket->write; + $permissiontoedit = $object->status < 8 && !$user->socid && $user->hasRight('ticket', 'write'); //$permissiontoedit = 0; // Thirdparty diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 61f8822836c..04dd36fad38 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -90,9 +90,9 @@ if ($object->id > 0) { } else { restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype); } -$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->lire) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); -$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); -$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)); +$usercanread = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'lire')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'lire'))); +$usercancreate = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'creer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'creer'))); +$usercandelete = (($object->type == Product::TYPE_PRODUCT && $user->hasRight('produit', 'supprimer')) || ($object->type == Product::TYPE_SERVICE && $user->hasRight('service', 'supprimer'))); /* From 539a7666eb9d4aa4348a98a44a6e1a06ff7d45f0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 4 Feb 2024 18:45:35 +0100 Subject: [PATCH 55/90] Clean code --- htdocs/bookcal/bookcalindex.php | 2 +- htdocs/bookcal/class/availabilities.class.php | 29 ------- htdocs/bookcal/class/calendar.class.php | 29 ------- htdocs/comm/remx.php | 9 --- htdocs/compta/bank/bankentries_list.php | 1 - htdocs/compta/bank/line.php | 3 - .../cashcontrol/class/cashcontrol.class.php | 10 --- htdocs/compta/facture/card-rec.php | 2 - htdocs/compta/facture/card.php | 6 +- htdocs/compta/index.php | 2 - htdocs/compta/sociales/card.php | 1 - htdocs/compta/tva/card.php | 1 - htdocs/contact/consumption.php | 2 +- htdocs/don/class/don.class.php | 7 -- htdocs/don/class/donstats.class.php | 2 - htdocs/don/stats/index.php | 79 ------------------- htdocs/ecm/file_card.php | 2 - htdocs/fichinter/note.php | 2 - htdocs/ftp/index.php | 7 -- htdocs/salaries/payments.php | 2 +- htdocs/salaries/virement_request.php | 2 +- htdocs/ticket/card.php | 2 +- htdocs/ticket/stats/index.php | 67 ---------------- htdocs/user/bank.php | 2 +- htdocs/user/class/user.class.php | 4 +- htdocs/user/virtualcard.php | 2 - htdocs/variants/combinations.php | 9 --- .../productattributevalueline_title.tpl.php | 4 +- .../productattributevalueline_view.tpl.php | 4 +- htdocs/webhook/class/target.class.php | 35 -------- htdocs/website/websiteaccount_card.php | 14 ---- 31 files changed, 15 insertions(+), 328 deletions(-) diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php index d2cb7c30a10..cbffda374fd 100644 --- a/htdocs/bookcal/bookcalindex.php +++ b/htdocs/bookcal/bookcalindex.php @@ -35,7 +35,7 @@ $action = GETPOST('action', 'aZ09'); // Security check -// if (! $user->rights->bookcal->myobject->read) { +// if (! $user->hasRight('bookcal', 'myobject', 'read')) { // accessforbidden(); // } $socid = GETPOST('socid', 'int'); diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index d80af0daa87..f4091827496 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -525,14 +525,6 @@ class Availabilities extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('bookcal', 'availabilities', 'write')) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->availabilities->availabilities_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - $now = dol_now(); $this->db->begin(); @@ -651,13 +643,6 @@ class Availabilities extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'AVAILABILITIES_UNVALIDATE'); } @@ -675,13 +660,6 @@ class Availabilities extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'AVAILABILITIES_CANCEL'); } @@ -699,13 +677,6 @@ class Availabilities extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->write)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'AVAILABILITIES_REOPEN'); } diff --git a/htdocs/bookcal/class/calendar.class.php b/htdocs/bookcal/class/calendar.class.php index 12086607201..37164e56051 100644 --- a/htdocs/bookcal/class/calendar.class.php +++ b/htdocs/bookcal/class/calendar.class.php @@ -482,14 +482,6 @@ class Calendar extends CommonObject return 0; } - /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->calendar->write)) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->calendar->calendar_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - $now = dol_now(); $this->db->begin(); @@ -608,13 +600,6 @@ class Calendar extends CommonObject return 0; } - /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->write)) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'MYOBJECT_UNVALIDATE'); } @@ -632,13 +617,6 @@ class Calendar extends CommonObject return 0; } - /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->write)) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'MYOBJECT_CANCEL'); } @@ -656,13 +634,6 @@ class Calendar extends CommonObject return 0; } - /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->write)) - || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && !empty($user->rights->bookcal->bookcal_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'MYOBJECT_REOPEN'); } diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index 3d7e1d5e3db..068fdff9052 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -69,9 +69,6 @@ if (GETPOST('cancel', 'alpha') && !empty($backtopage)) { } if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permissiontocreate) { - //if ($user->rights->societe->creer) - //if ($user->hasRight('facture', 'creer')) - $amount_ttc_1 = GETPOST('amount_ttc_1', 'alpha'); $amount_ttc_1 = price2num($amount_ttc_1); $amount_ttc_2 = GETPOST('amount_ttc_2', 'alpha'); @@ -160,9 +157,6 @@ if ($action == 'confirm_split' && GETPOST("confirm", "alpha") == 'yes' && $permi } if ($action == 'setremise' && $permissiontocreate) { - //if ($user->rights->societe->creer) - //if ($user->hasRight('facture', 'creer')) - $amount = price2num(GETPOST('amount', 'alpha'), '', 2); $desc = GETPOST('desc', 'alpha'); $tva_tx = GETPOST('tva_tx', 'alpha'); @@ -200,9 +194,6 @@ if ($action == 'setremise' && $permissiontocreate) { } if (GETPOST('action', 'aZ09') == 'confirm_remove' && GETPOST("confirm") == 'yes' && $permissiontocreate) { - //if ($user->rights->societe->creer) - //if ($user->hasRight('facture', 'creer')) - $db->begin(); $discount = new DiscountAbsolute($db); diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 4f98aa5ede5..fbe7f7c247a 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -787,7 +787,6 @@ if ($resql) { //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); - //if ($user->rights->bank->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); if (in_array($massaction, array('presend', 'predelete'))) { $arrayofmassactions = array(); } diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index 2ff4b955b55..f62fbd1af75 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -495,9 +495,6 @@ if ($result) { print '</td></tr>'; } - //$user->rights->banque->modifier=false; - //$user->rights->banque->consolidate=true; - // Type of payment / Number print "<tr><td>".$langs->trans("Type")." / ".$langs->trans("Numero"); print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>'; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index 88ab3172ad9..5e1e8de4259 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -262,16 +262,6 @@ class CashControl extends CommonObject return 0; } - /* - $posmodule = $this->posmodule; - if (!empty($user->rights->$posmodule->use)) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - } - */ - $now = dol_now(); // Update request diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index 60c24419459..42644ebd12a 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -168,8 +168,6 @@ if (empty($reshook)) { // Mass actions /*$objectclass='MyObject'; $objectlabel='MyObject'; - $permissiontoread = $user->rights->mymodule->read; - $permissiontodelete = $user->rights->mymodule->delete; $uploaddir = $conf->mymodule->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';*/ diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0dda399bbd0..ccfb8644863 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -153,9 +153,9 @@ if (getDolGlobalString('INVOICE_DISALLOW_REOPEN')) { $usercanunvalidate = ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !empty($usercancreate)) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('facture', 'invoice_advance', 'unvalidate'))); $usermustrespectpricemin = ((getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && !$user->hasRight('produit', 'ignore_price_min_advance')) || !getDolGlobalString('MAIN_USE_ADVANCED_PERMS')); -$usercancreatemargin = ($user->hasRight('margins', 'creer') ? $user->rights->margins->creer : 0); -$usercanreadallmargin = ($user->hasRight('margins', 'liretous') ? $user->rights->margins->liretous : 0); -$usercancreatewithdrarequest = ($user->hasRight('prelevement', 'bons', 'creer') ? $user->rights->prelevement->bons->creer : 0); +$usercancreatemargin = $user->hasRight('margins', 'creer'); +$usercanreadallmargin = $user->hasRight('margins', 'liretous'); +$usercancreatewithdrarequest = $user->hasRight('prelevement', 'bons', 'creer'); $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 84d49a433bf..3d8d6c10e1d 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -47,8 +47,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; // par de nombreux modules (banque, facture, commande a facturer, etc...) independamment // de l'utilisation de la compta ou non. C'est au sein de cet espace que chaque sous fonction // est protegee par le droit qui va bien du module concerne. -//if (!$user->rights->compta->general->lire) -// accessforbidden(); // Load translation files required by the page $langs->loadLangs(array('compta', 'bills')); diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index ba0991ac02e..9911bb2f6e8 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -843,7 +843,6 @@ if ($id > 0) { $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->tax->dir_output.'/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content $genallowed = 0; $delallowed = $user->hasRight('tax', 'charges', 'creer'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('tax', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 3991d6ae100..127aca426d3 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -841,7 +841,6 @@ if ($id > 0) { $relativepath = $objref.'/'.$objref.'.pdf'; $filedir = $conf->tax->dir_output.'/vat/'.$objref; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; - //$genallowed = $user->rights->tax->charges->lire; // If you can read, you can build the PDF to read content $genallowed = 0; $delallowed = $user->hasRight('tax', 'charges', 'creer'); // If you can create/edit, you can remove a file on card print $formfile->showdocuments('tax-vat', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang); diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 23b30813bb7..2b2e52e1bad 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -182,7 +182,7 @@ if ($object->thirdparty->fournisseur) { $elementTypeArray['supplier_order'] = $langs->transnoentitiesnoconv('SuppliersOrders'); } - // There no contact type for supplier proposals + // There are no contact type for supplier proposals // if ((isModEnabled("fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || isModEnabled("supplier_order") || isModEnabled("supplier_invoice")) && $user->rights->supplier_proposal->lire) $elementTypeArray['supplier_proposal']=$langs->transnoentitiesnoconv('SupplierProposals'); } diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 7ca733c5146..a1e90e39904 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -839,13 +839,6 @@ class Don extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->bom->bom_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'DON_REOPEN'); } diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index bd52f10dbc4..a4b8043f5ae 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -138,7 +138,6 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%m') as dm, sum(d.".$this->field.")"; $sql .= " FROM ".$this->from; - //if (empty($user->rights->societe->client->voir) && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; @@ -157,7 +156,6 @@ class DonationStats extends Stats { $sql = "SELECT date_format(d.datedon,'%m') as dm, avg(d.".$this->field.")"; $sql .= " FROM ".$this->from; - //if (empty($user->rights->societe->client->voir) && !$this->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql .= " WHERE ".dolSqlDateFilter('d.datedon', 0, 0, (int) $year, 1); $sql .= " AND ".$this->where; $sql .= " GROUP BY dm"; diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index ad544c1b921..6dc0fa264c5 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -104,85 +104,6 @@ if (!$mesg) { $px1->draw($filenamenb, $fileurlnb); } -// Build graphic amount of object -/* -$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear); -//var_dump($data); -// $data = array(array('Lib',val1,val2,val3),...) - -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png'; -} -else -{ - $filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png'; -} - -$px2 = new DolGraph(); -$mesg = $px2->isGraphKo(); -if (! $mesg) -{ - $px2->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfShipments")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; - $px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT")); - - $px2->draw($filenameamount,$fileurlamount); -} -*/ - -/* -$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); - -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png'; -} -else -{ - $filename_avg = $dir.'/shipmentsaverage-'.$year.'.png'; -} - -$px3 = new DolGraph(); -$mesg = $px3->isGraphKo(); -if (! $mesg) -{ - $px3->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode='depth'; - $px3->SetTitle($langs->trans("AmountAverage")); - - $px3->draw($filename_avg,$fileurl_avg); -} -*/ - // Show array $data = $stats->getAllByYear(); diff --git a/htdocs/ecm/file_card.php b/htdocs/ecm/file_card.php index fe6ada5a160..78200dd9d87 100644 --- a/htdocs/ecm/file_card.php +++ b/htdocs/ecm/file_card.php @@ -425,8 +425,6 @@ if ($action != 'edit') { print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit§ion='.urlencode($section).'&urlfile='.urlencode($urlfile).'">'.$langs->trans('Edit').'</a>'; } - //print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->ecm->setup); - print '</div>'; } diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php index 584feadd2fb..845294ce56a 100644 --- a/htdocs/fichinter/note.php +++ b/htdocs/fichinter/note.php @@ -84,8 +84,6 @@ if ($id > 0 || !empty($ref)) { $morehtmlref = '<div class="refidno">'; // Ref customer - //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', 0, 1); - //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->ficheinter->creer, 'string', '', null, null, '', 1); $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1); $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', null, null, '', 1); // Thirdparty diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index a015d68976d..b3b8a166cc5 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -611,13 +611,6 @@ if (!function_exists('ftp_connect')) { // Actions - /* - if ($user->rights->ftp->write && !empty($section)) - { - $formfile->form_attach_new_file(DOL_URL_ROOT.'/ftp/index.php','',0,$section,1); - } - else print ' '; - */ print '<br>'; print '<div id="delconst" class="right">'; diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 68d9dd23056..e60f6211f9e 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -416,7 +416,7 @@ $newcardbutton = ''; $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitleSeparator(); -$newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); +$newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->hasRight('salaries', 'write')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); diff --git a/htdocs/salaries/virement_request.php b/htdocs/salaries/virement_request.php index a17bf6e3dd2..7829bc312a9 100644 --- a/htdocs/salaries/virement_request.php +++ b/htdocs/salaries/virement_request.php @@ -104,7 +104,7 @@ if ($id > 0 || !empty($ref)) { $permissiontoread = $user->hasRight('salaries', 'read'); $permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles -$permissiontodelete = $user->rights->salaries->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID); +$permissiontodelete = $user->hasRight('salaries', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID); $moreparam = ''; if ($type == 'bank-transfer') { diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index 18e1305afc0..e8a4ed07698 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -760,7 +760,7 @@ if ($action == 'create' || $action == 'presend') { $formticket->withcancel = 1; $formticket->showForm(1, 'create', 0, null, $action); - /*} elseif ($action == 'edit' && $user->rights->ticket->write && $object->status < Ticket::STATUS_CLOSED) { + /*} elseif ($action == 'edit' && $user->hasRight('ticket', 'write') && $object->status < Ticket::STATUS_CLOSED) { $formticket = new FormTicket($db); $head = ticket_prepare_head($object); diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php index 5bd47cff622..9351dc74a5c 100644 --- a/htdocs/ticket/stats/index.php +++ b/htdocs/ticket/stats/index.php @@ -121,73 +121,6 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear); // $data = array(array('Lib',val1,val2,val3),...) -/*if (empty($user->rights->societe->client->voir) || $user->socid) { - $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenameamount = $dir.'/ticketsamountinyear-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.'.png'; -} - -$px2 = new DolGraph(); -$mesg = $px2->isGraphKo(); -if (!$mesg) { - $px2->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0, $px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfTickets")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfTicketsByMonthHT")); - - $px2->draw($filenameamount, $fileurlamount); -} - - -$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); - -if (empty($user->rights->societe->client->voir) || $user->socid) { - $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png'; - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png'; -} else { - $filename_avg = $dir.'/ticketsaverage-'.$year.'.png'; - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.'.png'; -} - -$px3 = new DolGraph(); -$mesg = $px3->isGraphKo(); -if (!$mesg) { - $px3->SetData($data); - $i = $startyear; $legend = array(); - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode = 'depth'; - $px3->SetTitle($langs->trans("AmountAverage")); - - $px3->draw($filename_avg, $fileurl_avg); -}*/ - - - // Show array $data = $stats->getAllByYear(); $arrayyears = array(); diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 613f41758ce..ca663c38448 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -89,7 +89,7 @@ $permissiontoaddbankaccount = ($user->hasRight('salaries', 'write') || $user->ha $permissiontoreadhr = $user->hasRight('hrm', 'read_personal_information', 'read') || $user->hasRight('hrm', 'write_personal_information', 'write'); $permissiontowritehr = $user->hasRight('hrm', 'write_personal_information', 'write'); -// Ok if user->rights->salaries->read or user->rights->hrm->read +// Ok if user->hasRight('salaries', 'read') or user->hasRight('hrm', 'read') //$result = restrictedArea($user, 'salaries|hrm', $object->id, 'user&user', $feature2); $ok = false; if ($user->id == $id) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 7b59b1f4375..b32fae3e182 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -789,7 +789,7 @@ class User extends CommonObject } $moduleRightsMapping = array( - 'product' => 'produit', // We must check $user->rights->produit... + 'product' => 'produit', 'margin' => 'margins', 'comptabilite' => 'compta' ); @@ -799,7 +799,7 @@ class User extends CommonObject $rightsPath = $moduleRightsMapping[$rightsPath]; } - // If module is abc@module, we check permission user->rights->module->abc->permlevel1 + // If module is abc@module, we check permission user->hasRight(module, abc, permlevel1) $tmp = explode('@', $rightsPath, 2); if (!empty($tmp[1])) { if (strpos($module, '@') !== false) { diff --git a/htdocs/user/virtualcard.php b/htdocs/user/virtualcard.php index adc174ff53e..b0e54d3153e 100644 --- a/htdocs/user/virtualcard.php +++ b/htdocs/user/virtualcard.php @@ -122,8 +122,6 @@ $morehtmlref .= '</a>'; $urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id); $morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover'); -//dol_banner_tab($object, 'id', $linkback, $user->rights->user->user->lire || $user->admin, 'rowid', 'ref', $morehtmlref); - print '<div class="fichecenter">'; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 04dd36fad38..83449b1fccb 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -861,15 +861,6 @@ if (!empty($id) || !empty($ref)) { print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; // List of mass actions available - /* - $arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), - ); - if ($user->rights->product->supprimer) $arrayofmassactions['predelete']='<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); - if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - */ $aaa = ''; if (count($productCombinations)) { diff --git a/htdocs/variants/tpl/productattributevalueline_title.tpl.php b/htdocs/variants/tpl/productattributevalueline_title.tpl.php index 7a2625170fe..b2905b535f2 100644 --- a/htdocs/variants/tpl/productattributevalueline_title.tpl.php +++ b/htdocs/variants/tpl/productattributevalueline_title.tpl.php @@ -18,8 +18,8 @@ * $object (invoice, order, ...) * $conf * $langs - * $element (used to test $user->rights->$element->creer) - * $permtoedit (used to replace test $user->rights->$element->creer) + * $element (used to test $user->hasRight('element', 'creer')) + * $permtoedit (used to replace test $user->hasright('element', 'creer')) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $outputalsopricetotalwithtax * $usemargins (0 to disable all margins columns, 1 to show according to margin setup) diff --git a/htdocs/variants/tpl/productattributevalueline_view.tpl.php b/htdocs/variants/tpl/productattributevalueline_view.tpl.php index 419038be5fb..1a43e884d06 100644 --- a/htdocs/variants/tpl/productattributevalueline_view.tpl.php +++ b/htdocs/variants/tpl/productattributevalueline_view.tpl.php @@ -20,8 +20,8 @@ * $langs * $dateSelector * $forceall (0 by default, 1 for supplier invoices/orders) - * $element (used to test $user->rights->$element->creer) - * $permtoedit (used to replace test $user->rights->$element->creer) + * $element (used to test $user->hasRight($element, 'creer')) + * $permtoedit (used to replace test $user->hasRight($element, 'creer')) * $senderissupplier (0 by default, 1 for supplier invoices/orders) * $inputalsopricewithtax (0 by default, 1 to also show column with unit price including tax) * $outputalsopricetotalwithtax diff --git a/htdocs/webhook/class/target.class.php b/htdocs/webhook/class/target.class.php index c5dbafc3183..9049a53e7fb 100644 --- a/htdocs/webhook/class/target.class.php +++ b/htdocs/webhook/class/target.class.php @@ -188,12 +188,6 @@ class Target extends CommonObject $this->fields['entity']['enabled'] = 0; } - // Example to show how to set values of fields definition dynamically - /*if ($user->rights->webhook->target->read) { - $this->fields['myfield']['visible'] = 1; - $this->fields['myfield']['noteditable'] = 0; - }*/ - // Unset fields that are disabled foreach ($this->fields as $key => $val) { if (isset($val['enabled']) && empty($val['enabled'])) { @@ -506,14 +500,6 @@ class Target extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->target->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->target->target_advance->validate)))) - { - $this->error='NotEnoughPermissions'; - dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR); - return -1; - }*/ - $now = dol_now(); $this->db->begin(); @@ -632,13 +618,6 @@ class Target extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->webhook_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'TARGET_UNVALIDATE'); } @@ -656,13 +635,6 @@ class Target extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->webhook_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'TARGET_CANCEL'); } @@ -680,13 +652,6 @@ class Target extends CommonObject return 0; } - /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->write)) - || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->webhook->webhook_advance->validate)))) - { - $this->error='Permission denied'; - return -1; - }*/ - return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'TARGET_REOPEN'); } diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index b80d6a6fdb7..cad85f13628 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -404,20 +404,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print dolGetButtonAction('', $langs->trans('ToClone'), 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.(!empty($object->socid) ? '&socid='.$object->socid : '').'&action=clone&token='.newToken(), '', $permissiontoadd); } - /* - if ($user->rights->sellyoursaas->create) - { - if ($object->status == 1) - { - print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=disable&token='.newToken().'">'.$langs->trans("Disable").'</a></div>'."\n"; - } - else - { - print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=enable&token='.newToken().'">'.$langs->trans("Enable").'</a></div>'."\n"; - } - } - */ - // Delete $params = array(); print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete, $params); From bcd401d4878f11594f4f5fb7e15081994dfb8137 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 5 Feb 2024 01:13:38 +0100 Subject: [PATCH 56/90] Fix phpcs --- dev/tools/rector/src/Renaming/UserRightsToFunction.php | 2 +- htdocs/core/class/CSMSFile.class.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index 5f484264f91..f1889b24f26 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -144,7 +144,7 @@ class UserRightsToFunction extends AbstractRector return $node; } - $caseok = false; // Will be tru if we can make the replacement. We must not do it for assignement like when $user->right->aaa->bbb = ... + $caseok = false; // Will be tru if we can make the replacement. We must not do it for assignment like when $user->right->aaa->bbb = ... $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { if (!$node->expr instanceof Node\Expr\Empty_) { diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index adfb7448c0c..848c0038cea 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -191,8 +191,7 @@ class CSMSFile } } } else { - $sms = new stdClass(); - $sms->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).'_SMS is not found'; + $this->error = 'The SMS manager "'.$classfile.'" defined into SMS setup MAIN_MODULE_'.strtoupper($sendmode).'_SMS is not found'; } } catch (Exception $e) { dol_print_error(null, 'Error to get list of senders: '.$e->getMessage()); @@ -200,7 +199,7 @@ class CSMSFile } else { // Send sms method not correctly defined // -------------------------------------- - $sms->error = 'Bad value for MAIN_SMS_SENDMODE constant'; + $this->error = 'Bad value for MAIN_SMS_SENDMODE constant'; $res = false; } } else { From b53b91d9af5fbdd9da2d8d4bb96114bbf0fd0201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:21:41 +0100 Subject: [PATCH 57/90] add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- .editorconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.editorconfig b/.editorconfig index 7df89a90eb3..cdaf5b3af2e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -22,3 +22,7 @@ indent_style = tab indent_style = tab [*.md] trim_trailing_whitespace = false +[*.sql] +indent_style = tab +trim_trailing_whitespace = true +indent_size = 4 From 866948625b3ee453c96d63f4c7b715b650912e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:22:05 +0100 Subject: [PATCH 58/90] add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 4 ++++ htdocs/install/mysql/tables/llx_ticket-ticket.sql | 3 +++ 2 files changed, 7 insertions(+) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 359d160e17b..3d5f8152277 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -215,3 +215,7 @@ UPDATE llx_const SET name = 'THIRDPARTY_CAN_HAVE_CUSTOMER_CATEGORY_EVEN_IF_NOT_C ALTER TABLE llx_fichinter ADD COLUMN signed integer DEFAULT NULL AFTER duree; ALTER TABLE llx_mailing ADD COLUMN messtype varchar(16) DEFAULT 'email' after rowid; + +ALTER TABLE llx_ticket ADD COLUMN model_pdf varchar(255); +ALTER TABLE llx_ticket ADD COLUMN last_main_doc varchar(255); +ALTER TABLE llx_ticket ADD COLUMN extraparams varchar(255); diff --git a/htdocs/install/mysql/tables/llx_ticket-ticket.sql b/htdocs/install/mysql/tables/llx_ticket-ticket.sql index dc7ab197735..ce5e191c0aa 100644 --- a/htdocs/install/mysql/tables/llx_ticket-ticket.sql +++ b/htdocs/install/mysql/tables/llx_ticket-ticket.sql @@ -45,5 +45,8 @@ CREATE TABLE llx_ticket email_date datetime, -- if ticket is created by email collector, we store here Date of message ip varchar(250), tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + model_pdf varchar(255), + last_main_doc varchar(255), -- relative filepath+filename of last main generated document + extraparams varchar(255), -- to save other parameters with json format import_key varchar(14) )ENGINE=innodb; From 1da1c473ba7989bf28cfeec53b2c717a62be05a0 Mon Sep 17 00:00:00 2001 From: MDW <mdeweerd@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:24:41 +0100 Subject: [PATCH 59/90] Improve wording in README (#27994) --- README.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1d7ea4b321c..481dee5890c 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ If you have low technical skills and you're looking to install Dolibarr ERP/CRM - [DoliWamp for Windows](https://wiki.dolibarr.org/index.php/Dolibarr_for_Windows_(DoliWamp)) - [DoliDeb for Debian](https://wiki.dolibarr.org/index.php/Dolibarr_for_Ubuntu_or_Debian) -- DoliRpm for Redhat, Fedora, OpenSuse, Mandriva or Mageia +- DoliRpm for Red Hat, Fedora, OpenSuse, Mandriva or Mageia Releases can be downloaded from [official website](https://www.dolibarr.org/). @@ -45,19 +45,19 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr. #### Generic install steps -- Check that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Releases). +- Verify that your installed PHP version is supported [see PHP support](https://wiki.dolibarr.org/index.php/Releases). -- Uncompress the downloaded .zip archive to copy the "dolibarr/htdocs" directory and all its files inside your web server root or get the files directly from GitHub (recommended if you know git as it makes it easier if you want to upgrade later): +- Uncompress the downloaded .zip archive to copy the `dolibarr/htdocs` directory and all its files inside your web server root or get the files directly from GitHub (recommended if you know git as it makes it easier if you want to upgrade later): `git clone https://github.com/dolibarr/dolibarr -b x.y` (where x.y is the main version like 3.6, 9.0, ...) -- Set up your web server to use "*dolibarr/htdocs*" as root if your web server does not have an already defined directory to point to. +- Set up your web server to use `dolibarr/htdocs` as root if your web server does not already define a directory to point to. - Create an empty `htdocs/conf/conf.php` file and set *write* permissions for your web server user (*write* permission will be removed once install is finished) - From your browser, go to the dolibarr "install/" page - The URL will depends on how your web setup was set up to point to your dolibarr installation. It may look like: + The URL will depend on how your web configuration directs to your dolibarr installation. It may look like: `http://localhost/dolibarr/htdocs/install/` @@ -71,18 +71,20 @@ On GNU/Linux, first check if your distribution has already packaged Dolibarr. - Follow the installer instructions -### SaaS/Cloud setup +### SaaS/Cloud Setup -If you don't have time to install it yourself, you can try some commercial 'ready to use' Cloud offers (See [https://saas.dolibarr.org](https://saas.dolibarr.org)). However, this third solution is not free. +If you lack the time to install it yourself, consider exploring commercial 'ready-to-use' Cloud offerings (refer to https://saas.dolibarr.org). Keep in mind that this third option comes with associated costs. ## UPGRADING Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate! +Follow these step-by-step instructions to seamlessly upgrade Dolibarr to the latest version: + - At first make a backup of your Dolibarr files & then [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr) -- Check that your installed PHP version is supported by the new version [see PHP support](https://wiki.dolibarr.org/index.php/Releases). -- Overwrite all old files from the 'dolibarr' directory with files provided into the new version's package. -- At first next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process. +- Verify that your installed PHP version is supported by the new version [see PHP support](https://wiki.dolibarr.org/index.php/Releases). +- Overwrite all old files from the 'dolibarr' directory with files provided in the new version's package. +- At your next access, Dolibarr will redirect you to the "install/" page to follow the upgrade process.  If an `install.lock` file exists to lock any other upgrade process, the application will ask you to remove the file manually (you should find the `install.lock` file in the directory used to store generated and uploaded documents, in most cases, it is the directory called "*documents*"). ## WHAT'S NEW @@ -114,7 +116,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Customer Orders management - Contracts/Subscription management - Interventions management -- Ticket System (+ Knowledge management) +- Ticket System (+ Knowledge management) - Partnership management - Shipping management - Customer Invoices/Credit notes and payment management @@ -123,10 +125,10 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Supplier/Purchase Management - Suppliers/Vendors + Contacts -- Supplier (price) requests +- Supplier (pricing) requests - Purchase Orders management - Delivery/Reception -- Supplier Invoices/credit notes and payment management +- Supplier Invoices/Credit notes and payment management - INCOTERMS Finance/Accounting @@ -142,7 +144,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) Collaboration -- Shared calendar/agenda (with ical and vcal import/export for third-party tools integration) +- Shared calendar/agenda (with `ical` and `vcal` import/export for third-party tools integration) - Projects & Tasks management - Event organization - Ticket System @@ -150,7 +152,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) HR - Human Resources Management -- Employee's leaves management +- Employee leave management - Expense reports - Recruitment management - Employee/staff management @@ -178,7 +180,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Multi-Language Support (Localization in most major languages) - Multi-users and groups with finely-grained rights - Multi-Currency -- Multi-Company (by adding of an external module) +- Multi-Company (by adding an external module) - Very user-friendly and easy to use - Customizable dashboards - Highly customizable: enable only the modules you need, add user personalized fields, choose your skin, several menu managers (can be used by internal users as a back-office with a particular menu, or by external users as a front-office with another one) @@ -192,7 +194,7 @@ See the [ChangeLog](https://github.com/Dolibarr/dolibarr/blob/develop/ChangeLog) - Argentina invoice numbering using A,B,C... - ZATCA e-invoicing QR-Code - Compatible with [European directives](https://europa.eu/legislation_summaries/taxation/l31057_en.htm) (2006/112/CE ... 2010/45/UE) - - Compatible with data privacy rules (Europe GDPR, ...) + - Compatible with data privacy rules (Europe's GDPR, ...) - ... - Flexible PDF & ODT generation for invoices, proposals, orders... - ... @@ -215,7 +217,7 @@ These are features that Dolibarr does **not** yet fully support: - Tasks dependencies in projects - Payroll module -- No native embedded Webmail, but you can send emails to contacts in Dolibarr with e.g. offers, invoices, etc. +- Native embedded Webmail, but you can send email to contacts in Dolibarr with e.g. offers, invoices, etc. - Dolibarr can't do coffee (yet) ## DOCUMENTATION @@ -225,7 +227,7 @@ Administrator, user, developer and translator's documentation are available alon ## CONTRIBUTING This project exists thanks to all the people who contribute. -Please read the instructions on how to contribute (report a bug/error, a feature request, send code ...) [[Contribute](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)] +Please read the instructions on how to contribute (report a bug/error, a feature request, send code, ...) [[Contributing](https://github.com/Dolibarr/dolibarr/blob/develop/.github/CONTRIBUTING.md)] A View on Contributors: From 080d8e0fa4cad63ec1071ec0f94b84296e79b95f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:33:19 +0100 Subject: [PATCH 60/90] fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- dev/tools/rector/src/Renaming/UserRightsToFunction.php | 5 +++-- htdocs/core/class/CSMSFile.class.php | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index f1889b24f26..995cd843f33 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -144,8 +144,9 @@ class UserRightsToFunction extends AbstractRector return $node; } - $caseok = false; // Will be tru if we can make the replacement. We must not do it for assignment like when $user->right->aaa->bbb = ... - $isInverse = false; + $caseok = false; // Will be true if we can make the replacement. We must not do it for assignment like when $user->right->aaa->bbb = ... + + $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { if (!$node->expr instanceof Node\Expr\Empty_) { return null; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 848c0038cea..d0b478556c6 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -55,7 +55,14 @@ class CSMSFile */ public $eol; + /** + * @var string address from + */ public $addr_from; + + /** + * @var string address to + */ public $addr_to; public $deferred; public $priority; From 1289cda4606075299d302d7bef780ec9f3f3092b Mon Sep 17 00:00:00 2001 From: MDW <mdeweerd@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:33:53 +0100 Subject: [PATCH 61/90] Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. --- htdocs/langs/en_US/datapolicy.lang | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/langs/en_US/datapolicy.lang b/htdocs/langs/en_US/datapolicy.lang index 0597a45db88..4f3f3682ab1 100644 --- a/htdocs/langs/en_US/datapolicy.lang +++ b/htdocs/langs/en_US/datapolicy.lang @@ -23,7 +23,7 @@ Module4100Desc = Module to manage Data Privacy (Conformity with the GDPR) # datapolicySetup = Module Data Privacy Policy Setup Deletion = Deletion of data -datapolicySetupPage = Depending of laws of your countries (Example <a href="http://www.privacy-regulation.eu/en/5.htm" target="_blank" rel="noopener noreferrer external">Article 5</a> of the GDPR), personal data must be kept for a period not exceeding that necessary for the purposes for which they were collected, except for archival purposes.<br>The deletion will be done automatically after a certain duration without event (the duration which you will have indicated below). +datapolicySetupPage = Depending on the laws of your countries (Example <a href="http://www.privacy-regulation.eu/en/5.htm" target="_blank" rel="noopener noreferrer external">Article 5</a> of the GDPR), personal data must be kept for a period not exceeding the duration the data is needed for the purpose for which it was collected, except for archival purposes.<br>The deletion will be done automatically after a certain duration without events (the duration which you will have indicated below). NB_MONTHS = %s months ONE_YEAR = 1 year NB_YEARS = %s years @@ -40,25 +40,25 @@ DATAPOLICY_CONTACT_FOURNISSEUR = Supplier DATAPOLICY_ADHERENT = Member DATAPOLICY_Tooltip_SETUP = Type of contact - Indicate your choices for each type. DATAPOLICYMail = Emails Setup -DATAPOLICYSUBJECTMAIL = Subject of email +DATAPOLICYSUBJECTMAIL = Subject of the email DATAPOLICYCONTENTMAIL = Content of the email DATAPOLICYSUBSITUTION = You can use the following variables in your email (LINKACCEPT allows to create a link recording the agreement of the person, LINKREFUSED makes it possible to record the refusal of the person): DATAPOLICYACCEPT = Message after agreement -DATAPOLICYREFUSE = Message after desagreement +DATAPOLICYREFUSE = Message after disagreement SendAgreementText = You can send a GDPR email to all your relevant contacts (who have not yet received an email and for which you have not registered anything about their GDPR agreement). To do this, use the following button. SendAgreement = Send emails AllAgreementSend = All emails have been sent -TXTLINKDATAPOLICYACCEPT = Text for the link "agreement" -TXTLINKDATAPOLICYREFUSE = Text for the link "desagreement" +TXTLINKDATAPOLICYACCEPT = Text for the link "agreement" +TXTLINKDATAPOLICYREFUSE = Text for the link "disagreement" # # Extrafields # DATAPOLICY_BLOCKCHECKBOX = GDPR : Processing of personal data -DATAPOLICY_consentement = Consent obtained for the processing of personal data -DATAPOLICY_opposition_traitement = Opposes the processing of his personal data -DATAPOLICY_opposition_prospection = Opposes the processing of his personal data for the purposes of prospecting +DATAPOLICY_consentement = Consent obtained for the processing of personal data +DATAPOLICY_opposition_traitement = Opposes to the processing of his personal data +DATAPOLICY_opposition_prospection = Opposes to the processing of his personal data for the purposes of prospecting # # Popup @@ -68,7 +68,7 @@ DATAPOLICY_POPUP_ANONYME_TEXTE = You can not delete this contact from Dolibarr b # # Button for portability -# +# DATAPOLICY_PORTABILITE = Portability GDPR DATAPOLICY_PORTABILITE_TITLE = Export of personal data DATAPOLICY_PORTABILITE_CONFIRMATION = You want to export the personal data of this contact. Are you sure ? @@ -78,11 +78,11 @@ DATAPOLICY_PORTABILITE_CONFIRMATION = You want to export the personal data of th # ANONYMISER_AT = Anonymised the %s -DATAPOLICY_date = Date of agreement/desagreement GDPR -DATAPOLICY_send = Date sending agreement email +DATAPOLICY_date = Date of agreement/disagreement GDPR +DATAPOLICY_send = Date agreement email sent DATAPOLICY_SEND = Send GDPR email MailSent = Email has been sent # ERROR -=Due to a technical problem, we were unable to register your choice. We apologize for that. Contact us to send us your choice. -NUMBER_MONTH_BEFORE_DELETION = Number of month before deletion +=Due to a technical problem, we were unable to register your choice. We apologize for that. Contact us to notify us your choice. +NUMBER_MONTH_BEFORE_DELETION = Number of months before deletion From b8fd3d54e2c42123d157bbf74614315c9709bd5e Mon Sep 17 00:00:00 2001 From: thibdrev <thibault.drevet@gmail.com> Date: Mon, 5 Feb 2024 01:34:50 +0100 Subject: [PATCH 62/90] qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() --- htdocs/ticket/class/ticketstats.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 95f807f0ebf..8ac77532d96 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -91,7 +91,7 @@ class TicketStats extends Stats /** * Return the number of tickets per month for a given year * - * @param string $year Year to scan + * @param int $year Year to scan * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month * @return array Array of values */ From b1f059de5874d5c393384fe9ec8b671c9362e040 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 5 Feb 2024 12:25:55 +0100 Subject: [PATCH 63/90] Fix user with readonly perm on email template must be able to read. --- htdocs/admin/mails_templates.php | 42 ++++++++++++++++----------- htdocs/core/class/html.form.class.php | 20 ++++++------- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 51c35a615be..13545002911 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -1061,7 +1061,7 @@ if ($num) { $obj = $db->fetch_object($resql); if ($obj) { - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { + if (($action == 'edit' || $action == 'preview') && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { print '<tr class="oddeven" id="rowid-'.$obj->rowid.'">'; $tmpaction = 'edit'; @@ -1075,21 +1075,25 @@ if ($num) { print '<td class="center">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">'; - print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">'; + if ($action == 'edit') { + print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">'; + } print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>'; print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '</td>'; } // Show main fields if (empty($reshook)) { - fieldList($fieldlist, $obj, $tabname[$id], 'edit'); + fieldList($fieldlist, $obj, $tabname[$id], $action); } // Action column if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { print '<td class="center">'; print '<input type="hidden" name="page" value="'.$page.'">'; print '<input type="hidden" name="rowid" value="'.$rowid.'">'; - print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">'; + if ($action == 'edit') { + print '<input type="submit" class="button buttongen button-save" name="actionmodify" value="'.$langs->trans("Modify").'">'; + } print '<div name="'.(!empty($obj->rowid) ? $obj->rowid : $obj->code).'"></div>'; print '<input type="submit" class="button buttongen button-cancel" name="actioncancel" value="'.$langs->trans("Cancel").'">'; print '</td>'; @@ -1113,18 +1117,18 @@ if ($num) { if ($showfield) { // Show line for topic, joinfiles and content if ($tmpfieldlist == 'topic') { - print '<strong>'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> '; - print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">'; + print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("Topic"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> '; + print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>'; print '<br>'."\n"; } if ($tmpfieldlist == 'email_from') { - print '<strong>'.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> '; - print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">'; + print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("MailFrom"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> '; + print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'-'.$rowid.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'"'.($action != 'edit' ? ' disabled' : '').'>'; print '<br>'."\n"; } if ($tmpfieldlist == 'joinfiles') { - print '<strong>'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</strong> '; - print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, false, 0, 1); + print '<div class="minwidth150 inline-block bold">'.$form->textwithpicto($langs->trans("FilesAttachedToEmail"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'</div> '; + print $form->selectyesno($tmpfieldlist.'-'.$rowid, (isset($obj->$tmpfieldlist) ? $obj->$tmpfieldlist : '0'), 1, ($action != 'edit'), 0, 1); print '<br>'."\n"; } @@ -1134,7 +1138,7 @@ if ($num) { if (!getDolGlobalString('FCKEDITOR_ENABLE_MAIL')) { $okforextended = false; } - $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%'); + $doleditor = new DolEditor($tmpfieldlist.'-'.$rowid, (!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : ''), '', 500, 'dolibarr_mailings', 'In', 0, $acceptlocallinktomedia, $okforextended, ROWS_6, '90%', ($action != 'edit' ? 1 : 0)); print $doleditor->Create(1); } if ($tmpfieldlist == 'content_lines') { @@ -1201,6 +1205,8 @@ if ($num) { print '<td class="center nowraponall" width="64">'; if ($canbemodified) { print '<a class="reposition editfielda" href="'.$url.'&action=edit&token='.newToken().'">'.img_edit().'</a>'; + } else { + print '<a class="reposition editfielda" href="'.$url.'&action=preview&token='.newToken().'">'.img_view().'</a>'; } if ($iserasable) { print '<a class="reposition marginleftonly" href="'.$url.'&action=delete&token='.newToken().'">'.img_delete().'</a>'; @@ -1351,7 +1357,7 @@ $db->close(); * @param array $fieldlist Array of fields * @param Object $obj If we show a particular record, obj is filled with record fields * @param string $tabname Name of SQL table - * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we don't want it to be rendered + * @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'preview'=show in readonly the template, 'hide'=Output field for the "add form" but we don't want it to be rendered * @return void */ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') @@ -1368,7 +1374,7 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') print '<td></td>'; } elseif ($value == 'fk_user') { print '<td>'; - if ($user->admin) { + if ($user->admin && $context != 'preview') { print $form->select_dolusers(empty($obj->$value) ? '' : $obj->$value, 'fk_user', 1, null, 0, ($user->admin ? '' : 'hierarchyme'), null, 0, 0, 0, '', 0, '', 'minwidth75 maxwidth100'); } else { if ($context == 'add') { // I am not admin and we show the add form @@ -1390,7 +1396,7 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') print '</td>'; } elseif ($value == 'lang') { print '<td>'; - if (getDolGlobalInt('MAIN_MULTILANGS')) { + if (getDolGlobalInt('MAIN_MULTILANGS') && $context != 'preview') { $selectedlang = GETPOSTISSET('langcode') ? GETPOST('langcode', 'aZ09') : $langs->defaultlang; if ($context == 'edit') { $selectedlang = $obj->lang; @@ -1410,7 +1416,7 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') } elseif ($value == 'type_template') { // Le type de template print '<td class="center">'; - if ($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) { + if (($context == 'edit' && !empty($obj->type_template) && !in_array($obj->type_template, array_keys($elementList))) || $context == 'preview') { // Current template type is an unknown type, so we must keep it as it is. print '<input type="hidden" name="type_template" value="'.$obj->type_template.'">'; print $obj->type_template; @@ -1422,6 +1428,8 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') //print '<td></td>'; } elseif ($context == 'edit' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { print '<td></td>'; + } elseif ($context == 'preview' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { + print '<td></td>'; } elseif ($context == 'hide' && in_array($value, array('topic', 'joinfiles', 'content', 'content_lines'))) { //print '<td></td>'; } else { @@ -1451,14 +1459,14 @@ function fieldList($fieldlist, $obj = null, $tabname = '', $context = '') } print '<td'.($classtd ? ' class="'.$classtd.'"' : '').'>'; - if ($value == 'private') { + if ($value == 'private' && $context != 'preview') { if (empty($user->admin)) { print $form->selectyesno($value, '1', 1); } else { print $form->selectyesno($value, (isset($obj->$value) ? $obj->$value : ''), 1); } } else { - print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'">'; + print '<input type="text" '.$size.'class="flat'.($class ? ' '.$class : '').'" value="'.(isset($obj->$value) ? $obj->$value : '').'" name="'. $value .'"'.($context == 'preview' ? ' disabled' : '').'>'; } print '</td>'; } diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 59c89d462c6..cad52fff5c9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -9489,16 +9489,16 @@ class Form /** * Return an html string with a select combo box to choose yes or no * - * @param string $htmlname Name of html select field - * @param string $value Pre-selected value - * @param int $option 0 return yes/no, 1 return 1/0 - * @param bool $disabled true or false - * @param int $useempty 1=Add empty line - * @param int $addjscombo 1=Add js beautifier on combo box - * @param string $morecss More CSS - * @param string $labelyes Label for Yes - * @param string $labelno Label for No - * @return string See option + * @param string $htmlname Name of html select field + * @param string $value Pre-selected value + * @param int $option 0 return yes/no, 1 return 1/0 + * @param bool $disabled true or false + * @param int $useempty 1=Add empty line + * @param int $addjscombo 1=Add js beautifier on combo box + * @param string $morecss More CSS + * @param string $labelyes Label for Yes + * @param string $labelno Label for No + * @return string See option */ public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0, $addjscombo = 0, $morecss = '', $labelyes = 'Yes', $labelno = 'No') { diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d9534099fd7..b044c997903 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1032,7 +1032,7 @@ body[class*="colorblind-"] .text-success{ color : <?php print $textDanger; ?> } -.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, +.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, .editfielda span.fa-eye, .editfieldlang { color: #ccc !important; } diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4ccaacce016..e91845038f4 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1289,7 +1289,7 @@ body[class*="colorblind-"] .text-success{ color : <?php print $textDanger; ?> } -.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, +.editfielda span.fa-pencil-alt, .editfielda span.fa-pencil-ruler, .editfielda span.fa-trash, .editfielda span.fa-crop, .editfielda span.fa-eye, .editfieldlang { color: #ccc !important; } From 2f78b49ca060ab18b3df88591e9ad3d5a33092c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:30:18 +0100 Subject: [PATCH 64/90] usage of else if is discouraged use elseif instead (#28017) * usage of else if is discouraged use elseif instead * Update UserRightsToFunction.php --- dev/tools/rector/src/Renaming/UserRightsToFunction.php | 2 +- htdocs/core/actions_setmoduleoptions.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/tools/rector/src/Renaming/UserRightsToFunction.php b/dev/tools/rector/src/Renaming/UserRightsToFunction.php index 995cd843f33..b655e3b82a8 100644 --- a/dev/tools/rector/src/Renaming/UserRightsToFunction.php +++ b/dev/tools/rector/src/Renaming/UserRightsToFunction.php @@ -146,7 +146,7 @@ class UserRightsToFunction extends AbstractRector $caseok = false; // Will be true if we can make the replacement. We must not do it for assignment like when $user->right->aaa->bbb = ... - $isInverse = false; + $isInverse = false; if ($node instanceof Node\Expr\BooleanNot) { if (!$node->expr instanceof Node\Expr\Empty_) { return null; diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 854f22bd197..1ca6c3d3697 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -47,7 +47,7 @@ if ($action == 'update' && is_array($arrayofparameters) && !empty($user->admin)) } else { $val_const = GETPOST($key, 'int'); } - } else if ($val['type'] == 'html') { + } elseif ($val['type'] == 'html') { $val_const = GETPOST($key, 'restricthtml'); } else { $val_const = GETPOST($key, 'alpha'); From c3f7f8aa2d56ebaa54a3413d0edc6486046fa009 Mon Sep 17 00:00:00 2001 From: William Mead <william.mead@manchenumerique.fr> Date: Mon, 5 Feb 2024 13:37:34 +0100 Subject: [PATCH 65/90] Adjusted contract expired services url (#28010) --- htdocs/core/menus/standard/eldy.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 4930959df6d..28eee47364c 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1435,7 +1435,7 @@ function get_left_menu_commercial($mainmenu, &$newmenu, $usemenuhider = 1, $left if ($usemenuhider || empty($leftmenu) || $leftmenu == "contracts") { $newmenu->add("/contrat/services_list.php?leftmenu=contracts&search_status=0", $langs->trans("MenuInactiveServices"), 2, $user->hasRight('contrat', 'lire')); $newmenu->add("/contrat/services_list.php?leftmenu=contracts&search_status=4", $langs->trans("MenuRunningServices"), 2, $user->hasRight('contrat', 'lire')); - $newmenu->add("/contrat/services_list.php?leftmenu=contracts&search_status=4&filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->hasRight('contrat', 'lire')); + $newmenu->add("/contrat/services_list.php?leftmenu=contracts&search_status=4%26filter=expired", $langs->trans("MenuExpiredServices"), 2, $user->hasRight('contrat', 'lire')); $newmenu->add("/contrat/services_list.php?leftmenu=contracts&search_status=5", $langs->trans("MenuClosedServices"), 2, $user->hasRight('contrat', 'lire')); } } From bb347d16f91329a1dc364bd315a66fb9c5ad3b23 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:38:59 +0100 Subject: [PATCH 66/90] Fix email collector add Repy to in ticket description (#28009) Co-authored-by: Hystepik <lmarcouiller@nltechno.com> --- htdocs/emailcollector/class/emailcollector.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 2329b7584ce..77ca53ff9a0 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1894,7 +1894,7 @@ class EmailCollector extends CommonObject if (getDolGlobalString('MAIN_IMAP_USE_PHPIMAP')) { $fromstring = $overview['from']; - //$replytostring = empty($overview['reply-to']) ? '' : $overview['reply-to']; + $replytostring = empty($overview['in_reply-to']) ? $headers['Reply-To'] : $overview['in_reply-to']; $sender = $overview['sender']; $to = $overview['to']; @@ -1905,7 +1905,7 @@ class EmailCollector extends CommonObject $subject = $overview['subject']; } else { $fromstring = $overview[0]->from; - //$replytostring = empty($overview[0]->replyto) ? '' : $overview[0]->replyto; + $replytostring = empty($overview['in_reply-to']) ? $headers['Reply-To'] : $overview['in_reply-to']; $sender = !empty($overview[0]->sender) ? $overview[0]->sender : ''; $to = $overview[0]->to; @@ -2257,13 +2257,16 @@ class EmailCollector extends CommonObject $description = $descriptiontitle = $descriptionmeta = $descriptionfull = ''; $descriptiontitle = $langs->trans("RecordCreatedByEmailCollector", $this->ref, $msgid); - + //TODO: Reply-to $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTopic").' : '.dol_escape_htmltag($subject)); $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailFrom").($langs->trans("MailFrom") != 'From' ? ' (From)' : '').' : '.dol_escape_htmltag($fromstring)); if ($sender) { $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("Sender").($langs->trans("Sender") != 'Sender' ? ' (Sender)' : '').' : '.dol_escape_htmltag($sender)); } $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailTo").($langs->trans("MailTo") != 'To' ? ' (To)' : '').' : '.dol_escape_htmltag($to)); + if ($replyto) { + $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailReply").($langs->trans("MailReply") != 'Reply to' ? ' (Reply to)' : '').' : '.dol_escape_htmltag($replyto)); + } if ($sendtocc) { $descriptionmeta = dol_concatdesc($descriptionmeta, $langs->trans("MailCC").($langs->trans("MailCC") != 'CC' ? ' (CC)' : '').' : '.dol_escape_htmltag($sendtocc)); } From de46046b52e7f08248a95290f321027336fdb192 Mon Sep 17 00:00:00 2001 From: William Mead <william.mead@manchenumerique.fr> Date: Mon, 5 Feb 2024 13:44:25 +0100 Subject: [PATCH 67/90] Qual phpstan utils class (#28013) * Fixed error type. Refactored sendBackup return type. Updated contributor details. * Update utils.class.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- htdocs/core/class/utils.class.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 42880621de5..4e5a3eb4e0d 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -1,8 +1,8 @@ <?php -/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2021 Regis Houssin <regis.houssin@inodbox.com> - * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr> - * Copyright (C) 2023 William Mead <william.mead@manchenumerique.fr> +/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2021 Regis Houssin <regis.houssin@inodbox.com> + * Copyright (C) 2022 Anthony Berton <anthony.berton@bb2a.fr> + * Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr> * * 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 @@ -1369,9 +1369,10 @@ class Utils } } + $result = false; if (!$error) { $result = $mailfile->sendfile(); - if ($result <= 0) { + if (!$result) { $error++; $output = $mailfile->error; } @@ -1379,13 +1380,13 @@ class Utils dol_syslog(__METHOD__, LOG_DEBUG); - $this->error = $error; + $this->error = "Error sending backp file ".((string) $error); $this->output = $output; - if ($result == true) { + if ($result) { return 0; } else { - return $result; + return -1; } } From c4a07576197869fb21fa900e90c0abd48064a457 Mon Sep 17 00:00:00 2001 From: noec764 <58433943+noec764@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:48:56 +0100 Subject: [PATCH 68/90] FIX: Reduction Input wasn't recovered properly (#28014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Noé <noe@scopen.fr> --- htdocs/takepos/reduction.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php index 31012517304..22012b79763 100644 --- a/htdocs/takepos/reduction.php +++ b/htdocs/takepos/reduction.php @@ -171,6 +171,7 @@ if (!isset($conf->global->TAKEPOS_NUMPAD_USE_PAYMENT_ICON) || getDolGlobalString function ValidateReduction() { console.log('ValidateReduction'); + reductionTotal = jQuery('#reduction_total').val(); if (reductionTotal.length <= 0) { console.error('Error no reduction'); From e67fddd3b652a2623822d08ed1694564382573c1 Mon Sep 17 00:00:00 2001 From: thibdrev <thibault.drevet@gmail.com> Date: Mon, 5 Feb 2024 13:51:40 +0100 Subject: [PATCH 69/90] qual: phpstan : various $xxx (int) does not accept array|string. (#28015) * qual: phpstan for htdocs/compta/bank/various_payment/card.php htdocs/compta/bank/various_payment/card.php 267 Property PaymentVarious::$id (int) does not accept null. htdocs/compta/bank/various_payment/card.php 267 Property PaymentVarious::$ref (string) does not accept null. htdocs/compta/bank/various_payment/card.php 287 Property PaymentVarious::$sens (int) does not accept array|string. * qual: phpstan for htdocs/compta/bank/class/paymentvarious.class.php htdocs/compta/bank/class/paymentvarious.class.php 502 Property PaymentVarious::$ref (string) does not accept int. * typo * qual: phpstan for htdocs/compta/paiement.php htdocs/compta/paiement.php 272 Property Paiement::$fk_account (int) does not accept array|string. * qual: phpstan for htdocs/fourn/facture/paiement.php htdocs/fourn/facture/paiement.php 318 Property Paiement::$paiementid (int) does not accept array|string. htdocs/fourn/facture/paiement.php 321 Property Paiement::$fk_account (int) does not accept array|string. --- .../bank/class/paymentvarious.class.php | 36 +++++++++++++++++-- htdocs/compta/bank/various_payment/card.php | 26 +++++++------- htdocs/compta/paiement.php | 16 ++++----- htdocs/fourn/facture/paiement.php | 20 +++++------ 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 5215cb53170..f74034a103b 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -60,18 +60,50 @@ class PaymentVarious extends CommonObject * @var int timestamp */ public $tms; + + /** + * @var int timestamp + */ public $datep; + + /** + * @var int timestamp + */ public $datev; /** - * @var int sens of operation + * @var int<0,1> Payment direction (debit or credit) */ public $sens; + + /** + * @var float + */ public $amount; + + /** + * @var int Payment type (fk_typepayment) + */ public $type_payment; + + /** + * @var string Payment reference + */ public $num_payment; + + /** + * @var string Name of cheque writer + */ public $chqemetteur; + + /** + * @var string Bank of cheque writer + */ public $chqbank; + + /** + * @var int Category id + */ public $category_transaction; /** @@ -499,7 +531,7 @@ class PaymentVarious extends CommonObject $result = $this->db->query($sql); if ($result) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_various"); - $this->ref = $this->id; + $this->ref = (string) $this->id; if ($this->id > 0) { if (isModEnabled("banque") && !empty($this->amount)) { diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 2000eaab192..b1c89d62edc 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -42,19 +42,19 @@ if (isModEnabled('project')) { $langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "categories")); // Get parameters -$id = GETPOST('id', 'int'); +$id = GETPOSTINT('id'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); -$accountid = GETPOST("accountid") > 0 ? GETPOST("accountid", "int") : 0; +$accountid = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0; $label = GETPOST("label", "alpha"); -$sens = GETPOST("sens", "int"); -$amount = price2num(GETPOST("amount", "alpha")); +$sens = GETPOSTINT("sens"); +$amount = GETPOSTFLOAT("amount"); $paymenttype = GETPOST("paymenttype", "aZ09"); $accountancy_code = GETPOST("accountancy_code", "alpha"); -$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int')); +$projectid = GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project'); if (isModEnabled('accounting') && getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : ''; } else { @@ -62,7 +62,7 @@ if (isModEnabled('accounting') && getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX' } // Security check -$socid = GETPOST("socid", "int"); +$socid = GETPOSTINT("socid"); if ($user->socid) { $socid = $user->socid; } @@ -102,20 +102,20 @@ if (empty($reshook)) { // Link to a project if ($action == 'classin' && $permissiontoadd) { $object->fetch($id); - $object->setProject(GETPOST('projectid', 'int')); + $object->setProject(GETPOSTINT('projectid')); } if ($action == 'add') { $error = 0; - $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday", 'int'), GETPOST("datepyear", 'int')); - $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); + $datep = dol_mktime(12, 0, 0, GETPOSTINT("datepmonth"), GETPOSTINT("datepday"), GETPOSTINT("datepyear")); + $datev = dol_mktime(12, 0, 0, GETPOSTINT("datevmonth"), GETPOSTINT("datevday"), GETPOSTINT("datevyear")); if (empty($datev)) { $datev = $datep; } $object->ref = ''; // TODO - $object->accountid = GETPOST("accountid", 'int') > 0 ? GETPOST("accountid", "int") : 0; + $object->accountid = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0; $object->datev = $datev; $object->datep = $datep; $object->amount = price2num(GETPOST("amount", 'alpha')); @@ -272,8 +272,8 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { $object->label = $langs->trans("CopyOf").' '.$object->label; } - $newdatepayment = dol_mktime(0, 0, 0, GETPOST('clone_date_paymentmonth', 'int'), GETPOST('clone_date_paymentday', 'int'), GETPOST('clone_date_paymentyear', 'int')); - $newdatevalue = dol_mktime(0, 0, 0, GETPOST('clone_date_valuemonth', 'int'), GETPOST('clone_date_valueday', 'int'), GETPOST('clone_date_valueyear', 'int')); + $newdatepayment = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_paymentmonth'), GETPOSTINT('clone_date_paymentday'), GETPOSTINT('clone_date_paymentyear')); + $newdatevalue = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_valuemonth'), GETPOSTINT('clone_date_valueday'), GETPOSTINT('clone_date_valueyear')); if ($newdatepayment) { $object->datep = $newdatepayment; } @@ -284,7 +284,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) { } if (GETPOSTISSET("clone_sens")) { - $object->sens = GETPOST("clone_sens", 'int'); + $object->sens = GETPOSTINT("clone_sens"); } else { $object->sens = $object->sens; } diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index cc6b2f1ced5..8a066a3ba42 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -46,10 +46,10 @@ $langs->loadLangs(array('companies', 'bills', 'banks', 'multicurrency')); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); -$facid = GETPOST('facid', 'int'); -$accountid = GETPOST('accountid', 'int'); +$facid = GETPOSTINT('facid'); +$accountid = GETPOSTINT('accountid'); $paymentnum = GETPOST('num_paiement', 'alpha'); -$socid = GETPOST('socid', 'int'); +$socid = GETPOSTINT('socid'); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); @@ -100,7 +100,7 @@ if (empty($reshook)) { if (($action == 'add_paiement' || ($action == 'confirm_paiement' && $confirm == 'yes')) && $usercanissuepayment) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); $paiement_id = 0; $totalpayment = 0; $multicurrency_totalpayment = 0; @@ -216,7 +216,7 @@ if (empty($reshook)) { if ($action == 'confirm_paiement' && $confirm == 'yes' && $usercanissuepayment) { $error = 0; - $datepaye = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzuser'); + $datepaye = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'), 'tzuser'); $db->begin(); @@ -269,7 +269,7 @@ if (empty($reshook)) { $paiement->paiementid = dol_getIdFromCode($db, GETPOST('paiementcode'), 'c_paiement', 'code', 'id', 1); $paiement->num_payment = GETPOST('num_paiement', 'alpha'); $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->fk_account = GETPOST('accountid', 'int'); + $paiement->fk_account = GETPOSTINT('accountid'); if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or @@ -287,7 +287,7 @@ if (empty($reshook)) { if (GETPOST('type') == Facture::TYPE_CREDIT_NOTE) { $label = '(CustomerInvoicePaymentBack)'; // Refund of a credit note } - $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOST('accountid', 'int'), GETPOST('chqemetteur'), GETPOST('chqbank')); + $result = $paiement->addPaymentToBank($user, 'payment', $label, GETPOSTINT('accountid'), GETPOST('chqemetteur'), GETPOST('chqbank')); if ($result < 0) { setEventMessages($paiement->error, $paiement->errors, 'errors'); $error++; @@ -488,7 +488,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date payment print '<tr><td><span class="fieldrequired">'.$langs->trans('Date').'</span></td><td>'; - $datepayment = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); + $datepayment = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear')); $datepayment = ($datepayment == '' ? (!getDolGlobalString('MAIN_AUTOFILL_DATE') ? -1 : '') : $datepayment); print $form->selectDate($datepayment, '', '', '', 0, "add_paiement", 1, 1, 0, '', '', $facture->date); print '</td></tr>'; diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 1c56799d7f3..56b24d73985 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -53,12 +53,12 @@ $cancel = GETPOST('cancel', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); -$facid = GETPOST('facid', 'int'); -$socid = GETPOST('socid', 'int'); -$accountid = GETPOST('accountid', 'int'); -$day = GETPOST('day', 'int'); -$month = GETPOST('month', 'int'); -$year = GETPOST('year', 'int'); +$facid = GETPOSTINT('facid'); +$socid = GETPOSTINT('socid'); +$accountid = GETPOSTINT('accountid'); +$day = GETPOSTINT('day'); +$month = GETPOSTINT('month'); +$year = GETPOSTINT('year'); $search_ref = GETPOST('search_ref', 'alpha'); $search_account = GETPOST('search_account', 'int'); @@ -67,10 +67,10 @@ $search_amount = GETPOST('search_amount', 'alpha'); // alpha because we must be $search_company = GETPOST('search_company', 'alpha'); $search_payment_num = GETPOST('search_payment_num', 'alpha'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOST('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); -$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 @@ -315,10 +315,10 @@ if (empty($reshook)) { $paiement->multicurrency_amounts = $multicurrency_amounts; $paiement->multicurrency_code = $multicurrency_code; // Array with all currency of payments dispatching $paiement->multicurrency_tx = $multicurrency_tx; // Array with all currency tx of payments dispatching - $paiement->paiementid = GETPOST('paiementid', 'int'); + $paiement->paiementid = GETPOSTINT('paiementid'); $paiement->num_payment = GETPOST('num_paiement', 'alphanohtml'); $paiement->note_private = GETPOST('comment', 'alpha'); - $paiement->fk_account = GETPOST('accountid', 'int'); + $paiement->fk_account = GETPOSTINT('accountid'); if (!$error) { // Create payment and update this->multicurrency_amounts if this->amounts filled or From 9320c31627ea5e50fd0c488ffe6c74204ac7b0f0 Mon Sep 17 00:00:00 2001 From: thibdrev <thibault.drevet@gmail.com> Date: Mon, 5 Feb 2024 13:58:06 +0100 Subject: [PATCH 70/90] qual:p phspstan for htdocs/compta/facture/list.php (#28016) htdocs/compta/facture/list.php 451 Property Paiement::$paiementid (int) does not accept array|string. --- htdocs/compta/facture/list.php | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index c2f9de79313..20a277903ae 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -82,8 +82,8 @@ if ($contextpage == 'poslist') { $optioncss = 'print'; } -$lineid = GETPOST('lineid', 'int'); -$userid = GETPOST('userid', 'int'); +$lineid = GETPOSTINT('lineid'); +$userid = GETPOSTINT('userid'); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); $search_refcustomer = GETPOST('search_refcustomer', 'alpha'); $search_type = GETPOST('search_type', 'int'); @@ -117,28 +117,28 @@ $search_customer_code = GETPOST("search_customer_code", 'alphanohtml'); $search_type_thirdparty = GETPOST("search_type_thirdparty", 'int'); $search_user = GETPOST('search_user', 'int'); $search_sale = GETPOST('search_sale', 'int'); -$search_date_startday = GETPOST('search_date_startday', 'int'); -$search_date_startmonth = GETPOST('search_date_startmonth', 'int'); -$search_date_startyear = GETPOST('search_date_startyear', 'int'); -$search_date_endday = GETPOST('search_date_endday', 'int'); -$search_date_endmonth = GETPOST('search_date_endmonth', 'int'); -$search_date_endyear = GETPOST('search_date_endyear', 'int'); +$search_date_startday = GETPOSTINT('search_date_startday'); +$search_date_startmonth = GETPOSTINT('search_date_startmonth'); +$search_date_startyear = GETPOSTINT('search_date_startyear'); +$search_date_endday = GETPOSTINT('search_date_endday'); +$search_date_endmonth = GETPOSTINT('search_date_endmonth'); +$search_date_endyear = GETPOSTINT('search_date_endyear'); $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear); // Use tzserver $search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear); -$search_date_valid_startday = GETPOST('search_date_valid_startday', 'int'); -$search_date_valid_startmonth = GETPOST('search_date_valid_startmonth', 'int'); -$search_date_valid_startyear = GETPOST('search_date_valid_startyear', 'int'); -$search_date_valid_endday = GETPOST('search_date_valid_endday', 'int'); -$search_date_valid_endmonth = GETPOST('search_date_valid_endmonth', 'int'); -$search_date_valid_endyear = GETPOST('search_date_valid_endyear', 'int'); +$search_date_valid_startday = GETPOSTINT('search_date_valid_startday'); +$search_date_valid_startmonth = GETPOSTINT('search_date_valid_startmonth'); +$search_date_valid_startyear = GETPOSTINT('search_date_valid_startyear'); +$search_date_valid_endday = GETPOSTINT('search_date_valid_endday'); +$search_date_valid_endmonth = GETPOSTINT('search_date_valid_endmonth'); +$search_date_valid_endyear = GETPOSTINT('search_date_valid_endyear'); $search_date_valid_start = dol_mktime(0, 0, 0, $search_date_valid_startmonth, $search_date_valid_startday, $search_date_valid_startyear); // Use tzserver $search_date_valid_end = dol_mktime(23, 59, 59, $search_date_valid_endmonth, $search_date_valid_endday, $search_date_valid_endyear); -$search_datelimit_startday = GETPOST('search_datelimit_startday', 'int'); -$search_datelimit_startmonth = GETPOST('search_datelimit_startmonth', 'int'); -$search_datelimit_startyear = GETPOST('search_datelimit_startyear', 'int'); -$search_datelimit_endday = GETPOST('search_datelimit_endday', 'int'); -$search_datelimit_endmonth = GETPOST('search_datelimit_endmonth', 'int'); -$search_datelimit_endyear = GETPOST('search_datelimit_endyear', 'int'); +$search_datelimit_startday = GETPOSTINT('search_datelimit_startday'); +$search_datelimit_startmonth = GETPOSTINT('search_datelimit_startmonth'); +$search_datelimit_startyear = GETPOSTINT('search_datelimit_startyear'); +$search_datelimit_endday = GETPOSTINT('search_datelimit_endday'); +$search_datelimit_endmonth = GETPOSTINT('search_datelimit_endmonth'); +$search_datelimit_endyear = GETPOSTINT('search_datelimit_endyear'); $search_datelimit_start = dol_mktime(0, 0, 0, $search_datelimit_startmonth, $search_datelimit_startday, $search_datelimit_startyear); $search_datelimit_end = dol_mktime(23, 59, 59, $search_datelimit_endmonth, $search_datelimit_endday, $search_datelimit_endyear); $search_categ_cus = GETPOST("search_categ_cus", 'int'); @@ -153,7 +153,7 @@ if ($search_late == 'late') { } $filtre = GETPOST('filtre', 'alpha'); -$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); @@ -411,9 +411,9 @@ if ($action == 'makepayment_confirm' && $user->hasRight('facture', 'paiement')) require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $arrayofselected = is_array($toselect) ? $toselect : array(); if (!empty($arrayofselected)) { - $bankid = GETPOST('bankid', 'int'); - $paiementid = GETPOST('paiementid', 'int'); - $paiementdate = dol_mktime(12, 0, 0, GETPOST('datepaimentmonth', 'int'), GETPOST('datepaimentday', 'int'), GETPOST('datepaimentyear', 'year')); + $bankid = GETPOSTINT('bankid'); + $paiementid = GETPOSTINT('paiementid'); + $paiementdate = dol_mktime(12, 0, 0, GETPOSTINT('datepaimentmonth'), GETPOSTINT('datepaimentday'), GETPOSTINT('datepaimentyear')); if (empty($paiementdate)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); $error++; From 756066e791c3142684dc220a2049da987394152f Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Mon, 5 Feb 2024 15:18:34 +0200 Subject: [PATCH 71/90] Qual fix trans (#28019) * fix translation * fix typo * fix typo * fix typo --- htdocs/langs/en_US/errors.lang | 4 ++-- htdocs/langs/en_US/mails.lang | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 624d106ff5e..71b2dccb2bf 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -407,7 +407,7 @@ ErrorTooManyAttempts= Too many attempts, please try again later TotalAmountEmpty=Total Amount Empty FailedToFoundTheConversionRateForInvoice=Failed to found the conversion rate for invoice -ThisIdNotDefined=$this->id not defined -OperNotDefined=Oper not defined +ThisIdNotDefined=Id not defined +OperNotDefined=Payment method not defined ErrorThisContactXIsAlreadyDefinedAsThisType=%s is already defined as contact for this type. ErrorThisGroupIsAlreadyDefinedAsThisType=The contacts with this group are already defined as contact for this type. diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index ff6f26f1992..704b4553dcc 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -189,6 +189,6 @@ EvenUnsubscribe=Include opt-out emails EvenUnsubscribeDesc=Include opt-out emails when you select emails as targets. Useful for mandatory service emails for example. XEmailsDoneYActionsDone=%s emails pre-qualified, %s emails successfully processed (for %s record/actions done) helpWithAi=Generate message from AI -YouCanMakeSomeInstructionForEmail=You Can Make Some Instruction For your Email (Exemple: generate image in email template...) +YouCanMakeSomeInstructionForEmail=You can make some instructions for your Email (Example: generate image in email template...) ModelTemplate=Email template -YouCanChooseAModelForYouMailContent= You can shoose one of models or generate one with Ai \ No newline at end of file +YouCanChooseAModelForYouMailContent= You can choose one of template models or generate one with AI From 9cac3156f72116c001b85cd6ac3b893fc859b71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:20:23 +0100 Subject: [PATCH 72/90] Update dbtable.php (#27997) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- htdocs/admin/system/dbtable.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/system/dbtable.php b/htdocs/admin/system/dbtable.php index c061294b9cd..c7e7c5baa5e 100644 --- a/htdocs/admin/system/dbtable.php +++ b/htdocs/admin/system/dbtable.php @@ -85,19 +85,20 @@ if (!$base) { } } - // var_dump($link); - print '<table class="noborder">'; print '<tr class="liste_titre">'; - print '<td>'.$langs->trans("Fields").'</td><td>'.$langs->trans("Type").'</td><td>'.$langs->trans("Index").'</td>'; - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; - print '<td></td>'; + print '<td>'.$langs->trans("Fields").'</td>'; + print '<td>'.$langs->trans("Type").'</td>'; + print '<td>'.$langs->trans("Collation").'</td>'; + print '<td>'.$langs->trans("Null").'</td>'; + print '<td>'.$langs->trans("Index").'</td>'; + print '<td>'.$langs->trans("Default").'</td>'; + print '<td>'.$langs->trans("Extra").'</td>'; + print '<td>'.$langs->trans("Privileges").'</td>'; print '<td>'.$langs->trans("FieldsLinked").'</td>'; print '</tr>'; - //$sql = "DESCRIBE ".$table; + // $sql = "DESCRIBE ".$table; $sql = "SHOW FULL COLUMNS IN ".$db->escape($table); $resql = $db->query($sql); @@ -106,15 +107,23 @@ if (!$base) { $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); - //var_dump($row); print '<tr class="oddeven">'; + // field print "<td>".$row[0]."</td>"; + // type print "<td>".$row[1]."</td>"; + // collation + print "<td>".$row[2]."</td>"; + // null print "<td>".$row[3]."</td>"; + // key print "<td>".(empty($row[4]) ? '' : $row[4])."</td>"; + // default print "<td>".(empty($row[5]) ? '' : $row[5])."</td>"; + // extra print "<td>".(empty($row[6]) ? '' : $row[6])."</td>"; + // privileges print "<td>".(empty($row[7]) ? '' : $row[7])."</td>"; print "<td>".(isset($link[$row[0]][0]) ? $link[$row[0]][0] : '')."."; From e987af39951efdcd0f73d77f7dc8118d5d8d61e8 Mon Sep 17 00:00:00 2001 From: thibdrev <thibault.drevet@gmail.com> Date: Mon, 5 Feb 2024 14:21:18 +0100 Subject: [PATCH 73/90] qual: phpstan - another batch of "getNextValue() should return string but returns int." (#27990) * Update mod_asset_advanced.php * Update mod_asset_standard.php * Update mod_bom_advanced.php * Update mod_bom_standard.php * Update mod_chequereceipt_mint.php * Update mod_chequereceipt_thyme.php * Update mod_commande_saphir.php * Update mod_contract_magre.php * Update mod_contract_serpis.php * Update mod_delivery_jade.php * Update mod_delivery_saphir.php * Update mod_expedition_ribera.php * Update mod_expedition_safor.php * Update mod_expensereport_jade.php * Update mod_expensereport_sand.php * Update mod_facture_mercure.php * Update mod_facture_terre.php * Update mod_arctic.php * Update mod_holiday_immaculate.php * Update mod_evaluation_advanced.php * Update mod_evaluation_standard.php * Update mod_member_advanced.php * Update mod_member_simple.php * Update mod_mo_advanced.php * Update mod_mo_standard.php * Update mod_payment_ant.php * Update mod_payment_cicada.php * Update mod_codeproduct_elephant.php * Update mod_lot_advanced.php * Update mod_lot_standard.php * Update mod_sn_advanced.php * Update mod_project_universal.php * Update mod_task_simple.php * Update mod_task_universal.php * Update mod_propale_marbre.php * Update mod_propale_saphir.php * Update mod_reception_beryl.php * Update mod_reception_moonstone.php * Update mod_codeclient_elephant.php * Update mod_codeclient_monkey.php * Update mod_ticket_simple.php * same as PR #27989 --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- htdocs/core/modules/asset/mod_asset_advanced.php | 2 +- htdocs/core/modules/asset/mod_asset_standard.php | 2 +- htdocs/core/modules/bom/mod_bom_advanced.php | 2 +- htdocs/core/modules/bom/mod_bom_standard.php | 2 +- htdocs/core/modules/cheque/mod_chequereceipt_mint.php | 2 +- htdocs/core/modules/cheque/mod_chequereceipt_thyme.php | 2 +- htdocs/core/modules/commande/mod_commande_saphir.php | 2 +- htdocs/core/modules/contract/mod_contract_magre.php | 4 ++-- htdocs/core/modules/contract/mod_contract_serpis.php | 4 ++-- htdocs/core/modules/delivery/mod_delivery_jade.php | 4 ++-- htdocs/core/modules/delivery/mod_delivery_saphir.php | 6 +++--- htdocs/core/modules/expedition/mod_expedition_ribera.php | 4 ++-- htdocs/core/modules/expedition/mod_expedition_safor.php | 4 ++-- .../core/modules/expensereport/mod_expensereport_jade.php | 2 +- .../core/modules/expensereport/mod_expensereport_sand.php | 2 +- htdocs/core/modules/facture/mod_facture_mercure.php | 4 ++-- htdocs/core/modules/facture/mod_facture_terre.php | 4 ++-- htdocs/core/modules/fichinter/mod_arctic.php | 4 ++-- htdocs/core/modules/holiday/mod_holiday_immaculate.php | 4 ++-- htdocs/core/modules/hrm/mod_evaluation_advanced.php | 2 +- htdocs/core/modules/hrm/mod_evaluation_standard.php | 2 +- htdocs/core/modules/member/mod_member_advanced.php | 2 +- htdocs/core/modules/member/mod_member_simple.php | 2 +- htdocs/core/modules/mrp/mod_mo_advanced.php | 2 +- htdocs/core/modules/mrp/mod_mo_standard.php | 2 +- htdocs/core/modules/payment/mod_payment_ant.php | 4 ++-- htdocs/core/modules/payment/mod_payment_cicada.php | 4 ++-- htdocs/core/modules/product/mod_codeproduct_elephant.php | 2 +- htdocs/core/modules/product_batch/mod_lot_advanced.php | 2 +- htdocs/core/modules/product_batch/mod_lot_standard.php | 2 +- htdocs/core/modules/product_batch/mod_sn_advanced.php | 2 +- htdocs/core/modules/project/mod_project_universal.php | 4 ++-- htdocs/core/modules/project/task/mod_task_simple.php | 4 ++-- htdocs/core/modules/project/task/mod_task_universal.php | 4 ++-- htdocs/core/modules/propale/mod_propale_marbre.php | 4 ++-- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- htdocs/core/modules/reception/mod_reception_beryl.php | 4 ++-- htdocs/core/modules/reception/mod_reception_moonstone.php | 4 ++-- htdocs/core/modules/societe/mod_codeclient_elephant.php | 2 +- htdocs/core/modules/societe/mod_codeclient_monkey.php | 2 +- htdocs/core/modules/ticket/mod_ticket_simple.php | 2 +- 41 files changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/core/modules/asset/mod_asset_advanced.php b/htdocs/core/modules/asset/mod_asset_advanced.php index ff39d1e2613..a1f800d309d 100644 --- a/htdocs/core/modules/asset/mod_asset_advanced.php +++ b/htdocs/core/modules/asset/mod_asset_advanced.php @@ -115,7 +115,7 @@ class mod_asset_advanced extends ModeleNumRefAsset * Return next free value * * @param Asset $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/asset/mod_asset_standard.php b/htdocs/core/modules/asset/mod_asset_standard.php index 549575f4adf..7c34cc27931 100644 --- a/htdocs/core/modules/asset/mod_asset_standard.php +++ b/htdocs/core/modules/asset/mod_asset_standard.php @@ -119,7 +119,7 @@ class mod_asset_standard extends ModeleNumRefAsset * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/bom/mod_bom_advanced.php b/htdocs/core/modules/bom/mod_bom_advanced.php index b8933a32504..0e9f3d4f977 100644 --- a/htdocs/core/modules/bom/mod_bom_advanced.php +++ b/htdocs/core/modules/bom/mod_bom_advanced.php @@ -120,7 +120,7 @@ class mod_bom_advanced extends ModeleNumRefBoms * * @param Product $objprod Object product * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objprod, $object) { diff --git a/htdocs/core/modules/bom/mod_bom_standard.php b/htdocs/core/modules/bom/mod_bom_standard.php index 4c40082336a..1e26ba2254a 100644 --- a/htdocs/core/modules/bom/mod_bom_standard.php +++ b/htdocs/core/modules/bom/mod_bom_standard.php @@ -114,7 +114,7 @@ class mod_bom_standard extends ModeleNumRefBoms * * @param Product $objprod Object product * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($objprod, $object) { diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 723786ed485..5106697211d 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -111,7 +111,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @param Societe $objsoc Object thirdparty * @param RemiseCheque $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Next value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index 4b73ae4a0a3..5a2ae083d2f 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -111,7 +111,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @param Societe $objsoc Object thirdparty * @param RemiseCheque $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 65c48a657cc..2cc4331e98e 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -120,7 +120,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 4a3f97e7214..ed7f5803b3e 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -120,7 +120,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @param Societe $objsoc third party object * @param Object $contract contract object - * @return string Value if OK, 0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($objsoc, $contract) { @@ -146,7 +146,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @param Societe $objsoc third party object * @param Object $objforref contract object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function contract_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index aba9d6df710..61a04306b25 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -124,7 +124,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @param Societe $objsoc third party object * @param Object $contract contract object - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $contract) { @@ -169,7 +169,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @param Societe $objsoc third party object * @param Object $objforref contract object - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function contract_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/delivery/mod_delivery_jade.php b/htdocs/core/modules/delivery/mod_delivery_jade.php index 579f4af7ced..c29a5f7f4bd 100644 --- a/htdocs/core/modules/delivery/mod_delivery_jade.php +++ b/htdocs/core/modules/delivery/mod_delivery_jade.php @@ -127,7 +127,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { @@ -176,7 +176,7 @@ class mod_delivery_jade extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object thirdparty * @param Object $object Object livraison - * @return string Descriptive text + * @return string|-1 Value if OK, -1 if KO */ public function delivery_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/delivery/mod_delivery_saphir.php b/htdocs/core/modules/delivery/mod_delivery_saphir.php index bb1b2e7ad33..209d848ec31 100644 --- a/htdocs/core/modules/delivery/mod_delivery_saphir.php +++ b/htdocs/core/modules/delivery/mod_delivery_saphir.php @@ -122,7 +122,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object third party * @param Object $object Object delivery - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { @@ -149,7 +149,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object third party * @param string $objforref Object for number to search - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function getNumRef($objsoc, $objforref) { @@ -163,7 +163,7 @@ class mod_delivery_saphir extends ModeleNumRefDeliveryOrder * * @param Societe $objsoc Object thirdparty * @param Object $object Object livraison - * @return string Descriptive text + * @return string|0 Value if OK, 0 if KO */ public function delivery_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index a90fc7c6653..2d8c5f7f138 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -118,7 +118,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @param Societe $objsoc Third party object * @param Object $shipment Shipment object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $shipment) { @@ -146,7 +146,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @param Societe $objsoc Third party object * @param Object $objforref Shipment object - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function expedition_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index ca265082d1a..579ba6a4d4f 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -119,7 +119,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @param Societe $objsoc Third party object * @param Object $shipment Shipment object - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $shipment) { @@ -163,7 +163,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @param Societe $objsoc Third party object * @param Object $objforref Shipment object - * @return string Next free value + * @return string|-1 Next free value, -1 if KO */ public function expedition_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index 48e05c7f8d6..60de9d22014 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -119,7 +119,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index 6bc4c6671dd..8a0165e3799 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -121,7 +121,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Next value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index fb00fd6246f..1aae660c1a9 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -134,7 +134,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { @@ -180,7 +180,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param string $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 12c722f6d9a..3336340cd63 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -201,7 +201,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param Facture $invoice Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Next ref value or last ref if $mode is 'last', <= 0 if KO + * @return string|int<-1,0> Next ref value or last ref if $mode is 'last', -1 or 0 if KO */ public function getNextValue($objsoc, $invoice, $mode = 'next') { @@ -285,7 +285,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param Societe $objsoc Object third party * @param string $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * @return string|int<-1,0> Next free value, -1 or 0 if error */ public function getNumRef($objsoc, $objforref, $mode = 'next') { diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index df2229e2211..4e23b6cb1e3 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -122,7 +122,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc = 0, $object = '') { @@ -149,7 +149,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @param Societe $objsoc Object third party * @param Object $objforref Object for number to search - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 954f33d8f2a..d86c9dcca1a 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -120,7 +120,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @param Societe $objsoc third party object * @param Object $holiday holiday object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $holiday) { @@ -146,7 +146,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @param User $fuser User object * @param Object $objforref Holiday object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function holiday_get_num($fuser, $objforref) { diff --git a/htdocs/core/modules/hrm/mod_evaluation_advanced.php b/htdocs/core/modules/hrm/mod_evaluation_advanced.php index 71fb0024d93..2c89930a5ab 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_advanced.php +++ b/htdocs/core/modules/hrm/mod_evaluation_advanced.php @@ -124,7 +124,7 @@ class mod_evaluation_advanced extends ModeleNumRefEvaluation * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/hrm/mod_evaluation_standard.php b/htdocs/core/modules/hrm/mod_evaluation_standard.php index c00b8e62a55..17cb75ad4ea 100644 --- a/htdocs/core/modules/hrm/mod_evaluation_standard.php +++ b/htdocs/core/modules/hrm/mod_evaluation_standard.php @@ -118,7 +118,7 @@ class mod_evaluation_standard extends ModeleNumRefEvaluation * Return next free value * * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($object) { diff --git a/htdocs/core/modules/member/mod_member_advanced.php b/htdocs/core/modules/member/mod_member_advanced.php index 221b55fa24e..5857692a045 100644 --- a/htdocs/core/modules/member/mod_member_advanced.php +++ b/htdocs/core/modules/member/mod_member_advanced.php @@ -125,7 +125,7 @@ class mod_member_advanced extends ModeleNumRefMembers * * @param Societe $objsoc Object third party * @param Adherent $object Object we need next value for - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/member/mod_member_simple.php b/htdocs/core/modules/member/mod_member_simple.php index bc52459f79c..7fe9e6da5b6 100644 --- a/htdocs/core/modules/member/mod_member_simple.php +++ b/htdocs/core/modules/member/mod_member_simple.php @@ -123,7 +123,7 @@ class mod_member_simple extends ModeleNumRefMembers * * @param Societe $objsoc Object third party * @param Adherent $object Object we need next value for - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/mrp/mod_mo_advanced.php b/htdocs/core/modules/mrp/mod_mo_advanced.php index 2fc5985cc84..b04001e84d3 100644 --- a/htdocs/core/modules/mrp/mod_mo_advanced.php +++ b/htdocs/core/modules/mrp/mod_mo_advanced.php @@ -121,7 +121,7 @@ class mod_mo_advanced extends ModeleNumRefMos * * @param Product $objprod Object product * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objprod, $object) { diff --git a/htdocs/core/modules/mrp/mod_mo_standard.php b/htdocs/core/modules/mrp/mod_mo_standard.php index 72ea06d05ab..d1e294fd3d3 100644 --- a/htdocs/core/modules/mrp/mod_mo_standard.php +++ b/htdocs/core/modules/mrp/mod_mo_standard.php @@ -114,7 +114,7 @@ class mod_mo_standard extends ModeleNumRefMos * * @param Product $objprod Object product * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objprod, $object) { diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 6fe019dde3b..4e60a5d8efa 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -120,7 +120,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { @@ -148,7 +148,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @param Societe $objsoc Object third party * @param string $objforref Object for number to search - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function commande_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index 3c6164bdb0b..6c90fec350a 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -121,7 +121,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @param Societe $objsoc Object thirdparty * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { @@ -168,7 +168,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @param Societe $objsoc Object third party * @param string $objforref Object for number to search - * @return string Next free value + * @return string|-1 Next free value, -1 if KO */ public function payment_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 858a62af001..123676074af 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -181,7 +181,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * * @param Product $objproduct Object product * @param int $type Produit ou service (0:product, 1:service) - * @return string Value if OK, '' if module not configured, <0 if KO + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objproduct = null, $type = -1) { diff --git a/htdocs/core/modules/product_batch/mod_lot_advanced.php b/htdocs/core/modules/product_batch/mod_lot_advanced.php index dce06566c8c..c455b639022 100644 --- a/htdocs/core/modules/product_batch/mod_lot_advanced.php +++ b/htdocs/core/modules/product_batch/mod_lot_advanced.php @@ -134,7 +134,7 @@ class mod_lot_advanced extends ModeleNumRefBatch * * @param Societe $objsoc Object thirdparty * @param Productlot $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/product_batch/mod_lot_standard.php b/htdocs/core/modules/product_batch/mod_lot_standard.php index b63aff30a84..82e4098a246 100644 --- a/htdocs/core/modules/product_batch/mod_lot_standard.php +++ b/htdocs/core/modules/product_batch/mod_lot_standard.php @@ -116,7 +116,7 @@ class mod_lot_standard extends ModeleNumRefBatch * * @param Societe $objsoc Object thirdparty * @param Productlot $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/product_batch/mod_sn_advanced.php b/htdocs/core/modules/product_batch/mod_sn_advanced.php index 41200b6fced..dd3ec1df88e 100644 --- a/htdocs/core/modules/product_batch/mod_sn_advanced.php +++ b/htdocs/core/modules/product_batch/mod_sn_advanced.php @@ -134,7 +134,7 @@ class mod_sn_advanced extends ModeleNumRefBatch * * @param Societe $objsoc Object thirdparty * @param Productlot $object Object we need next value for - * @return string Value if KO, <0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 4f2f5a421ae..e4b280cf226 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -126,7 +126,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @param Societe $objsoc Object third party * @param Project $project Object project - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $project) { @@ -158,7 +158,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @param Societe $objsoc Object third party * @param Project $project Object project - * @return string Next not used reference + * @return string|0 Next not used reference, 0 if KO */ public function project_get_num($objsoc = 0, $project = '') { diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 55f9472ab17..0eea8129ca3 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -124,7 +124,7 @@ class mod_task_simple extends ModeleNumRefTask * * @param Societe $objsoc Object third party * @param Task $object Object Task - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $object) { @@ -169,7 +169,7 @@ class mod_task_simple extends ModeleNumRefTask * * @param Societe $objsoc Object third party * @param Task $object Object task - * @return string Next not used reference + * @return string|-1 Next not used reference, -1 if KO */ public function task_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index b07f918d279..95c7d392ed0 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -121,7 +121,7 @@ class mod_task_universal extends ModeleNumRefTask * * @param Societe $objsoc Object third party * @param Task $object Object task - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $object) { @@ -149,7 +149,7 @@ class mod_task_universal extends ModeleNumRefTask * * @param Societe $objsoc Object third party * @param Task $object Object task - * @return string Next not used reference + * @return string|0 Next not used reference, 0 if KO */ public function project_get_num($objsoc = 0, $object = '') { diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index c85e0d3bc91..e5a8c1a0d9d 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @param Societe $objsoc Object third party * @param Propal $propal Object commercial proposal - * @return string Next value + * @return string|-1 Next value, -1 if KO */ public function getNextValue($objsoc, $propal) { @@ -168,7 +168,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @param Societe $objsoc Object third party * @param Object $objforref Object for number to search - * @return string Next free value + * @return string|-1 Next free value, -1 if KO */ public function getNumRef($objsoc, $objforref) { diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 399e59f6477..91772195411 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -127,7 +127,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * * @param Societe $objsoc Object third party * @param Propal $propal Object commercial proposal - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $propal) { diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 905cd90e662..164732886a3 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -99,7 +99,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @param Societe $objsoc Third party object * @param Object $reception Reception object - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $reception) { @@ -143,7 +143,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @param Societe $objsoc Third party object * @param Object $objforref Shipment object - * @return string Next free value + * @return string|-1 Next free value, -1 if KO */ public function reception_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index b7ab238caec..8742dede043 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -99,7 +99,7 @@ class mod_reception_moonstone extends ModelNumRefReception * * @param Societe $objsoc Third party object * @param Object|null $reception Reception object - * @return string Value if OK, 0 if KO + * @return string|0 Value if OK, 0 if KO */ public function getNextValue($objsoc, $reception) { @@ -131,7 +131,7 @@ class mod_reception_moonstone extends ModelNumRefReception * * @param Societe $objsoc Third party object * @param Object $objforref Reception object - * @return string Next free value + * @return string|0 Next free value, 0 if KO */ public function reception_get_num($objsoc, $objforref) { diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index c06fecc1af4..d598aef88b0 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -220,7 +220,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * * @param Societe $objsoc Object third party * @param int $type Client ou fournisseur (0:customer, 1:supplier) - * @return string Value if OK, '' if module not configured, <0 if KO + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = 0, $type = -1) { diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index f8f4235e81b..4014e942a51 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -112,7 +112,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * * @param Societe $objsoc Object third party * @param int $type Client ou fournisseur (1:client, 2:fournisseur) - * @return string Value if OK, '' if module not configured, <0 if KO + * @return string|-1 Value if OK, '' if module not configured, -1 if KO */ public function getNextValue($objsoc = 0, $type = -1) { diff --git a/htdocs/core/modules/ticket/mod_ticket_simple.php b/htdocs/core/modules/ticket/mod_ticket_simple.php index 00bd01289fa..943f26c2c50 100644 --- a/htdocs/core/modules/ticket/mod_ticket_simple.php +++ b/htdocs/core/modules/ticket/mod_ticket_simple.php @@ -119,7 +119,7 @@ class mod_ticket_simple extends ModeleNumRefTicket * * @param Societe $objsoc Object third party * @param Ticket $ticket Object ticket - * @return string Value if OK, 0 if KO + * @return string|-1 Value if OK, -1 if KO */ public function getNextValue($objsoc, $ticket) { From 505ca17ba9debb5aee65812ea0fafffe81039928 Mon Sep 17 00:00:00 2001 From: MDW <mdeweerd@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:29:18 +0100 Subject: [PATCH 74/90] Qual: Fix spelling and wording (#27995) # Qual: Fix spelling and wording Fix spelling (using beta codespell) and fix some wording in module README template and ChangeLog. Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- ChangeLog | 22 +++++++-------- .../codespell/codespell-lines-ignore.txt | 2 ++ htdocs/admin/stock.php | 2 +- .../categories/class/api_categories.class.php | 8 +++--- htdocs/compta/bank/line.php | 2 +- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/class/html.formticket.class.php | 2 +- htdocs/core/js/lib_notification.js.php | 2 +- htdocs/core/lib/accounting.lib.php | 10 +++---- htdocs/core/lib/admin.lib.php | 2 +- htdocs/core/lib/pdf.lib.php | 4 +-- htdocs/core/lib/report.lib.php | 12 ++++---- .../modules/mrp/doc/pdf_vinci.modules.php | 2 +- .../supplier_order/doc/pdf_cornas.modules.php | 2 +- .../doc/pdf_zenith.modules.php | 2 +- htdocs/expedition/dispatch.php | 2 +- .../fourn/class/fournisseur.product.class.php | 2 +- htdocs/main.inc.php | 2 +- htdocs/modulebuilder/template/README.md | 28 +++++++++---------- htdocs/product/class/productbatch.class.php | 2 +- htdocs/product/fournisseurs.php | 2 +- .../public/emailing/mailing-unsubscribe.php | 2 +- htdocs/public/stripe/ipn.php | 2 +- htdocs/reception/dispatch.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 25 files changed, 62 insertions(+), 60 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cfaa1ca3ad..bda30ca8caa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -124,7 +124,7 @@ NEW: filter on from/to period rather than month/year (#26378) NEW: FontAwesome - added possibility to select another version NEW: Get list evaluation with skills details in user fiche (#26510) NEW: hidden conf to disable use of dns_get_record (which can become unresponsive) (#26339) -NEW: HR: PDF Generation for each Human Resource Evaluations +NEW: HR: PDF Generation for each Human Resource Evaluations NEW: improved resource data structure NEW: Interventions: close notification for interventions NEW: Inventory: include sub warehouse in inventory @@ -254,7 +254,7 @@ NEW: add a $notrigger param to Product::updatePrice() method (#26404) NEW: add a rule to fix empty($conf->global->...) into !getDolGlobal... NEW: add column extraparams on societe_rib NEW: add phpunit for REST API of contacts -NEW: add barcode function to check if EAN13 is valid +NEW: add barcode function to check if EAN13 is valid WARNING: @@ -271,7 +271,7 @@ The following changes may create regressions for some external modules, but were * The property ->user_creation to store ID of user of creation has been renamed into ->user_creation_id. * The property ->user_modification to store ID of user of modification has been renamed into ->user_modification_id. * The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere. -* The duplicate property ->user_creat, ->date_creat, ->date_valid have been removed (use instead user_creation, date_creation, date_validation). +* The duplicate property ->user_creat, ->date_creat, ->date_valid have been removed (use instead user_creation, date_creation, date_validation). * The method get_substitutionarray_shipment_lines() has been removed. Use the generic get_substitutionarray_lines() instead. * The method ProductcustomerPrice->fetch_all_log() has been renamed into camel case ->fetchAllLog() * It was possible to use a variable $soc or $right inside a PHP code condition of some extrafields properties, this is no more true (this 2 variables are no more global variables). @@ -489,7 +489,7 @@ NEW: Accountancy - Quadratus export with attachments in accountancy export NEW: Accountancy - Can filter on a custom group of accounts. Perf or ledger list. NEW: Accountancy - Can select the export format during export of journals NEW: Accountancy - sort of column of custom group of account -NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions +NEW: Can upload a file with drag and drop on purchase invoice, vats, salaries and social contributions NEW: Authentication: #22740 add OpenID Connect impl NEW: Authentication: add experimental support for Google OAuth2 connection NEW: Authentication: can now edit service name for OAuth token @@ -677,14 +677,14 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * Minimal PHP version is now PHP 7.1 instead of PHP 7.0 -* Sensitive data like keys in setup pages, that need encryption (for example the API keys of users, the CRON security key, the keys into the Stripe module, or +* Sensitive data like keys in setup pages, that need encryption (for example the API keys of users, the CRON security key, the keys into the Stripe module, or external modules setup pages that store sensitive keys or password), are using the $dolibarr_main_instance_unique_id as part of the key for encryption. So, if you restore or duplicate the data from another instance dump, you must also -update this parameter in the conf.php file to allow decryption in the new instance, or +update this parameter in the conf.php file to allow decryption in the new instance, or better, you must reenter the sensitive data into the setup pages of the new instance to resave them correctly. -Note that to find all the parameters that are encrypted into the setup database, you can do a "SELECT * FROM llx_const WHERE value LIKE '%dolcrypt%';" +Note that to find all the parameters that are encrypted into the setup database, you can do a "SELECT * FROM llx_const WHERE value LIKE '%dolcrypt%';" * The deprecated method "escapeunderscore()" of database handlers has been removed. You must use "escapeforlike()" instead. -* The method "nb_expedition()" has been renamed into "countNbOfShipments()" +* The method "nb_expedition()" has been renamed into "countNbOfShipments()" * Revert default type of hooks. Default is now 'addreplace' hooks (and exception become 'output' hooks, that become deprecated). * Deprecated property libelle removed from entrepot class. * The type 'text' in ->fields property does not accept html content anymore. Use the type 'html' for that. @@ -1086,7 +1086,7 @@ WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: * Minimal PHP version is now PHP 7.0 instead of PHP 5.6 * Core has introduced a Universal Filter Syntax for search criteria. Example: ((((field1:=:value1) OR (field2:in:1,2,3)) AND ...). In rare case, some filters - could be provided by URL parameters. For such cases (societe/ajax/company.php), use of Universal Filter Syntax become mandatory. + could be provided by URL parameters. For such cases (societe/ajax/company.php), use of Universal Filter Syntax become mandatory. * The signature of method getNomUrl() of class ProductFournisseur has been modified to match the signature of method Product->getNomUrl() * Trigger ORDER_SUPPLIER_DISPATCH is removed, use ORDER_SUPPLIER_RECEIVE and/or LINEORDER_SUPPLIER_DISPATCH instead. * All functions fetch_all() have been set to deprecated for naming consistency, use fetchAll() instead. @@ -1164,7 +1164,7 @@ FIX: #23019 Impossible to add task times to an existing draft invoice FIX: #23072 FIX: #23075 FIX: #23087 -FIX: #23115 +FIX: #23115 FIX: #23116 FIX: #23117 FIX: #23281 @@ -7551,7 +7551,7 @@ FIX: #4583 Incorrect call of Categories::containing throws a DoliDB error FIX: #4649 Wrong parameters order FIX: #4768 FIX: #4785 -FIX: Add a test to show bugged module with a bad declaration of dictionaries to avoid to see clean module to be breaked. +FIX: Add a test to show bugged module with a bad declaration of dictionaries to avoid clean modules to be broken. FIX: add Croatia into list of country in EEC FIX: add missing global def for ttc column FIX: ajax error with multicompany module diff --git a/dev/tools/codespell/codespell-lines-ignore.txt b/dev/tools/codespell/codespell-lines-ignore.txt index 0d4e979d84a..fe245f74b46 100644 --- a/dev/tools/codespell/codespell-lines-ignore.txt +++ b/dev/tools/codespell/codespell-lines-ignore.txt @@ -21,6 +21,7 @@ print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=transfert">'.$langs->trans("TransferStock").'</a>'; $action = 'transfert'; $ensemblereponses = $obj->reponses; + $return .= '<br><span class="opacitymedium">'.$langs->trans("Payement").'</span> : <span class="info-box-label">'.$this->type_payment.'</span>'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, date_creation)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses, ip, date_creation)'; $sql = 'SELECT s.reponses'; @@ -61,5 +62,6 @@ $usercandelete = $user->rights->stock->mouvement->creer; $usercandelete = (($user->rights->stock->mouvement->supprimer)); $usercanread = $user->rights->stock->mouvement->lire; $usercanread = (($user->rights->stock->mouvement->lire)); +* The private array ->status_short, ->statuts and ->status_long are now array ->labelStatusShort and ->labelStatus everywhere. if (!$user->hasRight('stock', 'mouvement', 'lire')) { if ($action == "transfert") { diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 2e28b567e41..9b088c7e660 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "stocks")); -// Securit check +// Security check if (!$user->admin) { accessforbidden(); } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index e15571e5481..b938298f2c1 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -416,7 +416,7 @@ class Categories extends DolibarrApi return array( 'success' => array( 'code' => 200, - 'message' => 'Objects succefully linked to the category' + 'message' => 'Objects successfully linked to the category' ) ); } @@ -496,7 +496,7 @@ class Categories extends DolibarrApi return array( 'success' => array( 'code' => 200, - 'message' => 'Objects succefully linked to the category' + 'message' => 'Objects successfully linked to the category' ) ); } @@ -574,7 +574,7 @@ class Categories extends DolibarrApi return array( 'success' => array( 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' + 'message' => 'Objects successfully unlinked from the category' ) ); } @@ -652,7 +652,7 @@ class Categories extends DolibarrApi return array( 'success' => array( 'code' => 200, - 'message' => 'Objects succefully unlinked from the category' + 'message' => 'Objects successfully unlinked from the category' ) ); } diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index f62fbd1af75..0679b01951c 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -651,7 +651,7 @@ if ($result) { print "</table>"; // Code to adjust value date with plus and less picto using an Ajax call instead of a full reload of page - /* Not yet ready. We must manage inline replacemet of input date field + /* Not yet ready. We must manage inline replacement of input date field $urlajax = DOL_URL_ROOT.'/core/ajax/bankconciliate.php?token='.currentToken(); print ' <script type="text/javascript"> diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index c0758ca9661..783711eeeb9 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -989,7 +989,7 @@ class FormOther // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Creae an image for color + * Create an image for color * * @param string $color Color of image * @param string $module Name of module diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 23c2f0751f6..255f39c84ac 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -794,7 +794,7 @@ class FormTicket } /** - * Return html list of ticket anaytic codes + * Return html list of ticket analytic codes * * @param string $selected Id pre-selected category * @param string $htmlname Name of select component diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php index 3a980043d37..3562caed861 100644 --- a/htdocs/core/js/lib_notification.js.php +++ b/htdocs/core/js/lib_notification.js.php @@ -214,7 +214,7 @@ function check_events() { } else { console.log("Cancel check_events() with dolnotif_nb_test_for_page="+dolnotif_nb_test_for_page+". Check is useless because javascript Notification.permission is "+Notification.permission+" (blocked manually or web site is not https)."); - result = 2; // We return a positive so the repeated check will done even if authroization is not yet allowed may be after this check) + result = 2; // We return a positive so the repeated check will done even if authorization is not yet allowed may be after this check) } if (dolnotif_nb_test_for_page >= 5) { diff --git a/htdocs/core/lib/accounting.lib.php b/htdocs/core/lib/accounting.lib.php index 7b8cc48305e..3dce405cbdb 100644 --- a/htdocs/core/lib/accounting.lib.php +++ b/htdocs/core/lib/accounting.lib.php @@ -169,7 +169,7 @@ function length_accounta($accounta) * Show header of a page used to transfer/dispatch data in accounting * * @param string $nom Name of report - * @param string $variante Link for alternate report + * @param string $variant Link for alternate report * @param string $period Period of report * @param string $periodlink Link to switch period * @param string $description Description @@ -180,7 +180,7 @@ function length_accounta($accounta) * @param string $varlink Add a variable into the address of the page * @return void */ -function journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '') +function journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink = '', $moreparam = array(), $calcmode = '', $varlink = '') { global $langs; @@ -218,14 +218,14 @@ function journalHead($nom, $variante, $period, $periodlink, $description, $build if ($calcmode) { print '<tr>'; print '<td>'.$langs->trans("CalculationMode").'</td>'; - if (!$variante) { + if (!$variant) { print '<td colspan="3">'; } else { print '<td>'; } print $calcmode; - if ($variante) { - print '</td><td colspan="2">'.$variante; + if ($variant) { + print '</td><td colspan="2">'.$variant; } print '</td>'; print '</tr>'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 24d69b93348..b931362a191 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1753,7 +1753,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu if ($const == 'ADHERENT_MAILMAN_URL') { print '. '.$langs->trans("Example").': <a href="#" id="exampleclick1">'.img_down().'</a><br>'; - //print 'http://lists.exampe.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1'; + //print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members?adminpw=%MAILMAN_ADMINPW%&subscribees=%EMAIL%&send_welcome_msg_to_this_batch=1'; print '<div id="example1" class="hidden">'; print 'http://lists.example.com/cgi-bin/mailman/admin/%LISTE%/members/add?subscribees_upload=%EMAIL%&adminpw=%MAILMAN_ADMINPW%&subscribe_or_invite=0&send_welcome_msg_to_this_batch=0&notification_to_list_owner=0'; print '</div>'; diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index a6aa5c979af..2c46a1394b3 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -491,7 +491,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($sourcecompany->tva_intra); } } - // Professionnal Ids + // Professional Ids $reg = array(); if (getDolGlobalString('MAIN_PROFID1_IN_SOURCE_ADDRESS') && !empty($sourcecompany->idprof1)) { $tmp = $outputlangs->transcountrynoentities("ProfId1", $sourcecompany->country_code); @@ -655,7 +655,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t } } - // Professionnal Ids + // Professional Ids if (getDolGlobalString('MAIN_PROFID1_IN_ADDRESS') && !empty($targetcompany->idprof1)) { $tmp = $outputlangs->transcountrynoentities("ProfId1", $targetcompany->country_code); if (preg_match('/\((.+)\)/', $tmp, $reg)) { diff --git a/htdocs/core/lib/report.lib.php b/htdocs/core/lib/report.lib.php index b92963e0f7d..ebf4b39ab98 100644 --- a/htdocs/core/lib/report.lib.php +++ b/htdocs/core/lib/report.lib.php @@ -63,7 +63,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '<table class="border tableforfield centpercent">'."\n"; - $variante = ($periodlink || $exportlink); + $variant = ($periodlink || $exportlink); // Ligne de titre print '<tr>'; @@ -71,7 +71,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '<td>'; print $reportname; print '</td>'; - if ($variante) { + if ($variant) { print '<td></td>'; } print '</tr>'."\n"; @@ -82,7 +82,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '<td width="150">'.$langs->trans("CalculationMode").'</td>'; print '<td>'; print $calcmode; - if ($variante) { + if ($variant) { print '<td></td>'; } print '</td>'; @@ -96,7 +96,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description if ($period) { print $period; } - if ($variante) { + if ($variant) { print '<td class="nowraponall">'.$periodlink.'</td>'; } print '</td>'; @@ -106,7 +106,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '<tr>'; print '<td>'.$langs->trans("ReportDescription").'</td>'; print '<td>'.$description.'</td>'; - if ($variante) { + if ($variant) { print '<td></td>'; } print '</tr>'."\n"; @@ -117,7 +117,7 @@ function report_header($reportname, $notused, $period, $periodlink, $description print '<td>'; print dol_print_date($builddate, 'dayhour'); print '</td>'; - if ($variante) { + if ($variant) { print '<td>'.($exportlink ? $langs->trans("Export").': '.$exportlink : '').'</td>'; } print '</tr>'."\n"; diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index 33fc9caee68..510388802c8 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -399,7 +399,7 @@ class pdf_vinci extends ModelePDFMo $nexY = $tab_top + 5; - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); // Loop on each lines diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 14de46cbd33..4b5f44bad9b 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -473,7 +473,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $height_note = 0; } - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); $nexY = $tab_top + $this->tabTitleHeight; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index fccce3eaf22..db263cf690e 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -472,7 +472,7 @@ class pdf_zenith extends ModelePDFSupplierProposal $height_note = 0; } - // Use new auto collum system + // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); $nexY = $tab_top + $this->tabTitleHeight; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index cc3a31140ee..72c74a3f357 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -299,7 +299,7 @@ if ($action == 'updatelines' && $usercancreate) { } } - // If module stock is enabled and the stock decrease is done on edtion of this page + // If module stock is enabled and the stock decrease is done on edition of this page /* if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index b707fa0ff9c..b0698134d90 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -412,7 +412,7 @@ class ProductFournisseur extends Product $qty = price2num($qty, 'MS'); $unitBuyPrice = price2num($buyprice / $qty, 'MU'); - // We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50. + // We can have a purchase ref that need to buy 100 min for a given price and with a packaging of 50. //$packaging = price2num(((empty($this->packaging) || $this->packaging < $qty) ? $qty : $this->packaging), 'MS'); $packaging = price2num((empty($this->packaging) ? $qty : $this->packaging), 'MS'); diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2be1db14f83..ae11544681e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -3160,7 +3160,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ } $selected = -1; if (!getDolGlobalString('MAIN_USE_TOP_MENU_SEARCH_DROPDOWN')) { - // Select into select2 is awfull on smartphone. TODO Is this still true with select2 v4 ? + // Select with select2 is awful on smartphone. TODO Is this still true with select2 v4 ? if ($conf->browser->layout == 'phone') { $conf->global->MAIN_USE_OLD_SEARCH_FORM = 1; } diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index 30f081abd78..d6e49e154b7 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -1,4 +1,4 @@ -# MYMODULE FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) +# MYMODULE FOR [DOLIBARR ERP & CRM](https://www.dolibarr.org) ## Features @@ -12,7 +12,7 @@ Other external modules are available on [Dolistore.com](https://www.dolistore.co ## Translations -Translations can be completed manually by editing files into directories *langs*. +Translations can be completed manually by editing files in the module directories under `langs`. <!-- This module contains also a sample configuration for Transifex, under the hidden directory [.tx](.tx), so it is possible to manage translation using this service. @@ -25,27 +25,27 @@ There is a [Transifex project](https://transifex.com/projects/p/dolibarr-module- ## Installation -Prerequisites: You must have the Dolibarr ERP CRM software installed. You can down it from [Dolistore.org](https://www.dolibarr.org). -You can also get a ready to use instance in the cloud from htts://saas.dolibarr.org +Prerequisites: You must have Dolibarr ERP & CRM software installed. You can download it from [Dolistore.org](https://www.dolibarr.org). +You can also get a ready-to-use instance in the cloud from https://saas.dolibarr.org ### From the ZIP file and GUI interface -If the module is a ready to deploy zip file, so with a name module_xxx-version.zip (like when downloading it from a market place like [Dolistore](https://www.dolistore.com)), -go into menu ```Home - Setup - Modules - Deploy external module``` and upload the zip file. +If the module is a ready-to-deploy zip file, so with a name `module_xxx-version.zip` (e.g., when downloading it from a marketplace like [Dolistore](https://www.dolistore.com)), +go to menu `Home> Setup> Modules> Deploy external module` and upload the zip file. -Note: If this screen tell you that there is no "custom" directory, check that your setup is correct: +Note: If this screen tells you that there is no "custom" directory, check that your setup is correct: <!-- -- In your Dolibarr installation directory, edit the ```htdocs/conf/conf.php``` file and check that following lines are not commented: +- In your Dolibarr installation directory, edit the `htdocs/conf/conf.php` file and check that following lines are not commented: ```php //$dolibarr_main_url_root_alt ... //$dolibarr_main_document_root_alt ... ``` -- Uncomment them if necessary (delete the leading ```//```) and assign a sensible value according to your Dolibarr installation +- Uncomment them if necessary (delete the leading `//`) and assign the proper value according to your Dolibarr installation For example : @@ -66,9 +66,9 @@ Note: If this screen tell you that there is no "custom" directory, check that yo ### From a GIT repository -Clone the repository in ```$dolibarr_main_document_root_alt/mymodule``` +Clone the repository in `$dolibarr_main_document_root_alt/mymodule` -```sh +```shell cd ....../custom git clone git@github.com:gitlogin/mymodule.git mymodule ``` @@ -77,10 +77,10 @@ git clone git@github.com:gitlogin/mymodule.git mymodule ### Final steps -From your browser: +Using your browser: - Log into Dolibarr as a super-administrator - - Go to "Setup" -> "Modules" + - Go to "Setup"> "Modules" - You should now be able to find and enable the module @@ -93,4 +93,4 @@ GPLv3 or (at your option) any later version. See file COPYING for more informati ### Documentation -All texts and readmes are licensed under GFDL. +All texts and readme's are licensed under [GFDL](https://www.gnu.org/licenses/fdl-1.3.en.html). diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index cac5d5c05ee..01a1c8a8b41 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -372,7 +372,7 @@ class Productbatch extends CommonObject } /** - * Find first detail record that match eather eat-by or sell-by or batch within given warehouse + * Find first detailed record that match either eat-by, sell-by or batch within the warehouse * * @param int $fk_product_stock id product_stock for object * @param integer $eatby eat-by date for object - deprecated: a search must be done on batch number diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 735e09feead..84437ca0b05 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -302,7 +302,7 @@ if (empty($reshook)) { if (empty($packaging)) { $packaging = 1; } - /* We can have a puchase ref that need to buy 100 min for a given price and with a packaging of 50. + /* We can have a purchase ref that need to buy 100 min for a given price and with a packaging of 50. if ($packaging < $quantity) { $packaging = $quantity; }*/ diff --git a/htdocs/public/emailing/mailing-unsubscribe.php b/htdocs/public/emailing/mailing-unsubscribe.php index 06bd5db19f2..7987a082144 100644 --- a/htdocs/public/emailing/mailing-unsubscribe.php +++ b/htdocs/public/emailing/mailing-unsubscribe.php @@ -23,7 +23,7 @@ /** * \file public/emailing/mailing-unsubscribe.php * \ingroup mailing - * \brief Script use to update unsubcribe status of an email + * \brief Script use to update unsubscribe status of an email * https://myserver/public/emailing/mailing-unsubscribe.php?unsuscrib=1&securitykey=securitykey&tag=abcdefghijklmn */ diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 9e62d69cf6d..ca589c68981 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -467,7 +467,7 @@ if ($event->type == 'payout.created') { } if (!$error && isModEnabled('banque')) { - // Search again the payment to see if it is already linked to a bank payment record (We should always find the payement now we have created before). + // Search again the payment to see if it is already linked to a bank payment record (We should always find the payment that was created before). $ispaymentdone = 0; $sql = "SELECT p.rowid, p.fk_bank FROM llx_paiement as p"; $sql .= " WHERE p.ext_payment_id = '".$db->escape($paiement->ext_payment_id)."'"; diff --git a/htdocs/reception/dispatch.php b/htdocs/reception/dispatch.php index fdd5135eb75..aa3bd9991fc 100644 --- a/htdocs/reception/dispatch.php +++ b/htdocs/reception/dispatch.php @@ -205,7 +205,7 @@ if ($action == 'updatelines' && $permissiontoreceive) { $error++; } - // If module stock is enabled and the stock decrease is done on edtion of this page + // If module stock is enabled and the stock decrease is done on edition of this page /* if (!$error && GETPOST($ent, 'int') > 0 && isModEnabled('stock') && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER)) { $mouv = new MouvementStock($db); diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index e91845038f4..7d07f7edcf1 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -4513,7 +4513,7 @@ tr.liste_titre th, tr.liste_titre td, th.liste_titre { border-bottom: 1px solid #aaa; } -/* TODO Once title line is moved under title search, make border bottom of all th black and force to whit when it's first tr */ +/* TODO Once the title line is moved under title search, make th border bottoms black and force to white when it's the first tr */ tr:first-child th.liste_titre, tr:first-child th.liste_titre_sel { border-bottom: 1px solid #FFF ! important; } From 2b2f540992e4e41712c38a8d59fa5dc461936cb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 5 Feb 2024 14:32:00 +0100 Subject: [PATCH 75/90] Fix doc --- htdocs/core/class/html.formexpensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formexpensereport.class.php b/htdocs/core/class/html.formexpensereport.class.php index a94e076a3ba..2f6faab8363 100644 --- a/htdocs/core/class/html.formexpensereport.class.php +++ b/htdocs/core/class/html.formexpensereport.class.php @@ -51,7 +51,7 @@ class FormExpenseReport /** * Return the combobox for the different statuses of an expense report - * The list values are the ids for the table c_expensereport_statuts + * The list values are the ids from the labelStatus. * * @param int $selected preselect status * @param string $htmlname Name of HTML select From 1747a2ff36f4e6bf819c865b6fc716640b2fbeba Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO <aspangaro.dolibarr@gmail.com> Date: Mon, 5 Feb 2024 14:43:21 +0100 Subject: [PATCH 76/90] NEW Various payment - Use list of account when edit (#27992) * NEW Various payment - Use list of account when edit * Fix PHPStan 8.2 undefined variable * Update CSMSFile.class.php * Move to getDolGlobalString --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> --- htdocs/compta/bank/various_payment/card.php | 19 +++++-- .../core/class/html.formaccounting.class.php | 50 +++++++++++++++++-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index b1c89d62edc..62f51afd595 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -1,5 +1,5 @@ <?php -/* Copyright (C) 2017-2021 Alexandre Spangaro <aspangaro@open-dsi.fr> +/* Copyright (C) 2017-2024 Alexandre Spangaro <aspangaro@easya.solutions> * Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com> @@ -649,10 +649,11 @@ if ($id) { $editvalue = ''; if (isModEnabled('accounting')) { print '<tr><td class="nowrap">'; - print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0); print '</td><td>'; - if ($action == 'editaccountancy_code') { - print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + if ($action == 'editaccountancy_code' && (!$alreadyaccounted && $permissiontoadd)) { + //print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0); + print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code, 'accountancy_code', 0, 1, '', 1); } else { $accountingaccount = new AccountingAccount($db); $accountingaccount->fetch('', $object->accountancy_code, 1); @@ -672,7 +673,15 @@ if ($id) { print '<tr><td class="nowrap">'; print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0); print '</td><td>'; - print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0, null, '', 1, 'lengthAccounta'); + if ($action == 'editsubledger_account' && (!$alreadyaccounted && $permissiontoadd)) { + if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) { + print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->subledger_account, 'subledger_account', 1, 1, '', 1); + } else { + print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0, null, '', 1, 'lengthAccounta'); + } + } else { + print length_accounta($object->subledger_account); + } print '</td></tr>'; $bankaccountnotfound = 0; diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index a2448501e7d..7687677b073 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -1,9 +1,9 @@ <?php -/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> - * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> - * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> - * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> - * Copyright (C) 2016-2020 Alexandre Spangaro <aspangaro@open-dsi.fr> +/* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro> + * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com> + * Copyright (C) 2015 Ari Elbaz (elarifr) <github@accedinfo.com> + * Copyright (C) 2016 Marcos García <marcosgdf@gmail.com> + * Copyright (C) 2016-2024 Alexandre Spangaro <aspangaro@easya.solutions> * * 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 @@ -592,4 +592,44 @@ class FormAccounting extends Form return $out_array; } } + + /** + * Output html select to select accounting account + * + * @param string $page Page + * @param string $selected Id preselected + * @param string $htmlname Name of HTML select object + * @param int $option option (0: aggregate by general account or 1: aggregate by subaccount) + * @param int $useempty Show empty value in list + * @param string $filter optional filters criteria + * @param int $nooutput No print output. Return it only. + * @return void|string + */ + public function formAccountingAccount($page, $selected = '', $htmlname = 'none', $option = 0, $useempty = 1, $filter = '', $nooutput = 0) + { + global $langs; + + $out = ''; + if ($htmlname != "none") { + $out .= '<form method="post" action="' . $page . '">'; + $out .= '<input type="hidden" name="action" value="set'.$htmlname.'">'; + $out .= '<input type="hidden" name="token" value="' . newToken() . '">'; + if ($option == 0) { + $out .= $this->select_account($selected, $htmlname, $useempty, '', 1, 1, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'accounts', $filter); + } else { + $out .= $this->select_auxaccount($selected, $htmlname, $useempty, 'minwidth100 maxwidth300 maxwidthonsmartphone', 'subaccounts'); + } + $out .= '<input type="submit" class="button smallpaddingimp valignmiddle" name="modify" value="' . $langs->trans("Modify") . '">'; + //$out .= '<input type="submit" class="button smallpaddingimp valignmiddle button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">'; + $out .= '</form>'; + } else { + $out .= " "; + } + + if ($nooutput) { + return $out; + } else { + print $out; + } + } } From 411df8f216249e43763d5e5359279627594f8df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:44:03 +0100 Subject: [PATCH 77/90] order tables by relname for pgsql (#28020) --- htdocs/admin/system/database-tables.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/database-tables.php b/htdocs/admin/system/database-tables.php index d368e14d6e5..e122150571b 100644 --- a/htdocs/admin/system/database-tables.php +++ b/htdocs/admin/system/database-tables.php @@ -195,7 +195,7 @@ if (!$base) { print "</tr>\n"; $sql = "SELECT relname, seq_tup_read, idx_tup_fetch, n_tup_ins, n_tup_upd, n_tup_del"; - $sql .= " FROM pg_stat_user_tables"; + $sql .= " FROM pg_stat_user_tables ORDER BY relname"; $resql = $db->query($sql); if ($resql) { From a8034b226fa426e1a902edf3f7b66c5e16d244b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Mon, 5 Feb 2024 18:51:06 +0100 Subject: [PATCH 78/90] Better message --- htdocs/admin/fckeditor.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 92a235fc178..71105f078b5 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -126,16 +126,19 @@ if (GETPOST('save', 'alpha')) { $error++; } } else { - $error++; + $error = -1; // -1 means a warning message } - if (!$error) { + if ($error == 0) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } elseif ($error == -1) { + setEventMessages($langs->trans("EmptyMessageNotAllowedError"), null, 'warnings'); } else { setEventMessages($langs->trans("Error").' '.$db->lasterror(), null, 'errors'); } } + /* * View */ From 0970b23580a773f6bbb2389755ee29a79c4fbb5c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 6 Feb 2024 09:44:22 +0100 Subject: [PATCH 79/90] Add missing fields in merge of thirdparty --- htdocs/install/mysql/tables/llx_societe.sql | 8 ++++---- htdocs/societe/class/societe.class.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 639874b6231..111f4d8753c 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -43,13 +43,13 @@ create table llx_societe address varchar(255), -- company address zip varchar(25), -- zipcode town varchar(50), -- town - fk_departement integer DEFAULT 0, -- - fk_pays integer DEFAULT 0, -- + fk_departement integer DEFAULT 0, -- state + fk_pays integer DEFAULT 0, -- country fk_account integer DEFAULT 0, -- default bank account phone varchar(20), -- phone number fax varchar(20), -- fax number - url varchar(255), -- - email varchar(128), -- + url varchar(255), -- web site + email varchar(128), -- main email socialnetworks text DEFAULT NULL, -- json with socialnetworks diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 64eb928edf8..80793ce7d32 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5321,9 +5321,9 @@ class Societe extends CommonObject 'address', 'zip', 'town', 'state_id', 'country_id', 'phone', 'fax', 'email', 'socialnetworks', 'url', 'barcode', 'idprof1', 'idprof2', 'idprof3', 'idprof4', 'idprof5', 'idprof6', 'tva_intra', 'effectif_id', 'forme_juridique', 'remise_percent', 'remise_supplier_percent', 'mode_reglement_supplier_id', 'cond_reglement_supplier_id', 'name_bis', - 'stcomm_id', 'outstanding_limit', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', + 'stcomm_id', 'outstanding_limit', 'order_min_amount', 'supplier_order_min_amount', 'price_level', 'parent', 'default_lang', 'ref', 'ref_ext', 'import_key', 'fk_incoterms', 'fk_multicurrency', 'code_client', 'code_fournisseur', 'code_compta', 'code_compta_fournisseur', - 'model_pdf', + 'model_pdf', 'webservices_url', 'webservices_key', 'accountancy_code_sell', 'accountancy_code_buy' ); foreach ($listofproperties as $property) { if (empty($this->$property)) { From 3030cddaa1791b70fea3e403ab3db3916d3ee899 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Tue, 6 Feb 2024 17:05:52 +0100 Subject: [PATCH 80/90] Debug v19 selection of ticket printer per terminal --- htdocs/admin/receiptprinter.php | 4 ++-- htdocs/takepos/admin/appearance.php | 2 -- htdocs/takepos/admin/bar.php | 3 --- htdocs/takepos/admin/setup.php | 4 ++-- htdocs/takepos/index.php | 6 ++++-- htdocs/takepos/invoice.php | 13 ++++++++----- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 1305f812c76..2c7f58be336 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -392,11 +392,11 @@ if ($mode == 'config' && $user->admin) { print img_picto($langs->trans("Delete"), 'delete', 'class="paddingright"'); print '</a>'; // test icon - print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">'; + print '<a class="marginrightonly nowraponall" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">'; print img_picto($langs->trans("TestPrinterDesc"), 'printer', 'class="paddingright paddingleft"').'TXT'; print '</a>'; // test icon - print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter2&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">'; + print '<a class="marginrightonly nowraponall" href="'.$_SERVER['PHP_SELF'].'?mode=config&action=testprinter2&token='.newToken().'&printerid='.$printer->listprinters[$line]['rowid'].'&printername='.urlencode($printer->listprinters[$line]['name']).'">'; print img_picto($langs->trans("TestPrinterDesc2"), 'printer', 'class="paddingright paddingleft"').'IMG'; print '</a>'; print '</td>'; diff --git a/htdocs/takepos/admin/appearance.php b/htdocs/takepos/admin/appearance.php index 3f58d23146b..2871f0ecf1e 100644 --- a/htdocs/takepos/admin/appearance.php +++ b/htdocs/takepos/admin/appearance.php @@ -63,8 +63,6 @@ if (GETPOST('action', 'alpha') == 'set') { $db->rollback(); setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif (GETPOST('action', 'alpha') == 'setmethod') { - dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity); } diff --git a/htdocs/takepos/admin/bar.php b/htdocs/takepos/admin/bar.php index 0c8f41fb237..4c822640e6a 100644 --- a/htdocs/takepos/admin/bar.php +++ b/htdocs/takepos/admin/bar.php @@ -126,13 +126,11 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) { print '<td>'.$langs->trans("Parameters").'</td><td class="">'.$langs->trans("Value").'</td>'; print "</tr>\n"; - //if (getDolGlobalString('TAKEPOS_PRINT_METHOD') != "browser") { // Why this ? print '<tr class="oddeven value"><td>'; print $langs->trans("OrderPrinters").' (<a href="'.DOL_URL_ROOT.'/takepos/admin/orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>)'; print '</td>'; print '<td class="">'; print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0); - //print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1); print '</td></tr>'; if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) { @@ -141,7 +139,6 @@ if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) { print '</td>'; print '<td class="">'; print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0); - //print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1); print '</td></tr>'; } /*else { diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index e049a2e7b60..453d0115797 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -281,7 +281,7 @@ if (isModEnabled("service")) { print '<tr class="oddeven"><td>'; print $form->textwithpicto($langs->trans("RootCategoryForProductsToSell"), $langs->trans("RootCategoryForProductsToSellDesc")); print '<td>'; -print img_object('', 'category', 'class="paddingright"').$form->select_all_categories(Categorie::TYPE_PRODUCT, getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'), 'TAKEPOS_ROOT_CATEGORY_ID', 64, 0, 0, 0, 'widthcentpercentminusx'); +print img_object('', 'category', 'class="paddingright"').$form->select_all_categories(Categorie::TYPE_PRODUCT, getDolGlobalInt('TAKEPOS_ROOT_CATEGORY_ID'), 'TAKEPOS_ROOT_CATEGORY_ID', 64, 0, 0, 0, 'maxwidth500 widthcentpercentminusx'); print ajax_combobox('TAKEPOS_ROOT_CATEGORY_ID'); print "</td></tr>\n"; @@ -361,7 +361,7 @@ if (is_array($formmail->lines_model)) { } //var_dump($arraydefaultmessage); //var_dump($arrayofmessagename); -print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE, 'None', 1, 0, '', 0, 0, 0, '', '', 1); +print $form->selectarray('TAKEPOS_EMAIL_TEMPLATE_INVOICE', $arrayofmessagename, getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE'), 'None', 1, 0, '', 0, 0, 0, '', 'maxwidth500 widthcentpercentminusx', 1); print "</td></tr>\n"; // Control cash box at opening pos diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 59a667f5e90..1caaa2d6630 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -96,6 +96,8 @@ if ($conf->browser->layout == 'phone') { $MAXCATEG = (!getDolGlobalString('TAKEPOS_NB_MAXCATEG') ? $maxcategbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXCATEG); $MAXPRODUCT = (!getDolGlobalString('TAKEPOS_NB_MAXPRODUCT') ? $maxproductbydefaultforthisdevice : $conf->global->TAKEPOS_NB_MAXPRODUCT); +$term = empty($_SESSION['takeposterminal']) ? 1: $_SESSION['takeposterminal']; + /* $constforcompanyid = 'CASHDESK_ID_THIRDPARTY'.$_SESSION["takeposterminal"]; $soc = new Societe($db); @@ -1340,7 +1342,7 @@ if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { } else { $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);'); } - } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { + } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);'); } else { $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);'); @@ -1357,7 +1359,7 @@ if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT')) { if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { $menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action'=>'OpenDrawer();'); } -if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { +if (getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0 || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { $menus[$r++] = array( 'title' => '<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("DOL_OPEN_DRAWER").'</div>', 'action' => 'DolibarrOpenDrawer();', diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 17b22e4e750..444fc728796 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -157,6 +157,8 @@ if (isModEnabled('multicurrency') && !empty($_SESSION["takeposcustomercurrency"] } } +$term = empty($_SESSION["takeposterminal"]) ? 1 : $_SESSION["takeposterminal"]; + /* * Actions @@ -926,7 +928,7 @@ if (empty($reshook)) { if ($action == "order" && $placeid != 0 && ($user->hasRight('takepos', 'run') || defined('INCLUDE_PHONEPAGE_FROM_PUBLIC_PAGE'))) { include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { + if ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") { require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php'; $printer = new dolReceiptPrinter($db); } @@ -971,7 +973,7 @@ if (empty($reshook)) { $order_receipt_printer1 .= '</td></tr>'; } } - if ((getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { + if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 1; echo "<script>"; @@ -1003,7 +1005,7 @@ if (empty($reshook)) { $order_receipt_printer2 .= '</td></tr>'; } } - if ((getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { + if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 2; echo "<script>"; @@ -1035,7 +1037,7 @@ if (empty($reshook)) { $order_receipt_printer3 .= '</td></tr>'; } } - if ((getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { + if (((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") && $linestoprint > 0) { $invoice->fetch($placeid); //Reload object before send to printer $printer->orderprinter = 3; echo "<script>"; @@ -1063,6 +1065,7 @@ if (empty($reshook)) { $sectionwithinvoicelink .= $langs->trans('BillShortStatusValidated'); } } + $sectionwithinvoicelink .= '</span><br>'; if (getDolGlobalInt('TAKEPOS_PRINT_INVOICE_DOC_INSTEAD_OF_RECEIPT')) { $sectionwithinvoicelink .= ' <a target="_blank" class="button" href="' . DOL_URL_ROOT . '/document.php?token=' . newToken() . '&modulepart=facture&file=' . $invoice->ref . '/' . $invoice->ref . '.pdf">Invoice</a>'; @@ -1072,7 +1075,7 @@ if (empty($reshook)) { } else { $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="TakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>'; } - } elseif (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { + } elseif ((isModEnabled('receiptprinter') && getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$term) > 0) || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") { $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.')">'.$langs->trans('PrintTicket').'</button>'; } else { $sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.')">'.$langs->trans('PrintTicket').'</button>'; From f2774906ba3fb5e31132670bbe30b997bd16fec0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 7 Feb 2024 10:17:22 +0100 Subject: [PATCH 81/90] Use constant --- htdocs/comm/mailing/card.php | 37 +++++++++++++++----------- htdocs/societe/class/societe.class.php | 17 +++++++++--- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 323cb20e90d..dcd98d1605b 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -988,9 +988,9 @@ if ($action == 'create') { // From print '<tr><td class="titlefield">'; - print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + print $form->editfieldkey("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string'); print '</td><td>'; - print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + print $form->editfieldval("MailFrom", 'email_from', $object->email_from, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string'); $email = CMailFile::getValidAddress($object->email_from, 2); if ($email && !isValidEmail($email)) { $langs->load("errors"); @@ -1005,9 +1005,9 @@ if ($action == 'create') { // Errors to if ($object->messtype != 'sms') { print '<tr><td>'; - print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + print $form->editfieldkey("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string'); print '</td><td>'; - print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < 3, 'string'); + print $form->editfieldval("MailErrorsTo", 'email_errorsto', $object->email_errorsto, $object, $user->hasRight('mailing', 'creer') && $object->status < $object::STATUS_SENTCOMPLETELY, 'string'); $email = CMailFile::getValidAddress($object->email_errorsto, 2); if ($email && !isValidEmail($email)) { $langs->load("errors"); @@ -1055,19 +1055,24 @@ if ($action == 'create') { print '<tr><td>'; print $langs->trans("MAIN_MAIL_SENDMODE"); print '</td><td>'; - if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') { - $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')]; - } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) { - $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')]; - } else { - $text = $listofmethods['mail']; - } - print $text; - if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') { - if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') { - print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING').')</span>'; + if ($object->messtype != 'sms') { + if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') && getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') { + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING')]; + } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE')) { + $text = $listofmethods[getDolGlobalString('MAIN_MAIL_SENDMODE')]; + } else { + $text = $listofmethods['mail']; } - } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) { + print $text; + if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'default') { + if (getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING') != 'mail') { + print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER_EMAILING').')</span>'; + } + } elseif (getDolGlobalString('MAIN_MAIL_SENDMODE') != 'mail' && getDolGlobalString('MAIN_MAIL_SMTP_SERVER')) { + print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>'; + } + } else { + print 'SMS '; print ' <span class="opacitymedium">('.getDolGlobalString('MAIN_MAIL_SMTP_SERVER').')</span>'; } print '</td></tr>'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 80793ce7d32..a36088f41f5 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5388,9 +5388,8 @@ class Societe extends CommonObject if (!$error) { $objects = array( 'Adherent' => '/adherents/class/adherent.class.php', - 'Don' => array('file' => '/don/class/don.class.php', 'enabled' => isModEnabled('don')), 'Societe' => '/societe/class/societe.class.php', - //'Categorie' => '/categories/class/categorie.class.php', + //'Categorie' => '/categories/class/categorie.class.php', // Already processed previously 'ActionComm' => '/comm/action/class/actioncomm.class.php', 'Propal' => '/comm/propal/class/propal.class.php', 'Commande' => '/commande/class/commande.class.php', @@ -5401,7 +5400,6 @@ class Societe extends CommonObject 'Contact' => '/contact/class/contact.class.php', 'Contrat' => '/contrat/class/contrat.class.php', 'Expedition' => '/expedition/class/expedition.class.php', - 'Fichinter' => '/fichinter/class/fichinter.class.php', 'CommandeFournisseur' => '/fourn/class/fournisseur.commande.class.php', 'FactureFournisseur' => '/fourn/class/fournisseur.facture.class.php', 'FactureFournisseurRec' => '/fourn/class/fournisseur.facture-rec.class.php', @@ -5411,11 +5409,22 @@ class Societe extends CommonObject 'Delivery' => '/delivery/class/delivery.class.php', 'Product' => '/product/class/product.class.php', 'Project' => '/projet/class/project.class.php', - 'Ticket' => array('file' => '/ticket/class/ticket.class.php', 'enabled' => isModEnabled('ticket')), 'User' => '/user/class/user.class.php', 'Account' => '/compta/bank/class/account.class.php', 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php' ); + if ($this->db->DDLListTables($this->db->database_name, 'don')) { + $objects['Don'] = '/don/class/don.class.php'; + } + if ($this->db->DDLListTables($this->db->database_name, 'partnership')) { + $objects['PartnerShip'] = '/partnership/class/partnership.class.php'; + } + if ($this->db->DDLListTables($this->db->database_name, 'fichinter')) { + $objects['Fichinter'] = '/fichinter/class/fichinter.class.php'; + } + if ($this->db->DDLListTables($this->db->database_name, 'ticket')) { + $objects['Ticket'] = '/ticket/class/ticket.class.php'; + } //First, all core objects must update their tables foreach ($objects as $object_name => $object_file) { From d4e8c6bf9a91c3d06052747eab027e937b5db63c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Wed, 7 Feb 2024 11:55:02 +0100 Subject: [PATCH 82/90] NEW: Adding a recipient on emails sent, change status to sent partialy. --- htdocs/comm/mailing/cibles.php | 16 ++++++++++++++-- htdocs/core/class/commonobject.class.php | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index f2c2643c2bc..4dac837e45b 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -129,6 +129,11 @@ if ($action == 'add' && $user->hasRight('mailing', 'creer')) { // Add recipient } } if ($result > 0) { + // If status of emailing is sent completely, change to to send partially + if ($object->status == $object::STATUS_SENTCOMPLETELY) { + $object->setStatut($object::STATUS_SENTPARTIALY); + } + setEventMessages($langs->trans("XTargetsAdded", $result), null, 'mesgs'); $action = ''; } @@ -400,7 +405,14 @@ if ($object->fetch($id) >= 0) { print '<br>'; + $newcardbutton = ''; $allowaddtarget = ($object->status == $object::STATUS_DRAFT); + if (GETPOST('allowaddtarget')) { + $allowaddtarget = 1; + } + if (!$allowaddtarget) { + $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?id='.$object->id.'&allowaddtarget=1', '', $user->hasRight('mailing', 'creer')); + } // Show email selectors if ($allowaddtarget && $user->hasRight('mailing', 'creer')) { @@ -658,14 +670,14 @@ if ($object->fetch($id) >= 0) { print '<input type="hidden" name="page_y" value="">'; $morehtmlcenter = ''; - if ($allowaddtarget) { + if ($object->status == $object::STATUS_DRAFT) { $morehtmlcenter = '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'</a>'; } $morehtmlcenter .= '   <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=exportcsv&token='.newToken().'&exportcsv=1&id='.$object->id.'">'.img_picto('', 'download', 'class="pictofixedwidth"').$langs->trans("Download").'</a>'; $massactionbutton = ''; - print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 0, 0, 1); + print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit, 0, 0, 1); print '</form>'; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bc2ce54bc6f..b96df8f998b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4519,7 +4519,7 @@ abstract class CommonObject */ public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '', $fieldstatus = 'fk_statut') { - global $user, $langs, $conf; + global $user; $savElementId = $elementId; // To be used later to know if we were using the method using the id of this or not. From ac5f5a7cc5bb22e2ee892e6d78231f9bf4a4f3cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:19:07 +0100 Subject: [PATCH 83/90] fix travis (#28052) * fix travis * Update partnership.class.php --- htdocs/partnership/class/partnership.class.php | 15 +++++++++++++++ htdocs/societe/class/societe.class.php | 10 +++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 793cf118b64..0849f9ffc2b 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1061,6 +1061,21 @@ class Partnership extends CommonObject return $result; } + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty($db, $origin_id, $dest_id) + { + $tables = array('partnership'); + + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } + /** * Return the label of the status * diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a36088f41f5..d4d105b6d0e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -5301,7 +5301,7 @@ class Societe extends CommonObject */ public function mergeCompany($soc_origin_id) { - global $langs, $hookmanager, $user, $action; + global $conf, $langs, $hookmanager, $user, $action; $error = 0; $soc_origin = new Societe($this->db); // The thirdparty that we will delete @@ -5413,16 +5413,16 @@ class Societe extends CommonObject 'Account' => '/compta/bank/class/account.class.php', 'ConferenceOrBoothAttendee' => '/eventorganization/class/conferenceorboothattendee.class.php' ); - if ($this->db->DDLListTables($this->db->database_name, 'don')) { + if ($this->db->DDLListTables($conf->db->name, $this->db->prefix().'don')) { $objects['Don'] = '/don/class/don.class.php'; } - if ($this->db->DDLListTables($this->db->database_name, 'partnership')) { + if ($this->db->DDLListTables($conf->db->name, $this->db->prefix().'partnership')) { $objects['PartnerShip'] = '/partnership/class/partnership.class.php'; } - if ($this->db->DDLListTables($this->db->database_name, 'fichinter')) { + if ($this->db->DDLListTables($conf->db->name, $this->db->prefix().'fichinter')) { $objects['Fichinter'] = '/fichinter/class/fichinter.class.php'; } - if ($this->db->DDLListTables($this->db->database_name, 'ticket')) { + if ($this->db->DDLListTables($conf->db->name, $this->db->prefix().'ticket')) { $objects['Ticket'] = '/ticket/class/ticket.class.php'; } From 21036377d91ce870cbf277210a225bd79364a1b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:21:00 +0100 Subject: [PATCH 84/90] fix php doc (#28047) --- htdocs/core/modules/stock/doc/pdf_standard.modules.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index da930624da1..faac4839682 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -682,7 +682,7 @@ class pdf_standard extends ModelePDFStock * Show top header of page. * * @param TCPDF $pdf Object PDF - * @param Object $object Object to show + * @param Entrepot $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param string $titlekey Translation key to show as title of document @@ -697,12 +697,6 @@ class pdf_standard extends ModelePDFStock $default_font_size = pdf_getPDFFontSize($outputlangs); - if ($object->type == 1) { - $titlekey = 'ServiceSheet'; - } else { - $titlekey = 'StockSheet'; - } - pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); // Show Draft Watermark From 07dc47ff40833a411092b98467ee12956692cee6 Mon Sep 17 00:00:00 2001 From: sonikf <93765174+sonikf@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:24:33 +0200 Subject: [PATCH 85/90] fix undefined array key (#28048) --- htdocs/compta/recap-compta.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 5540b87c34d..2dda35eb209 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -247,6 +247,9 @@ if ($id > 0) { $balance = 0; foreach ($TData as &$data1) { $balance += $data1['amount']; + if (!isset($data1['balance'])) { + $data1['balance'] = 0; + } $data1['balance'] += $balance; } From 44d406ecc56dcb1f31f4c1db94493e019cf72494 Mon Sep 17 00:00:00 2001 From: Ikarus <44511582+LeKarSol@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:25:13 -0500 Subject: [PATCH 86/90] Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) --- htdocs/install/mysql/data/llx_10_c_regions.sql | 6 ++++++ .../mysql/data/llx_20_c_departements.sql | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/htdocs/install/mysql/data/llx_10_c_regions.sql b/htdocs/install/mysql/data/llx_10_c_regions.sql index 3a08a73fa6f..a88d05e2ff8 100644 --- a/htdocs/install/mysql/data/llx_10_c_regions.sql +++ b/htdocs/install/mysql/data/llx_10_c_regions.sql @@ -558,3 +558,9 @@ INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 2 INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23208, '', 0, 'Nor-Oriental'); INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 232, 23209, '', 0, 'Zuliana'); +-- Cuba Regions (id_country=77) +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7700, '', 0, 'Cuba'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7701, '', 0, 'Occidente'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7702, '', 0, 'Centro'); +INSERT INTO llx_c_regions (fk_pays, code_region, cheflieu, tncc, nom) values ( 77, 7703, '', 0, 'Occidente'); + diff --git a/htdocs/install/mysql/data/llx_20_c_departements.sql b/htdocs/install/mysql/data/llx_20_c_departements.sql index 59127065612..14f0ab419e2 100644 --- a/htdocs/install/mysql/data/llx_20_c_departements.sql +++ b/htdocs/install/mysql/data/llx_20_c_departements.sql @@ -2041,3 +2041,21 @@ INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-78 INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-79',22105,'Kilis'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-80',22104,'Osmaniye'); INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('TR-81',22106,'Düzce'); + +-- Provinces Cuba (id country=77) +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-PRI', 7701, 'Pinar del Rio'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-ART', 7701, 'Artemisa'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-HAB', 7701, 'La Habana'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-MYB', 7701, 'Mayabeque'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-MTZ', 7701, 'Matanzas'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-IJV', 7701, 'Isla de la Juventud'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-VLC', 7702, 'Villa Calra'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CFG', 7702, 'Cienfuegos'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-SSP', 7702, 'Sancti Spiritus'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CAV', 7702, 'Ciego de Avila'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-CMG', 7702, 'Camagüey'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-LTU', 7703, 'Las Tunas'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-GRM', 7703, 'Granma'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-SCU', 7703, 'Santiago de Cuba'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-GTM', 7703, 'Guantanamo'); +INSERT INTO llx_c_departements (code_departement, fk_region, nom) VALUES ('CU-HLG', 7703, 'Holguin'); From b04776cd1bdea9140b8b48d02848bfe59891b12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:26:32 +0100 Subject: [PATCH 87/90] Find the typo (#28050) * Find the typo * clean code --- .../modules/propale/doc/pdf_azur.modules.php | 2 +- .../modules/propale/doc/pdf_cyan.modules.php | 2 +- .../class/propalmergepdfproduct.class.php | 44 +++++++++++++++---- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index f9f40168f75..e2257e7dff0 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -760,7 +760,7 @@ class pdf_azur extends ModelePDFPropales $already_merged = array(); foreach ($object->lines as $line) { if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) { - // Find the desire PDF + // Find the desired PDF $filetomerge = new Propalmergepdfproduct($this->db); if (getDolGlobalInt('MAIN_MULTILANGS')) { diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 29c317bb131..a770ae1819f 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -873,7 +873,7 @@ class pdf_cyan extends ModelePDFPropales $already_merged = array(); foreach ($object->lines as $line) { if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) { - // Find the desire PDF + // Find the desired PDF $filetomerge = new Propalmergepdfproduct($this->db); if (getDolGlobalInt('MAIN_MULTILANGS')) { diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php index bc6491955fc..b691e6d6316 100644 --- a/htdocs/product/class/propalmergepdfproduct.class.php +++ b/htdocs/product/class/propalmergepdfproduct.class.php @@ -41,19 +41,39 @@ class Propalmergepdfproduct extends CommonObject */ public $table_element = 'propal_merge_pdf_product'; + /** + * @var int Id of product + */ public $fk_product; + + /** + * @var string Filename + */ public $file_name; + + /** + * @var int Id user + */ public $fk_user_author; + + /** + * @var int Id user + */ public $fk_user_mod; public $datec = ''; public $tms = ''; + + /** + * @var string lang code + */ public $lang; + /** + * @var PropalmergepdfproductLine[] + */ public $lines = array(); - - /** * Constructor * @@ -80,16 +100,16 @@ class Propalmergepdfproduct extends CommonObject // Clean parameters if (isset($this->fk_product)) { - $this->fk_product = trim($this->fk_product); + $this->fk_product = (int) $this->fk_product; } if (isset($this->file_name)) { $this->file_name = trim($this->file_name); } if (isset($this->fk_user_author)) { - $this->fk_user_author = trim($this->fk_user_author); + $this->fk_user_author = (int) $this->fk_user_author; } if (isset($this->fk_user_mod)) { - $this->fk_user_mod = trim($this->fk_user_mod); + $this->fk_user_mod = (int) $this->fk_user_mod; } if (isset($this->lang)) { $this->lang = trim($this->lang); @@ -99,7 +119,6 @@ class Propalmergepdfproduct extends CommonObject } - // Check parameters // Put here code to add control on parameters values @@ -535,10 +554,10 @@ class Propalmergepdfproduct extends CommonObject { $this->id = 0; - $this->fk_product = ''; + $this->fk_product = 0; $this->file_name = ''; - $this->fk_user_author = ''; - $this->fk_user_mod = ''; + $this->fk_user_author = 0; + $this->fk_user_mod = 0; $this->datec = ''; $this->tms = ''; $this->import_key = ''; @@ -560,7 +579,14 @@ class PropalmergepdfproductLine */ public $fk_product; + /** + * @var string Filename + */ public $file_name; + + /** + * @var string Code lang + */ public $lang; /** From fef5023ae039d19f8640a545bf1ce0c715dd904c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= <frederic34@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:26:58 +0100 Subject: [PATCH 88/90] add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch --- htdocs/install/mysql/migration/19.0.0-20.0.0.sql | 1 + htdocs/install/mysql/tables/llx_product.sql | 2 +- htdocs/product/class/product.class.php | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql index 3d5f8152277..0d551e98e17 100644 --- a/htdocs/install/mysql/migration/19.0.0-20.0.0.sql +++ b/htdocs/install/mysql/migration/19.0.0-20.0.0.sql @@ -219,3 +219,4 @@ ALTER TABLE llx_mailing ADD COLUMN messtype varchar(16) DEFAULT 'email' after ro ALTER TABLE llx_ticket ADD COLUMN model_pdf varchar(255); ALTER TABLE llx_ticket ADD COLUMN last_main_doc varchar(255); ALTER TABLE llx_ticket ADD COLUMN extraparams varchar(255); +ALTER TABLE llx_product ADD COLUMN last_main_doc varchar(255); diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 0dd84d550f5..ad7160f2dab 100644 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -108,7 +108,7 @@ create table llx_product price_autogen tinyint DEFAULT 0, fk_project integer DEFAULT NULL, -- Used when product was generated by a project or is specific to a project mandatory_period tinyint DEFAULT 0, -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action) - + last_main_doc varchar(255), fk_default_bom integer DEFAULT NULL, fk_default_workstation integer DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index a6252829e28..03df322f95f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -594,6 +594,7 @@ class Product extends CommonObject 'localtax1_type' => array('type'=>'varchar(10)', 'label'=>'Localtax1type', 'enabled'=>'1', 'position'=>155, 'notnull'=>1, 'visible'=>-1,), 'localtax2_tx' => array('type'=>'double(6,3)', 'label'=>'Localtax2tx', 'enabled'=>'1', 'position'=>160, 'notnull'=>0, 'visible'=>-1,), 'localtax2_type' => array('type'=>'varchar(10)', 'label'=>'Localtax2type', 'enabled'=>'1', 'position'=>165, 'notnull'=>1, 'visible'=>-1,), + 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>1, 'visible'=>-1, 'position'=>170), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), @@ -2538,7 +2539,7 @@ class Product extends CommonObject $sql = "SELECT p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note as note_private, p.customcode, p.fk_country, p.fk_state, p.lifetime, p.qc_frequency, p.price, p.price_ttc,"; $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.fk_default_workstation, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; - $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; + $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units, p.last_main_doc,"; $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished, p.fk_default_bom, p.mandatory_period,"; if (!getDolGlobalString('MAIN_PRODUCT_PERENTITY_SHARED')) { $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; @@ -2714,6 +2715,7 @@ class Product extends CommonObject $this->fk_unit = $obj->fk_unit; $this->price_autogen = $obj->price_autogen; $this->model_pdf = $obj->model_pdf; + $this->last_main_doc = $obj->last_main_doc; $this->mandatory_period = $obj->mandatory_period; From 7db64c5bcc08d3bc3149df0db021386da6ba110d Mon Sep 17 00:00:00 2001 From: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Date: Wed, 7 Feb 2024 16:29:24 +0100 Subject: [PATCH 89/90] NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 --- htdocs/comm/action/index.php | 17 +++++++++-- htdocs/comm/action/list.php | 16 ++++++++++- htdocs/comm/action/peruser.php | 14 ++++++++- htdocs/core/lib/agenda.lib.php | 52 +++++++++++++++++++++------------- 4 files changed, 76 insertions(+), 23 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ad681813b42..cbf37aae56d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -58,6 +58,7 @@ $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); $showbirthday = empty($conf->use_javascript_ajax) ? GETPOST("showbirthday", "int") : 1; +$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; // If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user. if (empty($filtert) && !getDolGlobalString('AGENDA_ALL_CALENDARS')) { @@ -419,6 +420,9 @@ $param .= "&maxprint=".urlencode($maxprint); if ($mode == 'show_day' || $mode == 'show_week' || $mode == 'show_month') { $param .= '&mode='.urlencode($mode); } +if ($search_categ_cus != 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); +} // Show navigation bar $nav = ''; @@ -843,11 +847,20 @@ if ($filtert > 0 || $usergroup > 0) { } $sql .= ")"; } + +// Search in categories, -1 is all and -2 is no categories +if ($search_categ_cus != -1) { + if ($search_categ_cus == -2) { + $sql .= " AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)"; + } elseif ($search_categ_cus > 0) { + $sql .= " AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".$db->sanitize($search_categ_cus)."))"; + } +} + // Sort on date $sql .= ' ORDER BY datep'; //print $sql; - dol_syslog("comm/action/index.php", LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -1495,7 +1508,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month $newparam .= '&viewcal=1'; print '<div class="liste_titre liste_titre_bydiv centpercent">'; - print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); + print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid, $search_categ_cus); print '</div>'; print '<div class="div-table-responsive-no-min sectioncalendarbymonth maxscreenheightless300">'; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 301216c6567..55cb92d71f3 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -96,6 +96,7 @@ $filter = GETPOST("search_filter", 'alpha', 3) ? GETPOST("search_filter", 'alpha $filtert = GETPOST("search_filtert", "int", 3) ? GETPOST("search_filtert", "int", 3) : GETPOST("filtert", "int", 3); $usergroup = GETPOST("search_usergroup", "int", 3) ? GETPOST("search_usergroup", "int", 3) : GETPOST("usergroup", "int", 3); $showbirthday = empty($conf->use_javascript_ajax) ? (GETPOST("search_showbirthday", "int") ? GETPOST("search_showbirthday", "int") : GETPOST("showbirthday", "int")) : 1; +$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ActionComm($db); @@ -388,6 +389,10 @@ if (GETPOST('dateend_dtendyear', 'int')) { if ($optioncss != '') { $param .= '&optioncss='.urlencode($optioncss); } +if ($search_categ_cus != 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); +} + // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -569,6 +574,15 @@ if ($dateend_dtend > 0) { $sql .= " AND a.datep2 <= '".$db->idate($dateend_dtend)."'"; } +// Search in categories, -1 is all and -2 is no categories +if ($search_categ_cus != -1) { + if ($search_categ_cus == -2) { + $sql .= " AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)"; + } elseif ($search_categ_cus > 0) { + $sql .= " AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".$db->sanitize($search_categ_cus)."))"; + } +} + // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -737,7 +751,7 @@ if ($massactionbutton) { $i = 0; print '<div class="liste_titre liste_titre_bydiv centpercent">'; -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid, $search_categ_cus); print '</div>'; print '<div class="div-table-responsive">'; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 1e480c79a14..90f2735998b 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -107,6 +107,7 @@ $status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GET $type = GETPOSTISSET("search_type") ? GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ? GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$search_categ_cus = GETPOST("search_categ_cus", "int", 3) ? GETPOST("search_categ_cus", "int", 3) : 0; // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array:aZ09')) { $actioncode = GETPOST('search_actioncode', 'array:aZ09', 3); @@ -322,6 +323,9 @@ if ($begin_d != '') { if ($end_d != '') { $param .= '&end_d='.urlencode($end_d); } +if ($search_categ_cus != 0) { + $param .= '&search_categ_cus='.urlencode($search_categ_cus); +} $param .= "&maxprint=".urlencode($maxprint); $paramnoactionodate = $param; @@ -513,7 +517,7 @@ $s = $newtitle; print $s; print '<div class="liste_titre liste_titre_bydiv centpercent">'; -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid, $search_categ_cus); print '</div>'; @@ -650,6 +654,14 @@ if ($status == 'done' || $status == '100') { if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; } +// Search in categories, -1 is all and -2 is no categories +if ($search_categ_cus != -1) { + if ($search_categ_cus == -2) { + $sql .= " AND NOT EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id)"; + } elseif ($search_categ_cus > 0) { + $sql .= " AND EXISTS (SELECT ca.fk_actioncomm FROM ".MAIN_DB_PREFIX."categorie_actioncomm as ca WHERE ca.fk_actioncomm = a.id AND ca.fk_categorie IN (".$db->sanitize($search_categ_cus)."))"; + } +} // Sort on date $sql .= $db->order("fk_user_action, datep"); //print $sql; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 1ed670a12bb..ff07283664d 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -28,24 +28,25 @@ /** * Show filter form in agenda view * - * @param Form $form Form object - * @param int $canedit Can edit filter fields - * @param int $status Status - * @param int $year Year - * @param int $month Month - * @param int $day Day - * @param int $showbirthday Show birthday - * @param string $filtera Filter on create by user - * @param string $filtert Filter on assigned to user - * @param string $filtered Filter of done by user - * @param int $pid Product id - * @param int $socid Third party id - * @param string $action Action string - * @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend - * @param string|array $actioncode Preselected value(s) of actioncode for filter on event type - * @param int $usergroupid Id of group to filter on users - * @param string $excludetype A type to exclude ('systemauto', 'system', '') - * @param int $resourceid Preselected value of resource for filter on resource + * @param Form $form Form object + * @param int $canedit Can edit filter fields + * @param int $status Status + * @param int $year Year + * @param int $month Month + * @param int $day Day + * @param int $showbirthday Show birthday + * @param string $filtera Filter on create by user + * @param string $filtert Filter on assigned to user + * @param string $filtered Filter of done by user + * @param int $pid Product id + * @param int $socid Third party id + * @param string $action Action string + * @param array $showextcals Array with list of external calendars (used to show links to select calendar), or -1 to show no legend + * @param string|array $actioncode Preselected value(s) of actioncode for filter on event type + * @param int $usergroupid Id of group to filter on users + * @param string $excludetype A type to exclude ('systemauto', 'system', '') + * @param int $resourceid Preselected value of resource for filter on resource + * @param array $search_categ_cus Tag id * @return void */ function print_actions_filter( @@ -66,7 +67,8 @@ function print_actions_filter( $actioncode = '', $usergroupid = 0, $excludetype = '', - $resourceid = 0 + $resourceid = 0, + $search_categ_cus = 0 ) { global $user, $langs, $db, $hookmanager; global $massaction; @@ -139,6 +141,18 @@ function print_actions_filter( print '</div>'; } + if (isModEnabled('categorie') && $user->hasRight('categorie', 'lire')) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($db); + $langs->load('categories'); + + print '<div class="divsearchfield">'; + print img_picto($langs->trans('Categories'), 'category', 'class="pictofixedwidth"'); + print $formother->select_categories('actioncomm', $search_categ_cus, 'search_categ_cus', 1, $langs->trans('ActionCommCategoriesArea')); + print '</div>'; + } + if ($canedit && !preg_match('/list/', $_SERVER["PHP_SELF"])) { // Status print '<div class="divsearchfield">'; From 2a28248dd4e9202d7cadfc9e91de35d29ab16173 Mon Sep 17 00:00:00 2001 From: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:26:17 +0100 Subject: [PATCH 90/90] Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit --- htdocs/core/class/cunits.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 85d0ce1f4a6..80d3a440958 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -103,14 +103,14 @@ class CUnits extends CommonDict $sql .= "code,"; $sql .= "label,"; $sql .= "short_label,"; - $sql .= "unit_type"; + $sql .= "unit_type,"; $sql .= "scale"; $sql .= ") VALUES ("; $sql .= " ".(!isset($this->id) ? 'NULL' : "'".$this->db->escape($this->id)."'").","; $sql .= " ".(!isset($this->code) ? 'NULL' : "'".$this->db->escape($this->code)."'").","; $sql .= " ".(!isset($this->label) ? 'NULL' : "'".$this->db->escape($this->label)."'").","; $sql .= " ".(!isset($this->short_label) ? 'NULL' : "'".$this->db->escape($this->short_label)."'").","; - $sql .= " ".(!isset($this->unit_type) ? 'NULL' : "'".$this->db->escape($this->unit_type)."'"); + $sql .= " ".(!isset($this->unit_type) ? 'NULL' : "'".$this->db->escape($this->unit_type)."'").","; $sql .= " ".(!isset($this->scale) ? 'NULL' : "'".$this->db->escape($this->scale)."'"); $sql .= ")";