diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
index a749ff269e5..c768b019d69 100644
--- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php
+++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php
@@ -182,7 +182,7 @@ abstract class ActionsAdherentCardCommon
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
- $result = $this->object->delete();
+ $result = $this->object->delete(0, $user, 0);
if ($result > 0)
{
header("Location: list.php");
@@ -424,7 +424,7 @@ abstract class ActionsAdherentCardCommon
if ($resql)
{
$obj = $this->db->fetch_object($resql);
-
+
$this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
}
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index 81aa2c7c6ad..fe3bd4f4cfd 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -585,7 +585,7 @@ if (empty($reshook))
if ($user->rights->adherent->supprimer && $action == 'confirm_delete' && $confirm == 'yes')
{
- $result=$object->delete($id);
+ $result=$object->delete($id, $user);
if ($result > 0)
{
if (! empty($backtopage))
diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php
index 20f5fa671c9..18e144c363c 100644
--- a/htdocs/adherents/class/adherent.class.php
+++ b/htdocs/adherents/class/adherent.class.php
@@ -705,11 +705,13 @@ class Adherent extends CommonObject
* Fonction qui supprime l'adherent et les donnees associees
*
* @param int $rowid Id of member to delete
+ * @param User $user User object
+ * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int <0 if KO, 0=nothing to do, >0 if OK
*/
- function delete($rowid)
+ function delete($rowid, $user, $notrigger=0)
{
- global $conf, $langs, $user;
+ global $conf, $langs;
$result = 0;
$error=0;
@@ -720,6 +722,14 @@ class Adherent extends CommonObject
$this->db->begin();
+ if (! $error && ! $notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('MEMBER_DELETE',$user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
+
// Remove category
$sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".$rowid;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
@@ -787,16 +797,6 @@ class Adherent extends CommonObject
}
}
- if (! $error)
- {
- // Call trigger
- $result=$this->call_trigger('MEMBER_DELETE',$user);
- if ($result < 0) { $error++; }
- // End call triggers
- }
-
-
-
if (! $error)
{
$this->db->commit();
@@ -1592,7 +1592,7 @@ class Adherent extends CommonObject
global $conf, $langs;
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) && $withpictoimg) $withpictoimg=0;
-
+
$result=''; $label='';
$link=''; $linkstart=''; $linkend='';
@@ -1602,7 +1602,7 @@ class Adherent extends CommonObject
$label.= Form::showphoto('memberphoto', $this, 80, 0, 0, 'photowithmargin photologintooltip', 'small', 0, 1);
$label.= '
';
}
-
+
$label.= '';
$label.= '' . $langs->trans("Member") . '';
if (! empty($this->ref))
@@ -1610,7 +1610,7 @@ class Adherent extends CommonObject
if (! empty($this->firstname) || ! empty($this->lastname))
$label.= '
' . $langs->trans('Name') . ': ' . $this->getFullName($langs);
$label.='
';
-
+
if ($option == 'card' || $option == 'category')
{
$link = '';
$linkend='';
-
+
//if ($withpictoimg == -1) $result.='';
$result.=$link;
if ($withpictoimg)
@@ -1658,7 +1658,7 @@ class Adherent extends CommonObject
}
$result.=$linkend;
//if ($withpictoimg == -1) $result.='
';
-
+
return $result;
}
@@ -1883,7 +1883,7 @@ class Adherent extends CommonObject
$modele = $conf->global->ADHERENT_ADDON_PDF;
}
}
-
+
$modelpath = "core/modules/member/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php
index 3defcabd059..4d13b6347ec 100644
--- a/htdocs/adherents/class/api_members.class.php
+++ b/htdocs/adherents/class/api_members.class.php
@@ -250,11 +250,7 @@ class Members extends DolibarrApi
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
- // The Adherent::delete() method uses the global variable $user.
- global $user;
- $user = DolibarrApiAccess::$user;
-
- if (! $member->delete($member->id)) {
+ if (! $member->delete($member->id, DolibarrApiAccess::$user)) {
throw new RestException(401,'error when deleting member');
}
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 06de3e09f95..949d55020c8 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -31,13 +31,17 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-$langs->load("members");
-$langs->load("companies");
+$langs->loadLangs(array("members","companies"));
+
+$action=GETPOST('action','aZ09');
+$massaction=GETPOST('massaction','alpha');
+$show_files=GETPOST('show_files','int');
+$confirm=GETPOST('confirm','alpha');
+$toselect = GETPOST('toselect', 'array');
// Security check
$result=restrictedArea($user,'adherent');
-$action=GETPOST('action','aZ09');
$filter=GETPOST("filter");
$statut=GETPOST("statut");
$search=GETPOST("search");
@@ -53,7 +57,7 @@ $search_country=GETPOST("search_country");
$search_phone=GETPOST("search_phone");
$search_phone_perso=GETPOST("search_phone_perso");
$search_phone_mobile=GETPOST("search_phone_mobile");
-$type=GETPOST("type");
+$search_type=GETPOST("search_type");
$search_email=GETPOST("search_email");
$search_categ = GETPOST("search_categ",'int');
$catid = GETPOST("catid",'int');
@@ -155,7 +159,7 @@ if (empty($reshook))
$search_firstname="";
$search_login="";
$search_company="";
- $type="";
+ $search_type="";
$search_email="";
$search_address="";
$search_zip="";
@@ -173,6 +177,14 @@ if (empty($reshook))
$toselect='';
$search_array_options=array();
}
+
+ // Mass actions
+ $objectclass='Adherent';
+ $objectlabel='Members';
+ $permtoread = $user->rights->adherent->lire;
+ $permtodelete = $user->rights->adherent->supprimer;
+ $uploaddir = $conf->adherent->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -193,8 +205,8 @@ $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.skype, d.birth, d.pu
$sql.= " d.fk_adherent_type as type_id, d.morphy, d.statut, d.datec as date_creation, d.tms as date_update,";
$sql.= " t.libelle as type, t.subscription,";
$sql.= " state.code_departement as state_code, state.nom as state_name";
-// Add fields for extrafields
-foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key;
+// Add fields from extrafields
+foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
$parameters=array();
$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
@@ -212,7 +224,7 @@ if ($search_categ > 0) $sql.= " AND cm.fk_categorie = ".$db->escape($search_ca
if ($search_categ == -2) $sql.= " AND cm.fk_categorie IS NULL";
$sql.= " AND d.entity IN (".getEntity('adherent').")";
if ($sall) $sql.=natural_search(array_keys($fieldstosearchall), $sall);
-if ($type > 0) $sql.=" AND t.rowid=".$db->escape($type);
+if ($search_type > 0) $sql.=" AND t.rowid=".$db->escape($search_type);
if ($statut != '') $sql.=" AND d.statut in (".$db->escape($statut).")"; // Peut valoir un nombre ou liste de nombre separes par virgules
if ($search_ref)
{
@@ -298,10 +310,10 @@ elseif ($action == 'search')
$titre=$langs->trans("MembersListQualified");
}
-if ($type > 0)
+if ($search_type > 0)
{
$membertype=new AdherentType($db);
- $result=$membertype->fetch(GETPOST("type"));
+ $result=$membertype->fetch(GETPOST("type",'int'));
$titre.=" (".$membertype->libelle.")";
}
@@ -326,7 +338,7 @@ if ($search_phone != '') $param.= "&search_phone=".urlencode($search_phone);
if ($search_phone_perso != '') $param.= "&search_phone_perso=".urlencode($search_phone_perso);
if ($search_phone_mobile != '') $param.= "&search_phone_mobile=".urlencode($search_phone_mobile);
if ($filter) $param.="&filter=".urlencode($filter);
-if ($type > 0) $param.="&type=".urlencode($type);
+if ($search_type > 0) $param.="&search_type=".urlencode($search_type);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
// Add $param from extra fields
foreach ($search_array_options as $key => $val)
@@ -346,7 +358,7 @@ if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->tr
//if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
-print '