dolibarr 21.0.0-beta
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 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 * or see https://www.gnu.org/
18 */
19
25include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
26require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
27
28
33{
34 public $name = 'EmailsFromUser'; // Identifiant du module mailing
35 // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found
36 public $desc = 'EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
37 public $require_module = array(); // Module mailing actif si modules require_module actifs
38 public $require_admin = 0; // Module mailing actif pour user admin ou non
39
43 public $picto = 'generic';
44 public $tooltip = 'UseFormatInputEmailToTarget';
45
46
52 public function __construct($db)
53 {
54 $this->db = $db;
55 }
56
57
66 public function getSqlArrayForStats()
67 {
68 global $langs;
69 $langs->load("users");
70
71 $statssql = array();
72 return $statssql;
73 }
74
75
84 public function getNbOfRecipients($sql = '')
85 {
86 return '';
87 }
88
89
96 public function url($id)
97 {
98 return '';
99 }
100
101
107 public function formFilter()
108 {
109 global $langs;
110
111 $s = '';
112 $s .= '<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
113 return $s;
114 }
115
116 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
123 public function add_to_target($mailing_id)
124 {
125 // phpcs:enable
126 global $conf, $langs, $_FILES;
127
128 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
129
130 $tmparray = explode(';', GETPOST('xinputuser'));
131
132 $email = $tmparray[0];
133 $lastname = empty($tmparray[1]) ? '' : $tmparray[1];
134 $firstname = empty($tmparray[2]) ? '' : $tmparray[2];
135 $other = empty($tmparray[3]) ? '' : $tmparray[3];
136
137 $cibles = array();
138 if (!empty($email)) {
139 if (isValidEmail($email)) {
140 $cibles[] = array(
141 'email' => $email,
142 'lastname' => $lastname,
143 'firstname' => $firstname,
144 'other' => $other,
145 'source_url' => '',
146 'source_id' => 0,
147 'source_type' => 'file'
148 );
149
150 return parent::addTargetsToDatabase($mailing_id, $cibles);
151 } else {
152 $langs->load("errors");
153 $this->error = $langs->trans("ErrorBadEMail", $email);
154 return -1;
155 }
156 } else {
157 $langs->load("errors");
158 $this->error = $langs->trans("ErrorBadEmail", $email);
159 return -1;
160 }
161 }
162}
$id
Definition account.php:48
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79