11 include_once DOL_DOCUMENT_ROOT.
'/core/modules/mailings/modules_mailings.php';
21 public $name =
'mailinglist_mymodule_myobject';
23 public $desc =
'My object emailing target selector';
25 public $require_admin = 0;
27 public $enabled =
'$conf->mymodule->enabled';
29 public $require_module = array();
34 public $picto =
'mymodule@mymodule';
52 if (is_array($conf->modules)) {
53 $this->enabled = in_array(
'mymodule', $conf->modules) ? 1 : 0;
66 $langs->load(
"members");
70 $arraystatus = array(1=>
'Option 1', 2=>
'Option 2');
73 $s .= $langs->trans(
"Status").
': ';
74 $s .=
'<select name="filter" class="flat">';
75 $s .=
'<option value="none"> </option>';
76 foreach ($arraystatus as $status) {
77 $s .=
'<option value="'.$status.
'">'.$status.
'</option>';
92 public function url($id)
94 return '<a href="'.dol_buildpath(
'/mymodule/myobject_card.php', 1).
'?id='.$id.
'">'.
img_object(
'',
"generic").
'</a>';
111 $sql =
" select rowid as id, email, firstname, lastname, plan, partner";
112 $sql .=
" from ".MAIN_DB_PREFIX.
"myobject";
113 $sql .=
" where email IS NOT NULL AND email != ''";
115 $sql .=
" AND status = '".$this->db->escape(
GETPOST(
'filter',
'alphanohtml')).
"'";
117 $sql .=
" ORDER BY email";
120 $result = $this->
db->query($sql);
122 $num = $this->
db->num_rows($result);
125 dol_syslog(
"mailinglist_mymodule_myobject.modules.php: mailing ".$num.
" targets found");
129 $obj = $this->
db->fetch_object($result);
130 if ($old <> $obj->email) {
132 'email' => $obj->email,
133 'name' => $obj->lastname,
135 'firstname' => $obj->firstname,
136 'other' => $obj->plan.
';'.$obj->partner,
137 'source_url' => $this->url($obj->id),
138 'source_id' => $obj->id,
139 'source_type' =>
'dolicloud'
149 $this->error = $this->
db->error();
162 return parent::addTargetsToDatabase($mailing_id, $target);
196 $a = parent::getNbOfRecipients(
"select count(distinct(email)) as nb from ".MAIN_DB_PREFIX.
"myobject as p where email IS NOT NULL AND email != ''");
$conf db
API class for accounts.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Parent class of emailing target selectors modules.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
formFilter()
Displays the filter form that appears in the mailing recipient selection page.
getSqlArrayForStats()
On the main mailing area, there is a box with statistics.
url($id)
Returns url link to file of the source of the recipient of the mailing.
__construct($db)
Constructor.
getNbOfRecipients($filter=1, $option='')
Return here number of distinct emails returned by your selector.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
add_to_target($mailing_id)
This is the main function that returns the array of emails.
mailing_mailinglist_mymodule
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)