Skip to content

Commit

Permalink
Show conflicted extension if save was not successful
Browse files Browse the repository at this point in the history
  • Loading branch information
jorikfon committed Sep 17, 2024
1 parent 8cefad4 commit 45f2aa8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Common/Messages/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
'gs_StoreAllPossibleRecords' => '',
'gs_DisableAllModules' => 'Отключить маркетплейс',
'gs_ErrorSaveSettings' => 'Ошибка сохранения настроек',
'mo_ThisNumberNotUniqueForExtensionsModels' => 'Указанный внутренний номер уже используется',
'mo_ThisNumberNotUniqueForExtensionsModels' => 'Указанный номер уже используется для - %record%',
'mo_ParkingExtension'=>'Слот для парковки %number%',
'pr_AddSIPProvider' => 'Подключить SIP',
'pr_AddIAXProvider' => 'Подключить IAX',
'pr_QualifyInstructionsIAX' => 'При включение этой опции Asterisk будет отправлять SIP Options пакеты. Это необходимо для поддержки NAT туннелирования на вашем маршрутизаторе.',
Expand Down
14 changes: 13 additions & 1 deletion src/Common/Models/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,24 @@ private function updateRelationshipsNumbers(): void
*/
public function validation(): bool
{

$existingRecord = self::findFirst(
[
'conditions' => 'number = :number:',
'bind' => ['number' => $this->number],
]
);
$currentRepresent = 'unknown';
if ($existingRecord!==null) {
$currentRepresent = $existingRecord->getRepresent();
}

$validation = new Validation();
$validation->add(
'number',
new UniquenessValidator(
[
'message' => $this->t('mo_ThisNumberNotUniqueForExtensionsModels'),
'message' => $this->t('mo_ThisNumberNotUniqueForExtensionsModels', ['record'=>$currentRepresent]),
]
)
);
Expand Down
3 changes: 3 additions & 0 deletions src/Common/Models/ModelsBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,9 @@ public function getRepresent(bool $needLink = false): string
$name = '<i class="cogs icon"></i> '
. $this->t('mo_SystemExten_' . $this->number);
break;
case Extensions::TYPE_PARKING:
$name = $this->t('mo_ParkingExtension',['number'=> $this->number]);
break;
case Extensions::TYPE_EXTERNAL:
case Extensions::TYPE_SIP:
default:
Expand Down

0 comments on commit 45f2aa8

Please sign in to comment.