dolibarr 21.0.0-alpha
modEmailCollector.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2004-2018 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 */
17
26include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
27
28
33{
39 public function __construct($db)
40 {
41 global $langs, $conf;
42
43 $this->db = $db;
44
45 // Id for module (must be unique).
46 // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id).
47 $this->numero = 50320;
48 // Key text used to identify module (for permissions, menus, etc...)
49 $this->rights_class = 'emailcollector';
50
51 // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...'
52 // It is used to group modules by family in module setup page
53 $this->family = "interface";
54 // Module position in the family on 2 digits ('01', '10', '20', ...)
55 $this->module_position = '23';
56 // Gives the possibility to the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
57 //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily")));
58
59 // Module label (no space allowed), used if translation string 'ModuledavName' not found (MyModue is name of module).
60 $this->name = preg_replace('/^mod/i', '', get_class($this));
61 // Module description, used if translation string 'ModuledavDesc' not found (MyModue is name of module).
62 $this->description = "EmailCollectorDescription";
63 // Used only if file README.md and README-LL.md not found.
64 $this->descriptionlong = "EmailCollectorDescription";
65
66 // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
67 $this->version = 'dolibarr';
68 // Key used in llx_const table to save module status enabled/disabled (where DAV is value of property name of module in uppercase)
69 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70 // Name of image file used for this module.
71 // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
72 // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
73 $this->picto = 'email';
74
75 // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
76 // for default path (eg: /dav/core/xxxxx) (0=disable, 1=enable)
77 // for specific path of parts (eg: /dav/core/modules/barcode)
78 // for specific css file (eg: /dav/css/dav.css.php)
79 $this->module_parts = array();
80
81 // Data directories to create when module is enabled.
82 // Example: this->dirs = array("/dav/temp","/dav/subdir");
83 $this->dirs = array();
84
85 // Config pages. Put here list of php page, stored into dav/admin directory, to use to setup module.
86 $this->config_page_url = array("emailcollector_list.php");
87
88 // Dependencies
89 $this->hidden = false; // A condition to hide module
90 $this->depends = array('always'=>'modCron'); // List of module class names as string that must be enabled if this module is enabled
91 $this->requiredby = array(); // List of module ids to disable if this one is disabled
92 $this->conflictwith = array(); // List of module class names as string this module is in conflict with
93 $this->langfiles = array("admin");
94 $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
95 $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...)
96 //$this->automatic_activation = array('FR'=>'davWasAutomaticallyActivatedBecauseOfYourCountryChoice');
97 //$this->always_enabled = true; // If true, can't be disabled
98
99 // Constants
100 // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
101 // Example: $this->const=array(0=>array('DAV_MYNEWCONST1','chaine','myvalue','This is a constant to add',1),
102 // 1=>array('DAV_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
103 // );
104 $this->const = array(
105 //1=>array('DAV_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1)
106 );
107
108
109 if (!isset($conf->emailcollector) || !isset($conf->emailcollector->enabled)) {
110 $conf->emailcollector = new stdClass();
111 $conf->emailcollector->enabled = 0;
112 }
113
114
115 // Array to add new pages in new tabs
116 $this->tabs = array();
117 // Example:
118 // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@dav:$user->rights->dav->read:/dav/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1
119 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dav:$user->rights->othermodule->read:/dav/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
120 // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname
121 //
122 // Where objecttype can be
123 // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
124 // 'contact' to add a tab in contact view
125 // 'contract' to add a tab in contract view
126 // 'group' to add a tab in group view
127 // 'intervention' to add a tab in intervention view
128 // 'invoice' to add a tab in customer invoice view
129 // 'invoice_supplier' to add a tab in supplier invoice view
130 // 'member' to add a tab in foundation member view
131 // 'opensurveypoll' to add a tab in opensurvey poll view
132 // 'order' to add a tab in sales order view
133 // 'order_supplier' to add a tab in supplier order view
134 // 'payment' to add a tab in payment view
135 // 'payment_supplier' to add a tab in supplier payment view
136 // 'product' to add a tab in product view
137 // 'propal' to add a tab in propal view
138 // 'project' to add a tab in project view
139 // 'stock' to add a tab in stock view
140 // 'thirdparty' to add a tab in third party view
141 // 'user' to add a tab in user view
142
143
144 // Dictionaries
145 $this->dictionaries = array();
146
147
148 // Boxes/Widgets
149 // Add here list of php file(s) stored in dav/core/boxes that contains class to show a widget.
150 $this->boxes = array(
151 //0=>array('file'=>'davwidget1.php@dav','note'=>'Widget provided by dav','enabledbydefaulton'=>'Home'),
152 //1=>array('file'=>'davwidget2.php@dav','note'=>'Widget provided by dav'),
153 //2=>array('file'=>'davwidget3.php@dav','note'=>'Widget provided by dav')
154 );
155
156
157 // Cronjobs (List of cron jobs entries to add when module is enabled)
158 // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week
159 $this->cronjobs = array(
160 0=>array('label'=>'Email collector', 'priority'=>50, 'jobtype'=>'method', 'class'=>'/emailcollector/class/emailcollector.class.php', 'objectname'=>'EmailCollector', 'method'=>'doCollect', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>5, 'unitfrequency'=>60, 'status'=>1, 'test'=>'isModEnabled("emailcollector")')
161 );
162
163
164 // Permissions
165 $this->rights = array(); // Permission array used by this module
166
167 // Main menu entries
168 $this->menu = array(); // List of menus to add
169
170 $r = 0;
171 $this->menu[$r] = array('fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
172 'type'=>'left', // This is a Left menu entry
173 'titre'=>'EmailCollectors',
174 'url'=>'/admin/emailcollector_list.php?leftmenu=admintools',
175 'langs'=>'admin', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
176 'position'=>400,
177 'enabled'=>'isModEnabled("emailcollector") && preg_match(\'/^(admintools|all)/\', $leftmenu)', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
178 'perms'=>'$user->admin', // Use 'perms'=>'$user->hasRight("mymodule","level1","level2")' if you want your menu with a permission rules
179 'target'=>'',
180 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
181 $r++;
182 }
183
192 public function init($options = '')
193 {
194 global $conf, $user, $langs;
195 $langs->load("admin");
196
197 $sql = array();
198
199 $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity;
200 $tmpresql = $this->db->query($tmpsql);
201 if ($tmpresql) {
202 if ($this->db->num_rows($tmpresql) == 0) {
203 $descriptionA1 = $langs->trans('EmailCollectorExampleToCollectTicketRequestsDesc');
204 $label = $langs->trans('EmailCollectorExampleToCollectTicketRequests');
205 $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
206 $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Ticket_Requests', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";
207
208 $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
209 $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
210 //$sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
211 //$sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
212 $sqlforexampleFilterA3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
213 $sqlforexampleFilterA3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'to', 'support@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
214
215 $sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
216 $sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Ticket_Requests' and entity = ".$conf->entity."), 'ticket', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
217
218 $sql[] = $sqlforexampleA1;
219
220 $sql[] = $sqlforexampleFilterA1;
221 //$sql[] = $sqlforexampleFilterA2;
222 $sql[] = $sqlforexampleFilterA3;
223
224 $sql[] = $sqlforexampleActionA1;
225 }
226 } else {
227 dol_print_error($this->db);
228 }
229
230 $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".$conf->entity;
231 $tmpresql = $this->db->query($tmpsql);
232 if ($tmpresql) {
233 if ($this->db->num_rows($tmpresql) == 0) {
234 $descriptionA1 = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware');
235 $label = $langs->trans('EmailCollectorExampleToCollectAnswersFromExternalEmailSoftware');
236 $sqlforexampleA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
237 $sqlforexampleA1 .= " VALUES (".$conf->entity.", 'Collect_Responses_Out', '".$this->db->escape($label)."', '".$this->db->escape($descriptionA1)."', 'Sent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";
238
239 $sqlforexampleFilterA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
240 $sqlforexampleFilterA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
241 $sqlforexampleFilterA2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
242 $sqlforexampleFilterA2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'withouttrackingidinmsgid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
243
244 $sqlforexampleActionA1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
245 $sqlforexampleActionA1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_Out' and entity = ".((int) $conf->entity)."), 'recordevent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
246
247 $sql[] = $sqlforexampleA1;
248
249 $sql[] = $sqlforexampleFilterA1;
250 $sql[] = $sqlforexampleFilterA2;
251
252 $sql[] = $sqlforexampleActionA1;
253 }
254 }
255
256 $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity);
257 $tmpresql = $this->db->query($tmpsql);
258 if ($tmpresql) {
259 if ($this->db->num_rows($tmpresql) == 0) {
260 $descriptionB1 = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswersDesc');
261 $label = $langs->trans('EmailCollectorExampleToCollectDolibarrAnswers');
262 $sqlforexampleB1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
263 $sqlforexampleB1 .= " VALUES (".$conf->entity.", 'Collect_Responses_In', '".$this->db->escape($label)."', '".$this->db->escape($descriptionB1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";
264
265 $sqlforexampleFilterB2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
266 $sqlforexampleFilterB2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity)."), 'isanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
267
268 $sqlforexampleActionB3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, date_creation, fk_user_creat, status)";
269 $sqlforexampleActionB3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Responses_In' and entity = ".((int) $conf->entity)."), 'recordevent', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
270
271 $sql[] = $sqlforexampleB1;
272
273 $sql[] = $sqlforexampleFilterB2;
274
275 $sql[] = $sqlforexampleActionB3;
276 }
277 } else {
278 dol_print_error($this->db);
279 }
280
281 $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity);
282 $tmpresql = $this->db->query($tmpsql);
283 if ($tmpresql) {
284 if ($this->db->num_rows($tmpresql) == 0) {
285 $descriptionC1 = $langs->trans("EmailCollectorExampleToCollectLeadsDesc");
286 $label = $langs->trans('EmailCollectorExampleToCollectLeads');
287 $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
288 $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Leads', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";
289
290 $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
291 $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
292 //$sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
293 //$sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
294 $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
295 $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'to', 'sales@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
296
297 $paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)'."\n".'socid=SETIFEMPTY:1'."\n".'usage_opportunity=SET:1'."\n".'description=EXTRACT:BODY:(.*)'."\n".'title=SET:Lead or message from __tmp_from__ received by email';
298 $sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";
299 $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Leads' and entity = ".((int) $conf->entity)."), 'project', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
300
301 $sql[] = $sqlforexampleC1;
302
303 $sql[] = $sqlforexampleFilterC1;
304 //$sql[] = $sqlforexampleFilterC2;
305 $sql[] = $sqlforexampleFilterC3;
306
307 $sql[] = $sqlforexampleActionC4;
308 }
309 } else {
310 dol_print_error($this->db);
311 }
312
313 $tmpsql = "SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity);
314 $tmpresql = $this->db->query($tmpsql);
315 if ($tmpresql) {
316 if ($this->db->num_rows($tmpresql) == 0) {
317 $descriptionC1 = $langs->trans("EmailCollectorExampleToCollectJobCandidaturesDesc");
318 $label = $langs->trans('EmailCollectorExampleToCollectJobCandidatures');
319 $sqlforexampleC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollector (entity, ref, label, description, source_directory, date_creation, fk_user_creat, status)";
320 $sqlforexampleC1 .= " VALUES (".$conf->entity.", 'Collect_Candidatures', '".$this->db->escape($label)."', '".$this->db->escape($descriptionC1)."', 'INBOX', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 0)";
321
322 $sqlforexampleFilterC1 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
323 $sqlforexampleFilterC1 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'isnotanswer', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
324 //$sqlforexampleFilterC2 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, date_creation, fk_user_creat, status)";
325 //$sqlforexampleFilterC2 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'withouttrackingid', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
326 $sqlforexampleFilterC3 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectorfilter (fk_emailcollector, type, rulevalue, date_creation, fk_user_creat, status)";
327 $sqlforexampleFilterC3 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'to', 'jobs@example.com', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
328
329 $paramstring = 'tmp_from=EXTRACT:HEADER:^From:(.*)(<.*>)?'."\n".'fk_recruitmentjobposition=EXTRACT:HEADER:^To:[^\n]*\+([^\n]*)'."\n".'description=EXTRACT:BODY:(.*)'."\n".'lastname=SET:__tmp_from__';
330 $sqlforexampleActionC4 = "INSERT INTO ".MAIN_DB_PREFIX."emailcollector_emailcollectoraction (fk_emailcollector, type, actionparam, date_creation, fk_user_creat, status)";
331 $sqlforexampleActionC4 .= " VALUES ((SELECT rowid FROM ".MAIN_DB_PREFIX."emailcollector_emailcollector WHERE ref = 'Collect_Candidatures' and entity = ".((int) $conf->entity)."), 'candidature', '".$this->db->escape($paramstring)."', '".$this->db->idate(dol_now())."', ".((int) $user->id).", 1)";
332
333 $sql[] = $sqlforexampleC1;
334
335 $sql[] = $sqlforexampleFilterC1;
336 //$sql[] = $sqlforexampleFilterC2;
337 $sql[] = $sqlforexampleFilterC3;
338
339 $sql[] = $sqlforexampleActionC4;
340 }
341 } else {
342 dol_print_error($this->db);
343 }
344
345 return $this->_init($sql, $options);
346 }
347
356 public function remove($options = '')
357 {
358 $sql = array();
359
360 return $this->_remove($sql, $options);
361 }
362}
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_remove($array_sql, $options='')
Disable function.
Description and activation class for module emailcollector.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_now($mode='auto')
Return date for now.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:142