dolibarr  9.0.0
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 
44  public $db;
45 
46 
47  // CHANGE THIS: Constructor name must be called mailing_xxx with xxx=name of your selector
53  function __construct($db)
54  {
55  $this->db=$db;
56  }
57 
58 
59  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
67  function add_to_target($mailing_id,$filtersarray=array())
68  {
69  // phpcs:enable
70  $target = array();
71 
72  // CHANGE THIS
73  // ----- Your code start here -----
74 
75  // You must fill the $target array with record like this
76  // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0', 'other'=>'other_0');
77  // ...
78  // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n', 'other'=>'other_n');
79 
80  // Example: $target[0]=array('email'=>'myemail@example.com', 'name'=>'Doe', 'firstname'=>'John', 'other'=>'Other information');
81 
82  // ----- Your code end here -----
83 
84  return parent::add_to_target($mailing_id, $target);
85  }
86 
87 
97  {
98  // CHANGE THIS: Optionnal
99 
100  //var $statssql=array();
101  //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL";
102  return array();
103  }
104 
105 
114  function getNbOfRecipients($sql='')
115  {
116  // CHANGE THIS: Optionnal
117 
118  // Example: return parent::getNbOfRecipients("SELECT count(*) as nb from dolibarr_table");
119  // Example: return 500;
120  return '?';
121  }
122 
129  function formFilter()
130  {
131  // CHANGE THIS: Optionnal
132 
133  $s='';
134  return $s;
135  }
136 
137 
145  function url($id)
146  {
147  // CHANGE THIS: Optionnal
148 
149  return '';
150  }
151 }
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.