Exemple #1
0
 public static function create($arFields)
 {
     CModule::IncludeModule('highloadblock');
     global $USER;
     if (!$USER_ID) {
         $USER_ID = $USER->GetID();
     }
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getById(6)->fetch();
     $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
     $entity_data_class = $entity->getDataClass();
     $dt = new \Bitrix\Main\Type\DateTime(date('Y-m-d H:i:s', strtotime(date("d.m.Y H:i:s"))), 'Y-m-d H:i:s');
     $data = array('UF_USER_ID' => $USER_ID, 'UF_DATETIME' => $dt, 'UF_TEXT' => $arFields["TEXT"], 'UF_PROG_ID' => $arFields["PROG_ID"]);
     $result = $entity_data_class::add($data);
     if ($result->isSuccess()) {
         return true;
     } else {
         return implode(', ', $result->getErrors());
     }
 }
 /**
  * getByIdHL() - get data from HL from ID
  * $HL_ID - id HL
  * $idElement - id element
  */
 public static function getByIdHL($HL_ID, $idElement, $field = false, $valField)
 {
     CModule::IncludeModule("highloadblock");
     $hlbl = $HL_ID;
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getById($hlbl)->fetch();
     if (!empty($hlblock)) {
         $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
         $entity_data_class = $entity->getDataClass();
         $row = $entity_data_class::getById($idElement)->fetch();
         if (!empty($row)) {
             if ($field) {
                 return $row[$valField];
             } else {
                 return $row;
             }
         } else {
             return false;
         }
     }
 }
             $arUserField["EDIT_FORM_LABEL"] = $arUserField["LIST_COLUMN_LABEL"] = $arUserField["LIST_FILTER_LABEL"] = array(LANGUAGE_ID => $_POST['PROPERTY_USER_TYPE_SETTINGS']['LANG'][$fieldName]);
         }
         $obUserField->Add($arUserField);
         $intSortStep += 100;
     }
 }
 $arImageResult = array();
 if (isset($_FILES['PROPERTY_DIRECTORY_VALUES']) && is_array($_FILES['PROPERTY_DIRECTORY_VALUES'])) {
     CFile::ConvertFilesToPost($_FILES['PROPERTY_DIRECTORY_VALUES'], $arImageResult);
 }
 if ($_POST["PROPERTY_USER_TYPE_SETTINGS"]["TABLE_NAME"] == '-1' && isset($result) && $result->isSuccess()) {
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getById($highBlockID)->fetch();
 } else {
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('=TABLE_NAME' => $_POST['PROPERTY_USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
 }
 $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
 $entityDataClass = $entity->getDataClass();
 $fieldsList = $entityDataClass::getMap();
 if (count($fieldsList) == 1 && isset($fieldsList['ID'])) {
     $fieldsList = $entityDataClass::getEntity()->getFields();
 }
 foreach ($_POST['PROPERTY_DIRECTORY_VALUES'] as $dirKey => $arDirValue) {
     if (isset($arDirValue["UF_DELETE"])) {
         if ($arDirValue["UF_DELETE"] === 'Y') {
             if (isset($arDirValue["ID"]) && intval($arDirValue["ID"]) > 0) {
                 $entityDataClass::delete($arDirValue["ID"]);
                 continue;
             }
         }
         unset($arDirValue["UF_DELETE"]);
     }
<?require($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/main/include/prolog_before.php');?>

<?
 $soc = $_POST['social'];
 $page = $_POST['page'];
if (!CModule::IncludeModule('highloadblock'))
   continue;
 
$ID = 1; //highloadblock Brendshl
 
//сначала выбрать информацию о ней из базы данных
$hldata = Bitrix\Highloadblock\HighloadBlockTable::getById($ID)->fetch();
 
 
//затем инициализировать класс сущности
$hlentity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hldata);
 
$hlDataClass = $hldata['NAME'].'Table';
 
$result = $hlDataClass::getList(array(
                      'select' => array('ID', 'UF_URL','UF_OD','UF_FB','UF_VK'),
                      'order' => array('UF_URL' =>'ASC'),
                      'filter' => array('UF_URL'=>$page),
                     ));
 $ID = '';                                                
while($res = $result->fetch())
{
    $ID = $res['ID'];
    $UF_VK=$res['UF_VK'];
    $UF_FB=$res['UF_FB'];
    $UF_OD=$res['UF_OD'];
Exemple #5
0
 function ImportPropertyDirectory($arProperty, $arEnumXmlNodes)
 {
     if (!CModule::IncludeModule('highloadblock')) {
         return true;
     }
     $rsProperty = CIBlockProperty::GetList(array(), array("ID" => $arProperty["ID"]));
     $arProperty = $rsProperty->Fetch();
     if (!$arProperty) {
         return true;
     }
     $tableName = 'b_' . strtolower($arProperty["CODE"]);
     if (strlen($arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"]) <= 0) {
         $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $tableName)))->fetch();
         if (!$hlblock) {
             $highBlockName = trim($arProperty["CODE"]);
             $highBlockName = preg_replace("/([^A-Za-z0-9]+)/", "", $highBlockName);
             if ($highBlockName == "") {
                 return GetMessage("IBLOCK_XML2_HBLOCK_NAME_IS_INVALID");
             }
             $highBlockName = strtoupper(substr($highBlockName, 0, 1)) . substr($highBlockName, 1);
             $data = array('NAME' => $highBlockName, 'TABLE_NAME' => $tableName);
             $result = Bitrix\Highloadblock\HighloadBlockTable::add($data);
             $highBlockID = $result->getId();
             $arFieldsName = array('UF_NAME' => array("Y", "string"), 'UF_XML_ID' => array("Y", "string"), 'UF_LINK' => array("N", "string"), 'UF_DESCRIPTION' => array("N", "string"), 'UF_FULL_DESCRIPTION' => array("N", "string"), 'UF_SORT' => array("N", "integer"), 'UF_FILE' => array("N", "file"), 'UF_DEF' => array("N", "boolean"));
             $obUserField = new CUserTypeEntity();
             $sort = 100;
             foreach ($arFieldsName as $fieldName => $fieldValue) {
                 $arUserField = array("ENTITY_ID" => "HLBLOCK_" . $highBlockID, "FIELD_NAME" => $fieldName, "USER_TYPE_ID" => $fieldValue[1], "XML_ID" => "", "SORT" => $sort, "MULTIPLE" => "N", "MANDATORY" => $fieldValue[0], "SHOW_FILTER" => "N", "SHOW_IN_LIST" => "Y", "EDIT_IN_LIST" => "Y", "IS_SEARCHABLE" => "N", "SETTINGS" => array());
                 $obUserField->Add($arUserField);
                 $sort += 100;
             }
         }
         $arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"] = $tableName;
         $obProperty = new CIBlockProperty();
         $obProperty->Update($arProperty["ID"], $arProperty);
     }
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $arProperty["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
     $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
     $entity_data_class = $entity->getDataClass();
     $arEnumMap = array();
     $rsData = $entity_data_class::getList(array("select" => array("ID", "UF_NAME", "UF_XML_ID", "UF_SORT")));
     while ($arData = $rsData->fetch()) {
         $arEnumMap[$arData["UF_XML_ID"]] = $arData;
     }
     $i = 0;
     foreach ($arEnumXmlNodes as $arE) {
         if ($arE["NAME"] == $this->mess["IBLOCK_XML2_TYPE_LIST"]) {
             $arE = $this->_xml_file->GetAllChildrenArray($arE);
             if (isset($arE[$this->mess["IBLOCK_XML2_VALUE_ID"]]) && isset($arE[$this->mess["IBLOCK_XML2_VALUE"]])) {
                 $xml_id = $arE[$this->mess["IBLOCK_XML2_VALUE_ID"]];
                 $arFields = array("UF_XML_ID" => $xml_id, "UF_NAME" => $arE[$this->mess["IBLOCK_XML2_VALUE"]]);
                 if (isset($arE[$this->mess["IBLOCK_XML2_PICTURE"]])) {
                     $arFields["UF_FILE"] = $this->MakeFileArray($arE[$this->mess["IBLOCK_XML2_PICTURE"]]);
                 }
                 if (!array_key_exists($xml_id, $arEnumMap)) {
                     $entity_data_class::add($arFields);
                 } elseif ($arEnumMap[$xml_id]["UF_NAME"] !== $arFields['UF_NAME']) {
                     $entity_data_class::update($arEnumMap[$xml_id]["ID"], $arFields);
                 }
             }
         }
     }
     return true;
 }
Exemple #6
0
function __recalcSaleDiscount($user_id)
{
	if(!$user_id) return;	
	
	CModule::IncludeModule('sale');
	CModule::IncludeModule('highloadblock');
	
	$UserPrc = false;
	
	$hlblock   = Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter'=>array('NAME' => 'UserDiscounts')))->fetch();
	$entity   = Bitrix\Highloadblock\HighloadBlockTable::compileEntity( $hlblock );
	$entity_data_class = $entity->getDataClass();
	$rsData = $entity_data_class::getList(array(
		"select" => array("*"),
		"order" => array("ID" => "ASC"),
		"filter" => array('UF_USER_ID' => $user_id)
	));
	if($arData = $rsData->Fetch())
	{
		$UserPrc = $arData['UF_DISCOUNT'];
	}
	if($UserPrc)
	{
		$bCreated = false;
		
		$dbSaleDiscounts = CSaleDiscount::GetList(
			array(),
			array(
				"ACTIVE" => "Y",
				//"XML_ID" => 'HL_DISCOUNT_'.$UserPrc,
			),
			false,
			false,
			array('ID','NAME',"XML_ID",'CONDITIONS')
		);
		while ($arSaleDiscount = $dbSaleDiscounts->Fetch())
		{
			$issetUsers = array();
			$CONDITIONS = unserialize($arSaleDiscount['CONDITIONS']);			
			foreach($CONDITIONS['CHILDREN'] as $arChildren)
			{
				if($arChildren['CLASS_ID'] == 'CondSaleOrderUserID')
				{
					$issetUsers[$arChildren['DATA']['value']] = $arChildren['DATA']['value'];
				}
			}
			if($arSaleDiscount['XML_ID'] == 'HL_DISCOUNT_'.$UserPrc)
			{
				$bCreated = true;
				if(!in_array($user_id, $issetUsers))
				{
					$CONDITIONS['CHILDREN'][] = Array(
                            'CLASS_ID' => 'CondSaleOrderUserID',
                            'DATA' => Array(
                                    'logic' => 'Equal',
                                    'value' => $user_id
								)
						);
					
					$arDiscountFields = array(
						'NAME' => $arSaleDiscount['NAME'],
						"ACTIVE" => 'Y',
						'CONDITIONS' => $CONDITIONS
					);
					CSaleDiscount::Update($arSaleDiscount['ID'], $arDiscountFields);
				}
			}
			else
			{
				if(in_array($user_id, $issetUsers))
				{
					
					$tmpCond = array();
					foreach($CONDITIONS['CHILDREN'] as $arChildren)
					{
						if(!($arChildren['CLASS_ID'] == 'CondSaleOrderUserID' && $arChildren['DATA']['value'] == $user_id))
						{
							$tmpCond[] = $arChildren;
						}
					}
					if(empty($tmpCond))
					{
						CSaleDiscount::Delete($arSaleDiscount['ID']);
					}
					else
					{
						$CONDITIONS['CHILDREN'] = $tmpCond;
						$arDiscountFields = array(
							'NAME' => $arSaleDiscount['NAME'],
							"ACTIVE" => 'Y',
							'CONDITIONS' => $CONDITIONS
						);
						CSaleDiscount::Update($arSaleDiscount['ID'], $arDiscountFields);
					}
				}
			}
		}
		
		
		if(!$bCreated)
		{
			$arDiscountFields = array(
				"LID" => 's1',
				"NAME" => 'Скидка пользователям - '.$UserPrc.'%',
				"ACTIVE_FROM" => '',
				"ACTIVE_TO" => '',
				"ACTIVE" => 'Y',
				"SORT" => 100,
				"PRIORITY" => 1,
				"LAST_DISCOUNT" => 'Y',
				"XML_ID" => 'HL_DISCOUNT_'.$UserPrc,
				'CONDITIONS' => Array(
			            'CLASS_ID' => 'CondGroup',
			            'DATA' => Array(
			                    'All' => 'OR',
			                    'True' => 'True'
						),
			            'CHILDREN' => Array(
							Array(
	                            'CLASS_ID' => 'CondSaleOrderUserID',
	                            'DATA' => Array(
	                                    'logic' => 'Equal',
	                                    'value' => $user_id
									)
							),
						)
					),
				'ACTIONS' => array(
					'CLASS_ID' => 'CondGroup',
					'DATA' => Array(
	                    'All' => 'AND',
					),
					'CHILDREN' => Array(
						Array(
                            'CLASS_ID' => 'ActSaleBsktGrp',
                            'DATA' => Array(
								'Type' => 'Discount',
								'Value' => $UserPrc,
								'Unit' => 'Perc',
								'All' => 'AND',
							),
							'CHILDREN' => Array()
						),
					)
				),
				'USER_GROUPS' => array(2),
			);			
			$DiscountID = CSaleDiscount::Add($arDiscountFields);
		}
	}
}
Exemple #7
0
 public static function getHLClass($filter)
 {
     $HLBlock = Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => $filter))->fetch();
     $HLEntity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($HLBlock);
     return $HLEntity->getDataClass();
 }
 private function addHIblockVariants(&$field)
 {
     $field['NAME_FIELD'] = isset($field['NAME_FIELD']) ? $field['NAME_FIELD'] : self::$config['HIBLOCK_DEFAULT_NAME_FIELD'];
     $field['ID_FIELD'] = isset($field['ID_FIELD']) ? $field['ID_FIELD'] : self::$config['HIBLOCK_DEFAULT_ID_FIELD'];
     if ($this->obCache->InitCache(self::$config['CACHE_TIME'], md5($this->iblock_id . __METHOD__ . $field['ID']), self::$config['CACHE_DIR'])) {
         $field['VARIANTS'] = $this->obCache->GetVars();
     } elseif ($this->obCache->StartDataCache()) {
         CModule::IncludeModule('highloadblock');
         $filter = array("filter" => array('TABLE_NAME' => $field['PROPERTY']['TABLE_NAME']));
         $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList($filter)->fetch();
         if (isset($hlblock['ID'])) {
             $result = array();
             $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
             $entity_data_class = $entity->getDataClass();
             $rsData = $entity_data_class::getList(array());
             while ($arData = $rsData->fetch()) {
                 $result[] = array('ID' => $arData[$field['ID_FIELD']], 'NAME' => $arData[$field['NAME_FIELD']]);
             }
             $field['VARIANTS'] = $result;
         }
         $this->obCache->EndDataCache($field['VARIANTS']);
     }
     foreach ($field['VARIANTS'] as &$variant) {
         if ($_REQUEST[$field['NAME']] == $variant['ID']) {
             $variant['SELECTED'] = 'Y';
             $this->filters[$field['NAME']]['PROPERTY_' . $field['PROPERTY']['CODE']] = $variant['ID'];
             break;
         }
     }
 }
 public static function getCountIDsHL($idHL)
 {
     global $USER;
     CModule::IncludeModule("highloadblock");
     $hlbl = $idHL;
     $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getById($hlbl)->fetch();
     $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
     $entity_data_class = $entity->getDataClass();
     $rsData = $entity_data_class::getList(array("select" => array("*"), "order" => array("ID" => "ASC"), "filter" => array('UF_USER' => $USER->GetID())));
     while ($arData = $rsData->Fetch()) {
         $arResult['WISH_LIST'][] = $arData;
     }
     //весь мой список желаний  конкретного user
     foreach ($arResult['WISH_LIST'] as $key => $value) {
         $arIDs[] = $value['UF_PRODUCT'];
     }
     return $arIDs;
 }
Exemple #10
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php";
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
use Bitrix\Main\Loader;
use Bitrix\Main\Application;
use Bitrix\Main\SystemException;
Loader::includeModule('highloadblock');
$data = array('NAME' => 'TestName', 'TABLE_NAME' => 'test_name');
$result = Bitrix\Highloadblock\HighloadBlockTable::add($data);
$ID = $result->getId();
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php";
Exemple #11
0
 private function getDataClass($hlblockId)
 {
     if (!$this->dataClass) {
         $hlblock = Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array("=ID" => $hlblockId)))->fetch();
         $entity = Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
         $this->dataClass = $entity->getDataClass();
     }
     return $this->dataClass;
 }