From cbb41b612655274a16b0274feb752f84d1e370e2 Mon Sep 17 00:00:00 2001 From: Guillaume Heurtier <guillaume.heurtier@maarch.org> Date: Wed, 2 Oct 2019 11:10:33 +0200 Subject: [PATCH] FEAT #11271 TIME 1:30 categories are now hardcoded - no longer loaded from xml --- .../class_business_app_tools_Abstract.php | 23 ++++------- src/app/resource/models/ResModelAbstract.php | 39 +++++++++---------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php index b65a673fb14..4ea3bbb9d92 100755 --- a/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php +++ b/apps/maarch_entreprise/class/class_business_app_tools_Abstract.php @@ -181,21 +181,14 @@ abstract class business_app_tools_Abstract extends Database 'script_details' => (string) $col->script_details, 'extensions' => $tab, ); - - $categories = $col->categories; - - if (count($categories) > 0) { - foreach ($categories->category as $cat) { - $label = (string) $cat->label; - if (!empty($label) && defined($label) - && constant($label) <> NULL - ) { - $label = constant($label); - } - $_SESSION['coll_categories'][$collId][(string) $cat->id] = $label; - } - $_SESSION['coll_categories'][$collId]['default_category'] = (string) $categories->default_category; - } + + $_SESSION['coll_categories']['letterbox_coll'] = [ + 'incoming' => defined('_INCOMING') ? _INCOMING : '_INCOMING', + 'outgoing' => defined('_OUTGOING') ? _OUTGOING : '_OUTGOING', + 'internal' => defined('_INTERNAL') ? _INTERNAL : '_INTERNAL', + 'ged_doc' => defined('_GED_DOC') ? _GED_DOC : '_GED_DOC' + ]; + $i++; } else { $_SESSION['collections'][$i] = array( diff --git a/src/app/resource/models/ResModelAbstract.php b/src/app/resource/models/ResModelAbstract.php index 12254f62d1b..b1ae8d678d9 100755 --- a/src/app/resource/models/ResModelAbstract.php +++ b/src/app/resource/models/ResModelAbstract.php @@ -300,26 +300,25 @@ abstract class ResModelAbstract return $categories; } - $categories = []; - - $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/config.xml']); - if ($loadedXml) { - foreach ($loadedXml->COLLECTION as $collection) { - $collection = (array)$collection; - - if ($collection['id'] == 'letterbox_coll') { - foreach ($collection['categories']->category as $category) { - $category = (array)$category; - - $categories[] = [ - 'id' => $category['id'], - 'label' => defined($category['label']) ? constant($category['label']) : $category['label'], - 'defaultCategory' => $category['id'] == $collection['categories']->default_category - ]; - } - } - } - } + $categories = [ + [ + 'id' => 'incoming', + 'label' => defined('_INCOMING') ? _INCOMING : '_INCOMING', + 'defaultCategory' => true + ], [ + 'id' => 'outgoing', + 'label' => defined('_OUTGOING') ? _OUTGOING : '_OUTGOING', + 'defaultCategory' => false + ], [ + 'id' => 'internal', + 'label' => defined('_INTERNAL') ? _INTERNAL : '_INTERNAL', + 'defaultCategory' => false + ], [ + 'id' => 'ged_doc', + 'label' => defined('_GED_DOC') ? _GED_DOC : '_GED_DOC', + 'defaultCategory' => false + ] + ]; return $categories; } -- GitLab