From 4c06384197dc8d47b836c2b8daaa6abead75948b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 11:13:14 +0100 Subject: [PATCH 1/5] Fix: differentiate sharing of "member" and "member_type" --- htdocs/adherents/class/adherent_type.class.php | 3 ++- htdocs/adherents/class/api_memberstypes.class.php | 2 +- htdocs/adherents/index.php | 2 +- htdocs/adherents/type.php | 2 +- htdocs/core/boxes/box_members.php | 2 +- htdocs/core/modules/mailings/fraise.modules.php | 2 +- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/societe/societecontact.php | 3 ++- 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5e9cbb07ca5..c352f5dc944 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -35,6 +35,7 @@ class AdherentType extends CommonObject public $table_element = 'adherent_type'; public $element = 'adherent_type'; public $picto = 'group'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * @var string @@ -307,7 +308,7 @@ class AdherentType extends CommonObject $sql = "SELECT rowid, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type"; - $sql.= " WHERE entity IN (".getEntity('adherent').")"; + $sql.= " WHERE entity IN (".getEntity('member_type').")"; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 26d3d115f75..f2dfba0367a 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -97,7 +97,7 @@ class MembersTypes extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= ' WHERE t.entity IN ('.getEntity('adherent').')'; + $sql.= ' WHERE t.entity IN ('.getEntity('member_type').')'; // Add sql filters if ($sqlfilters) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index a04b1df5786..fd418756bd6 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -65,7 +65,7 @@ $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d"; $sql.= " ON t.rowid = d.fk_adherent_type"; $sql.= " AND d.entity IN (".getEntity('adherent').")"; -$sql.= " WHERE t.entity IN (".getEntity('adherent').")"; +$sql.= " WHERE t.entity IN (".getEntity('member_type').")"; $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut"; dol_syslog("index.php::select nb of members by type", LOG_DEBUG); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index cc9fd872062..885e5a01251 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -216,7 +216,7 @@ if (! $rowid && $action != 'create' && $action != 'edit') $sql = "SELECT d.rowid, d.libelle as label, d.subscription, d.vote"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; - $sql.= " WHERE d.entity IN (".getEntity('adherent').")"; + $sql.= " WHERE d.entity IN (".getEntity('member_type').")"; $result = $db->query($sql); if ($result) diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 25fa257d098..e5819f0f14c 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -88,7 +88,7 @@ class box_members extends ModeleBoxes $sql.= " a.datec, a.tms, a.statut as status, a.datefin as date_end_subscription,"; $sql.= " t.subscription"; $sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as t"; - $sql.= " WHERE a.entity = ".$conf->entity; + $sql.= " WHERE a.entity IN (".getEntity('member').")"; $sql.= " AND a.fk_adherent_type = t.rowid"; $sql.= " ORDER BY a.tms DESC"; $sql.= $db->plimit($max, 0); diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index a1674d6ab08..f71b6b925f0 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -127,7 +127,7 @@ class mailing_fraise extends MailingTargets $s.=''; From 3859b5a92662c6fe3de5f31e06d36c050dcd9d15 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 14:20:53 +0100 Subject: [PATCH 3/5] Fix: Parameter must be an array or an object that implements Countable --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index b08993acf8a..fae976dec80 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -46,7 +46,7 @@ if (! empty($massaction) && count($toselect) < 1) $error++; setEventMessages($langs->trans("NoRecordSelected"), null, "warnings"); } -if (! $error && count($toselect) > $maxformassaction) +if (! $error && is_array($toselect) && count($toselect) > $maxformassaction) { setEventMessages($langs->trans('TooManyRecordForMassAction',$maxformassaction), null, 'errors'); $error++; From b2162492147f26443e051f84d477ae4d6526e6f6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 24 Feb 2018 15:01:29 +0100 Subject: [PATCH 4/5] Fix: missing hook parameters --- htdocs/adherents/list.php | 2 +- htdocs/comm/propal/list.php | 2 +- htdocs/commande/list.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/fourn/commande/list.php | 2 +- htdocs/fourn/facture/list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/supplier_proposal/list.php | 2 +- htdocs/user/index.php | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index a01cc379b3c..fc30d6f1ae2 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -574,7 +574,7 @@ if (! empty($arrayfields['d.datefin']['checked'])) print_liste_field_titr include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['d.datec']['checked'])) print_liste_field_titre($arrayfields['d.datec']['label'],$_SERVER["PHP_SELF"],"d.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index af67bd8107b..2903cee2a88 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -614,7 +614,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 13225c2c5d3..29590820b72 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -701,7 +701,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['c.datec']['checked'])) print_liste_field_titre($arrayfields['c.datec']['label'],$_SERVER["PHP_SELF"],"c.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index fe26efd490e..8d3f8971ef4 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -862,7 +862,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 0b45f2d63a0..ef5f8816a94 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -914,7 +914,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['cf.datec']['checked'])) print_liste_field_titre($arrayfields['cf.datec']['label'],$_SERVER["PHP_SELF"],"cf.date_creation","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 31d6ba2f183..0876cfc7595 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -762,7 +762,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['f.datec']['checked'])) print_liste_field_titre($arrayfields['f.datec']['label'],$_SERVER["PHP_SELF"],"f.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ebb2c0a421a..178432addbc 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -654,7 +654,7 @@ else // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index abf9f9cfd2a..74ee17affd5 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -599,7 +599,7 @@ if ($resql) // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields); + $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['sp.datec']['checked'])) print_liste_field_titre($arrayfields['sp.datec']['label'],$_SERVER["PHP_SELF"],"sp.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); diff --git a/htdocs/user/index.php b/htdocs/user/index.php index 6f9ac1f638a..b5edbafa89e 100644 --- a/htdocs/user/index.php +++ b/htdocs/user/index.php @@ -406,7 +406,7 @@ if (! empty($arrayfields['u.datepreviouslogin']['checked'])) print_liste_field_t // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"u.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); From 4581d6049cb17b641bbd29eedd98ee76e6e40d8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Feb 2018 12:52:39 +0100 Subject: [PATCH 5/5] Update societecontact.php --- htdocs/societe/societecontact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/societecontact.php b/htdocs/societe/societecontact.php index bac674b4e2b..67a44d87ccf 100644 --- a/htdocs/societe/societecontact.php +++ b/htdocs/societe/societecontact.php @@ -223,7 +223,7 @@ if ($id > 0 || ! empty($ref)) $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.= ", ".MAIN_DB_PREFIX."adherent_type as t"; $sql.= " WHERE d.fk_soc = ".$id; - $sql.= " AND fk_adherent_type = t.rowid"; + $sql.= " AND d.fk_adherent_type = t.rowid"; dol_syslog("get list sql=".$sql); $resql = $db->query($sql);