28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'emailcollectorfilter';
45 public $table_element =
'emailcollector_emailcollectorfilter';
50 public $picto =
'emailcollectorfilter@emailcollector';
76 public $fields = array(
77 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'position' => 1,
'notnull' => 1,
'index' => 1,
'comment' =>
"Id",),
78 'fk_emailcollector' => array(
'type' =>
'integer',
'label' =>
'Id of emailcollector',
'foreignkey' =>
'emailcollector.rowid'),
79 'type' => array(
'type' =>
'varchar(128)',
'label' =>
'Type',
'enabled' => 1,
'visible' => 1,
'position' => 10,
'notnull' => 1,),
80 'rulevalue' => array(
'type' =>
'varchar(255)',
'label' =>
'ValueOfRule',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'notnull' => -1,
'help' =>
"Value of Rule",),
81 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -2,
'position' => 500,
'notnull' => 1,),
82 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -2,
'position' => 501,
'notnull' => 1,),
83 'fk_user_creat' => array(
'type' =>
'integer',
'label' =>
'UserAuthor',
'enabled' => 1,
'visible' => -2,
'position' => 510,
'notnull' => 1,
'foreignkey' =>
'llx_user.rowid',),
84 'fk_user_modif' => array(
'type' =>
'integer',
'label' =>
'UserModif',
'enabled' => 1,
'visible' => -2,
'position' => 511,
'notnull' => -1,),
85 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'visible' => -2,
'position' => 1000,
'notnull' => -1,),
86 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'position' => 1000,
'notnull' => 1,
'default' =>
'1',
'arrayofkeyval' => array(
'0' =>
'Disabled',
'1' =>
'Enabled')),
89 public $fk_emailcollector;
96 public $date_creation;
98 public $fk_user_creat;
99 public $fk_user_modif;
113 global $conf, $langs;
117 $this->ismultientitymanaged = 0;
118 $this->isextrafieldmanaged = 0;
121 $this->fields[
'rowid'][
'visible'] = 0;
123 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
124 $this->fields[
'entity'][
'enabled'] = 0;
128 foreach ($this->fields as $key => $val) {
129 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
130 unset($this->fields[$key]);
135 foreach ($this->fields as $key => $val) {
136 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
137 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
138 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
155 if (empty($this->
type)) {
156 $langs->load(
"errors");
157 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
160 if (!in_array($this->
type, array(
'seen',
'unseen',
'unanswered',
'answered',
'withtrackingidinmsgid',
'withouttrackingidinmsgid',
'withtrackingid',
'withouttrackingid',
'isanswer',
'isnotanswer')) && empty($this->rulevalue)) {
161 $langs->load(
"errors");
162 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"SearchString"));
166 if (in_array($this->
type, array(
'to')) && strpos($this->rulevalue,
'+') !=
false) {
167 $langs->load(
"errors");
168 $this->errors[] = $langs->trans(
"ErrorCharPlusNotSupportedByImapForSearch");
184 global $langs, $hookmanager, $extrafields;
201 $object->ref =
"copy_of_".$object->ref;
205 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
206 $extrafields->fetch_name_optionals_label($this->table_element);
207 foreach (
$object->array_options as $key => $option) {
208 $shortkey = preg_replace(
'/options_/',
'', $key);
209 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
210 unset(
$object->array_options[$key]);
216 $object->context[
'createfromclone'] =
'createfromclone';
217 $result =
$object->createCommon($user);
221 $this->errors =
$object->errors;
224 unset(
$object->context[
'createfromclone']);
231 $this->db->rollback();
243 public function fetch($id, $ref =
null)
269 public function delete(
User $user, $notrigger = 0)
284 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
286 global $db, $conf, $langs, $hookmanager;
287 global $dolibarr_main_authentication, $dolibarr_main_demo;
290 if (!empty($conf->dol_no_mouse_hover)) {
296 $label =
'<u>'.$langs->trans(
"EmailcollectorFilter").
'</u>';
298 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
300 $url =
dol_buildpath(
'/emailcollector/emailcollectorfilter_card.php', 1).
'?id='.$this->id;
302 if ($option !=
'nolink') {
304 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
305 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
306 $add_save_lastsearch_values = 1;
308 if ($add_save_lastsearch_values) {
309 $url .=
'&save_lastsearch_values=1';
314 if (empty($notooltip)) {
316 $label = $langs->trans(
"ShowEmailcollectorFilter");
317 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
319 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
320 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
329 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
332 $linkstart =
'<a href="'.$url.
'"';
333 $linkstart .= $linkclose.
'>';
336 $result .= $linkstart;
338 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
340 if ($withpicto != 2) {
341 $result .= $this->ref;
346 global $action, $hookmanager;
347 $hookmanager->initHooks(array(
'emailcollectorfilterdao'));
348 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
349 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
351 $result = $hookmanager->resPrint;
353 $result .= $hookmanager->resPrint;
381 if (empty($this->labelStatus)) {
384 $this->labelStatus[1] = $langs->trans(
'Enabled');
385 $this->labelStatus[0] = $langs->trans(
'Disabled');
389 return $this->labelStatus[$status];
390 } elseif ($mode == 1) {
391 return $this->labelStatus[$status];
392 } elseif ($mode == 2) {
394 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
395 } elseif ($status == 0) {
396 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
398 } elseif ($mode == 3) {
400 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
401 } elseif ($status == 0) {
402 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
404 } elseif ($mode == 4) {
406 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
407 } elseif ($status == 0) {
408 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
410 } elseif ($mode == 5) {
412 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
413 } elseif ($status == 0) {
414 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
416 } elseif ($mode == 6) {
418 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
419 } elseif ($status == 0) {
420 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
434 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
435 $sql .=
' fk_user_creat, fk_user_modif';
436 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
437 $sql .=
' WHERE t.rowid = '.((int) $id);
438 $result = $this->db->query($sql);
440 if ($this->db->num_rows($result)) {
441 $obj = $this->db->fetch_object($result);
443 $this->
id = $obj->rowid;
445 $this->user_creation_id = $obj->fk_user_creat;
446 $this->user_modification_id = $obj->fk_user_modif;
447 $this->date_creation = $this->db->jdate($obj->datec);
448 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
451 $this->db->free($result);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=0)
Create object in the database.
updateCommon(User $user, $notrigger=0)
Update object into database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Class to manage Dolibarr database access.
Class for EmailCollectorFilter.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
create(User $user, $notrigger=0)
Create object into database.
info($id)
Charge les information d'ordre info dans l'objet commande.
update(User $user, $notrigger=0)
Update object into database.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
LibStatut($status, $mode=0)
Return the status.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
getLibStatut($mode=0)
Return label of the status.
createFromClone(User $user, $fromid)
Clone and object into another one.
Class to manage Dolibarr users.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type