Example #1
0
 function CheckFields($ACTION, &$arFields)
 {
     if ((is_set($arFields, "SMILE_TYPE") || $ACTION == "ADD") && $arFields["SMILE_TYPE"] != "I" && $arFields["SMILE_TYPE"] != "S") {
         return False;
     }
     if ((is_set($arFields, "IMAGE") || $ACTION == "ADD") && strlen($arFields["IMAGE"]) <= 0) {
         return False;
     }
     if ((is_set($arFields, "SORT") || $ACTION == "ADD") && IntVal($arFields["SORT"]) <= 0) {
         $arFields["SORT"] = 150;
     }
     if (is_set($arFields, "LANG") || $ACTION == "ADD") {
         for ($i = 0; $i < count($arFields["LANG"]); $i++) {
             if (!is_set($arFields["LANG"][$i], "LID") || strlen($arFields["LANG"][$i]["LID"]) <= 0) {
                 return false;
             }
             if (!is_set($arFields["LANG"][$i], "NAME") || strlen($arFields["LANG"][$i]["NAME"]) <= 0) {
                 return false;
             }
         }
         $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
         while ($arLang = $db_lang->Fetch()) {
             $bFound = False;
             for ($i = 0; $i < count($arFields["LANG"]); $i++) {
                 if ($arFields["LANG"][$i]["LID"] == $arLang["LID"]) {
                     $bFound = True;
                 }
             }
             if (!$bFound) {
                 return false;
             }
         }
     }
     return True;
 }
Example #2
0
 protected function setLangIds()
 {
     $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
     while ($lang = $db_lang->Fetch()) {
         $this->lang_ids[] = $lang["LID"];
     }
 }
 function CheckFields($ACTION, &$arFields)
 {
     global $DB;
     if (is_set($arFields, "SORT") && IntVal($arFields["SORT"]) <= 0) {
         $arFields["SORT"] = 100;
     }
     if (is_set($arFields, "LOCATION_ID") && (!is_array($arFields["LOCATION_ID"]) || count($arFields["LOCATION_ID"]) <= 0)) {
         return false;
     }
     if (is_set($arFields, "LANG")) {
         $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
         while ($arLang = $db_lang->Fetch()) {
             $bFound = False;
             $coountarFieldLang = count($arFields["LANG"]);
             for ($i = 0; $i < $coountarFieldLang; $i++) {
                 if ($arFields["LANG"][$i]["LID"] == $arLang["LID"] && strlen($arFields["LANG"][$i]["NAME"]) > 0) {
                     $bFound = True;
                 }
             }
             if (!$bFound) {
                 return false;
             }
         }
     }
     return True;
 }
Example #4
0
 public static function CheckFields($ACTION, &$arFields, $ID = 0)
 {
     $aMsg = array();
     if (is_set($arFields, "LANG") || $ACTION == "ADD") {
         if (!is_array($arFields["LANG"])) {
             $arFields["LANG"] = array();
         }
         $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc");
         while ($arLang = $db_lang->Fetch()) {
             $bFound = False;
             foreach ($arFields["LANG"] as $key => $res) {
                 if (is_array($res) && $res["LID"] == $arLang["LID"]) {
                     $arFields["LANG"][$key]["NAME"] = trim($res["NAME"]);
                     if (strLen($arFields["LANG"][$key]["NAME"]) > 0) {
                         $bFound = True;
                         break;
                     }
                 }
             }
             if (!$bFound) {
                 $aMsg[] = array("id" => 'POINTS[NAME][LID][' . $arLang["LID"] . ']', "text" => str_replace("#LANG#", $arLang["NAME"] . " [" . $arLang["LID"] . "]", GetMessage("FORUM_PE_ERROR_NONAME")));
             }
         }
     }
     if (is_set($arFields, "MIN_POINTS") || $ACTION == "ADD") {
         $arFields["MIN_POINTS"] = trim($arFields["MIN_POINTS"]);
         if (strLen($arFields["MIN_POINTS"]) <= 0) {
             $aMsg[] = array("id" => 'POINTS[MIN_POINTS]', "text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_EMPTY"));
         } elseif (preg_match("/[^0-9]/", $arFields["MIN_POINTS"])) {
             $aMsg[] = array("id" => 'POINTS[MIN_POINTS]', "text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_BAD"));
         } else {
             $arFields["MIN_POINTS"] = intVal($arFields["MIN_POINTS"]);
             $db_res = CForumPoints::GetList(array(), array("MIN_POINTS" => $arFields["MIN_POINTS"]));
             if ($db_res && ($res = $db_res->GetNext())) {
                 if ($ACTION == "ADD" || $ID == 0 || $ID != $res["ID"]) {
                     $aMsg[] = array("id" => 'POINTS[MIN_POINTS]', "text" => GetMessage("FORUM_PE_ERROR_MIN_POINTS_EXIST"));
                 }
             }
         }
     }
     $arFields["VOTES"] = intval($arFields["VOTES"]);
     if (!empty($aMsg)) {
         $e = new CAdminException(array_reverse($aMsg));
         $GLOBALS["APPLICATION"]->ThrowException($e);
         return false;
     }
     return true;
 }
Example #5
0
 public static function CheckFields($ACTION, &$arFields, $ID = "")
 {
     global $DB, $APPLICATION;
     if ((is_set($arFields, "SORT") || $ACTION == "ADD") && IntVal($arFields["SORT"]) <= 0) {
         $arFields["SORT"] = 100;
     }
     if ((is_set($arFields, "ID") || $ACTION == "ADD") && strlen($arFields["ID"]) <= 0) {
         return false;
     }
     if (is_set($arFields, "ID") && strlen($ID) > 0 && $ID != $arFields["ID"]) {
         return false;
     }
     if (is_set($arFields, "ID") && !preg_match("#[A-Za-z]#i", $arFields["ID"]) || strlen($ID) > 0 && !preg_match("#[A-Za-z]#i", $ID)) {
         $APPLICATION->ThrowException(GetMessage("SKGS_ID_NOT_SYMBOL"), "ID");
         return false;
     }
     if ($ACTION == "ADD") {
         $arFields["ID"] = $DB->ForSql($arFields["ID"], 1);
         $db_res = $DB->Query("SELECT ID FROM b_sale_status WHERE ID = '" . $arFields["ID"] . "'");
         if ($db_res->Fetch()) {
             $APPLICATION->ThrowException(GetMessage("SKGS_SALE_STATUS_ALREADY_EXISTS"), "ID");
             return false;
         }
     }
     if (is_set($arFields, "LANG")) {
         $b = 'sort';
         $o = 'asc';
         $db_lang = CLangAdmin::GetList($b, $o, array("ACTIVE" => "Y"));
         while ($arLang = $db_lang->Fetch()) {
             $bFound = false;
             foreach ($arFields["LANG"] as &$arOneLang) {
                 if ($arOneLang["LID"] == $arLang["LID"] && '' != $arOneLang["NAME"]) {
                     $bFound = true;
                     break;
                 }
             }
             if (isset($arOneLang)) {
                 unset($arOneLang);
             }
             if (!$bFound) {
                 return false;
             }
         }
     }
     return true;
 }
Example #6
0
	public static function CheckFields($ACTION, &$arFields, $ID = "")
	{
		global $DB;

		if ((is_set($arFields, "SORT") || $ACTION=="ADD") && IntVal($arFields["SORT"])<= 0) $arFields["SORT"] = 100;
		if ((is_set($arFields, "ID") || $ACTION=="ADD") && strlen($arFields["ID"])<=0) return false;

		if (is_set($arFields, "ID") && strlen($ID)>0 && $ID!=$arFields["ID"]) return false;

		if((is_set($arFields, "ID") && !preg_match("#[A-Za-z]#i", $arFields["ID"])) || (strlen($ID)>0 && !preg_match("#[A-Za-z]#i", $ID)))
		{
			$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGS_ID_NOT_SYMBOL"), "ERROR_ID_NOT_SYMBOL");
			return false;
		}

		if ($ACTION=="ADD")
		{
			$arFields["ID"] = $DB->ForSql($arFields["ID"], 1);
			$db_res = $DB->Query("SELECT ID FROM b_sale_status WHERE ID = '".$arFields["ID"]."' ");
			if ($db_res->Fetch()) return false;
		}

		if (is_set($arFields, "LANG"))
		{
			$db_lang = CLangAdmin::GetList(($b="sort"), ($o="asc"), array("ACTIVE" => "Y"));
			while ($arLang = $db_lang->Fetch())
			{
				$bFound = false;
				foreach ($arFields["LANG"] as &$arOneLang)
				{
					if ($arOneLang["LID"] == $arLang["LID"] && '' != $arOneLang["NAME"])
					{
						$bFound = true;
						break;
					}
				}
				if (isset($arOneLang))
					unset($arOneLang);
				if (!$bFound) return false;
			}
		}

		return true;
	}
Example #7
0
 function CheckFields($ACTION, &$arFields, $ID = "")
 {
     global $DB;
     if ((is_set($arFields, "SORT") || $ACTION == "ADD") && IntVal($arFields["SORT"]) <= "Y") {
         $arFields["SORT"] = 100;
     }
     if ((is_set($arFields, "ID") || $ACTION == "ADD") && strlen($arFields["ID"]) <= 0) {
         return false;
     }
     if (is_set($arFields, "ID") && strlen($ID) > 0 && $ID != $arFields["ID"]) {
         return false;
     }
     if (is_set($arFields, "ID") && !preg_match("#[A-Za-z]#i", $arFields["ID"]) || strlen($ID) > 0 && !preg_match("#[A-Za-z]#i", $ID)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SKGS_ID_NOT_SYMBOL"), "ERROR_ID_NOT_SYMBOL");
         return false;
     }
     if ($ACTION == "ADD") {
         $arFields["ID"] = $DB->ForSql($arFields["ID"], 1);
         $db_res = $DB->Query("SELECT ID FROM b_sale_status WHERE ID = '" . $arFields["ID"] . "' ");
         if ($db_res->Fetch()) {
             return false;
         }
     }
     if (is_set($arFields, "LANG")) {
         $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
         while ($arLang = $db_lang->Fetch()) {
             $bFound = False;
             for ($i = 0; $i < count($arFields["LANG"]); $i++) {
                 if ($arFields["LANG"][$i]["LID"] == $arLang["LID"] && strlen($arFields["LANG"][$i]["NAME"]) > 0) {
                     $bFound = True;
                 }
             }
             if (!$bFound) {
                 return false;
             }
         }
     }
     return True;
 }
Example #8
0
 /**
  * The function modifies the parameters of the region
  *
  * @param int $ID region code
  * @param array $arFields array with parameters region
  * @return int $ID code region
  */
 public static function UpdateRegion($ID, $arFields)
 {
     global $DB;
     $ID = intval($ID);
     if ($ID <= 0 || !CSaleLocation::RegionCheckFields("UPDATE", $arFields)) {
         return false;
     }
     foreach (GetModuleEvents("sale", "OnBeforeRegionUpdate", true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields)) === false) {
             return false;
         }
     }
     $strUpdate = $DB->PrepareUpdate("b_sale_location_region", $arFields);
     $strSql = "UPDATE b_sale_location_region 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::GetRegionLangByID($ID, $arLang["LID"])) {
             $strUpdate = $DB->PrepareUpdate("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
             //print_r($arFields);die();
             $strSql = "UPDATE b_sale_location_region_lang SET " . $strUpdate . " WHERE ID = " . $arCntLang["ID"] . "";
         } else {
             $arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
             $strSql = "INSERT INTO b_sale_location_region_lang(REGION_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
         }
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     foreach (GetModuleEvents("sale", "OnRegionUpdate", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
Example #9
0
        }
        return;
    }
    $currencyID = $currency['CURRENCY'];
    $isEditMode = true;
}
$isBaseCurrency = $currencyID !== '' && $currencyID === $baseCurrencyID;
$currency['IS_ACCOUNTING_CURRENCY'] = $currencyID !== '' && $currencyID === CCrmCurrency::GetAccountCurrencyID();
$currency['IS_INVOICE_CURRENCY'] = $currencyID !== '' && $currencyID === CCrmCurrency::getInvoiceDefault();
$arResult['CURRENCY_ID'] = $currencyID;
$arResult['CURRENCY'] = $currency;
$arResult['FORM_ID'] = 'CRM_CURRENCY_EDIT';
$arResult['GRID_ID'] = 'CRM_CURRENCY_EDIT';
$arResult['BACK_URL'] = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CURRENCY_LIST'], array());
$langs = array();
$rsLang = CLangAdmin::GetList($by = 'sort', $order = 'asc');
while ($arLang = $rsLang->Fetch()) {
    $lid = $arLang['LID'];
    $langs[$lid] = array('NAME' => $arLang['NAME']);
}
$arResult['LANGS'] = $langs;
$currencyLocs = array();
if ($currencyID !== '') {
    $rs = CCurrencyLang::GetList($by = '', $order = '', $currencyID);
    while ($ary = $rs->GetNext()) {
        $loc = array();
        $loc['FULL_NAME'] = $ary['FULL_NAME'];
        $loc['FORMAT_STRING'] = $ary['FORMAT_STRING'];
        $loc['DEC_POINT'] = $ary['DEC_POINT'];
        $loc['THOUSANDS_SEP'] = $ary['THOUSANDS_SEP'];
        $loc['THOUSANDS_VARIANT'] = $ary['THOUSANDS_VARIANT'];
$arSelectFields = $lAdmin->GetVisibleHeaderColumns();
$arSelectFieldsMap = array();
foreach ($arSelectFields as &$strOneFieldName) {
    $arSelectFieldsMap[$strOneFieldName] = true;
}
if (isset($strOneFieldName)) {
    unset($strOneFieldName);
}
$mxKey = array_search('NAME_LID', $arSelectFields);
if (false !== $mxKey) {
    unset($arSelectFields[$mxKey]);
}
$arLangList = array();
$arLangDefList = array();
if (array_key_exists('NAME_LID', $arSelectFieldsMap)) {
    $rsPriceLangs = CLangAdmin::GetList($by1 = "sort", $order1 = "asc");
    while ($arPriceLang = $rsPriceLangs->Fetch()) {
        $arLangList[$arPriceLang['LID']] = true;
        $arLangDefList[$arPriceLang['LID']] = str_replace('#LANG#', htmlspecialcharsex($arPriceLang['NAME']), GetMessage('BT_CAT_GROUP_ADM_LANG_MESS'));
    }
}
if (array_key_exists("mode", $_REQUEST) && $_REQUEST["mode"] == "excel") {
    $arNavParams = false;
} else {
    $arNavParams = array("nPageSize" => CAdminResult::GetNavSize($sTableID));
}
$dbResultList = CCatalogGroup::GetList(array($by => $order), array(), false, $arNavParams, $arSelectFields);
$dbResultList = new CAdminResult($dbResultList, $sTableID);
$dbResultList->NavStart();
$lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("group_admin_nav")));
$arRows = array();
Example #11
0
 private static function GetLanguagesID()
 {
     if (self::$LANGS_ID) {
         return self::$LANGS_ID;
     }
     self::$LANGS_ID = array();
     $by = 'sort';
     $order = 'asc';
     $dbResult = CLangAdmin::GetList($by, $order);
     while ($arResult = $dbResult->Fetch()) {
         self::$LANGS_ID[] = $arResult['LID'];
     }
     return self::$LANGS_ID;
 }
Example #12
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main" . "/SetCorePath.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/Start.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/classes/general/virtual_io.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/freetrix/modules/main/classes/general/virtual_file.php";
$Application = \Freetrix\Main\Application::getInstance();
$Application->initializeExtendedKernel(array("get" => $_GET, "post" => $_POST, "files" => $_FILES, "cookie" => $_COOKIE, "server" => $_SERVER, "env" => $_ENV));
$GLOBALS["APPLICATION"] = new CMain();
if (defined("SITE_ID")) {
    define("LANG", SITE_ID);
}
if (defined("LANG")) {
    if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
        $currentLangGetter = CLangAdmin::GetByID(LANG);
    } else {
        $currentLangGetter = CLang::GetByID(LANG);
    }
    $definedLang = $currentLangGetter->Fetch();
} else {
    $definedLang = $GLOBALS["APPLICATION"]->GetLang();
    define("LANG", $definedLang["LID"]);
}
$_762722495 = $definedLang["LID"];
define("SITE_ID", $definedLang["LID"]);
define("SITE_DIR", $definedLang["DIR"]);
define("SITE_SERVER_NAME", $definedLang["SERVER_NAME"]);
define("SITE_CHARSET", $definedLang["CHARSET"]);
define("FORMAT_DATE", $definedLang["FORMAT_DATE"]);
define("FORMAT_DATETIME", $definedLang["FORMAT_DATETIME"]);
define("LANG_DIR", $definedLang["DIR"]);
Example #13
0
/** @var Bitrix\Sale\Order $saleOrder */
Admin\OrderEdit::initCouponsData($saleOrder->getUserId(), $ID);
CUtil::InitJSCore();
$APPLICATION->SetTitle(Loc::getMessage("SALE_OVIEW_TITLE", array("#ID#" => $saleOrder->getId(), "#NUM#" => strlen($saleOrder->getField('ACCOUNT_NUMBER')) > 0 ? $saleOrder->getField('ACCOUNT_NUMBER') : $saleOrder->getId(), "#DATE#" => $saleOrder->getDateInsert()->toString())));
\Bitrix\Main\Page\Asset::getInstance()->addJs("/bitrix/js/sale/admin/order_edit.js");
ob_start();
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/admin/order_history.php";
$historyContent = ob_get_contents();
ob_end_clean();
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
/* context menu */
$aMenu = array();
$aMenu[] = array("ICON" => "btn_list", "TEXT" => Loc::getMessage("SALE_OVIEW_TO_LIST"), "TITLE" => Loc::getMessage("SALE_OVIEW_TO_LIST_TITLE"), "LINK" => "/bitrix/admin/sale_order.php?lang=" . LANGUAGE_ID . GetFilterParams("filter_"));
$aMenu[] = array("TEXT" => Loc::getMessage("SALE_OVIEW_TO_EDIT"), "TITLE" => Loc::getMessage("SALE_OVIEW_TO_EDIT_TITLE"), "LINK" => "/bitrix/admin/sale_order_edit.php?ID=" . $ID . "&lang=" . LANGUAGE_ID . GetFilterParams("filter_"));
$arSysLangs = array();
$db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
while ($arLang = $db_lang->Fetch()) {
    $arSysLangs[] = $arLang["LID"];
}
$arReports = array();
$dirs = array($_SERVER["DOCUMENT_ROOT"] . "/bitrix/admin/reports/", $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/reports/");
foreach ($dirs as $dir) {
    if (file_exists($dir)) {
        if ($handle = opendir($dir)) {
            while (($file = readdir($handle)) !== false) {
                $file_contents = '';
                if ($file == "." || $file == ".." || $file == ".access.php") {
                    continue;
                }
                if (is_file($dir . $file) && ToUpper(substr($file, -4)) == ".PHP") {
                    $rep_title = $file;
Example #14
0
 public static function initializeBasicKernel()
 {
     //language independed classes
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/punycode.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/charset_converter.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/main.php";
     //main class
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/option.php";
     //options and settings class
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache.php";
     //various cache classes
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/cache_html.php";
     //html cache class support
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/module.php";
     error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE);
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_io.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_file.php";
     //define global application object
     $GLOBALS["APPLICATION"] = new \CMain();
     if (defined("SITE_ID")) {
         define("LANG", SITE_ID);
     }
     if (defined("LANG")) {
         if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
             $db_lang = CLangAdmin::getByID(LANG);
         } else {
             $db_lang = CLang::getByID(LANG);
         }
         $arLang = $db_lang->fetch();
     } else {
         $arLang = $GLOBALS["APPLICATION"]->getLang();
         // define("LANG", $arLang["LID"]);
     }
     $lang = $arLang["LID"];
     // define("SITE_ID", $arLang["LID"]);
     // define("SITE_DIR", $arLang["DIR"]);
     // define("SITE_SERVER_NAME", $arLang["SERVER_NAME"]);
     // define("SITE_CHARSET", $arLang["CHARSET"]);
     // define("FORMAT_DATE", $arLang["FORMAT_DATE"]);
     // define("FORMAT_DATETIME", $arLang["FORMAT_DATETIME"]);
     // define("LANG_DIR", $arLang["DIR"]);
     // define("LANG_CHARSET", $arLang["CHARSET"]);
     // define("LANG_ADMIN_LID", $arLang["LANGUAGE_ID"]);
     // define("LANGUAGE_ID", $arLang["LANGUAGE_ID"]);
     /// нужна кодировка для конвертации
     $GLOBALS["APPLICATION"]->reinitPath();
     //global var, is used somewhere
     $GLOBALS["sDocPath"] = $GLOBALS["APPLICATION"]->getCurPage();
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/tools.php");
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/date_format.php");
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/database.php");
     IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/main.php");
     IncludeModuleLangFile(__FILE__);
     error_reporting(\COption::getOptionInt("main", "error_reporting", E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE) & ~E_STRICT);
     if (!defined("BX_COMP_MANAGED_CACHE") && \COption::getOptionString("main", "component_managed_cache_on", "Y") != "N") {
     }
     // define("BX_COMP_MANAGED_CACHE", true);
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/filter_tools.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/ajax_tools.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/urlrewriter.php";
     \CModule::addAutoloadClasses("main", array("CBitrixComponent" => "classes/general/component.php", "CComponentEngine" => "classes/general/component_engine.php", "CComponentAjax" => "classes/general/component_ajax.php", "CBitrixComponentTemplate" => "classes/general/component_template.php", "CComponentUtil" => "classes/general/component_util.php", "CControllerClient" => "classes/general/controller_member.php", "PHPParser" => "classes/general/php_parser.php", "CDiskQuota" => "classes/" . $GLOBALS["DBType"] . "/quota.php", "CEventLog" => "classes/general/event_log.php", "CEventMain" => "classes/general/event_log.php", "CAdminFileDialog" => "classes/general/file_dialog.php", "WLL_User" => "classes/general/liveid.php", "WLL_ConsentToken" => "classes/general/liveid.php", "WindowsLiveLogin" => "classes/general/liveid.php", "CAllFile" => "classes/general/file.php", "CFile" => "classes/" . $GLOBALS["DBType"] . "/file.php", "CTempFile" => "classes/general/file_temp.php", "CFavorites" => "classes/" . $GLOBALS["DBType"] . "/favorites.php", "CUserOptions" => "classes/general/user_options.php", "CGridOptions" => "classes/general/grids.php", "CUndo" => "/classes/general/undo.php", "CAutoSave" => "/classes/general/undo.php", "CRatings" => "classes/" . $GLOBALS["DBType"] . "/ratings.php", "CRatingsComponentsMain" => "classes/" . $GLOBALS["DBType"] . "/ratings_components.php", "CRatingRule" => "classes/general/rating_rule.php", "CRatingRulesMain" => "classes/" . $GLOBALS["DBType"] . "/rating_rules.php", "CTopPanel" => "public/top_panel.php", "CEditArea" => "public/edit_area.php", "CComponentPanel" => "public/edit_area.php", "CTextParser" => "classes/general/textparser.php", "CPHPCacheFiles" => "classes/general/cache_files.php", "CTimeZone" => "classes/general/time.php", "CDataXML" => "classes/general/xml.php", "CRsaProvider" => "classes/general/rsasecurity.php", "CRsaSecurity" => "classes/general/rsasecurity.php", "CRsaBcmathProvider" => "classes/general/rsabcmath.php", "CRsaOpensslProvider" => "classes/general/rsaopenssl.php", "CASNReader" => "classes/general/asn.php", "CBXShortUri" => "classes/" . $GLOBALS["DBType"] . "/short_uri.php", "CFinder" => "classes/general/finder.php", "CAccess" => "classes/general/access.php", "CAuthProvider" => "classes/general/authproviders.php", "IProviderInterface" => "classes/general/authproviders.php", "CGroupAuthProvider" => "classes/general/authproviders.php", "CUserAuthProvider" => "classes/general/authproviders.php", "Bitrix\\Main\\Entity\\Base" => "lib/entity/base.php", "Bitrix\\Main\\Entity\\DataManager" => "lib/entity/base.php", "Bitrix\\Main\\Entity\\Field" => "lib/entity/field.php", "Bitrix\\Main\\Entity\\ScalarField" => "lib/entity/scalarfield.php", "Bitrix\\Main\\Entity\\IntegerField" => "lib/entity/integerfield.php", "Bitrix\\Main\\Entity\\FloatField" => "lib/entity/floatfield.php", "Bitrix\\Main\\Entity\\StringField" => "lib/entity/stringfield.php", "Bitrix\\Main\\Entity\\TextField" => "lib/entity/textfield.php", "Bitrix\\Main\\Entity\\BooleanField" => "lib/entity/booleanfield.php", "Bitrix\\Main\\Entity\\DateField" => "lib/entity/datefield.php", "Bitrix\\Main\\Entity\\DatetimeField" => "lib/entity/datetimefield.php", "Bitrix\\Main\\Entity\\EnumField" => "lib/entity/enumfield.php", "Bitrix\\Main\\Entity\\ExpressionField" => "lib/entity/expressionfield.php", "Bitrix\\Main\\Entity\\UField" => "lib/entity/ufield.php", "WorkgroupEntity" => "lib/workgroup.php", "Bitrix\\Main\\Entity\\ReferenceField" => "lib/entity/referencefield.php", "Bitrix\\Main\\Entity\\Query" => "lib/entity/query.php", "Bitrix\\Main\\Entity\\QueryChain" => "lib/entity/querychain.php", "Bitrix\\Main\\Entity\\QueryChainElement" => "lib/entity/querychainelement.php", "SiteEntity" => "lib/site.php", "Site" => "lib/site.php", "UserEntity" => "lib/user.php", "UtsUserEntity" => "lib/utsuser.php", "UtmUserEntity" => "lib/utmuser.php", "UserGroupEntity" => "lib/usergroup.php", "GroupEntity" => "lib/group.php", "CTableSchema" => "classes/general/table_schema.php", "CUserCounter" => "classes/" . $GLOBALS["DBType"] . "/user_counter.php", "CHotKeys" => "classes/general/hot_keys.php", "CHotKeysCode" => "classes/general/hot_keys.php", "CBXSanitizer" => "classes/general/sanitizer.php", "CBXArchive" => "classes/general/archive.php", "CAdminNotify" => "classes/general/admin_notify.php", "CBXFavAdmMenu" => "classes/general/favorites.php", "CAdminInformer" => "classes/general/admin_informer.php"));
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/agent.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/user.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/event.php";
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/general/menu.php";
     AddEventHandler("main", "OnAfterEpilog", array("CCacheManager", "_Finalize"));
     require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/classes/" . $GLOBALS["DBType"] . "/usertype.php";
     //component 2.0 template engines
     // нужно до подключения init.php
     $GLOBALS["arCustomTemplateEngines"] = array();
 }
 /**
  * Returns array with status name on all site languages
  * @param string $name Status name
  * @param int $statusId (optional) Status ID needed if we updating status.
  * @return array Array of status names.
  */
 private function getStatusLang($name, $statusId = false)
 {
     if (!CModule::IncludeModule('sale')) {
         return false;
     }
     $arStatusLang = array();
     $by = "sort";
     $order = "asc";
     $dbLang = CLangAdmin::GetList($by, $order, array("ACTIVE" => "Y"));
     self::ensureLanguageDefined();
     while ($arLang = $dbLang->Fetch()) {
         $statusName = '';
         if ($statusId && $arLang["LID"] != self::$languageID) {
             $arLangStatus = CSaleStatus::GetLangByID($statusId, $arLang["LID"]);
             if ($arLangStatus && isset($arLangStatus['NAME'])) {
                 $statusName = $arLangStatus['NAME'];
             }
         }
         if (strlen($statusName) <= 0) {
             $statusName = $name;
         }
         $arStatusLang[] = array('LID' => $arLang["LID"], 'NAME' => $statusName);
     }
     return $arStatusLang;
 }
Example #16
0
 /**
  * <p>Метод изменяет параметры города с кодом ID на значения из массива arFields. Метод динамичный.</p>
  *
  *
  * @param int $ID  Код города.
  *
  * @param array $arFields  Массив с параметрами города должен содержать ключи: <ul> <li> <b>NAME</b> -
  * название города (не зависящее от языка);</li> <li> <b>SHORT_NAME</b> -
  * сокращенное название города - абревиатура (не зависящее от
  * языка);</li> <li> <b>&lt;код языка&gt;</b> - ключем является код языка, а
  * значением ассоциативный массив вида <pre class="syntax"> array("LID" =&gt; "код
  * языка", "NAME" =&gt; "название города на этом языке", "SHORT_NAME" =&gt;
  * "сокращенное название города (аббревиатура) на этом языке")</pre> Эта
  * пара ключ-значение должна присутствовать для каждого языка
  * системы.</li> </ul>
  *
  * @return int <p>Возвращается код измененного города или <i>false</i> у случае
  * ошибки.</p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/sale/classes/csalelocation/csalelocation__updatecity.3fe4165d.php
  * @author Bitrix
  */
 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::update($locId, self::refineFieldsForSaveCRC($item['ID'], $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;
 }
Example #17
0
CModule::IncludeModule('currency');
IncludeModuleLangFile(__FILE__);
$errorMessage = array();
$ID = '';
if (isset($_REQUEST['ID'])) {
    $ID = (string) $_REQUEST['ID'];
}
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("currency_curr"), "ICON" => "", "TITLE" => GetMessage("currency_curr_settings")), array("DIV" => "edit2", "TAB" => GetMessage("BT_CURRENCY_EDIT_TAB_NAME_LANGUAGE"), "ICON" => "", "TITLE" => GetMessage("BT_CURRENCY_EDIT_TAB_TITLE_LANGUAGE")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
$arTemplates = CCurrencyLang::GetFormatTemplates();
$separatorList = CCurrencyLang::GetSeparatorTypes(true);
$langList = array();
$langID = array();
$by = "sort";
$order = "asc";
$langIterator = CLangAdmin::GetList($by, $order);
while ($oneLang = $langIterator->Fetch()) {
    $langID[] = $oneLang['LID'];
    $langList[$oneLang['LID']] = $oneLang['NAME'];
}
unset($oneLang, $langIterator, $order, $by);
$arFields = array();
if ($_SERVER['REQUEST_METHOD'] == 'POST' && $CURRENCY_RIGHT == "W" && !empty($_POST['Update']) && check_bitrix_sessid()) {
    if (!isset($_POST['BASE']) || $_POST['BASE'] != 'Y') {
        $arFields = array('AMOUNT' => isset($_POST['AMOUNT']) ? $_POST['AMOUNT'] : '', 'AMOUNT_CNT' => isset($_POST['AMOUNT_CNT']) ? $_POST['AMOUNT_CNT'] : '', 'SORT' => isset($_POST['SORT']) ? $_POST['SORT'] : '', 'NUMCODE' => isset($_POST['NUMCODE']) ? $_POST['NUMCODE'] : '');
    } else {
        $arFields = array('AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => isset($_POST['SORT']) ? $_POST['SORT'] : '', 'NUMCODE' => isset($_POST['NUMCODE']) ? $_POST['NUMCODE'] : '');
    }
    if (!$ID && isset($_POST['CURRENCY'])) {
        $arFields['CURRENCY'] = $_POST['CURRENCY'];
    }
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/include.php";
$CURRENCY_RIGHT = $APPLICATION->GetGroupRight("currency");
if ($CURRENCY_RIGHT == "D") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
__IncludeLang(GetLangFileName($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/lang/", "/currencies.php"));
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/currency/prolog.php";
ClearVars("f_");
$message = null;
$bVarsFromForm = false;
$ID = htmlspecialcharsEx(trim($ID));
$ID = strlen($ID) <= 0 ? false : $ID;
$db_result_lang = CLangAdmin::GetList($by = "sort", $order = "asc");
$iCount = 0;
while ($db_result_lang_array = $db_result_lang->Fetch()) {
    $arLangsLID[$iCount] = $db_result_lang_array["LID"];
    $arLangNamesLID[$iCount] = htmlspecialcharsbx($db_result_lang_array["NAME"]);
    $iCount++;
}
$aTabs = array(array("DIV" => "edit1", "TAB" => GetMessage("currency_curr"), "ICON" => "main_user_edit", "TITLE" => GetMessage("currency_curr_settings")));
$tabControl = new CAdminTabControl("tabControl", $aTabs);
if ($_SERVER["REQUEST_METHOD"] == "POST" && $CURRENCY_RIGHT == "W" && strlen($Update) > 0 && check_bitrix_sessid()) {
    $arFields = array("AMOUNT" => $_POST['AMOUNT'], "AMOUNT_CNT" => $_POST['AMOUNT_CNT'], "SORT" => $_POST['SORT']);
    if (isset($_POST['CURRENCY'])) {
        $arFields["CURRENCY"] = $_POST['CURRENCY'];
    }
    $strAction = $ID ? 'UPDATE' : 'ADD';
    $bVarsFromForm = !CCurrency::CheckFields($strAction, $arFields, $ID);
Example #19
0
 public static function AddRegion($arFields)
 {
     global $DB;
     if (!CSaleLocation::RegionCheckFields("ADD", $arFields)) {
         return false;
     }
     if (self::isLocationProMigrated()) {
         return self::AddLocationUnattached('REGION', $arFields);
     }
     foreach (GetModuleEvents('sale', 'OnBeforeRegionAdd', true) as $arEvent) {
         if (ExecuteModuleEventEx($arEvent, array($arFields)) === false) {
             return false;
         }
     }
     $arInsert = $DB->PrepareInsert("b_sale_location_region", $arFields);
     $strSql = "INSERT INTO b_sale_location_region(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
     $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     $ID = IntVal($DB->LastID());
     $b = "sort";
     $o = "asc";
     $db_lang = CLangAdmin::GetList($b, $o, array("ACTIVE" => "Y"));
     while ($arLang = $db_lang->Fetch()) {
         if ($arFields[$arLang["LID"]]) {
             $arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
             $strSql = "INSERT INTO b_sale_location_region_lang(REGION_ID, " . $arInsert[0] . ") " . "VALUES(" . $ID . ", " . $arInsert[1] . ")";
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         }
     }
     foreach (GetModuleEvents('sale', 'OnRegionAdd', true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($ID, $arFields));
     }
     return $ID;
 }
Example #20
0
	/**
	* The function adds a new region
	* 
	* @param array $arFields array with parameters region
	* @return int $ID code region
	*/
	function AddRegion($arFields)
	{
		global $DB;

		if (!CSaleLocation::RegionCheckFields("ADD", $arFields))
			return false;

		$db_events = GetModuleEvents("sale", "OnBeforeRegionAdd");
		while ($arEvent = $db_events->Fetch())
			if (ExecuteModuleEventEx($arEvent, array($arFields))===false)
				return false;

		$arInsert = $DB->PrepareInsert("b_sale_location_region", $arFields);
		$strSql =
			"INSERT INTO b_sale_location_region(".$arInsert[0].") ".
			"VALUES(".$arInsert[1].")";
		$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);

		$ID = IntVal($DB->LastID());

		$db_lang = CLangAdmin::GetList(($b="sort"), ($o="asc"), array("ACTIVE" => "Y"));
		while ($arLang = $db_lang->Fetch())
		{
			if ($arFields[$arLang["LID"]])
			{
				$arInsert = $DB->PrepareInsert("b_sale_location_region_lang", $arFields[$arLang["LID"]]);
				$strSql =
					"INSERT INTO b_sale_location_region_lang(REGION_ID, ".$arInsert[0].") ".
					"VALUES(".$ID.", ".$arInsert[1].")";
				$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);
			}
		}

		$events = GetModuleEvents("sale", "OnRegionAdd");
		while ($arEvent = $events->Fetch())
			ExecuteModuleEventEx($arEvent, array($ID, $arFields));

		return $ID;
	}
Example #21
0
?>
&amp;lang=<?echo LANG?>">
<?php 
echo freetrix_sessid_post();
?>
<?
$tabControl->Begin();
$tabControl->BeginNextTab();
?>
	<tr class="heading">
		<td colspan="2"><b><?echo GetMessage("main_options_sys")?></b></td>
	</tr>
	<tr>
		<td><?echo GetMessage("MAIN_ADMIN_DEFAULT_LANG")?></td>
		<td><?php 
echo CLangAdmin::SelectBox("admin_lid", COption::GetOptionString("main", "admin_lid", "en"));
?>
</td>
	</tr>
	<?
	ShowParamsHTMLByArray($arAllOptions["main"]);
	?>
<?
$tabControl->BeginNextTab();
?>
	<tr class="heading">
		<td colspan="2"><b><?echo GetMessage("MAIN_OPTION_CTRL_LOC")?></b></td>
	</tr>

<?
ShowParamsHTMLByArray($arAllOptions["auth"]);
Example #22
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
$forumPermissions = $APPLICATION->GetGroupRight("forum");
if ($forumPermissions == "D") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/forum/include.php";
ClearVars();
IncludeModuleLangFile(__FILE__);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/forum/prolog.php";
$ID = IntVal($ID);
$langCount = 0;
$arSysLangs = $arSysLangNames = array();
$db_lang = CLangAdmin::GetList($b = "sort", $o = "asc");
$arError = array();
$message = false;
$bInitVars = false;
while ($arLang = $db_lang->Fetch()) {
    $arSysLangs[$langCount] = $arLang["LID"];
    $arSysLangNames[$langCount] = htmlspecialcharsbx($arLang["NAME"]);
    $langCount++;
}
$arGroups = CForumGroup::GetByLang(LANGUAGE_ID);
array_unshift($arGroups, array("ID" => 0, "NAME" => "..."));
if ((strlen($save) > 0 || strlen($apply) > 0) && $REQUEST_METHOD == "POST" && $forumPermissions == "W" && check_bitrix_sessid()) {
    $arFields = array("SORT" => intVal(intVal($SORT) <= 0 ? 150 : $SORT), "PARENT_ID" => $_REQUEST["FORUM_GROUP"]["PARENT_ID"]);
    for ($i = 0; $i < count($arSysLangs); $i++) {
        $arFields["LANG"][] = array("LID" => $arSysLangs[$i], "NAME" => $_REQUEST["FORUM_GROUP"]["LANG"][$arSysLangs[$i]]["NAME"], "DESCRIPTION" => $_REQUEST["FORUM_GROUP"]["LANG"][$arSysLangs[$i]]["DESCRIPTION"]);
    }
    if (!CForumGroup::CheckFields($ID > 0 ? "UPDATE" : "ADD", $arFields, $ID > 0 ? $ID : false)) {
Example #23
0
function saleLocationImport($arParams)
{
    global $DB;
    $arReturn = array('STEP' => false, 'ERROR' => '', 'AMOUNT' => 0, 'POS' => 0, 'MESSAGE' => '');
    $step_length = intval($arParams["STEP_LENGTH"]);
    if ($step_length <= 0) {
        $step_length = 10;
    }
    define('ZIP_STEP_LENGTH', $step_length);
    define('LOC_STEP_LENGTH', $step_length);
    define('DLZIPFILE', $arParams["DLZIPFILE"]);
    $STEP = intval($arParams['STEP']);
    $CSVFILE = $arParams["CSVFILE"];
    $LOADZIP = $arParams["LOADZIP"];
    $bSync = $arParams["SYNC"] == "Y";
    if (isset($arParams['TMP_PATH'])) {
        $sTmpFilePath = $arParams['TMP_PATH'];
    } else {
        $sTmpFilePath = CTempFile::GetDirectoryName(12, 'sale');
    }
    if (strlen($CSVFILE) > 0 && !in_array($CSVFILE, array('loc_ussr.csv', 'loc_ua.csv', 'loc_kz.csv', 'loc_usa.csv', 'loc_cntr.csv', 'locations.csv'))) {
        //echo GetMessage('SL_IMPORT_ERROR_FILES');
        $arReturn['ERROR'] = GetMessage('SL_IMPORT_ERROR_FILES');
    } else {
        if ($STEP == 1 && strlen($CSVFILE) <= 0) {
            if ($LOADZIP == 'Y') {
                $STEP = 2;
            } else {
                $STEP = 3;
            }
        }
        switch ($STEP) {
            case 0:
                $arReturn['MESSAGE'] = GetMessage('WSL_IMPORT_FILES_LOADING');
                $arReturn['STEP'] = 1;
                break;
            case 1:
                $time_limit = ini_get('max_execution_time');
                if ($time_limit < LOC_STEP_LENGTH) {
                    set_time_limit(LOC_STEP_LENGTH + 5);
                }
                $start_time = time();
                $finish_time = $start_time + LOC_STEP_LENGTH;
                $file_url = $sTmpFilePath . $CSVFILE;
                if (!file_exists($file_url)) {
                    $arReturn['ERROR'] = GetMessage('SL_IMPORT_ERROR_NO_LOC_FILE');
                    break;
                }
                $bFinish = true;
                $arSysLangs = array();
                $db_lang = CLangAdmin::GetList($b = "sort", $o = "asc", array("ACTIVE" => "Y"));
                while ($arLang = $db_lang->Fetch()) {
                    $arSysLangs[$arLang["LID"]] = $arLang["LID"];
                }
                $arLocations = array();
                if (!$bSync) {
                    if (!is_set($_SESSION["LOC_POS"])) {
                        CSaleLocation::DeleteAll();
                    }
                } else {
                    $dbLocations = CSaleLocation::GetList(array(), array(), false, false, array("ID", "COUNTRY_ID", "REGION_ID", "CITY_ID"));
                    while ($arLoc = $dbLocations->Fetch()) {
                        $arLocations[$arLoc["ID"]] = $arLoc;
                    }
                }
                if (count($arLocations) <= 0) {
                    $bSync = false;
                }
                include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/csv_data.php";
                $csvFile = new CCSVData();
                $csvFile->LoadFile($file_url);
                $csvFile->SetFieldsType("R");
                $csvFile->SetFirstHeader(false);
                $csvFile->SetDelimiter(",");
                $arRes = $csvFile->Fetch();
                if (!is_array($arRes) || count($arRes) <= 0 || strlen($arRes[0]) != 2) {
                    $strWarning .= GetMessage('SL_IMPORT_ERROR_WRONG_LOC_FILE') . "<br />";
                }
                if (strlen($strWarning) <= 0) {
                    $DefLang = $arRes[0];
                    if (!in_array($DefLang, $arSysLangs)) {
                        $strWarning .= GetMessage('SL_IMPORT_ERROR_NO_LANG') . "<br />";
                    }
                }
                if (strlen($strWarning) > 0) {
                    $arReturn['ERROR'] = $strWarning . "<br />";
                    break;
                }
                if (is_set($_SESSION["LOC_POS"])) {
                    $csvFile->SetPos($_SESSION["LOC_POS"]);
                    $CurCountryID = $_SESSION["CUR_COUNTRY_ID"];
                    $CurRegionID = $_SESSION["CUR_REGION_ID"];
                    $numCountries = $_SESSION["NUM_COUNTRIES"];
                    $numRegiones = $_SESSION["NUM_REGIONES"];
                    $numCities = $_SESSION["NUM_CITIES"];
                    $numLocations = $_SESSION["NUM_LOCATIONS"];
                } else {
                    $CurCountryID = 0;
                    $CurRegionID = 0;
                    $numCountries = 0;
                    $numRegiones = 0;
                    $numCities = 0;
                    $numLocations = 0;
                }
                $tt = 0;
                while ($arRes = $csvFile->Fetch()) {
                    $type = ToUpper($arRes[0]);
                    $tt++;
                    $arArrayTmp = array();
                    foreach ($arRes as $ind => $value) {
                        if ($ind % 2 && isset($arSysLangs[$value])) {
                            $arArrayTmp[$value] = array("LID" => $value, "NAME" => $arRes[$ind + 1]);
                            if ($value == $DefLang) {
                                $arArrayTmp["NAME"] = $arRes[$ind + 1];
                            }
                        }
                    }
                    //country
                    if (is_array($arArrayTmp) && strlen($arArrayTmp["NAME"]) > 0) {
                        if ($type == "S") {
                            $CurRegionID = null;
                            $arRegionList = array();
                            $CurCountryID = null;
                            $arContList = array();
                            $LLL = 0;
                            if ($bSync) {
                                $db_contList = CSaleLocation::GetList(array(), array("COUNTRY_NAME" => $arArrayTmp["NAME"], "LID" => $DefLang));
                                if ($arContList = $db_contList->Fetch()) {
                                    $LLL = IntVal($arContList["ID"]);
                                    $CurCountryID = IntVal($arContList["COUNTRY_ID"]);
                                }
                            }
                            if (IntVal($CurCountryID) <= 0) {
                                $CurCountryID = CSaleLocation::AddCountry($arArrayTmp);
                                $CurCountryID = IntVal($CurCountryID);
                                if ($CurCountryID > 0) {
                                    $numCountries++;
                                    if (IntVal($LLL) <= 0) {
                                        $LLL = CSaleLocation::AddLocation(array("COUNTRY_ID" => $CurCountryID));
                                        if (IntVal($LLL) > 0) {
                                            $numLocations++;
                                        }
                                    }
                                }
                            }
                        } elseif ($type == "R") {
                            $CurRegionID = null;
                            $arRegionList = array();
                            $LLL = 0;
                            if ($bSync) {
                                $db_rengList = CSaleLocation::GetList(array(), array("COUNTRY_ID" => $CurCountryID, "REGION_NAME" => $arArrayTmp["NAME"], "LID" => $DefLang));
                                if ($arRegionList = $db_rengList->Fetch()) {
                                    $LLL = $arRegionList["ID"];
                                    $CurRegionID = IntVal($arRegionList["REGION_ID"]);
                                }
                            }
                            if (IntVal($CurRegionID) <= 0) {
                                $CurRegionID = CSaleLocation::AddRegion($arArrayTmp);
                                $CurRegionID = IntVal($CurRegionID);
                                if ($CurRegionID > 0) {
                                    $numRegiones++;
                                    if (IntVal($LLL) <= 0) {
                                        $LLL = CSaleLocation::AddLocation(array("COUNTRY_ID" => $CurCountryID, "REGION_ID" => $CurRegionID));
                                        if (IntVal($LLL) > 0) {
                                            $numLocations++;
                                        }
                                    }
                                }
                            }
                        } elseif ($type == "T" && IntVal($CurCountryID) > 0) {
                            $city_id = 0;
                            $LLL = 0;
                            $arCityList = array();
                            if ($bSync) {
                                $arFilter = array("COUNTRY_ID" => $CurCountryID, "CITY_NAME" => $arArrayTmp["NAME"], "LID" => $DefLang);
                                if (IntVal($CurRegionID) > 0) {
                                    $arFilter["REGION_ID"] = $CurRegionID;
                                }
                                $db_cityList = CSaleLocation::GetList(array(), $arFilter);
                                if ($arCityList = $db_cityList->Fetch()) {
                                    $LLL = $arCityList["ID"];
                                    $city_id = IntVal($arCityList["CITY_ID"]);
                                }
                            }
                            if ($city_id <= 0) {
                                $city_id = CSaleLocation::AddCity($arArrayTmp);
                                $city_id = IntVal($city_id);
                                if ($city_id > 0) {
                                    $numCities++;
                                }
                            }
                            if ($city_id > 0) {
                                if (IntVal($LLL) <= 0) {
                                    $LLL = CSaleLocation::AddLocation(array("COUNTRY_ID" => $CurCountryID, "REGION_ID" => $CurRegionID, "CITY_ID" => $city_id));
                                    if (intval($LLL) > 0) {
                                        $numLocations++;
                                    }
                                }
                            }
                        }
                    }
                    if ($tt == 10) {
                        $tt = 0;
                        $cur_time = time();
                        if ($cur_time >= $finish_time) {
                            $cur_step = $csvFile->GetPos();
                            $amount = $csvFile->iFileLength;
                            $_SESSION["LOC_POS"] = $cur_step;
                            $_SESSION["CUR_COUNTRY_ID"] = $CurCountryID;
                            $_SESSION["CUR_REGION_ID"] = $CurRegionID;
                            $_SESSION["NUM_COUNTRIES"] = $numCountries;
                            $_SESSION["NUM_REGIONES"] = $numRegiones;
                            $_SESSION["NUM_CITIES"] = $numCities;
                            $_SESSION["NUM_LOCATIONS"] = $numLocations;
                            $bFinish = false;
                            //echo "<script>Import(1, {AMOUNT:".CUtil::JSEscape($amount).",POS:".CUtil::JSEscape($cur_step)."})</script>";
                            $arReturn['STEP'] = 1;
                            $arReturn['AMOUNT'] = $amount;
                            $arReturn['POS'] = $cur_step;
                            break;
                        }
                    }
                }
                if ($bFinish) {
                    unset($_SESSION["LOC_POS"]);
                    $strOK = GetMessage('SL_IMPORT_LOC_STATS') . '<br />';
                    $strOK = str_replace('#NUMCOUNTRIES#', intval($numCountries), $strOK);
                    $strOK = str_replace('#NUMREGIONES#', intval($numRegiones), $strOK);
                    $strOK = str_replace('#NUMCITIES#', intval($numCities), $strOK);
                    $strOK = str_replace('#NUMLOCATIONS#', intval($numLocations), $strOK);
                    $arReturn['MESSAGE'] = $strOK;
                    $arReturn['STEP'] = $LOADZIP == "Y" ? 2 : 3;
                    //echo '<script>Import('.($LOADZIP == "Y" ? 2 : 3).')</script>';
                }
                break;
            case 2:
                $time_limit = ini_get('max_execution_time');
                if ($time_limit < ZIP_STEP_LENGTH) {
                    set_time_limit(ZIP_STEP_LENGTH + 5);
                }
                $start_time = time();
                $finish_time = $start_time + ZIP_STEP_LENGTH;
                if ($LOADZIP == "Y" && file_exists($sTmpFilePath . DLZIPFILE)) {
                    $rsLocations = CSaleLocation::GetList(array(), array("LID" => 'ru'), false, false, array("ID", "CITY_NAME_LANG", "REGION_NAME_LANG"));
                    $arLocationMap = array();
                    while ($arLocation = $rsLocations->Fetch()) {
                        if (strlen($arLocation["REGION_NAME_LANG"]) > 0) {
                            if (strlen($arLocation["CITY_NAME_LANG"]) > 0) {
                                $arLocationMap[$arLocation["CITY_NAME_LANG"]][$arLocation["REGION_NAME_LANG"]] = $arLocation["ID"];
                            }
                        } else {
                            $arLocationMap[$arLocation["CITY_NAME_LANG"]] = $arLocation["ID"];
                        }
                    }
                    $DB->StartTransaction();
                    include_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/csv_data.php";
                    $csvFile = new CCSVData();
                    $csvFile->LoadFile($sTmpFilePath . DLZIPFILE);
                    $csvFile->SetFieldsType("R");
                    $csvFile->SetFirstHeader(false);
                    $csvFile->SetDelimiter(";");
                    if (is_set($_SESSION, 'ZIP_POS')) {
                        $numZIP = $_SESSION["NUM_ZIP"];
                        $csvFile->SetPos($_SESSION["ZIP_POS"]);
                    } else {
                        CSaleLocation::ClearAllLocationZIP();
                        unset($_SESSION["NUM_ZIP"]);
                        $numZIP = 0;
                    }
                    $bFinish = true;
                    $tt = 0;
                    $REGION = "";
                    while ($arRes = $csvFile->Fetch()) {
                        $tt++;
                        $CITY = $arRes[1];
                        if (strlen($arRes[3]) > 0) {
                            $REGION = $arRes[3];
                        }
                        if (array_key_exists($CITY, $arLocationMap)) {
                            if (strlen($REGION) > 0) {
                                $ID = $arLocationMap[$CITY][$REGION];
                            } else {
                                $ID = $arLocationMap[$CITY];
                            }
                        } else {
                            $ID = 0;
                        }
                        if ($ID) {
                            CSaleLocation::AddLocationZIP($ID, $arRes[2]);
                            $numZIP++;
                        }
                        if ($tt == 10) {
                            $tt = 0;
                            $cur_time = time();
                            if ($cur_time >= $finish_time) {
                                $cur_step = $csvFile->GetPos();
                                $amount = $csvFile->iFileLength;
                                $_SESSION["ZIP_POS"] = $cur_step;
                                $_SESSION["NUM_ZIP"] = $numZIP;
                                $bFinish = false;
                                $arReturn['STEP'] = 2;
                                $arReturn['AMOUNT'] = $amount;
                                $arReturn['POS'] = $cur_step;
                                break;
                            }
                        }
                    }
                    $DB->Commit();
                    if ($bFinish) {
                        unset($_SESSION["ZIP_POS"]);
                        $numCity = CSaleLocation::_GetZIPImportStats();
                        $strOK = GetMessage('SL_IMPORT_ZIP_STATS');
                        $strOK = str_replace('#NUMZIP#', intval($numZIP), $strOK);
                        $strOK = str_replace('#NUMCITIES#', intval($numCity["CITY_CNT"]), $strOK);
                        $arReturn['MESSAGE'] = $strOK;
                        $arReturn['STEP'] = 3;
                        $arReturn['PB_REMOVE'] = true;
                        break;
                    }
                } else {
                    $arReturn['ERROR'] = GetMessage('SL_IMPORT_ERROR_NO_ZIP_FILE') . '<br>';
                    $arReturn['STEP'] = 3;
                    break;
                }
                break;
            case 3:
                $arReturn['COMPLETE'] = true;
                break;
        }
    }
    return $arReturn;
}
Example #24
0
 * @package bitrix
 * @subpackage main
 * @copyright 2001-2013 Bitrix
 */
require_once substr(__FILE__, 0, strlen(__FILE__) - strlen("/include.php")) . "/bx_root.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/start.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_io.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/virtual_file.php";
//define global application object
$GLOBALS["APPLICATION"] = new CMain();
if (defined("SITE_ID")) {
    define("LANG", SITE_ID);
}
if (defined("LANG")) {
    if (defined("ADMIN_SECTION") && ADMIN_SECTION === true) {
        $db_lang = CLangAdmin::GetByID(LANG);
    } else {
        $db_lang = CLang::GetByID(LANG);
    }
    $arLang = $db_lang->Fetch();
} else {
    $arLang = $GLOBALS["APPLICATION"]->GetLang();
    define("LANG", $arLang["LID"]);
}
$lang = $arLang["LID"];
define("SITE_ID", $arLang["LID"]);
define("SITE_DIR", $arLang["DIR"]);
define("SITE_SERVER_NAME", $arLang["SERVER_NAME"]);
define("SITE_CHARSET", $arLang["CHARSET"]);
define("FORMAT_DATE", $arLang["FORMAT_DATE"]);
define("FORMAT_DATETIME", $arLang["FORMAT_DATETIME"]);
Example #25
0
$arSelectFields = array_values($arSelectFields);
$arSelectFieldsMap = array_merge($arSelectFieldsMap, array_fill_keys($arSelectFields, true));

$mxKey = array_search('NAME_LID', $arSelectFields);
if (false !== $mxKey)
{
	unset($arSelectFields[$mxKey]);
	$arSelectFields = array_values($arSelectFields);
}

$arLangList = array();
$arLangDefList = array();
if ($arSelectFieldsMap['NAME_LID'])
{
	$rsPriceLangs = CLangAdmin::GetList(($by1="sort"), ($order1="asc"));
	while ($arPriceLang = $rsPriceLangs->Fetch())
	{
		$arLangList[$arPriceLang['LID']] = true;
		$arLangDefList[$arPriceLang['LID']] = str_replace('#LANG#', htmlspecialcharsex($arPriceLang['NAME']), GetMessage('BT_CAT_GROUP_ADM_LANG_MESS'));
	}
}

$arNavParams = (isset($_REQUEST["mode"]) && 'excel' == $_REQUEST["mode"]
	? false
	: array("nPageSize" => CAdminResult::GetNavSize($sTableID))
);

$dbResultList = CCatalogGroup::GetList(
	array($by => $order),
	array(),