diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index cc920e3d124..84c1f5954b9 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -72,7 +72,7 @@ $object = new Mailing($db); if ($action == 'add') { - $module=GETPOST("module"); + $module=GETPOST("module",'alpha'); $result=-1; foreach ($modulesdir as $dir) @@ -89,14 +89,10 @@ if ($action == 'add') { require_once $file; - // We fill $filtersarray. Using this variable is now deprecated. Kept for backward compatibility. - $filtersarray=array(); - if (isset($_POST["filter"])) $filtersarray[0]=$_POST["filter"]; - // Add targets into database $obj = new $classname($db); dol_syslog("Call add_to_target on class ".$classname); - $result=$obj->add_to_target($id,$filtersarray); + $result=$obj->add_to_target($id); } } if ($result > 0) diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 7a4d53172f4..588d61faf5e 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -331,10 +331,9 @@ class mailing_contacts1 extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Optional filter data (deprecated) * @return int <0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/core/modules/mailings/example.modules.php b/htdocs/core/modules/mailings/example.modules.php index 0af52dc5bd2..cd0a0ee9d5a 100644 --- a/htdocs/core/modules/mailings/example.modules.php +++ b/htdocs/core/modules/mailings/example.modules.php @@ -61,10 +61,9 @@ class mailing_example extends MailingTargets * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray If you used the formFilter function. Empty otherwise. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable $target = array(); diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 43798799acd..151d828aa61 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -225,17 +225,11 @@ class mailing_fraise extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Param to filter sql request. Deprecated. Should use $_POST instead. * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable - // Deprecation warning - if ($filtersarray) { - dol_syslog(__METHOD__ . ": filtersarray parameter is deprecated", LOG_WARNING); - } - global $langs,$_POST; // Load translation files required by the page diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index b2477c1fd55..91539359d6e 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -151,17 +151,11 @@ class mailing_pomme extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Requete sql de selection des destinataires * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id, $filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable - // Deprecation warning - if ($filtersarray) { - dol_syslog(__METHOD__ . ": filtersarray parameter is deprecated", LOG_WARNING); - } - global $conf, $langs; $langs->load("companies"); diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 49205cf6f80..5465b0af5c3 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -57,10 +57,9 @@ class mailing_thirdparties extends MailingTargets * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray If you used the formFilter function. Empty otherwise. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id, $filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 91bd5127c1f..fc57a364c9d 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -82,26 +82,26 @@ class mailing_thirdparties_services_expired extends MailingTargets * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. - * @param array $filtersarray If you used the formFilter function. Empty otherwise. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable - $target = array(); - - // ----- Your code start here ----- + $key=GETPOST('filter','int'); $cibles = array(); $j = 0; $product=''; - foreach($filtersarray as $key) + if ($key == '0') { - if ($key == '0') return "Error: You must choose a filter"; - $product=$this->arrayofproducts[$key]; + $this->error = "Error: You must choose a filter"; + $this->errors[] = $this->error; + return $this->error; } + $product=$this->arrayofproducts[$key]; + $now=dol_now(); // La requete doit retourner: id, email, name diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 7de27a0c753..a4caef12af8 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -115,10 +115,9 @@ class mailing_xinputfile extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Requete sql de selection des destinataires * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index 2364eeb08ef..bcbf5d9a41b 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -113,10 +113,9 @@ class mailing_xinputuser extends MailingTargets * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing - * @param array $filtersarray Requete sql de selection des destinataires * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index 545e53d350a..460df7e96bf 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -97,14 +97,12 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets * This is the main function that returns the array of emails * * @param int $mailing_id Id of emailing - * @param array $filtersarray Requete sql de selection des destinataires * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id,$filtersarray=array()) + function add_to_target($mailing_id) { // phpcs:enable $target = array(); - $cibles = array(); $j = 0; @@ -114,7 +112,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; $sql.= " ORDER BY email"; - // Stocke destinataires dans cibles + // Stocke destinataires dans target $result=$this->db->query($sql); if ($result) { @@ -129,7 +127,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $obj = $this->db->fetch_object($result); if ($old <> $obj->email) { - $cibles[$j] = array( + $target[$j] = array( 'email' => $obj->email, 'name' => $obj->lastname, 'id' => $obj->id, @@ -162,7 +160,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets // ----- Your code end here ----- - return parent::add_to_target($mailing_id, $cibles); + return parent::add_to_target($mailing_id, $target); }