dolibarr 18.0.6
xinputuser.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 * or see https://www.gnu.org/
17 */
18
24include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
25require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
26
27
32{
33 public $name = 'EmailsFromUser'; // Identifiant du module mailing
34 // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
35 public $desc = 'EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36 public $require_module = array(); // Module mailing actif si modules require_module actifs
37 public $require_admin = 0; // Module mailing actif pour user admin ou non
38
42 public $picto = 'generic';
43 public $tooltip = 'UseFormatInputEmailToTarget';
44
45
51 public function __construct($db)
52 {
53 $this->db = $db;
54 }
55
56
65 public function getSqlArrayForStats()
66 {
67 global $langs;
68 $langs->load("users");
69
70 $statssql = array();
71 return $statssql;
72 }
73
74
83 public function getNbOfRecipients($sql = '')
84 {
85 return '';
86 }
87
88
95 public function url($id)
96 {
97 return '';
98 }
99
100
106 public function formFilter()
107 {
108 global $langs;
109
110 $s = '';
111 $s .= '<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
112 return $s;
113 }
114
115 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
122 public function add_to_target($mailing_id)
123 {
124 // phpcs:enable
125 global $conf, $langs, $_FILES;
126
127 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
128
129 $tmparray = explode(';', GETPOST('xinputuser'));
130
131 $email = $tmparray[0];
132 $lastname = empty($tmparray[1]) ? '' : $tmparray[1];
133 $firstname = empty($tmparray[2]) ? '' : $tmparray[2];
134 $other = empty($tmparray[3]) ? '' : $tmparray[3];
135
136 $cibles = array();
137 if (!empty($email)) {
138 if (isValidEMail($email)) {
139 $cibles[] = array(
140 'email' => $email,
141 'lastname' => $lastname,
142 'firstname' => $firstname,
143 'other' => $other,
144 'source_url' => '',
145 'source_id' => '',
146 'source_type' => 'file'
147 );
148
149 return parent::addTargetsToDatabase($mailing_id, $cibles);
150 } else {
151 $langs->load("errors");
152 $this->error = $langs->trans("ErrorBadEMail", $email);
153 return -1;
154 }
155 } else {
156 $langs->load("errors");
157 $this->error = $langs->trans("ErrorBadEmail", $email);
158 return -1;
159 }
160 }
161}
Parent class of emailing target selectors modules.
Class to offer a selector of emailing targets with Rule 'xinputuser'.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
__construct($db)
Constructor.
add_to_target($mailing_id)
Ajoute destinataires dans table des cibles.
url($id)
Renvoie url lien vers fiche de la source du destinataire du mailing.
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.