dolibarr  9.0.0
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 <http://www.gnu.org/licenses/>.
16  * or see http://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  var $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  var $desc='EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e
36  var $require_module=array(); // Module mailing actif si modules require_module actifs
37  var $require_admin=0; // Module mailing actif pour user admin ou non
38  var $picto='generic';
39  var $tooltip='UseFormatInputEmailToTarget';
40 
41 
47  function __construct($db)
48  {
49  $this->db=$db;
50  }
51 
52 
62  {
63  global $langs;
64  $langs->load("users");
65 
66  $statssql=array();
67  return $statssql;
68  }
69 
70 
79  function getNbOfRecipients($sql='')
80  {
81  return '';
82  }
83 
84 
91  function url($id)
92  {
93  return '';
94  }
95 
96 
102  function formFilter()
103  {
104  global $langs;
105 
106  $s='';
107  $s.='<input type="text" name="xinputuser" class="flat minwidth300" value="'.GETPOST("xinputuser").'">';
108  return $s;
109  }
110 
111  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
119  function add_to_target($mailing_id,$filtersarray=array())
120  {
121  // phpcs:enable
122  global $conf,$langs,$_FILES;
123 
124  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
125 
126  $tmparray=explode(';',GETPOST('xinputuser'));
127  $email=$tmparray[0];
128  $lastname=$tmparray[1];
129  $firstname=$tmparray[2];
130  $other=$tmparray[3];
131 
132  $cibles=array();
133  if (! empty($email))
134  {
135  if (isValidEMail($email))
136  {
137  $cibles[] = array(
138  'email' => $email,
139  'lastname' => $lastname,
140  'firstname' => $firstname,
141  'other' => $other,
142  'source_url' => '',
143  'source_id' => '',
144  'source_type' => 'file'
145  );
146 
147  return parent::add_to_target($mailing_id, $cibles);
148  }
149  else
150  {
151  $langs->load("errors");
152  $this->error = $langs->trans("ErrorBadEMail",$email);
153  return -1;
154  }
155  }
156  else
157  {
158  $langs->load("errors");
159  $this->error = $langs->trans("ErrorBadEmail",$email);
160  return -1;
161  }
162  }
163 }
GETPOST($paramname, $check='none', $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.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
add_to_target($mailing_id, $filtersarray=array())
Ajoute destinataires dans table des cibles.
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings...
__construct($db)
Constructor.
Parent class of emailing target selectors modules.