dolibarr  16.0.5
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 
131  $email = $tmparray[0];
132  $lastname = empty($tmparray[1]) ? '' : $tmparray[1];
133  $firstname = empty($tmparray[2]) ? '' : $tmparray[2];
134  $other = empty($tmparray[3]) ? '' : $tmparray[3];
135 
136  $cibles = array();
137  if (!empty($email)) {
138  if (isValidEMail($email)) {
139  $cibles[] = array(
140  'email' => $email,
141  'lastname' => $lastname,
142  'firstname' => $firstname,
143  'other' => $other,
144  'source_url' => '',
145  'source_id' => '',
146  'source_type' => 'file'
147  );
148 
149  return parent::addTargetsToDatabase($mailing_id, $cibles);
150  } else {
151  $langs->load("errors");
152  $this->error = $langs->trans("ErrorBadEMail", $email);
153  return -1;
154  }
155  } else {
156  $langs->load("errors");
157  $this->error = $langs->trans("ErrorBadEmail", $email);
158  return -1;
159  }
160  }
161 }
db
$conf db
API class for accounts.
Definition: inc.php:41
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
mailing_xinputuser\formFilter
formFilter()
Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings.
Definition: xinputuser.modules.php:106
MailingTargets
Parent class of emailing target selectors modules.
Definition: modules_mailings.php:32
mailing_xinputuser\getSqlArrayForStats
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
Definition: xinputuser.modules.php:65
mailing_xinputuser\getNbOfRecipients
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.
Definition: xinputuser.modules.php:83
mailing_xinputuser\add_to_target
add_to_target($mailing_id)
Ajoute destinataires dans table des cibles.
Definition: xinputuser.modules.php:122
mailing_xinputuser\__construct
__construct($db)
Constructor.
Definition: xinputuser.modules.php:51
mailing_xinputuser
Class to offer a selector of emailing targets with Rule 'xinputuser'.
Definition: xinputuser.modules.php:31
mailing_xinputuser\url
url($id)
Renvoie url lien vers fiche de la source du destinataire du mailing.
Definition: xinputuser.modules.php:95