From 25a6be008a199bec10b4eeae055235d2296e946b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 23 Jan 2023 21:34:20 +0100 Subject: [PATCH 1/2] clean code emailcollectorfilter --- .../class/emailcollectorfilter.class.php | 27 +++---------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index cff80aa4153..327159f61a4 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -206,16 +206,14 @@ class EmailCollectorFilter extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // $object->title = $langs->trans("CopyOf")." ".$object->title; + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } @@ -252,26 +250,10 @@ class EmailCollectorFilter extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - if ($result > 0 && !empty($this->table_element_line)) { - $this->fetchLines(); - } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); - - // Load lines with object EmailcollectorFilterLine - - return count($this->lines)?1:0; - }*/ - /** * Update object into database * @@ -317,7 +299,6 @@ class EmailCollectorFilter extends CommonObject } $result = ''; - $companylink = ''; $label = ''.$langs->trans("EmailcollectorFilter").''; $label .= '
'; @@ -468,7 +449,7 @@ class EmailCollectorFilter extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); } From d08965c293ecee1409c4720e63bd6d19463d1afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 23 Jan 2023 21:42:09 +0100 Subject: [PATCH 2/2] Update emailcollectoraction.class.php --- .../class/emailcollectoraction.class.php | 60 ++----------------- 1 file changed, 4 insertions(+), 56 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index e43a86da515..5616abbbd35 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -24,8 +24,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for EmailCollectorAction @@ -113,37 +111,6 @@ class EmailCollectorAction extends CommonObject public $status; // END MODULEBUILDER PROPERTIES - - - // If this object has a subtable with lines - - // /** - // * @var string Name of subtable line - // */ - //public $table_element_line = 'emailcollectoractiondet'; - - // /** - // * @var string Field with ID of parent key if this field has a parent - // */ - //public $fk_element = 'fk_emailcollectoraction'; - - // /** - // * @var string Name of subtable class that manage subtable lines - // */ - //public $class_element_line = 'EmailcollectorActionline'; - - // /** - // * @var array List of child tables. To test if we can delete object. - // */ - //protected $childtables=array(); - - // /** - // * @var EmailcollectorActionLine[] Array of subtable lines - // */ - //public $lines = array(); - - - /** * Constructor * @@ -225,16 +192,14 @@ class EmailCollectorAction extends CommonObject // Clear fields $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... + // $object->title = $langs->trans("CopyOf")." ".$object->title; + // Clear extrafields that are unique if (is_array($object->array_options) && count($object->array_options) > 0) { $extrafields->fetch_name_optionals_label($this->table_element); foreach ($object->array_options as $key => $option) { $shortkey = preg_replace('/options_/', '', $key); if (!empty($extrafields->attributes[$this->element]['unique'][$shortkey])) { - //var_dump($key); - //var_dump($clonedObj->array_options[$key]); exit; unset($object->array_options[$key]); } } @@ -271,26 +236,10 @@ class EmailCollectorAction extends CommonObject public function fetch($id, $ref = null) { $result = $this->fetchCommon($id, $ref); - // if ($result > 0 && !empty($this->table_element_line)) { - // $this->fetchLinesCommon(); - // } + return $result; } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); - - // Load lines with object EmailcollectorActionLine - - return count($this->lines)?1:0; - }*/ - /** * Update object into database * @@ -336,7 +285,6 @@ class EmailCollectorAction extends CommonObject } $result = ''; - $companylink = ''; $label = ''.$langs->trans("EmailcollectorAction").''; $label .= '
'; @@ -487,7 +435,7 @@ class EmailCollectorAction extends CommonObject $this->user_creation_id = $obj->fk_user_creat; $this->user_modification_id = $obj->fk_user_modif; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem); }