Exemplo n.º 1
1
 public static function delete($id)
 {
     //We know for sure that languages and sites can refer to the culture.
     //Other entities should place CultureOnBeforeDelete event handler.
     $result = new Entity\DeleteResult();
     $res = LanguageTable::getList(array('filter' => array('=CULTURE_ID' => $id)));
     while ($language = $res->fetch()) {
         $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_lang", array("#LID#" => $language["LID"]))));
     }
     $res = \Bitrix\Main\SiteTable::getList(array('filter' => array('=CULTURE_ID' => $id)));
     while ($site = $res->fetch()) {
         $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_site", array("#LID#" => $site["LID"]))));
     }
     if (!$result->isSuccess()) {
         return $result;
     }
     return parent::delete($id);
 }
Exemplo n.º 2
0
 public function GetAdminListViewHTML($userField, $htmlControl)
 {
     $rsLang = LanguageTable::query()->setFilter(['LID' => $htmlControl['VALUE']])->setSelect(['NAME'])->exec();
     if ($lang = $rsLang->fetch()) {
         return $lang['NAME'];
     }
 }
Exemplo n.º 3
0
 public static function getAdminListViewHTML($property, $value, $strHTMLControlName)
 {
     $rsLang = LanguageTable::query()->setFilter(['LID' => $value['VALUE']])->setSelect(['NAME'])->exec();
     if ($lang = $rsLang->fetch()) {
         return $lang['NAME'];
     }
 }
Exemplo n.º 4
0
 protected function getCurrentLang()
 {
     $context = $this->getContext();
     $request = $context->getRequest();
     $defaultLang = $request["lang"];
     if ($defaultLang == '') {
         $defaultLang = \COption::getOptionString("main", "admin_lid");
     }
     if ($defaultLang != '') {
         $langDb = LanguageTable::getById($defaultLang);
         if ($language = $langDb->fetch()) {
             return $language;
         }
     }
     return null;
 }
Exemplo n.º 5
0
 /**
  * Convert the info block to i18n.
  * 
  * @param string $propCodePublicId
  * @param string $propCodeLang
  * @param string $defaultLang
  * 
  * @throws InternationalizeException
  * @throws \Exception
  */
 public function convert($propCodePublicId, $propCodeLang, $defaultLang)
 {
     $rsDefaultLang = LanguageTable::query()->setFilter(['LID' => $defaultLang])->exec();
     if ($rsDefaultLang->getSelectedRowsCount() <= 0) {
         throw new InternationalizeException([Loc::getMessage('NOTAMEDIA_I18N_IMANAGER_NOT_FOUND_LANG')]);
     }
     foreach ($this->converters as $converter) {
         $this->connection->startTransaction();
         try {
             $converter->internationalize($propCodePublicId, $propCodeLang, $defaultLang);
             $converter->fill($propCodePublicId, $propCodeLang, $defaultLang);
         } catch (\Exception $e) {
             $this->connection->rollbackTransaction();
             throw $e;
         }
         $this->connection->commitTransaction();
     }
 }
Exemplo n.º 6
0
 function InstallUserFields()
 {
     $ImportantUserFields = $this->GetIdeaUserFields();
     $messages = array();
     $db_res = \Bitrix\Main\Localization\LanguageTable::getList(array('order' => array('SORT' => 'ASC')));
     while ($ar = $db_res->fetch()) {
         $messages[$ar["LID"]] = IncludeModuleLangFile(__FILE__, $ar["LID"], true);
     }
     foreach ($ImportantUserFields as $UserFieldName => $Exists) {
         if (!$Exists) {
             $EDIT_FORM_LABEL = array();
             foreach ($messages as $lid => $mess) {
                 $EDIT_FORM_LABEL[$lid] = $mess["IDEA_" . $UserFieldName . "_DESCRIPTION"];
             }
             $UserType = new CUserTypeEntity();
             switch ($UserFieldName) {
                 case "UF_CATEGORY_CODE":
                     GetMessage("IDEA_UF_CATEGORY_CODE_DESCRIPTION");
                     $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL));
                     break;
                 case "UF_ANSWER_ID":
                     GetMessage("IDEA_UF_ANSWER_ID_DESCRIPTION");
                     $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "integer", "IS_SEARCHABLE" => "N", "MULTIPLE" => "Y", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL));
                     break;
                 case "UF_ORIGINAL_ID":
                     GetMessage("IDEA_UF_ORIGINAL_ID_DESCRIPTION");
                     $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "string", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL));
                     break;
                 case "UF_STATUS":
                     GetMessage("IDEA_UF_STATUS_DESCRIPTION");
                     $ID = $UserType->Add(array("ENTITY_ID" => "BLOG_POST", "FIELD_NAME" => $UserFieldName, "USER_TYPE_ID" => "enumeration", "IS_SEARCHABLE" => "N", "EDIT_FORM_LABEL" => $EDIT_FORM_LABEL));
                     if (intval($ID) > 0) {
                         $UserTypeEnum = new CUserFieldEnum();
                         $UserTypeEnum->SetEnumValues($ID, array("n0" => array("SORT" => 100, "XML_ID" => "NEW", "VALUE" => GetMessage("IDEA_UF_STATUS_NEW_TITLE"), "DEF" => "Y"), "n1" => array("SORT" => 200, "XML_ID" => "PROCESSING", "VALUE" => GetMessage("IDEA_UF_STATUS_PROCESSING_TITLE"), "DEF" => "N"), "n2" => array("SORT" => 300, "XML_ID" => "COMPLETED", "VALUE" => GetMessage("IDEA_UF_STATUS_COMPLETED_TITLE"), "DEF" => "N")));
                     }
                     break;
             }
         }
     }
 }
Exemplo n.º 7
0
 public static function setLanguageList($languages = self::LANGUAGES_DEFAULT, $customList = array())
 {
     if ($languages == self::LANGUAGES_ACTIVE || $languages == self::LANGUAGES_EXIST) {
         self::$languageList = array();
         if ($languages == self::LANGUAGES_ACTIVE) {
             $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('ACTIVE' => 'Y')));
         } else {
             $languageIterator = LanguageTable::getList(array('select' => array('ID')));
         }
         while ($lang = $languageIterator->fetch()) {
             self::$languageList[] = $lang['ID'];
         }
         unset($lang, $languageIterator);
     } elseif ($languages == self::LANGUAGES_CUSTOM) {
         if (!is_array($customList)) {
             $customList = array($customList);
         }
         self::$languageList = $customList;
     } else {
         self::$languageList = array("ru", "en", "de", "ua");
     }
 }
Exemplo n.º 8
0
 public static function GetLangSwitcherArray()
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION;
     $result = array();
     $db_res = \Bitrix\Main\Localization\LanguageTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC')));
     while ($ar = $db_res->fetch()) {
         $ar["NAME"] = htmlspecialcharsbx($ar["NAME"]);
         $ar["SELECTED"] = $ar["LID"] == LANG;
         global $QUERY_STRING;
         $p = rtrim(str_replace("&#", "#", preg_replace("/lang=[^&#]*&*/", "", $QUERY_STRING)), "&");
         $ar["PATH"] = $APPLICATION->GetCurPage() . "?lang=" . $ar["LID"] . ($p != '' ? '&amp;' . htmlspecialcharsbx($p) : '');
         $result[] = $ar;
     }
     return $result;
 }
Exemplo n.º 9
0
 }
 // create iblock
 $arNewOffers = array();
 if ($boolFlag) {
     $DB->StartTransaction();
     foreach ($arNewIBlocksList as $intIBlockID => $arIBlockInfo) {
         if (CATALOG_NEW_OFFERS_IBLOCK_NEED == $arIBlockInfo['OFFERS_IBLOCK_ID']) {
             // need new offers
             $arResultNewCatalogItem = array();
             if ('Y' == $arIBlockInfo['CREATE_OFFERS_NEW_TYPE']) {
                 $rsIBlockTypes = CIBlockType::GetByID($arIBlockInfo['OFFERS_NEW_TYPE']);
                 if ($arIBlockType = $rsIBlockTypes->Fetch()) {
                     $arIBlockInfo['OFFERS_TYPE'] = $arIBlockInfo['OFFERS_NEW_TYPE'];
                 } else {
                     $arFields = array('ID' => $arIBlockInfo['OFFERS_NEW_TYPE'], 'SECTIONS' => 'N', 'IN_RSS' => 'N', 'SORT' => 500);
                     $languageIterator = Main\Localization\LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC')));
                     while ($language = $languageIterator->fetch()) {
                         $arFields['LANG'][$language['ID']]['NAME'] = $arIBlockInfo['OFFERS_NEW_TYPE'];
                     }
                     unset($language, $languageIterator);
                     $obIBlockType = new CIBlockType();
                     $mxOffersType = $obIBlockType->Add($arFields);
                     if (!$mxOffersType) {
                         $boolFlag = false;
                         $strWarning .= Loc::getMessage('CAT_IBLOCK_OFFERS_ERR_NEW_IBLOCK_TYPE_NOT_ADD', array('#PRODUCT#' => $arCurrentIBlocks[$intIBlockID]['INFO'], '#ERROR#' => $obIBlockType->LAST_ERROR)) . '<br />';
                     } else {
                         $arIBlockInfo['OFFERS_TYPE'] = $arIBlockInfo['OFFERS_NEW_TYPE'];
                     }
                 }
             }
             if ($boolFlag) {
Exemplo n.º 10
0
 /**
  * @return void
  */
 public static function clearCurrencyCache()
 {
     $currencyTableName = CurrencyTable::getTableName();
     $managedCache = Application::getInstance()->getManagedCache();
     $managedCache->clean(self::CACHE_CURRENCY_LIST_ID, $currencyTableName);
     $languageIterator = LanguageTable::getList(array('select' => array('ID')));
     while ($oneLanguage = $languageIterator->fetch()) {
         $managedCache->clean(self::CACHE_CURRENCY_LIST_ID . '_' . $oneLanguage['ID'], $currencyTableName);
     }
     unset($oneLanguage, $languageIterator);
     $managedCache->clean(self::CACHE_BASE_CURRENCY_ID, $currencyTableName);
     global $stackCacheManager;
     $stackCacheManager->Clear('currency_rate');
     $stackCacheManager->Clear('currency_currency_lang');
 }
Exemplo n.º 11
0
 public static function createBaseTypes()
 {
     $types = array('COUNTRY' => array('CODE' => 'COUNTRY', 'SORT' => 100, 'DISPLAY_SORT' => 700, 'NAME' => array()), 'REGION' => array('CODE' => 'REGION', 'SORT' => 300, 'DISPLAY_SORT' => 500, 'NAME' => array()), 'CITY' => array('CODE' => 'CITY', 'SORT' => 600, 'DISPLAY_SORT' => 100, 'NAME' => array()));
     $langs = array();
     $res = \Bitrix\Main\Localization\LanguageTable::getList();
     while ($item = $res->Fetch()) {
         $MESS = array();
         @(include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lang/' . $item['LID'] . '/lib/location/migration/migrate.php');
         if (!empty($MESS)) {
             $types['COUNTRY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_COUNTRY'];
             $types['REGION']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_REGION'];
             $types['CITY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_CITY'];
         }
         $langs[$item['LID']] = true;
     }
     $typeCode2Id = array();
     $res = Location\TypeTable::getList(array('select' => array('ID', 'CODE')));
     while ($item = $res->Fetch()) {
         $typeCode2Id[$item['CODE']] = $item['ID'];
     }
     foreach ($types as $code => &$type) {
         foreach ($langs as $lid => $f) {
             $type['NAME'][$lid] = \Bitrix\Sale\Location\Admin\NameHelper::getTranslatedName($type['NAME'], $lid);
         }
         if (!isset($typeCode2Id[$type['CODE']])) {
             $typeCode2Id[$type['CODE']] = Location\TypeTable::add($type);
         } else {
             // ensure it has all appropriate translations
             // we can not use ::updateMultipleForOwner() here, because user may rename types manually
             Location\Name\TypeTable::addAbsentForOwner($typeCode2Id[$type['CODE']], $type['NAME']);
         }
     }
     return $typeCode2Id;
 }
Exemplo n.º 12
0
 private static function getLanguages()
 {
     $langs = array();
     $res = Localization\LanguageTable::getList();
     while ($item = $res->fetch()) {
         $langs[] = $item['LID'];
     }
     return $langs;
 }
Exemplo n.º 13
0
$languages = array();
// LID => NAME
$groups = array();
// ID => NAME
$errors = array();
$tasks = array();
// ID => TASK
$result = TaskTable::getList(array('select' => array('*'), 'filter' => array('=MODULE_ID' => 'sale', '=BINDING' => 'status')));
while ($row = $result->fetch()) {
    $tasks[$row['ID']] = $row;
}
asort($tasks);
$statusFields = StatusTable::getEntity()->getFields();
$statusLangFields = StatusLangTable::getEntity()->getFields();
// get languages
$result = LanguageTable::getList(array('select' => array('LID', 'NAME'), 'filter' => array('=ACTIVE' => 'Y')));
while ($row = $result->fetch()) {
    $languages[$row['LID']] = $row['NAME'];
}
// get groups
$saleGroupIds = array();
$result = $APPLICATION->GetGroupRightList(array('MODULE_ID' => 'sale', 'G_ACCESS' => 'U'));
while ($row = $result->Fetch()) {
    if ($row['GROUP_ID'] > 2) {
        $saleGroupIds[] = $row['GROUP_ID'];
    }
}
if ($saleGroupIds) {
    $result = GroupTable::getList(array('select' => array('ID', 'NAME'), 'filter' => array('=ID' => $saleGroupIds), 'order' => array('C_SORT' => 'ASC', 'ID' => 'ASC')));
    while ($row = $result->fetch()) {
        $groups[$row['ID']] = $row['NAME'];
Exemplo n.º 14
0
	function InstallDB()
	{
		global $DB, $APPLICATION;
		global $stackCacheManager;
		global $CACHE_MANAGER;

		$this->errors = false;

		$bitrix24Path = $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/bitrix24/';
		$bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path);
		unset($bitrix24Path);

		if (!$DB->Query("SELECT COUNT(CURRENCY) FROM b_catalog_currency", true)):
			$this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/currency/install/db/".strtolower($DB->type)."/install.sql");
		endif;

		if ($this->errors !== false)
		{
			$APPLICATION->ThrowException(implode("", $this->errors));
			return false;
		}
		RegisterModule("currency");
		$stackCacheManager->Clear("currency_currency_lang");
		$CACHE_MANAGER->Clean("currency_currency_list", 'b_catalog_currency');
		$CACHE_MANAGER->Clean("currency_base_currency", 'b_catalog_currency');
		$stackCacheManager->Clear("currency_rate");

		if (Loader::includeModule("currency"))
		{
			$currencyIterator = CurrencyTable::getList(array(
				'select' => array('CURRENCY'),
				'limit' => 1
			));
			if (!($currency = $currencyIterator->fetch()))
			{
				$languageID = '';
				$siteIterator = SiteTable::getList(array(
					'select' => array('LID', 'LANGUAGE_ID'),
					'filter' => array('DEF' => 'Y', 'ACTIVE' => 'Y')
				));
				if ($site = $siteIterator->fetch())
				{
					$languageID = (string)$site['LANGUAGE_ID'];
				}
				if (isset($site))
					unset($site);
				unset($siteIterator);

				if ($languageID == '')
					$languageID = 'en';

				$currencyList = array();
				$currencySetID = '';
				switch ($languageID)
				{
					case 'ua':
					case 'de':
					case 'en':
						$currencySetID = $languageID;
						break;
					case 'ru':
						if (!$bitrix24)
						{
							$languageIterator = LanguageTable::getList(array(
								'select' => array('ID'),
								'filter' => array('ID' => 'kz', 'ACTIVE' => 'Y')
							));
							if ($existLanguage = $languageIterator->fetch())
							{
								$currencySetID = $existLanguage['ID'];
							}
							if ($currencySetID == '')
							{
								$languageIterator = LanguageTable::getList(array(
									'select' => array('ID'),
									'filter' => array('ID' => 'ua', 'ACTIVE' => 'Y')
								));
								if ($existLanguage = $languageIterator->fetch())
								{
									$currencySetID = $existLanguage['ID'];
								}
							}
						}
						if ($currencySetID == '')
						{
							$currencySetID = $languageID;
						}
						break;
					default:
						$currencySetID = 'en';
						break;
				}
				$datetimeEntity = new SqlExpression(Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction());
				switch ($currencySetID)
				{
					case 'kz':
						$addCurrency = array(
							array('CURRENCY' => 'KZT', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
							array('CURRENCY' => 'RUB', 'AMOUNT' => 1, 'AMOUNT_CNT' => 4.72, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.72),
							array('CURRENCY' => 'USD', 'AMOUNT' => 1, 'AMOUNT_CNT' => 154.52, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 154.52),
							array('CURRENCY' => 'EUR', 'AMOUNT' => 1, 'AMOUNT_CNT' => 212.73, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 212.73)
						);
						break;
					case 'ua':
						$addCurrency = array(
							array('CURRENCY' => 'UAH', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
							array('CURRENCY' => 'RUB', 'AMOUNT' => 2.54, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.254),
							array('CURRENCY' => 'USD', 'AMOUNT' => 799.3, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 7.993),
							array('CURRENCY' => 'EUR', 'AMOUNT' => 1083.37, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 10.8337)
						);
						break;
					case 'ru':
						$addCurrency = array(
							array('CURRENCY' => 'RUB', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
							array('CURRENCY' => 'USD', 'AMOUNT' => 32.30, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 32.30),
							array('CURRENCY' => 'EUR', 'AMOUNT' => 43.80, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 43.80),
							array('CURRENCY' => 'UAH', 'AMOUNT' => 39.41, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.941),
							array('CURRENCY' => 'BYR', 'AMOUNT' => 36.72, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.003672)
						);
						break;
					case 'de':
						$addCurrency = array(
							array('CURRENCY' => 'EUR', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
							array('CURRENCY' => 'USD', 'AMOUNT' => 0.74, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.74)
						);
						break;
					default:
					case 'en':
						$addCurrency = array(
							array('CURRENCY' => 'USD', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
							array('CURRENCY' => 'EUR', 'AMOUNT' => 1.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.36)
						);
						break;
				}
				foreach ($addCurrency as &$fields)
				{
					$fields['CREATED_BY'] = null;
					$fields['MODIFIED_BY'] = null;
					$fields['DATE_CREATE'] = $datetimeEntity;
					$fields['DATE_UPDATE'] = $datetimeEntity;
					$currencyResult = CurrencyTable::add($fields);
					if ($currencyResult->isSuccess())
						$currencyList[] = $fields['CURRENCY'];
				}
				unset($currencyResult, $fields);

				if (!empty($currencyList))
				{
					Option::set('currency', 'installed_currencies', implode(',', $currencyList), '');
					$languageIterator = LanguageTable::getList(array(
						'select' => array('ID'),
						'filter' => array('ACTIVE' => 'Y')
					));
					while ($existLanguage = $languageIterator->fetch())
					{
						$CACHE_MANAGER->Clean('currency_currency_list_'.$existLanguage['ID']);
						$messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/currency/install_lang.php', $existLanguage['ID']);
						foreach($currencyList as &$oneCurrency)
						{
							$fields = array(
								'LID' => $existLanguage['ID'],
								'CURRENCY' => $oneCurrency,
								'THOUSANDS_SEP' => false,
								'DECIMALS' => 2,
								'HIDE_ZERO' => 'Y',
								'FORMAT_STRING' => $messList['CUR_INSTALL_'.$oneCurrency.'_FORMAT_STRING'],
								'FULL_NAME' => $messList['CUR_INSTALL_'.$oneCurrency.'_FULL_NAME'],
								'DEC_POINT' => $messList['CUR_INSTALL_'.$oneCurrency.'_DEC_POINT'],
								'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_'.$oneCurrency.'_THOUSANDS_SEP'],
								'CREATED_BY' => null,
								'MODIFIED_BY' => null,
								'DATE_CREATE' => $datetimeEntity,
								'TIMESTAMP_X' => $datetimeEntity
							);
							$resultCurrencyLang = CurrencyLangTable::add($fields);
						}
						unset($oneCurrency);
					}
					unset($existLanguage, $languageIterator);
					if (!$bitrix24)
					{
						$checkDate = DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));;
						CAgent::AddAgent('\Bitrix\Currency\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true);
					}
				}
			}
		}
		$stackCacheManager->Clear("currency_currency_lang");
		$CACHE_MANAGER->Clean("currency_currency_list", 'b_catalog_currency');
		$CACHE_MANAGER->Clean("currency_base_currency", 'b_catalog_currency');
		$stackCacheManager->Clear("currency_rate");

		return true;
	}
Exemplo n.º 15
0
 function InstallDB()
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!$DB->Query("SELECT 'x' FROM b_sale_basket", true)) {
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/install/db/" . $DBType . "/install.sql");
     }
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("", $this->errors));
         return false;
     }
     ModuleManager::registerModule('sale');
     $eventManager = \Bitrix\Main\EventManager::getInstance();
     $eventManager->registerEventHandlerCompatible('main', 'OnUserLogout', 'sale', '\\Bitrix\\Sale\\DiscountCouponsManager', 'logout');
     RegisterModuleDependences("main", "OnUserLogin", "sale", "CSaleUser", "OnUserLogin");
     RegisterModuleDependences("main", "OnUserLogout", "sale", "CSaleUser", "OnUserLogout");
     RegisterModuleDependences("main", "OnBeforeLangDelete", "sale", "CSalePersonType", "OnBeforeLangDelete");
     RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocation", "OnLangDelete");
     RegisterModuleDependences("main", "OnLanguageDelete", "sale", "CSaleLocationGroup", "OnLangDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleOrderUserProps", "OnUserDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserAccount", "OnUserDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleAuxiliary", "OnUserDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUser", "OnUserDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleRecurring", "OnUserDelete");
     RegisterModuleDependences("main", "OnUserDelete", "sale", "CSaleUserCards", "OnUserDelete");
     RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleOrder", "OnBeforeUserDelete");
     RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleAffiliate", "OnBeforeUserDelete");
     RegisterModuleDependences("main", "OnBeforeUserDelete", "sale", "CSaleUserAccount", "OnBeforeUserDelete");
     RegisterModuleDependences("main", "OnBeforeProlog", "main", "", "", 100, "/modules/sale/affiliate.php");
     RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "sale", "CSaleYMHandler", 'OnEventLogGetAuditTypes');
     RegisterModuleDependences("main", "OnEventLogGetAuditTypes", "sale", "CSalePaySystemAction", 'OnEventLogGetAuditTypes');
     RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleOrder", "OnBeforeCurrencyDelete");
     RegisterModuleDependences("currency", "OnBeforeCurrencyDelete", "sale", "CSaleLang", "OnBeforeCurrencyDelete");
     RegisterModuleDependences("currency", "OnModuleUnInstall", "sale", "", "CurrencyModuleUnInstallSale");
     RegisterModuleDependences("catalog", "OnSaleOrderSumm", "sale", "CSaleOrder", "__SaleOrderCount");
     RegisterModuleDependences("mobileapp", "OnBeforeAdminMobileMenuBuild", "sale", "CSaleMobileOrderUtils", "buildSaleAdminMobileMenu");
     RegisterModuleDependences("sender", "OnConnectorList", "sale", "\\Bitrix\\Sale\\SenderEventHandler", "onConnectorListBuyer");
     RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlGroup", "GetControlDescr", 100);
     RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketGroup", "GetControlDescr", 200);
     RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlBasketFields", "GetControlDescr", 300);
     RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlOrderFields", "GetControlDescr", 1000);
     RegisterModuleDependences("sale", "OnCondSaleControlBuildList", "sale", "CSaleCondCtrlCommon", "GetControlDescr", 10000);
     RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlGroup", "GetControlDescr", 100);
     RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlDelivery", "GetControlDescr", 200);
     RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlBasketGroup", "GetControlDescr", 300);
     RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCtrlSubGroup", "GetControlDescr", 1000);
     RegisterModuleDependences("sale", "OnCondSaleActionsControlBuildList", "sale", "CSaleActionCondCtrlBasketFields", "GetControlDescr", 1100);
     //pulling for mobile orders
     RegisterModuleDependences("sale", "OnOrderDelete", "sale", "CSaleMobileOrderPull", "onOrderDelete", 100);
     RegisterModuleDependences("sale", "OnOrderAdd", "sale", "CSaleMobileOrderPull", "onOrderAdd", 100);
     RegisterModuleDependences("sale", "OnOrderUpdate", "sale", "CSaleMobileOrderPull", "onOrderUpdate", 100);
     // sale product2product
     RegisterModuleDependences("sale", "OnBasketOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleOrderAdd", 100);
     RegisterModuleDependences("sale", "OnSaleStatusOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleStatusOrderHandler", 100);
     RegisterModuleDependences("sale", "OnSaleDeliveryOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeliveryOrderHandler", 100);
     RegisterModuleDependences("sale", "OnSaleDeductOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleDeductOrderHandler", 100);
     RegisterModuleDependences("sale", "OnSaleCancelOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSaleCancelOrderHandler", 100);
     RegisterModuleDependences("sale", "OnSalePayOrder", "sale", "\\Bitrix\\Sale\\Product2ProductTable", "onSalePayOrderHandler", 100);
     CAgent::AddAgent("\\Bitrix\\Sale\\Product2ProductTable::deleteOldProducts(10);", "sale", "N", 10 * 24 * 3600, "", "Y");
     COption::SetOptionString("sale", "viewed_capability", "N");
     COption::SetOptionString("sale", "viewed_count", 10);
     COption::SetOptionString("sale", "viewed_time", 5);
     COption::SetOptionString("sale", "p2p_status_list", serialize(array("N", "P", "F", "F_CANCELED", "F_DELIVERY", "F_PAY", "F_OUT")));
     CAgent::AddAgent("CSaleRecurring::AgentCheckRecurring();", "sale", "N", 7200, "", "Y");
     CAgent::AddAgent("CSaleOrder::RemindPayment();", "sale", "N", 86400, "", "Y");
     CAgent::AddAgent("CSaleViewedProduct::ClearViewed();", "sale", "N", 86400, "", "Y");
     CAgent::AddAgent("CSaleOrder::ClearProductReservedQuantity();", "sale", "N", 259200, "", "Y");
     COption::SetOptionString("sale", "product_reserve_clear_period", "3");
     if (CModule::IncludeModule("sale")) {
         $dbStatusList = CSaleStatus::GetList(array(), array(), false, false, array());
         if (!($arStatusList = $dbStatusList->Fetch())) {
             $arLandDataN = array();
             $arLandDataF = array();
             $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y')));
             while ($language = $languageIterator->fetch()) {
                 IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/status.php", $language['ID']);
                 $arLandDataN[] = array("LID" => $language['ID'], "NAME" => GetMessage("SIM_ACCEPTED"), "DESCRIPTION" => GetMessage("SIM_ACCEPTED_DESCR"));
                 $arLandDataF[] = array("LID" => $language['ID'], "NAME" => GetMessage("SIM_FINISHED"), "DESCRIPTION" => GetMessage("SIM_FINISHED_DESCR"));
             }
             unset($language, $languageIterator);
             CSaleStatus::Add(array("ID" => "N", "SORT" => 100, "LANG" => $arLandDataN));
             CSaleStatus::Add(array("ID" => "F", "SORT" => 200, "LANG" => $arLandDataF));
         }
         // enabling location pro
         COption::SetOptionString("sale", "sale_locationpro_migrated", "Y");
         COption::SetOptionString("sale", "sale_locationpro_enabled", "Y");
         if (\Bitrix\Main\ModuleManager::isModuleInstalled('bitrix24')) {
             // this will create at least base types if we are at Bitrix24
             include_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/sale/lib/location/migration/migrate.php";
             \Bitrix\Sale\Location\Migration\CUpdaterLocationPro::createBaseTypes();
         }
         CSaleYMHandler::install();
     }
     return true;
 }
Exemplo n.º 16
0
	protected function installCurrencies()
	{
		if (!Loader::includeModule('currency'))
			return;

		$bitrix24Path = $_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/bitrix24/';
		$bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path);
		unset($bitrix24Path);

		$currencyIterator = \Bitrix\Currency\CurrencyTable::getList(array(
			'select' => array('CURRENCY'),
			'limit' => 1
		));
		$currency = $currencyIterator->fetch();
		if (!empty($currency))
			return;

		$languageID = '';
		$siteIterator = SiteTable::getList(array(
			'select' => array('LID', 'LANGUAGE_ID'),
			'filter' => array('=DEF' => 'Y', '=ACTIVE' => 'Y')
		));
		if ($site = $siteIterator->fetch())
			$languageID = (string)$site['LANGUAGE_ID'];
		unset($site, $siteIterator);

		if ($languageID == '')
			$languageID = 'en';

		$currencyList = array();
		$currencySetID = '';
		switch ($languageID)
		{
			case 'ua':
			case 'de':
			case 'en':
			case 'la':
			case 'tc':
			case 'sc':
				$currencySetID = $languageID;
				break;
			case 'ru':
				if (!$bitrix24)
				{
					$languageIterator = LanguageTable::getList(array(
						'select' => array('ID'),
						'filter' => array('=ID' => 'kz', '=ACTIVE' => 'Y')
					));
					if ($existLanguage = $languageIterator->fetch())
						$currencySetID = $existLanguage['ID'];

					if ($currencySetID == '')
					{
						$languageIterator = LanguageTable::getList(array(
							'select' => array('ID'),
							'filter' => array('=ID' => 'ua', '=ACTIVE' => 'Y')
						));
						if ($existLanguage = $languageIterator->fetch())
							$currencySetID = $existLanguage['ID'];
					}
					unset($existLanguage, $languageIterator);
				}
				if ($currencySetID == '')
					$currencySetID = $languageID;
				break;
			default:
				$currencySetID = 'en';
				break;
		}
		$datetimeEntity = new Main\DB\SqlExpression(Main\Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction());
		switch ($currencySetID)
		{
			case 'kz':
				$addCurrency = array(
					array('CURRENCY' => 'KZT', 'NUMCODE' => '398', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 3.09, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.09),
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 185.5, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 185.5),
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 198.13, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 198.13)
				);
				break;
			case 'ua':
				$addCurrency = array(
					array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 4.00, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.4),
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 2355.70, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 23.557),
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 2579.49, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 25.7949)
				);
				break;
			case 'ru':
				$addCurrency = array(
					array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 57.39, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 57.39),
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 62.77, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 62.77),
					array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 24.53, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 2.453),
					array('CURRENCY' => 'BYR', 'NUMCODE' => '974', 'AMOUNT' => 39.44, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.003944)
				);
				break;
			case 'de':
			case 'la':
				$addCurrency = array(
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 0.91, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.91),
					array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 14.65, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1465),
					array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 29.12, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2912),
					array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 14.59, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01459)
				);
				break;
			case 'tc':
			case 'sc':
				$addCurrency = array(
					array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 6.21, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1610),
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 6.75, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1482),
					array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1.93, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.5181),
					array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 9,94, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.0994)
				);
				break;
			default:
			case 'en':
				$addCurrency = array(
					array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1),
					array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1.09, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.09),
					array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 16.09, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1609),
					array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 31.24, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.3124),
					array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 16.02, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01602)
				);
				break;
		}
		foreach ($addCurrency as &$fields)
		{
			$fields['CREATED_BY'] = null;
			$fields['MODIFIED_BY'] = null;
			$fields['DATE_CREATE'] = $datetimeEntity;
			$fields['DATE_UPDATE'] = $datetimeEntity;
			$currencyResult = \Bitrix\Currency\CurrencyTable::add($fields);
			if ($currencyResult->isSuccess())
				$currencyList[] = $fields['CURRENCY'];
		}
		unset($currencyResult, $fields);

		if (!empty($currencyList))
		{
			Option::set('currency', 'installed_currencies', implode(',', $currencyList), '');
			$languageIterator = LanguageTable::getList(array(
				'select' => array('ID'),
				'filter' => array('=ACTIVE' => 'Y')
			));
			while ($existLanguage = $languageIterator->fetch())
			{
				$messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/currency/install_lang.php', $existLanguage['ID']);
				foreach($currencyList as &$oneCurrency)
				{
					$fields = array(
						'LID' => $existLanguage['ID'],
						'CURRENCY' => $oneCurrency,
						'THOUSANDS_SEP' => false,
						'DECIMALS' => 2,
						'HIDE_ZERO' => 'Y',
						'FORMAT_STRING' => $messList['CUR_INSTALL_'.$oneCurrency.'_FORMAT_STRING'],
						'FULL_NAME' => $messList['CUR_INSTALL_'.$oneCurrency.'_FULL_NAME'],
						'DEC_POINT' => $messList['CUR_INSTALL_'.$oneCurrency.'_DEC_POINT'],
						'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_'.$oneCurrency.'_THOUSANDS_SEP'],
						'CREATED_BY' => null,
						'MODIFIED_BY' => null,
						'DATE_CREATE' => $datetimeEntity,
						'TIMESTAMP_X' => $datetimeEntity
					);
					$resultCurrencyLang = \Bitrix\Currency\CurrencyLangTable::add($fields);
					unset($resultCurrencyLang);
				}
				unset($oneCurrency, $messList);
			}
			unset($existLanguage, $languageIterator);
			if (!$bitrix24)
			{
				$checkDate = Main\Type\DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));;
				CAgent::AddAgent('\Bitrix\Currency\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true);
				unset($checkDate);
			}
			\Bitrix\Currency\CurrencyManager::clearCurrencyCache();
		}
		unset($datetimeEntity);
	}
Exemplo n.º 17
0
 /**
  * Clear currency cache.
  *
  * @param string $language		Language id.
  * @return void
  */
 public static function clearCurrencyCache($language = '')
 {
     $language = static::checkLanguage($language);
     $currencyTableName = CurrencyTable::getTableName();
     $managedCache = Application::getInstance()->getManagedCache();
     $managedCache->clean(self::CACHE_CURRENCY_LIST_ID, $currencyTableName);
     if (empty($language)) {
         $languageIterator = LanguageTable::getList(array('select' => array('ID')));
         while ($oneLanguage = $languageIterator->fetch()) {
             $managedCache->clean(self::CACHE_CURRENCY_LIST_ID . '_' . $oneLanguage['ID'], $currencyTableName);
             $managedCache->clean(self::CACHE_CURRENCY_SHORT_LIST_ID . $oneLanguage['ID'], $currencyTableName);
         }
         unset($oneLanguage, $languageIterator);
     } else {
         $managedCache->clean(self::CACHE_CURRENCY_LIST_ID . '_' . $language, $currencyTableName);
         $managedCache->clean(self::CACHE_CURRENCY_SHORT_LIST_ID . $language, $currencyTableName);
     }
     $managedCache->clean(self::CACHE_BASE_CURRENCY_ID, $currencyTableName);
     /** @global \CStackCacheManager $stackCacheManager */
     global $stackCacheManager;
     $stackCacheManager->clear('currency_rate');
     $stackCacheManager->clear('currency_currency_lang');
 }
Exemplo n.º 18
0
 $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
 $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
 $countQuery->setFilter(array('ORDER_DISCOUNT_DATA.ID' => null));
 $totalCount = $countQuery->setLimit(1)->setOffset(null)->exec()->fetch();
 unset($countQuery);
 if ((int) $totalCount['CNT'] > 0) {
     $adminNotify = false;
     $adminNotifyIterator = CAdminNotify::GetList(array(), array('MODULE_ID' => 'sale', 'TAG' => 'BASKET_DISCOUNT_CONVERTED'));
     if (!$adminNotifyIterator) {
         $adminNotify = $adminNotifyIterator->Fetch();
     }
     unset($adminNotifyIterator);
     if (empty($adminNotify)) {
         $langMess = array();
         $langList = array();
         $languageIterator = \Bitrix\Main\Localization\LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y')));
         while ($oneLanguage = $languageIterator->fetch()) {
             $langList[] = $oneLanguage['ID'];
         }
         unset($oneLanguage, $languageIterator);
         $messID = 'SALE_CONVERTER_ADMIN_NOTIFY_CONVERT_BASKET_DISCOUNT';
         foreach ($langList as &$oneLanguage) {
             $mess = Loc::loadLanguageFile(__FILE__, $oneLanguage);
             if (!isset($mess[$messID]) || empty($mess[$messID])) {
                 continue;
             }
             $langMess[$oneLanguage] = str_replace('#LINK#', '/bitrix/admin/settings.php?lang=' . $oneLanguage . '&mid=sale', $mess[$messID]);
         }
         unset($mess, $oneLanguage);
         reset($langMess);
         $defaultMess = isset($langMess[LANGUAGE_ID]) ? $langMess[LANGUAGE_ID] : current($langMess);
Exemplo n.º 19
0
 protected function installCurrencies()
 {
     if (!Loader::includeModule('currency')) {
         return;
     }
     $bitrix24Path = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/bitrix24/';
     $bitrix24 = file_exists($bitrix24Path) && is_dir($bitrix24Path);
     unset($bitrix24Path);
     $currencyIterator = \Bitrix\Currency\CurrencyTable::getList(array('select' => array('CURRENCY'), 'limit' => 1));
     $currency = $currencyIterator->fetch();
     if (!empty($currency)) {
         return;
     }
     $languageID = '';
     $siteIterator = SiteTable::getList(array('select' => array('LID', 'LANGUAGE_ID'), 'filter' => array('=DEF' => 'Y', '=ACTIVE' => 'Y')));
     if ($site = $siteIterator->fetch()) {
         $languageID = (string) $site['LANGUAGE_ID'];
     }
     unset($site, $siteIterator);
     if ($languageID == '') {
         $languageID = 'en';
     }
     $currencyList = array();
     $currencySetID = '';
     switch ($languageID) {
         case 'ua':
         case 'de':
         case 'en':
         case 'la':
         case 'tc':
         case 'sc':
         case 'in':
             $currencySetID = $languageID;
             break;
         case 'ru':
             if (!$bitrix24) {
                 $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => 'kz', '=ACTIVE' => 'Y')));
                 if ($existLanguage = $languageIterator->fetch()) {
                     $currencySetID = $existLanguage['ID'];
                 }
                 if ($currencySetID == '') {
                     $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => 'ua', '=ACTIVE' => 'Y')));
                     if ($existLanguage = $languageIterator->fetch()) {
                         $currencySetID = $existLanguage['ID'];
                     }
                 }
                 unset($existLanguage, $languageIterator);
             }
             if ($currencySetID == '') {
                 $currencySetID = $languageID;
             }
             break;
         default:
             $currencySetID = 'en';
             break;
     }
     $datetimeEntity = new Main\DB\SqlExpression(Main\Application::getConnection()->getSqlHelper()->getCurrentDateTimeFunction());
     switch ($currencySetID) {
         case 'kz':
             $addCurrency = array(array('CURRENCY' => 'KZT', 'NUMCODE' => '398', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 4.4, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.4), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 283.17, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 283.17), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 310.78, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 310.78));
             break;
         case 'ua':
             $addCurrency = array(array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 3.61, 'AMOUNT_CNT' => 10, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.361), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 2322.93, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 23.2293), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 2548.19, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 25.4819));
             break;
         case 'ru':
             $addCurrency = array(array('CURRENCY' => 'RUB', 'NUMCODE' => '643', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 64.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 64.36), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 70.59999999999999, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 70.59999999999999), array('CURRENCY' => 'UAH', 'NUMCODE' => '980', 'AMOUNT' => 27.69, 'AMOUNT_CNT' => 10, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 2.769), array('CURRENCY' => 'BYR', 'NUMCODE' => '974', 'AMOUNT' => 36.9, 'AMOUNT_CNT' => 10000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.00369));
             break;
         case 'de':
         case 'la':
             $addCurrency = array(array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 0.91, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.91), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 14.35, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1435), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 23.21, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2321), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 13.97, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01397));
             break;
         case 'tc':
         case 'sc':
             $addCurrency = array(array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 6.36, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 6.36), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 6.97, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 6.97), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1.61, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.61), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 9.74, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.09737));
             break;
         case 'in':
             $addCurrency = array(array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 65.31, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 65.31), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 71.56, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 71.56), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 10.27, 'AMOUNT_CNT' => 1, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 10.27), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 16.56, 'AMOUNT_CNT' => 1, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 16.56));
             break;
         case 'br':
             $addCurrency = array(array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 3.9, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 3.9), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 4.29, 'AMOUNT_CNT' => 1, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 4.29), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 61.44, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.6143999999999999), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 5.99, 'AMOUNT_CNT' => 100, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.0599));
             break;
         default:
         case 'en':
             $addCurrency = array(array('CURRENCY' => 'USD', 'NUMCODE' => '840', 'AMOUNT' => 1, 'AMOUNT_CNT' => 1, 'SORT' => 100, 'BASE' => 'Y', 'CURRENT_BASE_RATE' => 1), array('CURRENCY' => 'EUR', 'NUMCODE' => '978', 'AMOUNT' => 1.1, 'AMOUNT_CNT' => 1, 'SORT' => 200, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 1.1), array('CURRENCY' => 'CNY', 'NUMCODE' => '156', 'AMOUNT' => 15.73, 'AMOUNT_CNT' => 100, 'SORT' => 300, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.1573), array('CURRENCY' => 'BRL', 'NUMCODE' => '986', 'AMOUNT' => 25.35, 'AMOUNT_CNT' => 100, 'SORT' => 400, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.2535), array('CURRENCY' => 'INR', 'NUMCODE' => '356', 'AMOUNT' => 15.31, 'AMOUNT_CNT' => 1000, 'SORT' => 500, 'BASE' => 'N', 'CURRENT_BASE_RATE' => 0.01531));
             break;
     }
     foreach ($addCurrency as &$fields) {
         $fields['CREATED_BY'] = null;
         $fields['MODIFIED_BY'] = null;
         $fields['DATE_CREATE'] = $datetimeEntity;
         $fields['DATE_UPDATE'] = $datetimeEntity;
         $currencyResult = \Bitrix\Currency\CurrencyTable::add($fields);
         if ($currencyResult->isSuccess()) {
             $currencyList[] = $fields['CURRENCY'];
         }
     }
     unset($currencyResult, $fields);
     if (!empty($currencyList)) {
         Option::set('currency', 'installed_currencies', implode(',', $currencyList), '');
         $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y')));
         while ($existLanguage = $languageIterator->fetch()) {
             $messList = Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/currency/install_lang.php', $existLanguage['ID']);
             foreach ($currencyList as &$oneCurrency) {
                 $fields = array('LID' => $existLanguage['ID'], 'CURRENCY' => $oneCurrency, 'THOUSANDS_SEP' => false, 'DECIMALS' => 2, 'HIDE_ZERO' => 'Y', 'FORMAT_STRING' => $messList['CUR_INSTALL_' . $oneCurrency . '_FORMAT_STRING'], 'FULL_NAME' => $messList['CUR_INSTALL_' . $oneCurrency . '_FULL_NAME'], 'DEC_POINT' => $messList['CUR_INSTALL_' . $oneCurrency . '_DEC_POINT'], 'THOUSANDS_VARIANT' => $messList['CUR_INSTALL_' . $oneCurrency . '_THOUSANDS_SEP'], 'CREATED_BY' => null, 'MODIFIED_BY' => null, 'DATE_CREATE' => $datetimeEntity, 'TIMESTAMP_X' => $datetimeEntity);
                 $resultCurrencyLang = \Bitrix\Currency\CurrencyLangTable::add($fields);
                 unset($resultCurrencyLang);
             }
             unset($oneCurrency, $messList);
         }
         unset($existLanguage, $languageIterator);
         if (!$bitrix24) {
             $checkDate = Main\Type\DateTime::createFromTimestamp(strtotime('tomorrow 00:01:00'));
             CAgent::AddAgent('\\Bitrix\\Currency\\CurrencyTable::currencyBaseRateAgent();', 'currency', 'Y', 86400, '', 'Y', $checkDate->toString(), 100, false, true);
             unset($checkDate);
         }
         \Bitrix\Currency\CurrencyManager::clearCurrencyCache();
     }
     unset($datetimeEntity);
 }
Exemplo n.º 20
0
 /**
  * Gets menu with language select box.
  * 
  * @return array|null
  */
 public static function getLangMenu()
 {
     global $APPLICATION;
     $request = Application::getInstance()->getContext()->getRequest();
     $relatedId = $request->get('I18N_RELATED_ID') ? $request->get('I18N_RELATED_ID') : $request->get('ID');
     $page = basename($request->getRequestedPage());
     if ($page === 'iblock_element_edit.php') {
         $model = static::MODEL_ELEMENT;
     } elseif ($page === 'iblock_section_edit.php') {
         $model = static::MODEL_SECTION;
     } else {
         $model = null;
     }
     if ($model === null || !$request->get('IBLOCK_ID') || !$relatedId) {
         return null;
     }
     $menu = [];
     $currentLang = static::getCurrentLang($model);
     $settings = static::getIblockSettings($request->get('IBLOCK_ID'));
     $itemVersions = static::getItemVersions($model, $relatedId, $settings);
     $rsLangs = LanguageTable::query()->setSelect(['LID', 'NAME'])->exec();
     while ($lang = $rsLangs->fetch()) {
         $queryParams = 'I18N_RELATED_ID=' . $relatedId . '&i18n_lang=' . $lang['LID'];
         if (isset($itemVersions[$lang['LID']])) {
             $queryParams .= '&ID=' . $itemVersions[$lang['LID']];
         }
         $menu[$lang['LID']] = ['TEXT' => $lang['NAME'], 'LINK' => $APPLICATION->GetCurPageParam($queryParams, ['ID', 'i18n_lang', 'I18N_RELATED_ID'])];
     }
     return ['TEXT' => $menu[$currentLang]['TEXT'], 'ICON' => 'btn_copy', 'MENU' => array_filter($menu, function ($key) use($currentLang) {
         if ($key === $currentLang) {
             return false;
         } else {
             return true;
         }
     }, ARRAY_FILTER_USE_KEY)];
 }
Exemplo n.º 21
0
 public function createTypes()
 {
     $res = \Bitrix\Main\Localization\LanguageTable::getList();
     $types = array('COUNTRY' => array('CODE' => 'COUNTRY', 'SORT' => 100, 'NAME' => array()), 'REGION' => array('CODE' => 'REGION', 'SORT' => 300, 'NAME' => array()), 'CITY' => array('CODE' => 'CITY', 'SORT' => 600, 'NAME' => array()));
     while ($item = $res->Fetch()) {
         $MESS = array();
         include $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/sale/lang/' . $item['LID'] . '/lib/location/migration/migrate.php';
         $types['COUNTRY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_COUNTRY'];
         $types['REGION']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_REGION'];
         $types['CITY']['NAME'][$item['LID']]['NAME'] = $MESS['SALE_LOCATION_TYPE_CITY'];
     }
     $res = Location\TypeTable::getList();
     while ($item = $res->Fetch()) {
         unset($types[$item['CODE']]);
     }
     foreach ($types as $type) {
         $res = Location\TypeTable::add($type);
         if (!($this->data['TYPE'][$type['CODE']] = $res->getId())) {
             throw new Main\SystemException('Cannot add location type: ' . implode(', ', $res->getErrors()), 0, __FILE__, __LINE__);
         }
     }
 }
Exemplo n.º 22
0
 private function __getLangMessages($path, $messID, $langList)
 {
     $result = array();
     if (empty($messID)) {
         return $result;
     }
     if (!is_array($messID)) {
         $messID = array($messID);
     }
     if (!is_array($langList)) {
         $langList = array($langList);
     }
     if (empty($langList)) {
         $languageIterator = LanguageTable::getList(array('select' => array('ID'), 'filter' => array('ACTIVE' => 'Y')));
         while ($oneLanguage = $languageIterator->fetch()) {
             $langList[] = $oneLanguage['ID'];
         }
         unset($oneLanguage, $languageIterator);
     }
     foreach ($langList as &$oneLanguage) {
         $mess = Loc::loadLanguageFile($path, $oneLanguage);
         foreach ($messID as &$oneMess) {
             if (empty($oneMess) || !isset($mess[$oneMess]) || empty($mess[$oneMess])) {
                 continue;
             }
             if (!isset($result[$oneMess])) {
                 $result[$oneMess] = array();
             }
             $result[$oneMess][$oneLanguage] = $mess[$oneMess];
         }
         unset($oneMess, $mess);
     }
     unset($oneLanguage);
     return $result;
 }
Exemplo n.º 23
0
 protected static function getLangsFromDb()
 {
     $langsFromDb = array();
     $res = \Bitrix\Main\Localization\LanguageTable::getList(array('select' => array('ID')));
     while ($item = $res->fetch()) {
         $langsFromDb[$item['ID']] = true;
     }
     return $langsFromDb;
 }
Exemplo n.º 24
0
 public static function CheckFields($ACTION, &$arFields, $statusId = '')
 {
     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($statusId) > 0 && $statusId != $arFields["ID"]) {
         return false;
     }
     if (is_set($arFields, "ID") && !preg_match("#[A-Za-z]#i", $arFields["ID"]) || strlen($statusId) > 0 && !preg_match("#[A-Za-z]#i", $statusId)) {
         $GLOBALS["APPLICATION"]->ThrowException(Loc::getMessage("SKGS_ID_NOT_SYMBOL"), "ERROR_ID_NOT_SYMBOL");
         return false;
     }
     $result = new Result();
     if (!self::$statusFields) {
         self::$statusFields = StatusTable::getEntity()->getScalarFields();
         self::$langFields = StatusLangTable::getEntity()->getScalarFields();
         self::$taskFields = StatusGroupTaskTable::getEntity()->getScalarFields();
     }
     switch ($ACTION) {
         case 'ADD':
             $statusId = $arFields['ID'];
             StatusTable::checkFields($result, null, array_intersect_key($arFields, self::$statusFields));
             break;
         case 'UPDATE':
             StatusTable::checkFields($result, $statusId, array_intersect_key(array_diff_key($arFields, array('ID' => 1)), self::$statusFields));
             break;
         default:
             throw new SystemException('Invalid action: ' . $ACTION, 0, __FILE__, __LINE__);
     }
     if (isset($arFields['LANG']) && is_array($arFields['LANG']) && !empty($arFields['LANG'])) {
         $availableLanguages = array_map('current', LanguageTable::getList(array('select' => array('LID'), 'filter' => array('=ACTIVE' => 'Y')))->fetchAll());
         foreach ($arFields['LANG'] as $data) {
             if ($data['NAME'] && in_array($data['LID'], $availableLanguages)) {
                 StatusLangTable::checkFields($result, null, array('STATUS_ID' => $statusId) + array_intersect_key($data, self::$langFields));
             } else {
                 return false;
             }
         }
     }
     return $result->isSuccess();
 }
Exemplo n.º 25
0
 public static function clearCurrencyCache()
 {
     global $CACHE_MANAGER, $stackCacheManager;
     $CACHE_MANAGER->Clean('currency_currency_list');
     $languageIterator = LanguageTable::getList(array('select' => array('ID')));
     while ($oneLanguage = $languageIterator->fetch()) {
         $CACHE_MANAGER->Clean('currency_currency_list_' . $oneLanguage['ID']);
     }
     unset($oneLanguage, $languageIterator);
     $CACHE_MANAGER->Clean('currency_base_currency');
     $stackCacheManager->Clear('currency_rate');
 }