26require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $element =
'emailcollectorfilter';
43 public $table_element =
'emailcollector_emailcollectorfilter';
48 public $ismultientitymanaged = 0;
53 public $isextrafieldmanaged = 0;
58 public $picto =
'emailcollectorfilter@emailcollector';
84 public $fields = array(
85 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'position'=>1,
'notnull'=>1,
'index'=>1,
'comment'=>
"Id",),
86 'fk_emailcollector' => array(
'type'=>
'integer',
'label'=>
'Id of emailcollector',
'foreignkey'=>
'emailcollector.rowid'),
87 'type' => array(
'type'=>
'varchar(128)',
'label'=>
'Type',
'enabled'=>1,
'visible'=>1,
'position'=>10,
'notnull'=>1,),
88 'rulevalue' => array(
'type'=>
'varchar(255)',
'label'=>
'ValueOfRule',
'enabled'=>1,
'visible'=>1,
'position'=>30,
'notnull'=>-1,
'help'=>
"Value of Rule",),
89 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-2,
'position'=>500,
'notnull'=>1,),
90 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>1,
'visible'=>-2,
'position'=>501,
'notnull'=>1,),
91 'fk_user_creat' => array(
'type'=>
'integer',
'label'=>
'UserAuthor',
'enabled'=>1,
'visible'=>-2,
'position'=>510,
'notnull'=>1,
'foreignkey'=>
'llx_user.rowid',),
92 'fk_user_modif' => array(
'type'=>
'integer',
'label'=>
'UserModif',
'enabled'=>1,
'visible'=>-2,
'position'=>511,
'notnull'=>-1,),
93 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>1,
'visible'=>-2,
'position'=>1000,
'notnull'=>-1,),
94 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'position'=>1000,
'notnull'=>1,
'default'=>1,
'arrayofkeyval'=>array(
'0'=>
'Disabled',
'1'=>
'Enabled')),
97 public $fk_emailcollector;
104 public $date_creation;
108 public $fk_user_creat;
109 public $fk_user_modif;
123 global $conf, $langs;
128 $this->fields[
'rowid'][
'visible'] = 0;
130 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
131 $this->fields[
'entity'][
'enabled'] = 0;
135 foreach ($this->fields as $key => $val) {
136 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
137 unset($this->fields[$key]);
142 foreach ($this->fields as $key => $val) {
143 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
144 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
145 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
162 if (empty($this->
type)) {
163 $langs->load(
"errors");
164 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Type"));
167 if (!in_array($this->
type, array(
'seen',
'unseen',
'unanswered',
'answered',
'withtrackingidinmsgid',
'withouttrackingidinmsgid',
'withtrackingid',
'withouttrackingid',
'isanswer',
'isnotanswer')) && empty($this->rulevalue)) {
168 $langs->load(
"errors");
169 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"SearchString"));
173 if (in_array($this->
type, array(
'to')) && strpos($this->rulevalue,
'+') !=
false) {
174 $langs->load(
"errors");
175 $this->errors[] = $langs->trans(
"ErrorCharPlusNotSupportedByImapForSearch");
191 global $langs, $hookmanager, $extrafields;
196 $object =
new self($this->db);
201 $object->fetchCommon($fromid);
204 unset($object->fk_user_creat);
205 unset($object->import_key);
208 $object->ref =
"copy_of_".$object->ref;
212 if (is_array($object->array_options) && count($object->array_options) > 0) {
213 $extrafields->fetch_name_optionals_label($this->table_element);
214 foreach ($object->array_options as $key => $option) {
215 $shortkey = preg_replace(
'/options_/',
'', $key);
216 if (!empty($extrafields->attributes[$this->element][
'unique'][$shortkey])) {
217 unset($object->array_options[$key]);
223 $object->context[
'createfromclone'] =
'createfromclone';
224 $result = $object->createCommon($user);
227 $this->error = $object->error;
228 $this->errors = $object->errors;
231 unset($object->context[
'createfromclone']);
238 $this->db->rollback();
250 public function fetch($id, $ref =
null)
276 public function delete(
User $user, $notrigger =
false)
291 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
293 global $db, $conf, $langs, $hookmanager;
294 global $dolibarr_main_authentication, $dolibarr_main_demo;
297 if (!empty($conf->dol_no_mouse_hover)) {
303 $label =
'<u>'.$langs->trans(
"EmailcollectorFilter").
'</u>';
305 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
307 $url =
dol_buildpath(
'/emailcollector/emailcollectorfilter_card.php', 1).
'?id='.$this->id;
309 if ($option !=
'nolink') {
311 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
312 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
313 $add_save_lastsearch_values = 1;
315 if ($add_save_lastsearch_values) {
316 $url .=
'&save_lastsearch_values=1';
321 if (empty($notooltip)) {
323 $label = $langs->trans(
"ShowEmailcollectorFilter");
324 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
326 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
327 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
336 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
339 $linkstart =
'<a href="'.$url.
'"';
340 $linkstart .= $linkclose.
'>';
343 $result .= $linkstart;
345 $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);
347 if ($withpicto != 2) {
348 $result .= $this->ref;
353 global $action, $hookmanager;
354 $hookmanager->initHooks(array(
'emailcollectorfilterdao'));
355 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
356 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
358 $result = $hookmanager->resPrint;
360 $result .= $hookmanager->resPrint;
388 if (empty($this->labelStatus)) {
391 $this->labelStatus[1] = $langs->trans(
'Enabled');
392 $this->labelStatus[0] = $langs->trans(
'Disabled');
396 return $this->labelStatus[$status];
397 } elseif ($mode == 1) {
398 return $this->labelStatus[$status];
399 } elseif ($mode == 2) {
401 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
402 } elseif ($status == 0) {
403 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
405 } elseif ($mode == 3) {
407 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
408 } elseif ($status == 0) {
409 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
411 } elseif ($mode == 4) {
413 return img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
414 } elseif ($status == 0) {
415 return img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle').
' '.$this->labelStatus[$status];
417 } elseif ($mode == 5) {
419 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
420 } elseif ($status == 0) {
421 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
423 } elseif ($mode == 6) {
425 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut4',
'',
false, 0, 0,
'',
'valignmiddle');
426 } elseif ($status == 0) {
427 return $this->labelStatus[$status].
' '.
img_picto($this->labelStatus[$status],
'statut5',
'',
false, 0, 0,
'',
'valignmiddle');
441 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
442 $sql .=
' fk_user_creat, fk_user_modif';
443 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
444 $sql .=
' WHERE t.rowid = '.((int) $id);
445 $result = $this->db->query($sql);
447 if ($this->db->num_rows($result)) {
448 $obj = $this->db->fetch_object($result);
450 $this->
id = $obj->rowid;
452 $this->user_creation_id = $obj->fk_user_creat;
453 $this->user_modification_id = $obj->fk_user_modif;
454 $this->date_creation = $this->db->jdate($obj->datec);
455 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
458 $this->db->free($result);
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Parent class of all other business classes (invoices, contracts, proposals, orders,...
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
Class to manage Dolibarr database access.
Class for EmailCollectorFilter.
create(User $user, $notrigger=false)
Create object into database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
info($id)
Charge les informations d'ordre info dans l'objet commande.
__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 optionaly the picto)
getLibStatut($mode=0)
Return label of the status.
createFromClone(User $user, $fromid)
Clone and object into another one.
update(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr users.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $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.
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