public function Delete($configId) { $configId = intval($configId); if ($configId <= 0) { $this->error = new CVoxImplantError(__METHOD__, 'CONFIG_ID_NULL', GetMessage('VI_SIP_CONFIG_ID_NULL')); return false; } $orm = VI\SipTable::getList(array('filter' => array('=CONFIG_ID' => $configId))); $element = $orm->fetch(); if (!$element) { return false; } if (intval($element['REG_ID']) > 0 && !$this->DeleteSipRegistration($element['REG_ID'])) { return false; } VI\SipTable::delete($element['ID']); VI\ConfigTable::delete($configId); return true; }
public static function DeleteConfigBySearchId($searchId) { if (strlen($searchId) <= 0) { return array('ERROR' => 'Config is`t found for undefined number'); } $orm = VI\ConfigTable::getList(array('filter' => array('=SEARCH_ID' => (string) $searchId))); $config = $orm->fetch(); if (!$config) { $result = array('ERROR' => 'Config is`t found for number: ' . $searchId); } else { $orm = VI\QueueTable::getList(array('filter' => array('=CONFIG_ID' => $config["ID"]))); while ($row = $orm->fetch()) { VI\QueueTable::delete($row['ID']); } VI\ConfigTable::delete($config["ID"]); $result = array('RESULT' => 'OK', 'ERROR' => ''); } return $result; }
public static function DeletePhoneConfig($configId) { $configId = intval($configId); $result = VI\ConfigTable::getList(array('select' => array('ID', 'SEARCH_ID'), 'filter' => array('=ID' => $configId))); $config = $result->fetch(); if (!$config) { return false; } $needChangePortalNumber = false; VI\ConfigTable::delete($configId); if ($config['SEARCH_ID'] == CVoxImplantConfig::GetPortalNumber()) { $needChangePortalNumber = true; } $result = VI\QueueTable::getList(array('select' => array('ID'), 'filter' => array('=CONFIG_ID' => $configId))); while ($row = $result->fetch()) { VI\QueueTable::delete($row['ID']); } $firstPhoneNumber = ''; $result = VI\ConfigTable::getList(array('select' => array('ID', 'SEARCH_ID'))); while ($row = $result->fetch()) { if (!$firstPhoneNumber) { $firstPhoneNumber = $row['SEARCH_ID']; } } if (!$firstPhoneNumber) { CVoxImplantConfig::SetModeStatus(CVoxImplantConfig::MODE_RENT, false); } if ($needChangePortalNumber) { if ($firstPhoneNumber) { CVoxImplantConfig::SetPortalNumber($firstPhoneNumber); } else { CVoxImplantConfig::SetPortalNumber(CVoxImplantConfig::LINK_BASE_NUMBER); } } return true; }