public static function UpdateCity($ID, $arFields) { global $DB; $ID = intval($ID); if ($ID <= 0 || !CSaleLocation::CityCheckFields("UPDATE", $arFields)) { return false; } foreach (GetModuleEvents("sale", "OnBeforeCityUpdate", true) as $arEvent) { if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) { return false; } } if (self::isLocationProMigrated()) { try { $locId = self::getLocationIdByCityId($ID); if (!$locId) { return false; } $res = Location\LocationTable::updateExtended($locId, self::refineFieldsForSaveCRC($locId, $arFields), array('REBALANCE' => false)); if ($res->isSuccess()) { return $ID; } return false; } catch (Exception $e) { return false; } } else { $strUpdate = $DB->PrepareUpdate("b_sale_location_city", $arFields); $strSql = "UPDATE b_sale_location_city SET " . $strUpdate . " WHERE ID = " . $ID . ""; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y")); while ($arLang = $db_lang->Fetch()) { if ($arCntLang = CSaleLocation::GetCityLangByID($ID, $arLang["LID"])) { $strUpdate = $DB->PrepareUpdate("b_sale_location_city_lang", $arFields[$arLang["LID"]]); $strSql = "UPDATE b_sale_location_city_lang SET " . $strUpdate . " WHERE ID = " . $arCntLang["ID"] . ""; } else { $arInsert = $DB->PrepareInsert("b_sale_location_city_lang", $arFields[$arLang["LID"]]); $strSql = "INSERT INTO b_sale_location_city_lang(CITY_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")"; } $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } } foreach (GetModuleEvents("sale", "OnCityUpdate", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $arFields)); } return $ID; }