dolibarr  7.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  *
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 
118  function add_to_target($mailing_id,$filtersarray=array())
119  {
120  global $conf,$langs,$_FILES;
121 
122  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
123 
124  $tmparray=explode(';',GETPOST('xinputuser'));
125  $email=$tmparray[0];
126  $lastname=$tmparray[1];
127  $firstname=$tmparray[2];
128  $other=$tmparray[3];
129 
130  $cibles=array();
131  if (! empty($email))
132  {
133  if (isValidEMail($email))
134  {
135  $cibles[] = array(
136  'email' => $email,
137  'lastname' => $lastname,
138  'firstname' => $firstname,
139  'other' => $other,
140  'source_url' => '',
141  'source_id' => '',
142  'source_type' => 'file'
143  );
144 
145  return parent::add_to_target($mailing_id, $cibles);
146  }
147  else
148  {
149  $langs->load("errors");
150  $this->error = $langs->trans("ErrorBadEMail",$email);
151  return -1;
152  }
153  }
154  else
155  {
156  $langs->load("errors");
157  $this->error = $langs->trans("ErrorBadEmail",$email);
158  return -1;
159  }
160 
161  }
162 
163 }
164 
Class to offer a selector of emailing targets with Rule 'xinputuser'.
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.
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.