FIX module for emailing target selection must use a condition on module

This commit is contained in:
Laurent Destailleur 2022-05-28 20:42:29 +02:00
parent 2c9c55bc75
commit f6ad688ddd
9 changed files with 25 additions and 5 deletions

View File

@ -135,7 +135,7 @@ if (GETPOST('exportcsv', 'int')) {
$sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut as status, mc.date_envoi, mc.tms,";
$sql .= " mc.source_id, mc.source_type, mc.error_text";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
$sql .= " WHERE mc.fk_mailing=".((int) $object->id);
$sql .= " WHERE mc.fk_mailing = ".((int) $object->id);
$sql .= $db->order($sortfield, $sortorder);
$resql = $db->query($sql);
@ -365,17 +365,19 @@ if ($object->fetch($id) >= 0) {
$obj = new $classname($db);
// Check if qualified
$qualified = (is_null($obj->enabled) ? 1 : dol_eval($obj->enabled, 1));
// Check dependencies
$qualified = (isset($obj->enabled) ? $obj->enabled : 1);
foreach ($obj->require_module as $key) {
if (!$conf->$key->enabled || (!$user->admin && $obj->require_admin)) {
if (empty($conf->$key->enabled) || (empty($user->admin) && $obj->require_admin)) {
$qualified = 0;
//print "Les prerequis d'activation du module mailing ne sont pas respectes. Il ne sera pas actif";
break;
}
}
// Si le module mailing est qualifie
// If module is qualified
if ($qualified) {
$var = !$var;

View File

@ -42,6 +42,8 @@ class mailing_advthirdparties extends MailingTargets
*/
public $db;
public $enabled = '$conf->societe->enabled';
/**
* Constructor

View File

@ -38,6 +38,8 @@ class mailing_contacts1 extends MailingTargets
public $require_module = array("societe"); // Module mailing actif si modules require_module actifs
public $require_admin = 0; // Module mailing actif pour user admin ou non
public $enabled = '$conf->societe->enabled';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -41,6 +41,8 @@ class mailing_fraise extends MailingTargets
public $require_module = array('adherent');
public $enabled = '$conf->adherent->enabled';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -36,6 +36,11 @@ class MailingTargets // This can't be abstract as it is used for some method
*/
public $db;
/**
* @var string Condition to be enabled
*/
public $enabled;
/**
* @var string Error code (or message)
*/

View File

@ -41,6 +41,8 @@ class mailing_partnership extends MailingTargets
*/
public $db;
public $enabled = '$conf->partnership->enabled';
/**
* Constructor

View File

@ -31,6 +31,8 @@ class mailing_thirdparties extends MailingTargets
public $require_module = array("societe"); // This module allows to select by categories must be also enabled if category module is not activated
public $enabled = '$conf->societe->enabled';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -29,6 +29,8 @@ class mailing_thirdparties_services_expired extends MailingTargets
public $require_module = array('contrat');
public $enabled = '$conf->societe->enabled';
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/

View File

@ -24,7 +24,8 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets
// CHANGE THIS: Set to 1 if selector is available for admin users only
public $require_admin = 0;
public $enabled = 0;
public $enabled = '$conf->mymodule->enabled';
public $require_module = array();
/**