26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions.lib.php';
71 $langs->load(
"mails");
72 $transstring =
"MailingModuleDesc".$this->name;
75 if ($langs->trans($this->name) != $this->name) {
76 $s = $langs->trans($this->
name);
77 } elseif ($langs->trans($transstring) != $transstring) {
78 $s = $langs->trans($transstring);
83 if ($this->tooltip && is_object(
$form)) {
84 $s .=
' '.$form->textwithpicto(
'', $langs->trans($this->tooltip), 1, 1);
107 $result = $this->
db->query($sql);
109 $obj = $this->
db->fetch_object($result);
112 $this->error = $this->
db->lasterror();
139 $sql =
"SELECT COUNT(*) nb FROM ".MAIN_DB_PREFIX.
"mailing_cibles";
140 $sql .=
" WHERE fk_mailing = ".((int) $mailing_id);
141 $result = $this->
db->query($sql);
143 $obj = $this->
db->fetch_object($result);
146 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing";
147 $sql .=
" SET nbemail = ".$nb.
" WHERE rowid = ".((int) $mailing_id);
148 if (!$this->
db->query($sql)) {
150 $this->error = $this->
db->error();
169 global $dolibarr_main_instance_unique_id;
175 $num = count($cibles);
176 foreach ($cibles as $targetarray) {
177 if (!empty($targetarray[
'email'])) {
178 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"mailing_cibles";
179 $sql .=
" (fk_mailing,";
180 $sql .=
" fk_contact,";
181 $sql .=
" lastname, firstname, email, other, source_url, source_id,";
183 $sql .=
" source_type)";
184 $sql .=
" VALUES (".$mailing_id.
",";
185 $sql .= (empty($targetarray[
'fk_contact']) ?
'0' :
"'".$this->db->escape($targetarray[
'fk_contact']).
"'").
",";
186 $sql .=
"'".$this->db->escape($targetarray[
'lastname']).
"',";
187 $sql .=
"'".$this->db->escape($targetarray[
'firstname']).
"',";
188 $sql .=
"'".$this->db->escape($targetarray[
'email']).
"',";
189 $sql .=
"'".$this->db->escape($targetarray[
'other']).
"',";
190 $sql .=
"'".$this->db->escape($targetarray[
'source_url']).
"',";
191 $sql .= (empty($targetarray[
'source_id']) ?
'null' :
"'".$this->db->escape($targetarray[
'source_id']).
"'").
",";
192 $sql .=
"'".$this->db->escape(
dol_hash($dolibarr_main_instance_unique_id.
";".$targetarray[
'email'].
";".$targetarray[
'lastname'].
";".$mailing_id.
";".$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY,
'md5')).
"',";
193 $sql .=
"'".$this->db->escape($targetarray[
'source_type']).
"')";
195 $result = $this->
db->query($sql);
199 if ($this->
db->errno() !=
'DB_ERROR_RECORD_ALREADY_EXISTS') {
201 dol_syslog($this->
db->error().
' : '.$targetarray[
'email']);
202 $this->error = $this->
db->error().
' : '.$targetarray[
'email'];
203 $this->
db->rollback();
210 dol_syslog(__METHOD__.
": mailing ".$j.
" targets added");
230 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"mailing_cibles";
231 $sql .=
" SET statut=3";
232 $sql .=
" WHERE fk_mailing = ".((int) $mailing_id).
" AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX.
"mailing_unsubscribe AS mu WHERE mu.entity IN ('".
getEntity(
'mailing').
"'))";
234 dol_syslog(__METHOD__.
":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG);
235 $result = $this->
db->query($sql);
257 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"mailing_cibles";
258 $sql .=
" WHERE fk_mailing = ".((int) $mailing_id);
260 if (!$this->
db->query($sql)) {
Parent class of emailing target selectors modules.
__construct($db)
Constructor.
addTargetsToDatabase($mailing_id, $cibles)
Add a list of targets int the database.
getDesc()
Return description of email selector.
getNbOfRecipients($sql)
Retourne nombre de destinataires.
clear_target($mailing_id)
Supprime tous les destinataires de la table des cibles.
update_nb($mailing_id)
Met a jour nombre de destinataires.
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings.
getNbOfRecords()
Return number of records for email selector.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.
$conf db
API class for accounts.