Skip to content

Commit b9e426a

Browse files
committed
✨ Add secondary translations group for bots and enhance bot configuration handling 🎉🔧
- Introduced a new optional field for secondary translations group in bot configuration. - Updated form handling to accommodate the new field and ensure proper validation. - Enhanced bot item retrieval to include both primary and secondary translation groups.
1 parent af97a93 commit b9e426a

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

lhc_web/design/defaulttheme/tpl/lhdepartment/parts/bot_configuration.tpl.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="row">
22
<div class="col-6">
33
<div class="form-group">
4-
<label>Bot</label>
4+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Bot');?></label>
55
<?php echo erLhcoreClassRenderHelper::renderCombobox( array (
66
'input_name' => 'bot_id',
77
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Select bot'),
@@ -14,7 +14,7 @@
1414
</div>
1515
<div class="col-6">
1616
<div class="form-group">
17-
<label>Translations group</label>
17+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Translations group, primary');?></label>
1818
<?php echo erLhcoreClassRenderHelper::renderCombobox( array (
1919
'input_name' => 'bot_tr_id',
2020
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Select translations'),
@@ -24,6 +24,17 @@
2424
'list_function' => 'erLhcoreClassModelGenericBotTrGroup::getList'
2525
)); ?>
2626
</div>
27+
<div class="form-group">
28+
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Translations group, secondary');?></label>
29+
<?php echo erLhcoreClassRenderHelper::renderCombobox( array (
30+
'input_name' => 'bot_tr_id_2',
31+
'optional_field' => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/lists/search_panel','Select translations'),
32+
'selected_id' => isset($departament->bot_configuration_array['bot_tr_id_2']) ? $departament->bot_configuration_array['bot_tr_id_2'] : 0,
33+
'css_class' => 'form-control form-control-sm',
34+
'display_name' => 'name',
35+
'list_function' => 'erLhcoreClassModelGenericBotTrGroup::getList'
36+
)); ?>
37+
</div>
2738
</div>
2839
</div>
2940

lhc_web/lib/core/lhdepartament/lhdepartament.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ public static function validateDepartment(erLhcoreClassModelDepartament & $depar
195195
'bot_tr_id' => new ezcInputFormDefinitionElement(
196196
ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)
197197
),
198+
'bot_tr_id_2' => new ezcInputFormDefinitionElement(
199+
ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1)
200+
),
198201
'theme_ind' => new ezcInputFormDefinitionElement(
199202
ezcInputFormDefinitionElement::OPTIONAL, 'int', array('min_range' => 1), FILTER_REQUIRE_ARRAY
200203
),
@@ -741,11 +744,16 @@ public static function validateDepartment(erLhcoreClassModelDepartament & $depar
741744
$botConfiguration['transfer_min_priority'] = '';
742745
}
743746

744-
if ( $form->hasValidData( 'bot_tr_id' ) )
745-
{
747+
if ( $form->hasValidData( 'bot_tr_id' ) ) {
746748
$botConfiguration['bot_tr_id'] = $form->bot_tr_id;
747-
} else {
748-
$botConfiguration['bot_tr_id'] = 0;
749+
} elseif (isset($botConfiguration['bot_tr_id'])) {
750+
unset($botConfiguration['bot_tr_id']);
751+
}
752+
753+
if ( $form->hasValidData( 'bot_tr_id_2' ) ) {
754+
$botConfiguration['bot_tr_id_2'] = $form->bot_tr_id_2;
755+
} elseif (isset($botConfiguration['bot_tr_id_2'])) {
756+
unset($botConfiguration['bot_tr_id_2']);
749757
}
750758

751759
if ( $form->hasValidData( 'theme_ind' ) )

lhc_web/lib/core/lhgenericbot/lhgenericbotworkflow.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,7 +2680,19 @@ public static function translateMessage($message, $params = array())
26802680
if ($department instanceof erLhcoreClassModelDepartament) {
26812681
$configuration = $department->bot_configuration_array;
26822682
if (isset($configuration['bot_tr_id']) && $configuration['bot_tr_id'] > 0 && !empty($identifiers)) {
2683-
$items = erLhcoreClassModelGenericBotTrItem::getList(array('filterin' => array('identifier' => array_keys($identifiers)),'filter' => array('group_id' => $configuration['bot_tr_id'])));
2683+
2684+
$groupsFilter = array_filter(array_unique(array(
2685+
(int) $configuration['bot_tr_id'],
2686+
isset($configuration['bot_tr_id_2']) ? (int) $configuration['bot_tr_id_2'] : 0
2687+
)));
2688+
2689+
$items = erLhcoreClassModelGenericBotTrItem::getList(array(
2690+
'filterin' => array(
2691+
'identifier' => array_keys($identifiers),
2692+
'group_id' => $groupsFilter
2693+
)
2694+
));
2695+
26842696
foreach ($items as $item) {
26852697
$item->translateByChat($locale, $params);
26862698
$identifiers[$item->identifier]['replace'] = $item->translation_front;

0 commit comments

Comments
 (0)