dolibarr 23.0.3
xinputuser.modules.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
26include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
28
29
34{
35 public $name = 'EmailsFromUser'; // Identifiant du module mailing
36 // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
37 public $desc = 'EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée
38
42 public $require_module = array(); // Module mailing actif si modules require_module actifs
43
47 public $require_admin = 0; // Module mailing actif pour user admin ou non
48
52 public $picto = 'generic';
53 public $tooltip = 'UseFormatInputEmailToTarget';
54
55
61 public function __construct($db)
62 {
63 $this->db = $db;
64 }
65
66
75 public function getSqlArrayForStats()
76 {
77 global $langs;
78 $langs->load("users");
79
80 $statssql = array();
81 return $statssql;
82 }
83
84
93 public function getNbOfRecipients($sql = '')
94 {
95 return '';
96 }
97
98
105 public function url($id)
106 {
107 return '';
108 }
109
110
116 public function formFilter()
117 {
118 global $langs;
119
120 $s = '<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
121
122 return $s;
123 }
124
125 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
132 public function add_to_target($mailing_id)
133 {
134 // phpcs:enable
135 global $conf, $langs, $_FILES;
136
137 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
138
139 $tmparray = explode(';', GETPOST('xinputuser'));
140
141 $email = $tmparray[0];
142 $lastname = empty($tmparray[1]) ? '' : $tmparray[1];
143 $firstname = empty($tmparray[2]) ? '' : $tmparray[2];
144 $other = empty($tmparray[3]) ? '' : $tmparray[3];
145
146 $cibles = array();
147 if (!empty($email)) {
148 if (isValidEmail($email)) {
149 $cibles[] = array(
150 'email' => $email,
151 'lastname' => $lastname,
152 'firstname' => $firstname,
153 'other' => $other,
154 'source_url' => '',
155 'source_id' => 0,
156 'source_type' => 'file'
157 );
158
159 return parent::addTargetsToDatabase($mailing_id, $cibles);
160 } else {
161 $langs->load("errors");
162 $this->error = $langs->trans("ErrorBadEMail", $email);
163 return -1;
164 }
165 } else {
166 $langs->load("errors");
167 $this->error = $langs->trans("ErrorBadEmail", $email);
168 return -1;
169 }
170 }
171}
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
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)
Provide the URL to the car of the source information of the recipient for the 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.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.