Remove deprecated parameter

This commit is contained in:
Laurent Destailleur 2018-12-11 10:15:13 +01:00
parent 434cf2e046
commit 5ec9a1ca7f
10 changed files with 21 additions and 44 deletions

View File

@ -72,7 +72,7 @@ $object = new Mailing($db);
if ($action == 'add') if ($action == 'add')
{ {
$module=GETPOST("module"); $module=GETPOST("module",'alpha');
$result=-1; $result=-1;
foreach ($modulesdir as $dir) foreach ($modulesdir as $dir)
@ -89,14 +89,10 @@ if ($action == 'add')
{ {
require_once $file; 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 // Add targets into database
$obj = new $classname($db); $obj = new $classname($db);
dol_syslog("Call add_to_target on class ".$classname); 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) if ($result > 0)

View File

@ -331,10 +331,9 @@ class mailing_contacts1 extends MailingTargets
* Ajoute destinataires dans table des cibles * Ajoute destinataires dans table des cibles
* *
* @param int $mailing_id Id of emailing * @param int $mailing_id Id of emailing
* @param array $filtersarray Optional filter data (deprecated)
* @return int <0 si erreur, nb ajout si ok * @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 // phpcs:enable
global $conf, $langs; global $conf, $langs;

View File

@ -61,10 +61,9 @@ class mailing_example extends MailingTargets
* This is the main function that returns the array of emails * This is the main function that returns the array of emails
* *
* @param int $mailing_id Id of mailing. No need to use it. * @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 * @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 // phpcs:enable
$target = array(); $target = array();

View File

@ -225,17 +225,11 @@ class mailing_fraise extends MailingTargets
* Ajoute destinataires dans table des cibles * Ajoute destinataires dans table des cibles
* *
* @param int $mailing_id Id of emailing * @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 * @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 // phpcs:enable
// Deprecation warning
if ($filtersarray) {
dol_syslog(__METHOD__ . ": filtersarray parameter is deprecated", LOG_WARNING);
}
global $langs,$_POST; global $langs,$_POST;
// Load translation files required by the page // Load translation files required by the page

View File

@ -151,17 +151,11 @@ class mailing_pomme extends MailingTargets
* Ajoute destinataires dans table des cibles * Ajoute destinataires dans table des cibles
* *
* @param int $mailing_id Id of emailing * @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 * @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 // phpcs:enable
// Deprecation warning
if ($filtersarray) {
dol_syslog(__METHOD__ . ": filtersarray parameter is deprecated", LOG_WARNING);
}
global $conf, $langs; global $conf, $langs;
$langs->load("companies"); $langs->load("companies");

View File

@ -57,10 +57,9 @@ class mailing_thirdparties extends MailingTargets
* This is the main function that returns the array of emails * This is the main function that returns the array of emails
* *
* @param int $mailing_id Id of mailing. No need to use it. * @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 * @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 // phpcs:enable
global $conf, $langs; global $conf, $langs;

View File

@ -82,26 +82,26 @@ class mailing_thirdparties_services_expired extends MailingTargets
* This is the main function that returns the array of emails * This is the main function that returns the array of emails
* *
* @param int $mailing_id Id of mailing. No need to use it. * @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 * @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 // phpcs:enable
$target = array(); $key=GETPOST('filter','int');
// ----- Your code start here -----
$cibles = array(); $cibles = array();
$j = 0; $j = 0;
$product=''; $product='';
foreach($filtersarray as $key) if ($key == '0')
{ {
if ($key == '0') return "Error: You must choose a filter"; $this->error = "Error: You must choose a filter";
$product=$this->arrayofproducts[$key]; $this->errors[] = $this->error;
return $this->error;
} }
$product=$this->arrayofproducts[$key];
$now=dol_now(); $now=dol_now();
// La requete doit retourner: id, email, name // La requete doit retourner: id, email, name

View File

@ -115,10 +115,9 @@ class mailing_xinputfile extends MailingTargets
* Ajoute destinataires dans table des cibles * Ajoute destinataires dans table des cibles
* *
* @param int $mailing_id Id of emailing * @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 * @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 // phpcs:enable
global $conf,$langs,$_FILES; global $conf,$langs,$_FILES;

View File

@ -113,10 +113,9 @@ class mailing_xinputuser extends MailingTargets
* Ajoute destinataires dans table des cibles * Ajoute destinataires dans table des cibles
* *
* @param int $mailing_id Id of emailing * @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 * @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 // phpcs:enable
global $conf,$langs,$_FILES; global $conf,$langs,$_FILES;

View File

@ -97,14 +97,12 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
* This is the main function that returns the array of emails * This is the main function that returns the array of emails
* *
* @param int $mailing_id Id of emailing * @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 * @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 // phpcs:enable
$target = array(); $target = array();
$cibles = array();
$j = 0; $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'])."'"; if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'";
$sql.= " ORDER BY email"; $sql.= " ORDER BY email";
// Stocke destinataires dans cibles // Stocke destinataires dans target
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) if ($result)
{ {
@ -129,7 +127,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
if ($old <> $obj->email) if ($old <> $obj->email)
{ {
$cibles[$j] = array( $target[$j] = array(
'email' => $obj->email, 'email' => $obj->email,
'name' => $obj->lastname, 'name' => $obj->lastname,
'id' => $obj->id, 'id' => $obj->id,
@ -162,7 +160,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
// ----- Your code end here ----- // ----- Your code end here -----
return parent::add_to_target($mailing_id, $cibles); return parent::add_to_target($mailing_id, $target);
} }