From cc8af7b1d0361f790b1fc79b094d312ec887501b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 10 Feb 2022 09:19:14 +0100 Subject: [PATCH] FIX not active value are not hidden (missing filter of field) (#20032) * FIX not active value are not hidden (missing filter of field) * FIX wrong category table and wrong object id --- htdocs/core/class/html.form.class.php | 6 +++++- .../class/knowledgerecord.class.php | 4 ++-- htdocs/knowledgemanagement/knowledgerecord_card.php | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3375e9f7cc4..09225f97158 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7379,7 +7379,11 @@ class Form $objecttmp = null; - $InfoFieldList = explode(":", $objectdesc); + $InfoFieldList = explode(":", $objectdesc, 4); + $vartmp = $InfoFieldList[3]; + $InfoFieldList[4] = preg_replace('/^.*:(\w*)$/', '\1', $vartmp); // take the sort field + $InfoFieldList[3] = preg_replace('/:\w*$/', '', $vartmp); // take the filter field + $classname = $InfoFieldList[0]; $classpath = $InfoFieldList[1]; $addcreatebuttonornot = empty($InfoFieldList[2]) ? 0 : $InfoFieldList[2]; diff --git a/htdocs/knowledgemanagement/class/knowledgerecord.class.php b/htdocs/knowledgemanagement/class/knowledgerecord.class.php index b241cb2d9e9..8b1635273cd 100644 --- a/htdocs/knowledgemanagement/class/knowledgerecord.class.php +++ b/htdocs/knowledgemanagement/class/knowledgerecord.class.php @@ -115,7 +115,7 @@ class KnowledgeRecord extends CommonObject 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,), 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,), //'url' => array('type'=>'varchar(255)', 'label'=>'URL', 'enabled'=>'1', 'position'=>55, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflow200', 'help'=>'UrlForInfoPage'), - 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php:0::pos', 'label'=>'SuggestedForTicketsInGroup', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory', 'csslist'=>'minwidth200 tdoverflowmax250'), + 'fk_c_ticket_category' => array('type'=>'integer:CTicketCategory:ticket/class/cticketcategory.class.php:0:(t.active:=:1):pos', 'label'=>'SuggestedForTicketsInGroup', 'enabled'=>'$conf->ticket->enabled', 'position'=>512, 'notnull'=>0, 'visible'=>-1, 'help'=>'YouCanLinkArticleToATicketCategory', 'csslist'=>'minwidth200 tdoverflowmax250'), 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>1, 'visible'=>5, 'default'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '9'=>'Obsolete'),), ); public $rowid; @@ -459,7 +459,7 @@ class KnowledgeRecord extends CommonObject public function delete(User $user, $notrigger = false) { $error = 0; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_member WHERE fk_member = ".((int) $this->rowid); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement WHERE fk_knowledgemanagement = ".((int) $this->id); dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/knowledgemanagement/knowledgerecord_card.php b/htdocs/knowledgemanagement/knowledgerecord_card.php index a388175dbcf..2fcf05a4393 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_card.php +++ b/htdocs/knowledgemanagement/knowledgerecord_card.php @@ -175,10 +175,10 @@ if ($action == 'create') { print '
'; print ''; print ''; - if ($backtopage) { + if (!empty($backtopage)) { print ''; } - if ($backtopageforcancel) { + if (!empty($backtopageforcancel)) { print ''; } @@ -192,7 +192,7 @@ if ($action == 'create') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_add.tpl.php'; - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 1); if (count($cate_arbo)) { @@ -225,10 +225,10 @@ if (($id || $ref) && $action == 'edit') { print ''; print ''; print ''; - if ($backtopage) { + if (!empty($backtopage)) { print ''; } - if ($backtopageforcancel) { + if (!empty($backtopageforcancel)) { print ''; } @@ -239,7 +239,7 @@ if (($id || $ref) && $action == 'edit') { // Common attributes include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_edit.tpl.php'; - if ($conf->categorie->enabled) { + if (!empty($conf->categorie->enabled)) { $cate_arbo = $form->select_all_categories(Categorie::TYPE_KNOWLEDGEMANAGEMENT, '', 'parent', 64, 0, 1); if (count($cate_arbo)) {