dolibarr  7.0.0-beta
example.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This file is an example to follow to add your own email selector inside
5  * the Dolibarr email tool.
6  * Follow instructions given in README file to know what to change to build
7  * your own emailing list selector.
8  * Code that need to be changed in this file are marked by "CHANGE THIS" tag.
9  */
10 
17 include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php';
18 
19 
20 // CHANGE THIS: Class name must be called mailing_xxx with xxx=name of your selector
21 
27 {
28  // CHANGE THIS: Put here a name not already used
29  var $name='example';
30  // CHANGE THIS: Put here a description of your selector module.
31  // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found
32  var $desc='Put here a description';
33  // CHANGE THIS: Set to 1 if selector is available for admin users only
34  var $require_admin=0;
35  // CHANGE THIS: Add a tooltip language key to add a tooltip help icon after the email target selector
36  var $tooltip='MyTooltipLangKey';
37 
38  var $require_module=array();
39  var $picto='';
40  var $db;
41 
42 
43  // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector
49  function __construct($db)
50  {
51  $this->db=$db;
52  }
53 
54 
62  function add_to_target($mailing_id,$filtersarray=array())
63  {
64  $target = array();
65 
66  // CHANGE THIS
67  // ----- Your code start here -----
68 
69  // You must fill the $target array with record like this
70  // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0');
71  // ...
72  // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n');
73 
74  // Example: $target[0]=array('email'=>'myemail@example.com', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information');
75 
76  // ----- Your code end here -----
77 
78  return parent::add_to_target($mailing_id, $target);
79  }
80 
81 
91  {
92  // CHANGE THIS: Optionnal
93 
94  //var $statssql=array();
95  //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
96  return array();
97  }
98 
99 
108  function getNbOfRecipients($sql='')
109  {
110  // CHANGE THIS: Optionnal
111 
112  // Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table");
113  // Example: return 500;
114  return '?';
115  }
116 
123  function formFilter()
124  {
125  // CHANGE THIS: Optionnal
126 
127  $s='';
128  return $s;
129  }
130 
131 
139  function url($id)
140  {
141  // CHANGE THIS: Optionnal
142 
143  return '';
144  }
145 
146 }
147 
add_to_target($mailing_id, $filtersarray=array())
This is the main function that returns the array of emails.
url($id)
Can include an URL link on each record provided by selector shown on target page. ...
formFilter()
This is to add a form filter to provide variant of selector If used, the HTML select must be called "...
Class to manage a list of personalised recipients for mailing feature.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
__construct($db)
Constructor.
Parent class of emailing target selectors modules.
getNbOfRecipients($sql='')
Return here number of distinct emails returned by your selector.