From 3a5fe5063d4d2514d5c6acccb0b673cb71b5773f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 May 2022 16:19:00 +0200 Subject: [PATCH] Debug v16 --- htdocs/adherents/partnership.php | 17 ++++++++++++----- htdocs/core/actions_massactions.inc.php | 6 +++--- htdocs/core/lib/company.lib.php | 2 +- htdocs/core/modules/modPartnership.class.php | 3 +-- htdocs/core/tpl/card_presend.tpl.php | 2 +- htdocs/core/tpl/massactions_pre.tpl.php | 2 +- htdocs/partnership/admin/setup.php | 6 +++--- htdocs/partnership/class/partnership.class.php | 2 +- .../class/partnershiputils.class.php | 4 ++-- htdocs/partnership/partnership_card.php | 2 +- htdocs/partnership/partnership_list.php | 2 +- htdocs/public/partnership/new.php | 4 ++-- htdocs/societe/partnership.php | 6 +++--- 13 files changed, 32 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/partnership.php b/htdocs/adherents/partnership.php index 160a037c187..a01e7d28ed2 100644 --- a/htdocs/adherents/partnership.php +++ b/htdocs/adherents/partnership.php @@ -85,11 +85,18 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if ($conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'member') accessforbidden(); -if (empty($conf->partnership->enabled)) accessforbidden(); -if (empty($permissiontoread)) accessforbidden(); -if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); - +if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') != 'member') { + accessforbidden('Partnership module is not activated for members'); +} +if (empty($conf->partnership->enabled)) { + accessforbidden(); +} +if (empty($permissiontoread)) { + accessforbidden(); +} +if ($action == 'edit' && empty($permissiontoadd)) { + accessforbidden(); +} if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT) { accessforbidden(); } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 383684b377a..b94655fbc14 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -90,7 +90,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdparty = new User($db); } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdparty = new Adherent($db); } if ($objecttmp->element == 'holiday') { @@ -110,7 +110,7 @@ if (!$error && $massaction == 'confirm_presend') { if ($objecttmp->element == 'expensereport') { $thirdpartyid = $objecttmp->fk_user_author; } - if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $thirdpartyid = $objecttmp->fk_member; } if ($objecttmp->element == 'holiday') { @@ -264,7 +264,7 @@ if (!$error && $massaction == 'confirm_presend') { $fuser = new User($db); $fuser->fetch($objectobj->fk_user_author); $sendto = $fuser->email; - } elseif ($objectobj->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif ($objectobj->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objectobj->fk_member); $sendto = $fadherent->email; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 197a6c95687..4938d20c3c4 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -263,7 +263,7 @@ function societe_prepare_head(Societe $object) $h++; } - if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'thirdparty') { + if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') { if (!empty($user->rights->partnership->read)) { $langs->load("partnership"); $nbPartnership = is_array($object->partnerships) ? count($object->partnerships) : 0; diff --git a/htdocs/core/modules/modPartnership.class.php b/htdocs/core/modules/modPartnership.class.php index 8ebbd3029b7..13877c7418f 100644 --- a/htdocs/core/modules/modPartnership.class.php +++ b/htdocs/core/modules/modPartnership.class.php @@ -177,8 +177,7 @@ class modPartnership extends DolibarrModules // Array to add new pages in new tabs $this->tabs = array(); - $tabtoadd = (!empty(getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR')) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') ? 'member' : 'thirdparty'; - + $tabtoadd = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); if ($tabtoadd == 'member') { $fk_mainmenu = "members"; } else { diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index 83f96c1bcb1..0c744e165d3 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -152,7 +152,7 @@ if ($action == 'presend') { $fuser = new User($db); $fuser->fetch($object->fk_user_author); $liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">"; - } elseif ($object->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif ($object->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($object->fk_member); $liste['member'] = $fadherent->getFullName($outputlangs)." <".$fadherent->email.">"; diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 207dc1b7265..678bf219bef 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -131,7 +131,7 @@ if ($massaction == 'presend') { $fuser = new User($db); $fuser->fetch($thirdpartyid); $liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">"; - } elseif ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $fadherent = new Adherent($db); $fadherent->fetch($objecttmp->fk_member); $liste['member'] = $fadherent->getFullName($langs)." <".$fadherent->email.">"; diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 100dc7027a3..a398a6860b1 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -124,8 +124,8 @@ print ''; print ''.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").''; print ''; print ''; print ajax_combobox('select_PARTNERSHIP_IS_MANAGED_FOR'); print ''; @@ -133,7 +133,7 @@ print ''.$langs->trans("partnershipforthirdparty print ''; -//if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { +//if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; print ''; $dnbdays = '30'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 7d7d6a65d14..030cbf09e79 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -199,7 +199,7 @@ class Partnership extends CommonObject $this->db = $db; - if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { $this->fields['fk_member'] = array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'member', 'csslist'=>'tdoverflowmax150'); } else { $this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'company', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150'); diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index ef4f7cfdeb4..9ad2e5b7ca2 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -64,7 +64,7 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); if ($managedfor != 'member') { return 0; // If option 'PARTNERSHIP_IS_MANAGED_FOR' = 'thirdparty', this cron job does nothing. @@ -219,7 +219,7 @@ class PartnershipUtils { global $conf, $langs, $user; - $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; + $managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR'); $partnership = new Partnership($this->db); $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index c83a83e6357..9752651ef29 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -79,7 +79,7 @@ $permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd & $permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; +$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); if (empty($conf->partnership->enabled)) accessforbidden(); if (empty($permissiontoread)) accessforbidden(); diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index 42d4354516e..014d576f5d6 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -74,7 +74,7 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -$managedfor = empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) ? 'thirdparty' : $conf->global->PARTNERSHIP_IS_MANAGED_FOR; +$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty'); if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php index fe57f4ea424..d7ee25613a8 100644 --- a/htdocs/public/partnership/new.php +++ b/htdocs/public/partnership/new.php @@ -204,9 +204,9 @@ if (empty($reshook) && $action == 'add') { $partnership = new Partnership($db); // We try to find the thirdparty or the member - if (empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) || $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'thirdparty') { + if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') { $partnership->fk_member = 0; - } elseif ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { + } elseif (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') { $partnership->fk_soc = 0; } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 2ce4884932e..05079d263a9 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -52,7 +52,7 @@ if (!empty($user->socid)) { $socid = $user->socid; } -if (empty($id) && $socid && (empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) || $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'thirdparty')) { +if (empty($id) && $socid && (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty')) { $id = $socid; } @@ -94,8 +94,8 @@ $usercanclose = $user->rights->partnership->write; // Used by the include of act $upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'thirdparty') { - accessforbidden(); +if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') != 'thirdparty') { + accessforbidden('Partnership is not activated for thirdparties'); } if (empty($conf->partnership->enabled)) { accessforbidden();