- Модуль: voximplant
- Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_sip.php
- Класс: CVoxImplantSip
- Вызов: CVoxImplantSip::Update
public function Update($configId, $fields)
{
$configId = intval($configId);
if ($configId <= 0)
{
$this->error = new CVoxImplantError(__METHOD__, 'CONFIG_ID_NULL', GetMessage('VI_SIP_CONFIG_ID_NULL'));
return false;
}
$arUpdate = $this->PrepareFields($fields, self::CHECK_UPDATE);
if (!$arUpdate)
return false;
if (isset($arUpdate['SEARCH_ID']))
{
$orm = VIConfigTable::getList(Array(
'filter'=>Array(
'=SEARCH_ID' => $arUpdate['SEARCH_ID'],
'!=ID' => $configId
)
));
if ($orm->fetch())
{
$this->error = new CVoxImplantError(__METHOD__, 'SEARCH_ID_EXISTS', GetMessage('VI_SIP_SEARCH_ID_EXISTS'));
return false;
}
}
if (isset($arUpdate['PHONE_NAME']))
{
$orm = VIConfigTable::getList(Array(
'filter'=>Array(
'=PHONE_NAME' => $arUpdate['PHONE_NAME'],
'!=ID' => $configId
)
));
if ($orm->fetch())
{
$this->error = new CVoxImplantError(__METHOD__, 'TITLE_EXISTS', GetMessage('VI_SIP_TITLE_EXISTS'));
return false;
}
}
if (isset($arUpdate['SEARCH_ID']))
{
$result = BitrixVoximplantConfigTable::getById($configId);
$currentConfig = $result->fetch();
if ($currentConfig['SEARCH_ID'] == CVoxImplantConfig::GetPortalNumber())
{
COption::SetOptionString("voximplant", "portal_number", $arUpdate['SEARCH_ID']);
}
VIConfigTable::update($configId, Array(
'SEARCH_ID' => $arUpdate['SEARCH_ID'],
));
}
if (isset($arUpdate['PHONE_NAME']))
{
VIConfigTable::update($configId, Array(
'PHONE_NAME' => $arUpdate['PHONE_NAME'],
));
}
unset($arUpdate['SEARCH_ID']);
unset($arUpdate['PHONE_NAME']);
unset($arUpdate['CONFIG_ID']);
if (empty($arUpdate))
return true;
$orm = VISipTable::getList(Array(
'filter'=>Array(
'=CONFIG_ID' => $configId,
)
));
$entity = $orm->fetch();
if (!$entity)
{
$this->error = new CVoxImplantError(__METHOD__, 'CONFIG_NOT_FOUND', GetMessage('VI_SIP_CONFIG_NOT_FOUND'));
return false;
}
$arUpdate['REGISTRATION_STATUS_CODE'] = 0;
VISipTable::update($entity['ID'], $arUpdate);
if (isset($arUpdate['SERVER']) || isset($arUpdate['LOGIN']) || isset($arUpdate['PASSWORD']))
{
$orm = VISipTable::getById($entity['ID']);
$sipConfig = $orm->fetch();
if (
$entity['SERVER'] != $sipConfig['SERVER'] ||
$entity['LOGIN'] != $sipConfig['LOGIN'] ||
$entity['PASSWORD'] != $sipConfig['PASSWORD'] ||
$entity['AUTH_USER'] != $sipConfig['AUTH_USER'] ||
$entity['OUTBOUND_PROXY'] != $sipConfig['OUTBOUND_PROXY'] ||
$fields['NEED_UPDATE'] == 'Y'
)
{
$this->UpdateSipRegistration(
$sipConfig['REG_ID'],
$sipConfig['SERVER'],
$sipConfig['LOGIN'],
$sipConfig['PASSWORD'],
$sipConfig['AUTH_USER'],
$sipConfig['OUTBOUND_PROXY']
);
}
}
return true;
}