dolibarr  13.0.2
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 
24 include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
25 require_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  $email = $tmparray[0];
131  $lastname = $tmparray[1];
132  $firstname = $tmparray[2];
133  $other = $tmparray[3];
134 
135  $cibles = array();
136  if (!empty($email))
137  {
138  if (isValidEMail($email))
139  {
140  $cibles[] = array(
141  'email' => $email,
142  'lastname' => $lastname,
143  'firstname' => $firstname,
144  'other' => $other,
145  'source_url' => '',
146  'source_id' => '',
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 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to offer a selector of emailing targets with Rule &#39;xinputuser&#39;.
url($id)
Renvoie url lien vers fiche de la source du destinataire du mailing.
add_to_target($mailing_id)
Ajoute destinataires dans table des cibles.
$conf db
API class for accounts.
Definition: inc.php:54
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings...
getNbOfRecipients($sql= '')
Return here number of distinct emails returned by your selector.
__construct($db)
Constructor.
Parent class of emailing target selectors modules.