diff --git a/src/app/action/models/ActionModelAbstract.php b/src/app/action/models/ActionModelAbstract.php index 78c849eaba916d84476bad93eb7a4f5ae04ce79a..4282f48977957b541088192463abff1bc8656c8f 100644 --- a/src/app/action/models/ActionModelAbstract.php +++ b/src/app/action/models/ActionModelAbstract.php @@ -150,21 +150,12 @@ class ActionModelAbstract public static function getAction_pages() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists('custom/' .$customId. '/core/xml/actions_pages.xml')) { - $path = 'custom/' .$customId. '/core/xml/actions_pages.xml'; - } else { - $path = 'core/xml/actions_pages.xml'; - } - $tabActions_pages = []; $tabActions_pages['modules'][] = 'Apps'; - $xmlfile = simplexml_load_file($path); - - if (count($xmlfile) > 0) { - foreach ($xmlfile->ACTIONPAGE as $actionPage) { + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'core/xml/actions_pages.xml']); + if ($loadedXml) { + foreach ($loadedXml->ACTIONPAGE as $actionPage) { if (!defined((string) $actionPage->LABEL)) { $label = $actionPage->LABEL; } else { @@ -201,6 +192,7 @@ class ActionModelAbstract $tabActions_pages['modules'] = array_unique($tabActions_pages['modules']); sort($tabActions_pages['modules']); + return $tabActions_pages; } diff --git a/src/app/attachment/models/AttachmentModelAbstract.php b/src/app/attachment/models/AttachmentModelAbstract.php index 953380669bc1b2723f83cb10961127f75305e405..78a62d43b3536a65256c464a1f3c1bbf97053d74 100644 --- a/src/app/attachment/models/AttachmentModelAbstract.php +++ b/src/app/attachment/models/AttachmentModelAbstract.php @@ -81,25 +81,20 @@ class AttachmentModelAbstract public static function getAttachmentsTypesByXML() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/entreprise.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/entreprise.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/entreprise.xml'; - } - - $xmlfile = simplexml_load_file($path); $attachmentTypes = []; - $attachmentTypesXML = $xmlfile->attachment_types; - if (count($attachmentTypesXML) > 0) { - foreach ($attachmentTypesXML->type as $value) { - $label = defined((string) $value->label) ? constant((string) $value->label) : (string) $value->label; - $attachmentTypes[(string) $value->id] = [ - 'label' => $label, - 'icon' => (string)$value['icon'], - 'sign' => (empty($value['sign']) || (string)$value['sign'] == 'true') ? true : false - ]; + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/entreprise.xml']); + if ($loadedXml) { + $attachmentTypesXML = $loadedXml->attachment_types; + if (count($attachmentTypesXML) > 0) { + foreach ($attachmentTypesXML->type as $value) { + $label = defined((string) $value->label) ? constant((string) $value->label) : (string) $value->label; + $attachmentTypes[(string) $value->id] = [ + 'label' => $label, + 'icon' => (string)$value['icon'], + 'sign' => (empty($value['sign']) || (string)$value['sign'] == 'true') ? true : false + ]; + } } } diff --git a/src/app/basket/models/BasketModelAbstract.php b/src/app/basket/models/BasketModelAbstract.php index 4007841ef4ad6eec052c7b9b9cc00bc3a896e9ce..18cd388b930e1f3938c82051fad2456648d379cd 100644 --- a/src/app/basket/models/BasketModelAbstract.php +++ b/src/app/basket/models/BasketModelAbstract.php @@ -531,25 +531,17 @@ class BasketModelAbstract { ValidatorModel::arrayType($aArgs, ['unneeded']); - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/modules/basket/xml/basketpage.xml")) { - $path = "custom/{$customId}/modules/basket/xml/basketpage.xml"; - } else { - $path = 'modules/basket/xml/basketpage.xml'; - } - $basketPages = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); - if ($loadedXml) { - foreach ($loadedXml->BASKETPAGE as $value) { - if (empty($aArgs['unneeded']) || !in_array((string)$value->ID, $aArgs['unneeded'])) { - $basketPages[] = [ - 'id' => (string)$value->ID, - 'label' => constant((string)$value->LABEL), - 'name' => (string)$value->NAME - ]; - } + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/basket/xml/basketpage.xml']); + if ($loadedXml) { + foreach ($loadedXml->BASKETPAGE as $value) { + if (empty($aArgs['unneeded']) || !in_array((string)$value->ID, $aArgs['unneeded'])) { + $basketPages[] = [ + 'id' => (string)$value->ID, + 'label' => constant((string)$value->LABEL), + 'name' => (string)$value->NAME + ]; } } } diff --git a/src/app/doctype/models/DoctypeIndexesModelAbstract.php b/src/app/doctype/models/DoctypeIndexesModelAbstract.php index dfa25ad151ad7e53d0f7a0bb06cdf84243b7500d..cead9f1e02c7ed8acefb23486b6b7a4e44937f59 100644 --- a/src/app/doctype/models/DoctypeIndexesModelAbstract.php +++ b/src/app/doctype/models/DoctypeIndexesModelAbstract.php @@ -41,104 +41,94 @@ class DoctypeIndexesModelAbstract public static function getAllIndexes() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists('custom/' .$customId. '/apps/maarch_entreprise/xml/index_letterbox.xml')) { - $path = 'custom/' .$customId. '/apps/maarch_entreprise/xml/index_letterbox.xml'; - } else { - $path = 'apps/maarch_entreprise/xml/index_letterbox.xml'; - } - - $xmlfile = simplexml_load_file($path); - - $indexes = array(); - foreach ($xmlfile->INDEX as $item) { - $label = (string) $item->label; - if (!empty($label) && defined($label) && constant($label) <> null) { - $label = constant($label); - } - $img = (string) $item->img; - if (!empty($item->default_value)) { - $default = (string) $item->default_value; - if (!empty($default) && defined($default) && constant($default) <> null) { - $default = constant($default); + $indexes = []; + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/index_letterbox.xml']); + if ($loadedXml) { + foreach ($loadedXml->INDEX as $item) { + $label = (string) $item->label; + if (!empty($label) && defined($label) && constant($label) <> null) { + $label = constant($label); } - } else { - $default = false; - } - if (isset($item->values_list)) { - $values = array(); - $list = $item->values_list; - foreach ($list->value as $val) { - $labelVal = (string) $val->label; - if (!empty($labelVal) && defined($labelVal) && constant($labelVal) <> null) { - $labelVal = constant($labelVal); + $img = (string) $item->img; + if (!empty($item->default_value)) { + $default = (string) $item->default_value; + if (!empty($default) && defined($default) && constant($default) <> null) { + $default = constant($default); } - - array_push( - $values, - array( - 'id' => (string) $val->id, - 'label' => $labelVal, - ) - ); + } else { + $default = false; } - $tmpArr = array( - 'column' => (string) $item->column, - 'label' => $label, - 'type' => (string) $item->type, - 'img' => $img, - 'type_field' => 'select', - 'values' => $values, - 'default_value' => $default - ); - } elseif (isset($item->table)) { - $values = array(); - $tableXml = $item->table; - $tableName = (string) $tableXml->table_name; - $foreignKey = (string) $tableXml->foreign_key; - $foreignLabel = (string) $tableXml->foreign_label; - $whereClause = (string) $tableXml->where_clause; - $order = (string) $tableXml->order; - - - $res = DatabaseModel::select([ - 'select' => [$foreignKey, $foreignLabel], - 'table' => [$tableName], - 'where' => [$whereClause], - 'order_by' => [str_ireplace("order by", "", $order)] - ]); - - foreach ($res as $value) { - array_push( - $values, - array( + if (isset($item->values_list)) { + $values = []; + $list = $item->values_list; + foreach ($list->value as $val) { + $labelVal = (string) $val->label; + if (!empty($labelVal) && defined($labelVal) && constant($labelVal) <> null) { + $labelVal = constant($labelVal); + } + + $values[] = [ + 'id' => (string) $val->id, + 'label' => $labelVal + ]; + } + $tmpArr = [ + 'column' => (string) $item->column, + 'label' => $label, + 'type' => (string) $item->type, + 'img' => $img, + 'type_field' => 'select', + 'values' => $values, + 'default_value' => $default + ]; + } elseif (isset($item->table)) { + $values = []; + $tableXml = $item->table; + $tableName = (string) $tableXml->table_name; + $foreignKey = (string) $tableXml->foreign_key; + $foreignLabel = (string) $tableXml->foreign_label; + $whereClause = (string) $tableXml->where_clause; + $order = (string) $tableXml->order; + + + $res = DatabaseModel::select([ + 'select' => [$foreignKey, $foreignLabel], + 'table' => [$tableName], + 'where' => [$whereClause], + 'order_by' => [str_ireplace("order by", "", $order)] + ]); + + foreach ($res as $value) { + $values[] = [ 'id' => (string) $value[0], - 'label' => (string) $value[1], - ) - ); + 'label' => (string) $value[1] + ]; + } + + $tmpArr = [ + 'column' => (string) $item->column, + 'label' => $label, + 'type' => (string) $item->type, + 'img' => $img, + 'type_field' => 'select', + 'values' => $values, + 'default_value' => $default + ]; + } else { + $tmpArr = [ + 'column' => (string) $item->column, + 'label' => $label, + 'type' => (string) $item->type, + 'img' => $img, + 'type_field' => 'input', + 'default_value' => $default + ]; } - $tmpArr = array( - 'column' => (string) $item->column, - 'label' => $label, - 'type' => (string) $item->type, - 'img' => $img, - 'type_field' => 'select', - 'values' => $values, - 'default_value' => $default, - ); - } else { - $tmpArr = array( - 'column' => (string) $item->column, - 'label' => $label, - 'type' => (string) $item->type, - 'img' => $img, - 'type_field' => 'input', - 'default_value' => $default, - ); + array_push($indexes, $tmpArr); } - array_push($indexes, $tmpArr); } + return $indexes; } diff --git a/src/app/doctype/models/DoctypeModelAbstract.php b/src/app/doctype/models/DoctypeModelAbstract.php index 0afdc14bbf84daea25086ae38adb724627cc2707..f45b3156584f4d39dff799964970f8151fb29e20 100644 --- a/src/app/doctype/models/DoctypeModelAbstract.php +++ b/src/app/doctype/models/DoctypeModelAbstract.php @@ -116,25 +116,17 @@ class DoctypeModelAbstract public static function getProcessMode() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists('custom/' .$customId. '/apps/maarch_entreprise/xml/entreprise.xml')) { - $path = 'custom/' .$customId. '/apps/maarch_entreprise/xml/entreprise.xml'; - } else { - $path = 'apps/maarch_entreprise/xml/entreprise.xml'; - } - - $xmlfile = simplexml_load_file($path); - - $return['processing_modes'] = array(); - $return['process_mode_priority'] = array(); - $processingModes = $xmlfile->process_modes; - - if (count($processingModes) > 0) { - foreach ($processingModes->process_mode as $process) { - $label = (string) $process->label; - $return['processing_modes'][] = $label; - $return['process_mode_priority'][] = (string) $process->process_mode_priority; + $return['processing_modes'] = []; + $return['process_mode_priority'] = []; + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/entreprise.xml']); + if ($loadedXml) { + $processingModes = $loadedXml->process_modes; + if (count($processingModes) > 0) { + foreach ($processingModes->process_mode as $process) { + $return['processing_modes'][] = (string) $process->label; + $return['process_mode_priority'][] = (string) $process->process_mode_priority; + } } } diff --git a/src/app/entity/controllers/ListTemplateController.php b/src/app/entity/controllers/ListTemplateController.php index 185e13c69b221f76c8d7b5e0d92dc00725e741ef..e0f08aa2aa4a062b6aef995d5b71bbde8b8650ff 100644 --- a/src/app/entity/controllers/ListTemplateController.php +++ b/src/app/entity/controllers/ListTemplateController.php @@ -307,7 +307,8 @@ class ListTemplateController $roles[$key]['usedIn'] = []; $listTemplates = ListTemplateModel::get(['select' => ['object_id'], 'where' => ['object_type = ?', 'item_mode = ?'], 'data' => [$aArgs['typeId'], $roles[$key]['id']]]); foreach ($listTemplates as $listTemplate) { - $roles[$key]['usedIn'][] = $listTemplate['object_id']; + $entity = EntityModel::getById(['select' => ['short_label'], 'entityId' => $listTemplate['object_id']]); + $roles[$key]['usedIn'][] = $entity['short_label']; } } diff --git a/src/app/entity/models/EntityModelAbstract.php b/src/app/entity/models/EntityModelAbstract.php index 2dfd8dd00d75ab0a22d34e2d2b40b0111d133655..ca0a5d195d016ed29633c40b3020e8658d46be1f 100644 --- a/src/app/entity/models/EntityModelAbstract.php +++ b/src/app/entity/models/EntityModelAbstract.php @@ -340,25 +340,16 @@ class EntityModelAbstract public static function getTypes() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/modules/entities/xml/typentity.xml")) { - $path = "custom/{$customId}/modules/entities/xml/typentity.xml"; - } else { - $path = 'modules/entities/xml/typentity.xml'; - } - $types = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); - if ($loadedXml) { - foreach ($loadedXml->TYPE as $value) { - $types[] = [ - 'id' => (string)$value->id, - 'label' => (string)$value->label, - 'typelevel' => (string)$value->typelevel - ]; - } + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/entities/xml/typentity.xml']); + if ($loadedXml) { + foreach ($loadedXml->TYPE as $value) { + $types[] = [ + 'id' => (string)$value->id, + 'label' => (string)$value->label, + 'typelevel' => (string)$value->typelevel + ]; } } @@ -367,24 +358,15 @@ class EntityModelAbstract public static function getRoles() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/modules/entities/xml/roles.xml")) { - $path = "custom/{$customId}/modules/entities/xml/roles.xml"; - } else { - $path = 'modules/entities/xml/roles.xml'; - } - $roles = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); - if ($loadedXml) { - foreach ($loadedXml->ROLES->ROLE as $value) { - $roles[] = [ - 'id' => (string)$value->id, - 'label' => constant((string)$value->label), - ]; - } + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/entities/xml/roles.xml']); + if ($loadedXml) { + foreach ($loadedXml->ROLES->ROLE as $value) { + $roles[] = [ + 'id' => (string)$value->id, + 'label' => constant((string)$value->label), + ]; } } diff --git a/src/app/group/models/ServiceModelAbstract.php b/src/app/group/models/ServiceModelAbstract.php index a7667d0b5654d494b85ae9ba8b8fcde849af03d6..da7983cf5a77034abff4e021d57772dee245ea45 100644 --- a/src/app/group/models/ServiceModelAbstract.php +++ b/src/app/group/models/ServiceModelAbstract.php @@ -7,8 +7,7 @@ */ /** - * @brief Service Model - * + * @brief Service Model Abstract * @author dev@maarch.org */ @@ -43,15 +42,9 @@ class ServiceModelAbstract } } - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/config.xml'; - } + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/config.xml']); - $xmlfile = simplexml_load_file($path); - foreach ($xmlfile->MODULES as $mod) { + foreach ($loadedXml->MODULES as $mod) { $module = (string) $mod->moduleid; $xmlModuleFile = ServiceModel::getLoadedXml(['location' => $module]); @@ -132,18 +125,10 @@ class ServiceModelAbstract public static function getModulesAdministrationServicesByXML() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/config.xml'; - } - $modulesServices = []; - $xmlfile = simplexml_load_file($path); - foreach ($xmlfile->MODULES as $mod) { + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/config.xml']); + foreach ($loadedXml->MODULES as $mod) { $module = (string) $mod->moduleid; $xmlModuleFile = ServiceModel::getLoadedXml(['location' => $module]); @@ -168,23 +153,15 @@ class ServiceModelAbstract return $modulesServices; } - public static function getModulesAdministrationServicesByUserServices(array $aArgs = []) + public static function getModulesAdministrationServicesByUserServices(array $aArgs) { ValidatorModel::notEmpty($aArgs, ['userServices']); ValidatorModel::arrayType($aArgs, ['userServices']); - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/config.xml'; - } - $modulesServices = []; - $xmlfile = simplexml_load_file($path); - foreach ($xmlfile->MODULES as $mod) { + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/config.xml']); + foreach ($loadedXml->MODULES as $mod) { $module = (string) $mod->moduleid; $xmlModuleFile = ServiceModel::getLoadedXml(['location' => $module]); @@ -211,18 +188,10 @@ class ServiceModelAbstract public static function getApplicationAdministrationMenuByXML() { - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/menu.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/menu.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/menu.xml'; - } - $modulesServices = []; - $xmlfile = simplexml_load_file($path); - foreach ($xmlfile->MENU as $value) { + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/menu.xml']); + foreach ($loadedXml->MENU as $value) { $label = defined((string) $value->libconst) ? constant((string) $value->libconst) : (string) $value->libconst; $modulesServices['menuList'][] = [ @@ -233,6 +202,8 @@ class ServiceModelAbstract 'angular' => empty((string) $value->angular) ? 'false' : (string) $value->angular, ]; } + + $customId = CoreConfigModel::getCustomId(); if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; } else { diff --git a/src/app/notification/models/NotificationModelAbstract.php b/src/app/notification/models/NotificationModelAbstract.php index 28b650c84ae60c1c428ea1ec3ac814b8b96aa62e..d73cd785bb4cd8124bc0648507561364629af8fd 100644 --- a/src/app/notification/models/NotificationModelAbstract.php +++ b/src/app/notification/models/NotificationModelAbstract.php @@ -137,21 +137,13 @@ class NotificationModelAbstract 'table' => ['actions'], ]); - //get event system - $customId = CoreConfigModel::getCustomId(); - - if (file_exists('custom/'.$customId.'modules/notifications/xml/event_type.xml')) { - $path = 'custom/'.$customId.'modules/notifications/xml/event_type.xml'; - } else { - $path = 'modules/notifications/xml/event_type.xml'; - } - $xmlfile = simplexml_load_file($path); - if ($xmlfile) { - foreach ($xmlfile->event_type as $eventType) { - $tabEvent_Type[] = array( - 'id' => (string) $eventType->id, - 'label_action' => (string) $eventType->label, - ); + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/notifications/xml/event_type.xml']); + if ($loadedXml) { + foreach ($loadedXml->event_type as $eventType) { + $tabEvent_Type[] = [ + 'id' => (string) $eventType->id, + 'label_action' => (string) $eventType->label + ]; } } @@ -172,123 +164,57 @@ class NotificationModelAbstract public static function getDiffusionType() { - // // $customId = CoreConfigModel::getCustomId(); - - // // if (file_exists('custom/' .$customId. 'modules/notifications/xml/event_type.xml')) { - // // $path = 'custom/' .$customId. 'modules/notifications/xml/event_type.xml'; - // // } else { - // $path = 'modules/notifications/xml/diffusion_type.xml'; - // // } - // $xmlfile = simplexml_load_file($path); - // if ($xmlfile) { - // foreach ($xmlfile->diffusion_type as $diffusionType) { - // $result = []; - // if((string)$diffusionType->select){ - // if((string)$diffusionType->where){ - // $result = DatabaseModel::select([ - // 'select' => [(string)$diffusionType->select], - // 'table' => [(string)$diffusionType->from], - // 'where' => [(string)$diffusionType->where], - // 'data' => [(string)$diffusionType->data] - // ]); - // }else{ - // $result = DatabaseModel::select([ - // 'select' => [(string)$diffusionType->select], - // 'table' => [(string)$diffusionType->from], - // ]); - // } - // } - - // $tabDiffusion_Type[] = array( - // 'id' => (string) $diffusionType->id, - // 'label' => constant((string)$diffusionType->label), - // 'add_attachment' => (string)$diffusionType->add_attachment, - // 'script' => (string)$diffusionType->script, - // 'request' => $result, - // ); - - // } - // } - // $result = DatabaseModel::select([ - // 'select' => ['group_id as id, group_desc as label'], - // 'table' => ['usergroups'], - // 'where' => ['enabled = ?'], - // 'data' => ['Y'] - // ]); - $tabDiffusion_Type[] = array( + $diffusionTypes = []; + + $diffusionTypes[] = array( 'id' => 'group', 'label' => 'Groupe', 'add_attachment' => 'true', - //'request' => $result, ); - // $result = DatabaseModel::select([ - // 'select' => ['entity_id as id, entity_label as label'], - // 'table' => ['entities'], - // 'where' => ['enabled = ?'], - // 'data' => ['Y'] - // ]); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'entity', 'label' => 'Entité', 'add_attachment' => 'true', - //'request' => $result ); - // $result = DatabaseModel::select([ - // 'select' => ['id, label_status as label'], - // 'table' => ['status'] - // ]); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'dest_entity', 'label' => 'Service de l\'utilisateur destinataire', 'add_attachment' => 'false', - //'request' => $result ); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'dest_user', 'label' => 'Liste de diffusion du document', 'add_attachment' => 'false', - //'request' => $result ); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'dest_user_visa', 'label' => 'Viseur actuel du document', 'add_attachment' => 'true', - //'request' => $result ); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'dest_user_sign', 'label' => 'Signataire actuel du document', 'add_attachment' => 'true', - //'request' => $result ); - // $result = DatabaseModel::select([ - // 'select' => ["user_id as id, concat(firstname,' ',lastname) as label"], - // 'table' => ['users'] - // ]); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'user', 'label' => 'Utilisateur désigné', 'add_attachment' => 'true', - //'request' => $result ); - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'copy_list', 'label' => 'Liste de diffusion du document', 'add_attachment' => 'false', - //'request' => $result ); - $result = []; - - $tabDiffusion_Type[] = array( + $diffusionTypes[] = array( 'id' => 'contact', 'label' => 'Contact du document', - 'add_attachment' => 'true', - //'request' => $result + 'add_attachment' => 'true' ); - return $tabDiffusion_Type; + return $diffusionTypes; } public static function getDiffusionTypeGroups() diff --git a/src/app/report/models/ReportModelAbstract.php b/src/app/report/models/ReportModelAbstract.php index 0b044a6cdc483fd45e2cc293cb27d44903366d76..02945d4dc6b38f5efb3fc3b4318243c7f97ad0b0 100644 --- a/src/app/report/models/ReportModelAbstract.php +++ b/src/app/report/models/ReportModelAbstract.php @@ -25,18 +25,11 @@ class ReportModelAbstract ValidatorModel::notEmpty($aArgs, ['groupId']); ValidatorModel::stringType($aArgs, ['groupId']); - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/modules/reports/xml/reports.xml")) { - $path = "custom/{$customId}/modules/reports/xml/reports.xml"; - } else { - $path = 'modules/reports/xml/reports.xml'; - } - $reports = []; - $xmlfile = simplexml_load_file($path); - if ($xmlfile) { - foreach ($xmlfile->REPORT as $value) { + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'modules/reports/xml/reports.xml']); + if ($loadedXml) { + foreach ($loadedXml->REPORT as $value) { if ((string)$value->ENABLED == "true") { $reports[] = [ 'id' => (string)$value->ID, diff --git a/src/app/resource/models/ChronoModel.php b/src/app/resource/models/ChronoModel.php index ab31a00abdb65eea3a62f6c9cb50db1324d0cdef..5f2e691b25da88f1786868baa256bbd479d9d3eb 100644 --- a/src/app/resource/models/ChronoModel.php +++ b/src/app/resource/models/ChronoModel.php @@ -10,14 +10,11 @@ /** * @brief Chrono Model * @author dev@maarch.org - * @ingroup core */ namespace SrcCore\models; use Parameter\models\ParameterModel; -use SrcCore\models\CoreConfigModel; -use SrcCore\models\ValidatorModel; class ChronoModel { @@ -27,17 +24,10 @@ class ChronoModel ValidatorModel::stringType($aArgs, ['id', 'entityId']); ValidatorModel::intVal($aArgs, ['typeId', 'resId']); - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/chrono.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/chrono.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/chrono.xml'; - } - $elements = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/chrono.xml']); + if ($loadedXml) { foreach ($loadedXml->CHRONO as $chrono) { if ($chrono->id == $aArgs['id']) { $separator = (string)$chrono->separator; diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 535944ff5a00d6e6ae0b3d3158298abcf68e5bbc..b5205479c93147aa0485874a77afdbccb238e25b 100644 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -397,19 +397,11 @@ class UserController $type = explode('/', $mimeType); $ext = strtoupper(substr($data['name'], strrpos($data['name'], '.') + 1)); - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/extensions.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/extensions.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/extensions.xml'; - } - - $xmlfile = simplexml_load_file($path); - $fileAccepted = false; - if (count($xmlfile->FORMAT) > 0) { - foreach ($xmlfile->FORMAT as $value) { + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/extensions.xml']); + if ($loadedXml && count($loadedXml->FORMAT) > 0) { + foreach ($loadedXml->FORMAT as $value) { if (strtoupper($value->name) == $ext && strtoupper($value->mime) == strtoupper($mimeType)) { $fileAccepted = true; break; diff --git a/src/core/controllers/LogsController.php b/src/core/controllers/LogsController.php index 0878e0cef2b337254cca9114308a221d87397f58..373b6151ccbfd5abf21817d28b18f09ad145c77e 100644 --- a/src/core/controllers/LogsController.php +++ b/src/core/controllers/LogsController.php @@ -46,27 +46,17 @@ class LogsController { $loggingMethods = []; - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/logging_method.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/logging_method.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/logging_method.xml'; - } - - if (file_exists($path)) { - $xmlConfig = simplexml_load_file($path); - - if ($xmlConfig) { - foreach ($xmlConfig->METHOD as $METHOD) { - $loggingMethods[] = [ - 'ID' => (string)$METHOD->ID, - 'ACTIVATED' => (boolean)$METHOD->ENABLED, - 'LOGGER_NAME_TECH' => (string)$METHOD->LOGGER_NAME_TECH, - 'LOGGER_NAME_FUNC' => (string)$METHOD->LOGGER_NAME_FUNC, - 'LOG_FORMAT' => (string)$METHOD->APPLI_LOG_FORMAT, - 'CODE_METIER' => (string)$METHOD->CODE_METIER - ]; - } + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/logging_method.xml']); + if ($loadedXml) { + foreach ($loadedXml->METHOD as $METHOD) { + $loggingMethods[] = [ + 'ID' => (string)$METHOD->ID, + 'ACTIVATED' => (boolean)$METHOD->ENABLED, + 'LOGGER_NAME_TECH' => (string)$METHOD->LOGGER_NAME_TECH, + 'LOGGER_NAME_FUNC' => (string)$METHOD->LOGGER_NAME_FUNC, + 'LOG_FORMAT' => (string)$METHOD->APPLI_LOG_FORMAT, + 'CODE_METIER' => (string)$METHOD->CODE_METIER + ]; } } else { $loggingMethods[0]['ID'] = 'database'; diff --git a/src/core/models/CurlModel.php b/src/core/models/CurlModel.php index b7863338f5b5b1b0b025cd2a96dedff28f9f180a..c80f96939ae74ade9e09cab17683dd07858ef1bf 100644 --- a/src/core/models/CurlModel.php +++ b/src/core/models/CurlModel.php @@ -69,17 +69,10 @@ class CurlModel ValidatorModel::notEmpty($aArgs, ['curlCallId']); ValidatorModel::stringType($aArgs, ['curlCallId']); - $customId = CoreConfigModel::getCustomId(); - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/curlCall.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/curlCall.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/curlCall.xml'; - } - $curlConfig = []; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/curlCall.xml']); + if ($loadedXml) { $curlConfig['user'] = (string)$loadedXml->user; $curlConfig['password'] = (string)$loadedXml->password; foreach ($loadedXml->call as $call) { diff --git a/src/core/models/SecurityModel.php b/src/core/models/SecurityModel.php index 0ff07ac5868b357063e0732f593054825d6ab691..a03d530ea02b535c8b02225039790d16f9220d5c 100644 --- a/src/core/models/SecurityModel.php +++ b/src/core/models/SecurityModel.php @@ -77,20 +77,11 @@ class SecurityModel ValidatorModel::notEmpty($args, ['userId']); ValidatorModel::stringType($args, ['userId']); - $customId = CoreConfigModel::getCustomId(); - - if (file_exists("custom/{$customId}/apps/maarch_entreprise/xml/config.xml")) { - $path = "custom/{$customId}/apps/maarch_entreprise/xml/config.xml"; - } else { - $path = 'apps/maarch_entreprise/xml/config.xml'; - } - $cookieTime = 0; - if (file_exists($path)) { - $loadedXml = simplexml_load_file($path); - if ($loadedXml) { - $cookieTime = (string)$loadedXml->CONFIG->CookieTime; - } + + $loadedXml = CoreConfigModel::getXmlLoaded(['path' => 'apps/maarch_entreprise/xml/config.xml']); + if ($loadedXml) { + $cookieTime = (string)$loadedXml->CONFIG->CookieTime; } $user = DatabaseModel::select([