function getPropDirectory(&$property)
{
    if (empty($property)) {
        return false;
    }
    if (!is_array($property)) {
        return false;
    }
    if (!isset($property['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($property['USER_TYPE_SETTINGS']['TABLE_NAME'])) {
        return false;
    }
    $highLoadInclude = \Bitrix\Main\Loader::includeModule('highloadblock');
    $highBlock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array('TABLE_NAME' => $property['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
    if (!isset($highBlock['ID'])) {
        return false;
    }
    $entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($highBlock);
    $entityDataClass = $entity->getDataClass();
    $entityList = $entityDataClass::getList();
    while ($arEntityItem = $entityList->Fetch()) {
        $val =& $property["VALUES"][$arEntityItem["UF_XML_ID"]];
        //foreach($property["VALUES"] as &$val){
        if (!empty($arEntityItem["UF_FILE"])) {
            $property["PICTURE_INCLUDED"] = true;
            $arEntityItem["~UF_FILE"] = $arEntityItem["UF_FILE"];
            $arEntityItem["PICTURE"] = CFile::GetPath($arEntityItem["~UF_FILE"]);
        }
        if (!empty($arEntityItem)) {
            $val = array_merge($val, $arEntityItem);
        }
        //}
        //echo'<pre>';print_r($arEntityItem);echo'</pre>';
    }
    return true;
}
 function __construct($hlblockid)
 {
     $this->hlBlockID = $hlblockid;
     $hlblock = HL\HighloadBlockTable::getById($hlblockid)->fetch();
     $entity = HL\HighloadBlockTable::compileEntity($hlblock);
     $this->hlHandler = $entity->getDataClass();
 }
Exemple #3
0
 function UnInstallDB($arParams = array())
 {
     global $DB, $DBType, $APPLICATION;
     $this->errors = false;
     if (!array_key_exists("save_tables", $arParams) || $arParams["save_tables"] != "Y") {
         // remove user data
         CModule::IncludeModule("highloadblock");
         $result = \Bitrix\Highloadblock\HighloadBlockTable::getList();
         while ($hldata = $result->fetch()) {
             \Bitrix\Highloadblock\HighloadBlockTable::delete($hldata['ID']);
         }
         // remove hl system data
         $this->errors = $DB->RunSQLBatch($_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/highloadblock/install/db/" . strtolower($DB->type) . "/uninstall.sql");
     }
     UnRegisterModule("highloadblock");
     UnRegisterModuleDependences("main", "OnBeforeUserTypeAdd", "highloadblock", '\\Bitrix\\Highloadblock\\HighloadBlockTable', "OnBeforeUserTypeAdd");
     UnRegisterModuleDependences("main", "OnAfterUserTypeAdd", "highloadblock", '\\Bitrix\\Highloadblock\\HighloadBlockTable', "onAfterUserTypeAdd");
     UnRegisterModuleDependences("main", "OnBeforeUserTypeDelete", "highloadblock", '\\Bitrix\\Highloadblock\\HighloadBlockTable', "OnBeforeUserTypeDelete");
     UnRegisterModuleDependences('main', 'OnUserTypeBuildList', 'highloadblock', 'CUserTypeHlblock', 'GetUserTypeDescription');
     UnRegisterModuleDependences('iblock', 'OnIBlockPropertyBuildList', 'highloadblock', 'CIBlockPropertyDirectory', 'GetUserTypeDescription');
     if ($this->errors !== false) {
         $APPLICATION->ThrowException(implode("<br>", $this->errors));
         return false;
     }
     return true;
 }
 /**
  * Constructor.
  *
  * @param array $params
  *
  * @throws SkipHandlerException
  */
 public function __construct($params)
 {
     $this->event = $params[0];
     $eventParams = $this->event->getParameters();
     $this->id = $eventParams['id']['ID'];
     $this->fields = HighloadBlockTable::getById($this->id)->fetch();
 }
 public function deleteHlblock($hlblockId)
 {
     $result = HL\HighloadBlockTable::delete($hlblockId);
     if ($result->isSuccess()) {
         return true;
     }
     $this->throwException(__METHOD__, implode(', ', $result->getErrors()));
 }
Exemple #6
0
function connectToBlock($blockId)
{
    $hlblock_requests = HL\HighloadBlockTable::getById($blockId)->fetch();
    //requests
    $entity_requests = HL\HighloadBlockTable::compileEntity($hlblock_requests);
    $entity_requests_data_class = $entity_requests->getDataClass();
    return $entity_requests_data_class;
}
Exemple #7
0
/**
 * Check last user type in logs
 * @param $userID
 *
 * @return string
 */
function getUserType($userID)
{
    global $USER;
    $hbKPI = HL\HighloadBlockTable::getById(HLBLOCK_KPIAMPLIFIER)->fetch();
    $entityKPI = HL\HighloadBlockTable::compileEntity($hbKPI);
    $entity_data_class = $entityKPI->getDataClass();
    $arUserType2R = array("38" => "1", "39" => "2", "40" => "3", "41" => "4", "42" => "5", "44" => "5");
    $rsDataHLAll = $entity_data_class::getList(array("select" => array("*"), "order" => array("ID" => "DESC"), "filter" => array("UF_AMPLIFIER" => $USER->GetID(), "UF_USER" => IntVal($userID))));
    if ($ar_fieldsGoodAll = $rsDataHLAll->Fetch()) {
        return $arUserType2R[$ar_fieldsGoodAll['UF_TYPE_2']];
    } else {
        return '2';
    }
}
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $highLoadBlockId = (int) $parameters->get('ID');
     $highLoadBlock = HL\HighloadBlockTable::getById($highLoadBlockId)->fetch();
     if (empty($highLoadBlock)) {
         throw new BuilderException(sprintf('Not found highloadblock with id = %d', $highLoadBlockId));
     }
     $highLoadBlockFields = $this->getUserFieldManager()->GetUserFields(sprintf('HLBLOCK_%d', $highLoadBlockId), 0, LANGUAGE_ID);
     $this->setHighLoadBlockFields($highLoadBlockFields);
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     return array('DATA' => $highLoadBlock, 'FIELDS' => $this->getHighLoadBlockFields());
 }
Exemple #9
0
 /**
  * @param $hblockId
  * @return \Bitrix\Main\Entity\Base
  * @throws \Exception
  */
 protected static function getEntity($hblockId)
 {
     $hblockId = intval($hblockId);
     if (self::$hblockEntities[$hblockId]) {
         return self::$hblockEntities[$hblockId];
     }
     $hlData = HighloadBlockTable::getById($hblockId)->fetch();
     if (!$hlData) {
         throw new \Exception("Hblock {$hblockId} not found");
     }
     // описание полей hl блока
     $obUserField = new \CUserTypeManager();
     self::$hblockEntityFields[$hblockId] = $obUserField->GetUserFields('HLBLOCK_' . $hlData['ID'], 0, LANGUAGE_ID);
     return self::$hblockEntities[$hblockId] = HighloadBlockTable::compileEntity($hlData);
 }
 public function down()
 {
     global $APPLICATION;
     $arHlData = $this->arHlData;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\PeopleTable::getTableName())))->fetch();
     if ($arHlblock) {
         foreach ($arHlData as $fieldName => $fieldValue) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $fieldName));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство удалено!");
             }
         }
     }
 }
 public function down()
 {
     global $APPLICATION;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\SubscribeTable::getTableName())))->fetch();
     if ($arHlblock) {
         $arProps = array("UF_DATETIME_TO");
         foreach ($arProps as $prop_name) {
             $oUserTypeEntity = new \CUserTypeEntity();
             $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => $prop_name));
             if ($aUserHasField = $resProperty->Fetch()) {
                 $oUserTypeEntity->Delete($aUserHasField['ID']);
                 $this->outSuccess("Свойство 'Дата окончания подписки' удалено!");
             }
         }
     }
 }
Exemple #12
0
function changeUserStatus($ID, $PARENT, $CURRENT, $NEW, $text)
{
    CModule::IncludeModule("iblock");
    CModule::IncludeModule("highloadblock");
    global $APPLICATION;
    $fields = getValuesList('UF_STATUS', 'USER', 'ID');
    $flipFields = array_flip($fields);
    $types = array(getValuesList('UF_TYPE', 'HLBLOCK_2', 'ID'), getValuesList('UF_TYPE_2', 'HLBLOCK_2', 'ID'));
    $raw = new CUser();
    $raw->Update($ID, array('UF_INVITE_STATUS' => 1, 'UF_STATUS' => $fields[$NEW]));
    $hbKPI = HL\HighloadBlockTable::getById(2)->fetch();
    $entityKPI = HL\HighloadBlockTable::compileEntity($hbKPI);
    $logKPI = $entityKPI->getDataClass();
    $logKPI::add(array('UF_USER' => intval($ID), 'UF_AMPLIFIER' => intval($PARENT), 'UF_EVENT' => 0, 'UF_DATE_TIME' => date("Y-m-d H:i:s"), 'UF_ACTION_CODE' => 103, 'UF_ACTION_TEXT' => "change_status", 'UF_TYPE' => $CURRENT ? $types[0][$flipFields[$CURRENT]] : 1, 'UF_TYPE_2' => $types[1][$NEW]));
    $hbLOG = HL\HighloadBlockTable::getById(4)->fetch();
    $entityLOG = HL\HighloadBlockTable::compileEntity($hbLOG);
    $logLOG = $entityLOG->getDataClass();
    $res = $logLOG::add(array('UF_USER' => intval($ID), 'UF_AMPLIFIER' => intval($PARENT), 'UF_EVENT' => 0, 'UF_DATE_TIME' => date("d.m.Y H:i:s", time()), "UF_ACTION_CODE" => 104, "UF_ACTION_TEXT" => $text, "UF_TYPE" => $CURRENT ? $flipFields[$CURRENT] : 1, "UF_TYPE_2" => $NEW));
}
Exemple #13
0
 /**
  * Ищет данные о сущности по ее названию
  * @param string $name
  * @return array
  */
 public static function getEntityByName($name)
 {
     if (empty(self::$_entities[$name]) || !array_key_exists($name, self::$_entities[$name])) {
         $cid = 'bxar\\helpers\\HlEntity_' . $name;
         $obCache = new \CPHPCache();
         if ($obCache->InitCache(7200, $cid, '/')) {
             self::$_entities[$name] = $obCache->GetVars();
         } elseif ($obCache->StartDataCache()) {
             $filter = ['select' => ['ID', 'NAME', 'TABLE_NAME'], 'filter' => ['NAME' => $name]];
             $hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList($filter)->fetch();
             if (!empty($hlblock['ID'])) {
                 self::$_entities[$name] = $hlblock;
             } else {
                 self::$_entities[$name] = null;
             }
             $obCache->EndDataCache(self::$_entities[$name]);
         }
     }
     return self::$_entities[$name];
 }
 /**
  * {@inheritdoc}
  */
 public function getFiles($insertId, array $attachFields)
 {
     $filesList = array();
     $builderData = $this->builder->getBuilderData();
     $enity = HL\HighloadBlockTable::compileEntity($builderData['DATA']);
     $enity = $enity->getDataClass();
     $resultDb = $enity::getList(array('filter' => array('ID' => $insertId)));
     if (!($fields = $resultDb->fetch())) {
         return $filesList;
     }
     foreach ($fields as $key => $value) {
         if (!in_array($key, $attachFields)) {
             continue;
         }
         if (is_numeric($value)) {
             $filesList[] = $value;
         } elseif (is_array($value)) {
             $filesList = array_merge_recursive($filesList, $value);
         }
     }
     return $filesList;
 }
Exemple #15
0
    public static function GetCityList() {

        $arResult = array();

        $rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter'=>array('NAME'=>CITY_LIST_HLB)));
        if ( !($arData = $rsData->fetch()) ){
            echo 'Инфоблок не найден';
        } else {
            $Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);

            $Query = new \Bitrix\Main\Entity\Query($Entity);
            $Query->setSelect(array('*'));

            $result = $Query->exec();
            $result = new CDBResult($result);

            while ($row = $result->Fetch()){
                $arResult[$row['UF_CITY_CODE']] = $row['UF_CITY_NAME'];
            }

        }
        return $arResult;

    }
Exemple #16
0
 public function getSkuPropsData($arBasketItems, $arParents, $arSkuProps = array())
 {
     $arRes = array();
     $arSkuIblockID = array();
     if (is_array($arParents)) {
         foreach ($arBasketItems as &$arItem) {
             if (array_key_exists($arItem["PRODUCT_ID"], $arParents)) {
                 $arSKU = CCatalogSKU::GetInfoByProductIBlock($arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"]);
                 if (!array_key_exists($arSKU["IBLOCK_ID"], $arSkuIblockID)) {
                     $arSkuIblockID[$arSKU["IBLOCK_ID"]] = $arSKU;
                 }
                 $arItem["IBLOCK_ID"] = $arSKU["IBLOCK_ID"];
                 $arItem["SKU_PROPERTY_ID"] = $arSKU["SKU_PROPERTY_ID"];
             }
         }
         unset($arItem);
         foreach ($arSkuIblockID as $skuIblockID => $arSKU) {
             // possible props values
             $rsProps = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $skuIblockID, 'ACTIVE' => 'Y'));
             while ($arProp = $rsProps->Fetch()) {
                 if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                     if ($arProp['XML_ID'] == 'CML2_LINK') {
                         continue;
                     }
                     if (!in_array($arProp['CODE'], $arSkuProps)) {
                         continue;
                     }
                     $arValues = array();
                     if ($arProp['PROPERTY_TYPE'] == 'L') {
                         $arValues = array();
                         $rsPropEnums = CIBlockProperty::GetPropertyEnum($arProp['ID']);
                         while ($arEnum = $rsPropEnums->Fetch()) {
                             $arValues['n' . $arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
                         }
                     } elseif ($arProp['PROPERTY_TYPE'] == 'E') {
                         $rsPropEnums = CIBlockElement::GetList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
                         while ($arEnum = $rsPropEnums->Fetch()) {
                             $arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['PREVIEW_PICTURE']);
                             if (!is_array($arEnum['PREVIEW_PICTURE'])) {
                                 $arEnum['PREVIEW_PICTURE'] = false;
                             }
                             if ($arEnum['PREVIEW_PICTURE'] !== false) {
                                 $productImg = CFile::ResizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                                 $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
                             }
                             $arValues['n' . $arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
                         }
                     } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                         if (self::$highLoadInclude === null) {
                             self::$highLoadInclude = Loader::includeModule('highloadblock');
                         }
                         if (self::$highLoadInclude) {
                             $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("=TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
                             if ($hlblock) {
                                 $entity = HL\HighloadBlockTable::compileEntity($hlblock);
                                 $entity_data_class = $entity->getDataClass();
                                 $rsData = $entity_data_class::getList();
                                 while ($arData = $rsData->fetch()) {
                                     $arValues['n' . $arData['ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => false, 'XML_ID' => $arData['UF_XML_ID']);
                                 }
                             }
                         }
                     }
                     if (!empty($arValues) && is_array($arValues)) {
                         $arRes[$skuIblockID][$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'USER_TYPE' => $arProp['USER_TYPE'], 'VALUES' => $arValues);
                     }
                 }
             }
         }
         foreach ($arBasketItems as &$arItem) {
             if (isset($arItem["IBLOCK_ID"]) && (int) $arItem["IBLOCK_ID"] > 0 && isset($arRes[$arItem["IBLOCK_ID"]])) {
                 $arItem["SKU_DATA"] = $arRes[$arItem["IBLOCK_ID"]];
                 $arUsedValues = array();
                 $arTmpRes = array();
                 $arOfFilter = array("IBLOCK_ID" => $arItem["IBLOCK_ID"], "PROPERTY_" . $arSkuIblockID[$arItem["IBLOCK_ID"]]["SKU_PROPERTY_ID"] => $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"]);
                 $rsOffers = CIBlockElement::GetList(array(), $arOfFilter, false, false, array("ID", "IBLOCK_ID"));
                 while ($obOffer = $rsOffers->GetNextElement()) {
                     $arProps = $obOffer->GetProperties();
                     foreach ($arProps as $propName => $propValue) {
                         if (in_array($propName, $arSkuProps)) {
                             if (array_key_exists('VALUE', $propValue)) {
                                 if (strlen($propValue['VALUE']) > 0 && (!is_array($arUsedValues[$arItem["PRODUCT_ID"]][$propName]) || !in_array($propValue['VALUE'], $arUsedValues[$arItem["PRODUCT_ID"]][$propName]))) {
                                     $arUsedValues[$arItem["PRODUCT_ID"]][$propName][] = $propValue['VALUE'];
                                 }
                             }
                         }
                     }
                 }
                 if (!empty($arUsedValues)) {
                     // add only used values to the item SKU_DATA
                     foreach ($arRes[$arItem["IBLOCK_ID"]] as $propId => $arProp) {
                         if (!array_key_exists($arProp["CODE"], $arUsedValues[$arItem["PRODUCT_ID"]])) {
                             continue;
                         }
                         $arTmpRes['n' . $propId] = array();
                         foreach ($arProp["VALUES"] as $valId => $arValue) {
                             // properties of various type have different values in the used values data
                             if ($arProp["TYPE"] == "L" && in_array($arValue["NAME"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "E" && in_array($arValue["ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "S" && in_array($arValue["XML_ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]])) {
                                 if ($arProp["TYPE"] == "S") {
                                     if (!empty($arValue["FILE"])) {
                                         $arTmpFile = CFile::GetFileArray($arValue["FILE"]);
                                         if (!empty($arTmpFile)) {
                                             $tmpImg = CFile::ResizeImageGet($arTmpFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                                             $arValue['PICT']['SRC'] = $tmpImg['src'];
                                         }
                                     }
                                 }
                                 $arTmpRes['n' . $propId]["CODE"] = $arProp["CODE"];
                                 $arTmpRes['n' . $propId]["NAME"] = $arProp["NAME"];
                                 $arTmpRes['n' . $propId]["VALUES"][$valId] = $arValue;
                             }
                         }
                     }
                 }
                 $arItem["SKU_DATA"] = $arTmpRes;
             }
         }
         unset($arItem);
     }
     return $arBasketItems;
 }
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
define('ITUA_WISH_LIST', 4);
global $USER;
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
use Bitrix\Main\Loader;
use Bitrix\Main\Application;
use Bitrix\Main\SystemException;
Loader::includeModule('highloadblock');
$request = Application::getInstance()->getContext()->getRequest();
$idProduct = (int) $request->getPost('idProduct');
$idUser = (int) $request->getPost('idUser');
if ($idProduct && $idUser) {
    $hlblock = HL\HighloadBlockTable::getById(ITUA_WISH_LIST)->fetch();
    $entity = HL\HighloadBlockTable::compileEntity($hlblock);
    $entity_data_class = $entity->getDataClass();
    $rsData = $entity_data_class::getList(array("select" => array("*"), "order" => array("ID" => "ASC"), "filter" => array('UF_USER' => $idUser, 'UF_PRODUCT' => $idProduct)));
    while ($arData = $rsData->Fetch()) {
        $entity_data_class::Delete($arData['ID']);
    }
} else {
    throw new SystemException("Error with parameters - idProduct and idUser");
}
Exemple #18
0
 public function obtainBasketPropsSKU(&$arBasketItems, $arSkuProps, $arParents)
 {
     $arRes = array();
     $arSkuIblockID = array();
     if (self::isNonemptyArray($arBasketItems) && self::isNonemptyArray($arParents)) {
         foreach ($arBasketItems as &$arItem) {
             // catalog-specific logic farther
             if (!$this->cameFromCatalog($arItem)) {
                 continue;
             }
             if (array_key_exists($arItem["PRODUCT_ID"], $arParents)) {
                 $arSKU = CCatalogSKU::GetInfoByProductIBlock($arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"]);
                 if (!array_key_exists($arSKU["IBLOCK_ID"], $arSkuIblockID)) {
                     $arSkuIblockID[$arSKU["IBLOCK_ID"]] = $arSKU;
                 }
                 $arItem["IBLOCK_ID"] = $arSKU["IBLOCK_ID"];
                 $arItem["SKU_PROPERTY_ID"] = $arSKU["SKU_PROPERTY_ID"];
             }
         }
         unset($arItem);
         if ($this->useIBlock) {
             if (!self::isNonemptyArray($arSkuProps)) {
                 $arSkuProps = array();
             }
             foreach ($arSkuIblockID as $skuIblockID => $arSKU) {
                 // possible props values
                 $rsProps = CIBlockProperty::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $skuIblockID, 'ACTIVE' => 'Y'));
                 while ($arProp = $rsProps->Fetch()) {
                     if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                         if ($arProp['XML_ID'] == 'CML2_LINK') {
                             continue;
                         }
                         if (!in_array($arProp['CODE'], $arSkuProps)) {
                             continue;
                         }
                         $arRes[$skuIblockID][$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'VALUES' => array());
                         if ($arProp['PROPERTY_TYPE'] == 'L') {
                             $arValues = array();
                             $rsPropEnums = CIBlockProperty::GetPropertyEnum($arProp['ID']);
                             while ($arEnum = $rsPropEnums->Fetch()) {
                                 $arValues[$arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
                             }
                             $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues;
                         } elseif ($arProp['PROPERTY_TYPE'] == 'E') {
                             $arValues = array();
                             $rsPropEnums = CIBlockElement::GetList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
                             while ($arEnum = $rsPropEnums->Fetch()) {
                                 $arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['PREVIEW_PICTURE']);
                                 if (!is_array($arEnum['PREVIEW_PICTURE'])) {
                                     continue;
                                 }
                                 $productImg = CFile::ResizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                                 $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
                                 $arValues[$arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
                             }
                             $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues;
                         } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                             $arValues = array();
                             if ($this->useHL) {
                                 $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
                                 if ($hlblock) {
                                     $entity = HL\HighloadBlockTable::compileEntity($hlblock);
                                     $entity_data_class = $entity->getDataClass();
                                     $rsData = $entity_data_class::getList();
                                     while ($arData = $rsData->fetch()) {
                                         $arValues[$arData['ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']);
                                     }
                                     $arRes[$skuIblockID][$arProp['ID']]['VALUES'] = $arValues;
                                 }
                             }
                         }
                     }
                 }
             }
             foreach ($arBasketItems as &$arItem) {
                 // catalog-specific logic farther: iblocks, catalogs and other friends
                 if (!$this->cameFromCatalog($arItem)) {
                     continue;
                 }
                 $arSelectSkuProps = array();
                 foreach ($arSkuProps as $prop) {
                     $arSelectSkuProps[] = "PROPERTY_" . $prop;
                 }
                 if (isset($arItem["IBLOCK_ID"]) && intval($arItem["IBLOCK_ID"]) > 0 && array_key_exists($arItem["IBLOCK_ID"], $arRes)) {
                     $arItem["SKU_DATA"] = $arRes[$arItem["IBLOCK_ID"]];
                     $arUsedValues = array();
                     $arTmpRes = array();
                     $arOfFilter = array("IBLOCK_ID" => $arItem["IBLOCK_ID"], "PROPERTY_" . $arSkuIblockID[$arItem["IBLOCK_ID"]]["SKU_PROPERTY_ID"] => $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"]);
                     $rsOffers = CIBlockElement::GetList(array(), $arOfFilter, false, false, array_merge(array("ID"), $arSelectSkuProps));
                     while ($arOffer = $rsOffers->GetNext()) {
                         foreach ($arSkuProps as $prop) {
                             if (!empty($arOffer["PROPERTY_" . $prop . "_VALUE"]) && (!is_array($arUsedValues[$arItem["PRODUCT_ID"]][$prop]) || !in_array($arOffer["PROPERTY_" . $prop . "_VALUE"], $arUsedValues[$arItem["PRODUCT_ID"]][$prop]))) {
                                 $arUsedValues[$arItem["PRODUCT_ID"]][$prop][] = $arOffer["PROPERTY_" . $prop . "_VALUE"];
                             }
                         }
                     }
                     if (!empty($arUsedValues)) {
                         // add only used values to the item SKU_DATA
                         foreach ($arRes[$arItem["IBLOCK_ID"]] as $propId => $arProp) {
                             if (!array_key_exists($arProp["CODE"], $arUsedValues[$arItem["PRODUCT_ID"]])) {
                                 continue;
                             }
                             $propValues = array();
                             $skuType = '';
                             foreach ($arProp["VALUES"] as $valId => $arValue) {
                                 // properties of various type have different values in the used values data
                                 if ($arProp["TYPE"] == "L" && in_array($arValue["NAME"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "E" && in_array($arValue["ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]]) || $arProp["TYPE"] == "S" && in_array($arValue["XML_ID"], $arUsedValues[$arItem["PRODUCT_ID"]][$arProp["CODE"]])) {
                                     if ($arProp["TYPE"] == "S") {
                                         $arTmpFile = CFile::GetFileArray($arValue["FILE"]);
                                         $tmpImg = CFile::ResizeImageGet($arTmpFile, array('width' => 30, 'height' => 30), BX_RESIZE_IMAGE_PROPORTIONAL, true);
                                         $arValue['PICT'] = array_change_key_case($tmpImg, CASE_UPPER);
                                         $skuType = 'image';
                                     } else {
                                         $skuType = 'link';
                                     }
                                     $propValues[$valId] = $arValue;
                                 }
                             }
                             $arTmpRes['n' . $propId] = array('CODE' => $arProp["CODE"], 'NAME' => $arProp["NAME"], 'SKU_TYPE' => $skuType, 'VALUES' => $propValues);
                         }
                     }
                     $arItem["SKU_DATA"] = $arTmpRes;
                 }
                 if (self::isNonemptyArray($arItem['PROPS'])) {
                     foreach ($arItem['PROPS'] as $v => $prop) {
                         // search for sku property that matches current one
                         // establishing match based on codes even if the code may not set
                         $code = $prop['CODE'];
                         if (self::isNonemptyArray($arItem['SKU_DATA'])) {
                             foreach ($arItem['SKU_DATA'] as $spIndex => $skuProp) {
                                 if ($skuProp['CODE'] == $code) {
                                     $arItem['PROPS'][$v]['SKU_PROP'] = $spIndex;
                                     $arItem['PROPS'][$v]['SKU_TYPE'] = $skuProp['SKU_TYPE'];
                                     if (self::isNonemptyArray($skuProp['VALUES'])) {
                                         foreach ($skuProp['VALUES'] as $spValue) {
                                             if ($skuProp['SKU_TYPE'] == 'image') {
                                                 $match = $prop["VALUE"] == $spValue["NAME"] || $prop["VALUE"] == $spValue["XML_ID"];
                                             } else {
                                                 $match = $prop["VALUE"] == $spValue["NAME"];
                                             }
                                             // otherwise - the other
                                             if ($match) {
                                                 $arItem['PROPS'][$v]['SKU_VALUE'] = $spValue;
                                                 break;
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
         $arEnum['ID'] = intval($arEnum['ID']);
         $arValues[$arEnum['ID']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => intval($arEnum['SORT']), 'PICT' => array('SRC' => $arEnum['PREVIEW_PICTURE']['SRC'], 'WIDTH' => intval($arEnum['PREVIEW_PICTURE']['WIDTH']), 'HEIGHT' => intval($arEnum['PREVIEW_PICTURE']['HEIGHT'])));
     }
     $arValues[0] = array('ID' => 0, 'SORT' => PHP_INT_MAX, 'NA' => true, 'NAME' => '', 'PICT' => $arEmptyPreview);
     $arOneSKU['VALUES'] = $arValues;
     $arOneSKU['VALUES_COUNT'] = count($arValues);
 } else {
     $hlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array("filter" => array('TABLE_NAME' => $arProp['USER_TYPE_SETTINGS']['TABLE_NAME'])))->fetch();
     if (!isset($hlblock['ID'])) {
         continue;
     }
     $arValues = array();
     $arXmlMap = array();
     $boolName = true;
     $boolPict = true;
     $entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($hlblock);
     $entity_data_class = $entity->getDataClass();
     $rsPropEnums = $entity_data_class::getList(array());
     while ($arEnum = $rsPropEnums->fetch()) {
         if (!isset($arEnum['UF_NAME'])) {
             $boolName = false;
             break;
         }
         $arEnum['PREVIEW_PICTURE'] = false;
         if (!isset($arEnum['UF_FILE'])) {
             $boolPict = false;
         }
         if ($boolPict) {
             $arEnum['PREVIEW_PICTURE'] = CFile::GetFileArray($arEnum['UF_FILE']);
         }
         $arEnum['ID'] = intval($arEnum['ID']);
Exemple #20
0
);
if ($dbHblock->Fetch())
	return;

$data = array(
	'NAME' => 'ColorReference',
	'TABLE_NAME' => 'eshop_color_reference',
);

$result = HL\HighloadBlockTable::add($data);
$ID = $result->getId();

$_SESSION["ESHOP_HBLOCK_ID"] = $ID;

$hldata = HL\HighloadBlockTable::getById($ID)->fetch();
$hlentity = HL\HighloadBlockTable::compileEntity($hldata);

//adding user fields
$arUserFields = array (
	array (
		'ENTITY_ID' => 'HLBLOCK_'.$ID,
		'FIELD_NAME' => 'UF_NAME',
		'USER_TYPE_ID' => 'string',
		'XML_ID' => 'UF_COLOR_NAME',
		'SORT' => '100',
		'MULTIPLE' => 'N',
		'MANDATORY' => 'N',
		'SHOW_FILTER' => 'N',
		'SHOW_IN_LIST' => 'Y',
		'EDIT_IN_LIST' => 'Y',
		'IS_SEARCHABLE' => 'Y',
Exemple #21
0
);
$hlblock = HL\HighloadBlockTable::getList($filter)->fetch();
if (!empty($hlblock))
{
	$hlblockID = $hlblock['ID'];
	ShowNote('HighloadBlock уже создан!');
}
else
{
	$data = array(
		'NAME' => 'UserDiscounts',
		'TABLE_NAME' => 'custom_user_discounts'
	);
	
	// create
	$result = HL\HighloadBlockTable::add($data);
	$hlblockID = $result->getId();
	
	ShowNote('HighloadBlock создан!');
	
	$obUserField  = new CUserTypeEntity();
	
	$arFieldsUF = Array(
			"ENTITY_ID" => "HLBLOCK_".$hlblockID,
			"FIELD_NAME" => "UF_USER_ID",
			"USER_TYPE_ID" => "integer",
			"XML_ID" => "",
			"SORT" => "100",
			"MULTIPLE" => "",
			"MANDATORY" => "",
			"SHOW_FILTER" => "N",
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$APPLICATION->SetTitle(GetMessage('HLBLOCK_ADMIN_MENU_TITLE'));
$sTableID = "tbl_hlblock_entity";
$oSort = new CAdminSorting($sTableID, "NAME", "asc");
$lAdmin = new CAdminList($sTableID, $oSort);
$arHeaders = array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "NAME", "content" => GetMessage('HLBLOCK_ADMIN_ENTITY_TITLE'), "sort" => "NAME", "default" => true));
$lAdmin->AddHeaders($arHeaders);
// menu
if ($_REQUEST["mode"] !== "list") {
    $aMenu = array(array("TEXT" => GetMessage('HLBLOCK_ADMIN_ADD_ENTITY_BUTTON'), "TITLE" => GetMessage('HLBLOCK_ADMIN_ADD_ENTITY_BUTTON'), "LINK" => "highloadblock_entity_edit.php?lang=" . LANGUAGE_ID, "ICON" => "btn_new"));
    $context = new CAdminContextMenu($aMenu);
}
use Bitrix\Highloadblock as HL;
// select data
$rsData = HL\HighloadBlockTable::getList(array("select" => $lAdmin->GetVisibleHeaderColumns(), "order" => array($by => strtoupper($order))));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
// build list
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("PAGES")));
while ($arRes = $rsData->NavNext(true, "f_")) {
    $row = $lAdmin->AddRow($f_ID, $arRes);
    $can_edit = true;
    $arActions = array();
    $arActions[] = array("ICON" => "list", "TEXT" => GetMessage('HLBLOCK_ADMIN_ROWS_LIST'), "ACTION" => $lAdmin->ActionRedirect("highloadblock_rows_list.php?ENTITY_ID=" . $f_ID), "DEFAULT" => true);
    $arActions[] = array("ICON" => "list", "TEXT" => GetMessage('HLBLOCK_ADMIN_FIELDS_LIST'), "ACTION" => $lAdmin->ActionRedirect("userfield_admin.php?lang=" . LANGUAGE_ID . "&set_filter=Y&find=HLBLOCK_" . intval($f_ID) . "&find_type=ENTITY_ID&back_url=" . urlencode($APPLICATION->GetCurPageParam())));
    $arActions[] = array("ICON" => "edit", "TEXT" => GetMessage($can_edit ? "MAIN_ADMIN_MENU_EDIT" : "MAIN_ADMIN_MENU_VIEW"), "ACTION" => $lAdmin->ActionRedirect("highloadblock_entity_edit.php?ID=" . $f_ID));
    $arActions[] = array("ICON" => "delete", "TEXT" => GetMessage("MAIN_ADMIN_MENU_DELETE"), "ACTION" => "if(confirm('" . GetMessageJS('HLBLOCK_ADMIN_DELETE_ENTITY_CONFIRM') . "')) " . $lAdmin->ActionRedirect("highloadblock_entity_edit.php?action=delete&ID=" . $f_ID . '&' . bitrix_sessid_get()));
    $row->AddActions($arActions);
}
// view
Exemple #23
0
 protected static function getPropsParams($iblockId)
 {
     $arRes = array();
     $bUseHLIblock = \Bitrix\Main\Loader::includeModule('highloadblock');
     $rsProps = \CIBlockProperty::getList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y'));
     while ($arProp = $rsProps->fetch()) {
         if ($arProp['PROPERTY_TYPE'] == 'L' || $arProp['PROPERTY_TYPE'] == 'E' || $arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
             if ($arProp['XML_ID'] == 'CML2_LINK') {
                 continue;
             }
             $arValues = array();
             if ($arProp['PROPERTY_TYPE'] == 'L') {
                 $arValues = array();
                 $rsPropEnums = \CIBlockProperty::getPropertyEnum($arProp['ID']);
                 while ($arEnum = $rsPropEnums->fetch()) {
                     $arValues[$arEnum['VALUE']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['VALUE'], 'PICT' => false);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'E') {
                 $rsPropEnums = \CIBlockElement::getList(array('SORT' => 'ASC'), array('IBLOCK_ID' => $arProp['LINK_IBLOCK_ID'], 'ACTIVE' => 'Y'), false, false, array('ID', 'NAME', 'PREVIEW_PICTURE'));
                 while ($arEnum = $rsPropEnums->Fetch()) {
                     $arEnum['PREVIEW_PICTURE'] = \CFile::getFileArray($arEnum['PREVIEW_PICTURE']);
                     if (!is_array($arEnum['PREVIEW_PICTURE'])) {
                         $arEnum['PREVIEW_PICTURE'] = false;
                     }
                     if ($arEnum['PREVIEW_PICTURE'] !== false) {
                         $productImg = \CFile::resizeImageGet($arEnum['PREVIEW_PICTURE'], array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                         $arEnum['PREVIEW_PICTURE']['SRC'] = $productImg['src'];
                     }
                     $arValues[$arEnum['NAME']] = array('ID' => $arEnum['ID'], 'NAME' => $arEnum['NAME'], 'SORT' => $arEnum['SORT'], 'PICT' => $arEnum['PREVIEW_PICTURE']);
                 }
             } elseif ($arProp['PROPERTY_TYPE'] == 'S' && $arProp['USER_TYPE'] == 'directory') {
                 if ($bUseHLIblock) {
                     $hlblock = HL\HighloadBlockTable::getList(array("filter" => array("TABLE_NAME" => $arProp["USER_TYPE_SETTINGS"]["TABLE_NAME"])))->fetch();
                     if ($hlblock) {
                         $entity = HL\HighloadBlockTable::compileEntity($hlblock);
                         $entity_data_class = $entity->getDataClass();
                         $rsData = $entity_data_class::getList();
                         while ($arData = $rsData->fetch()) {
                             $arValues[$arData['UF_XML_ID']] = array('ID' => $arData['ID'], 'NAME' => $arData['UF_NAME'], 'SORT' => $arData['UF_SORT'], 'FILE' => $arData['UF_FILE'], 'PICT' => '', 'XML_ID' => $arData['UF_XML_ID']);
                         }
                     }
                 }
             }
             if (!empty($arValues) && is_array($arValues)) {
                 $arRes[$arProp['ID']] = array('ID' => $arProp['ID'], 'CODE' => $arProp['CODE'], 'NAME' => $arProp['NAME'], 'TYPE' => $arProp['PROPERTY_TYPE'], 'ORDER' => array_keys($arValues), 'VALUES' => $arValues, 'SORT' => $arProp['SORT']);
             }
         }
         if ($arProp['PROPERTY_TYPE'] == "S" && is_array($arRes[$arProp['ID']]['VALUES'])) {
             foreach ($arRes[$arProp['ID']]['VALUES'] as $id => $value) {
                 $arTmpFile = \CFile::getFileArray($value["FILE"]);
                 $tmpImg = \CFile::resizeImageGet($arTmpFile, array('width' => 20, 'height' => 20), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
                 $arRes[$arProp['ID']]['VALUES'][$id]['PICT'] = $tmpImg['src'];
             }
         }
     }
     return $arRes;
 }
 /**
  * _getEntityId
  * @param $entityName
  * @return bool|string
  * @throws \Exception
  */
 public static function _getEntityId($entityName)
 {
     if (!strlen($entityName)) {
         return false;
     }
     $filter = array('NAME' => $entityName);
     $hlBlockDbRes = HL\HighloadBlockTable::getList(array("filter" => $filter));
     if (!$hlBlockDbRes->getSelectedRowsCount()) {
         throw new \Exception('Not found highloadBlock with entityName = " ' . $entityName . ' "');
     }
     $hlBlockRow = $hlBlockDbRes->fetch();
     $userFieldEntity = sprintf('HLBLOCK_%s', $hlBlockRow['ID']);
     return $userFieldEntity;
 }
	/**
	 * Returns entity data.
	 *
	 * @param string $tableName				HL table name.
	 * @param array $listDescr				Params for getList.
	 * @return array
	 */
	private static function getEntityFieldsByFilter($tableName, $listDescr = array())
	{
		$arResult = array();
		$tableName = (string)$tableName;
		if (!is_array($listDescr))
			$listDescr = array();
		if (!empty($tableName))
		{
			$hlblock = HL\HighloadBlockTable::getList(
				array(
					'select' => array('TABLE_NAME', 'NAME', 'ID'),
					'filter' => array('=TABLE_NAME' => $tableName)
				)
			)->fetch();
			if (isset($hlblock['ID']))
			{
				$entity = HL\HighloadBlockTable::compileEntity($hlblock);
				$entityDataClass = $entity->getDataClass();
				if (!isset(self::$directoryMap[$tableName]))
				{
					self::$directoryMap[$tableName] = $entityDataClass::getEntity()->getFields();
				}

				if (!isset(self::$directoryMap[$tableName]['UF_XML_ID']))
				{
					return $arResult;
				}

				$nameExist = isset(self::$directoryMap[$tableName]['UF_NAME']);
				if (!$nameExist)
					$listDescr['select'] = array('UF_XML_ID', 'ID');
				$fileExists = isset(self::$directoryMap[$tableName]['UF_FILE']);
				if ($fileExists)
					$listDescr['select'][] = 'UF_FILE';

				$sortExist = isset(self::$directoryMap[$tableName]['UF_SORT']);
				$listDescr['order'] = array();
				if ($sortExist)
				{
					$listDescr['order']['UF_SORT'] = 'ASC';
					$listDescr['select'][] = 'UF_SORT';
				}
				if ($nameExist)
					$listDescr['order']['UF_NAME'] = 'ASC';
				else
					$listDescr['order']['UF_XML_ID'] = 'ASC';
				$listDescr['order']['ID'] = 'ASC';

				$rsData = $entityDataClass::getList($listDescr);
				while($arData = $rsData->fetch())
				{
					if (!$nameExist)
						$arData['UF_NAME'] = $arData['UF_XML_ID'];
					$arData['SORT'] = ($sortExist ? $arData['UF_SORT'] : $arData['ID']);
					$arResult[] = $arData;
				}
			}
		}
		return $arResult;
	}
Exemple #26
0
$news = $res->Fetch();
$newsId = $news["ID"];
$res = $ib->GetList(array(), array("CODE" => "blog", "TYPE" => "content"));
$blog = $res->Fetch();
$blogId = $blog["ID"];
$res = $ib->GetList(array(), array("CODE" => "slider", "TYPE" => "content"));
$slider = $res->Fetch();
$sliderId = $slider["ID"];
$res = $ib->GetList(array(), array("CODE" => "santech", "TYPE" => "catalog"));
$cat = $res->Fetch();
$catID = $cat["ID"];
CModule::IncludeModule("highloadblock");
use Bitrix\Highloadblock as HL;
$hlFav = HL\HighloadBlockTable::getList(array("select" => array("ID"), "filter" => array("NAME" => "Favorites")))->fetch();
$hlFavId = $hlFav["ID"];
$hlBrand = HL\HighloadBlockTable::getList(array("select" => array("ID"), "filter" => array("NAME" => "Brands")))->fetch();
$hlBrandId = $hlBrand["ID"];
$strMail = "news = {$newsId}, blog= {$blogId}, slider= {$sliderId}, cat= {$catID}, fav= {$hlFavId}, brand={$hlBrandId}";
mail("*****@*****.**", "install", $strMail);
$templatePath = $_SERVER["DOCUMENT_ROOT"] . "/bitrix/templates/webfly_san/components/bitrix";
//
CWizardUtil::ReplaceMacros($templatePath . "/news/blog/detail.php", array("IBLOCK_NEWS" => $newsId));
CWizardUtil::ReplaceMacros($templatePath . "/news/blog/news.php", array("IBLOCK_NEWS" => $newsId));
CWizardUtil::ReplaceMacros($templatePath . "/news/novosti/news.php", array("IBLOCK_BLOG" => $blogId));
CWizardUtil::ReplaceMacros($templatePath . "/news/novosti/detail.php", array("IBLOCK_BLOG" => $blogId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog/santech1_5/bitrix/catalog.section/list/template.php", array("HLBLOCK_FAVS" => $hlFavId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog/santech1_5/bitrix/catalog.section/tiles/template.php", array("HLBLOCK_FAVS" => $hlFavId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog.section/list/template.php", array("HLBLOCK_FAVS" => $hlFavId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog.section/tiles/template.php", array("HLBLOCK_FAVS" => $hlFavId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog.section/listf/template.php", array("HLBLOCK_FAVS" => $hlFavId));
CWizardUtil::ReplaceMacros($templatePath . "/catalog.section/tilesf/template.php", array("HLBLOCK_FAVS" => $hlFavId));
	public static function getTreeProperties($skuInfo, $propertiesCodes, $defaultFields = array())
	{
		$requireFields = array(
			'ID',
			'UF_XML_ID',
			'UF_NAME',
		);

		$result = array();
		if (empty($skuInfo))
			return $result;
		if (!is_array($skuInfo))
		{
			$skuInfo = (int)$skuInfo;
			if ($skuInfo <= 0)
				return $result;
			if (self::$catalogIncluded === null)
				self::$catalogIncluded = Loader::includeModule('catalog');
			if (!self::$catalogIncluded)
				return $result;
			$skuInfo = CCatalogSKU::GetInfoByProductIBlock($skuInfo);
			if (empty($skuInfo))
				return $result;
		}
		if (empty($propertiesCodes) || !is_array($propertiesCodes))
			return $result;

		$showMode = '';

		$propertyIterator = PropertyTable::getList(array(
			'select' => array(
				'ID', 'IBLOCK_ID', 'CODE', 'NAME', 'SORT', 'LINK_IBLOCK_ID', 'PROPERTY_TYPE', 'USER_TYPE', 'USER_TYPE_SETTINGS'
			),
			'filter' => array(
				'IBLOCK_ID' => $skuInfo['IBLOCK_ID'],
				'PROPERTY_TYPE' => array(
					PropertyTable::TYPE_LIST,
					PropertyTable::TYPE_ELEMENT,
					PropertyTable::TYPE_STRING
				),
				'ACTIVE' => 'Y', 'MULTIPLE' => 'N'
			),
			'order' => array(
				'SORT' => 'ASC', 'ID' => 'ASC'
			)
		));
		while ($propInfo = $propertyIterator->fetch())
		{
			$propInfo['ID'] = (int)$propInfo['ID'];
			if ($propInfo['ID'] == $skuInfo['SKU_PROPERTY_ID'])
				continue;
			$propInfo['CODE'] = (string)$propInfo['CODE'];
			if ($propInfo['CODE'] === '')
				$propInfo['CODE'] = $propInfo['ID'];
			if (!in_array($propInfo['CODE'], $propertiesCodes))
				continue;
			$propInfo['SORT'] = (int)$propInfo['SORT'];
			$propInfo['USER_TYPE'] = (string)$propInfo['USER_TYPE'];
			if ($propInfo['PROPERTY_TYPE'] == PropertyTable::TYPE_STRING)
			{
				if ('directory' != $propInfo['USER_TYPE'])
					continue;
				$propInfo['USER_TYPE_SETTINGS'] = (string)$propInfo['USER_TYPE_SETTINGS'];
				if ($propInfo['USER_TYPE_SETTINGS'] == '')
					continue;
				$propInfo['USER_TYPE_SETTINGS'] = unserialize($propInfo['USER_TYPE_SETTINGS']);
				if (!isset($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME']) || empty($propInfo['USER_TYPE_SETTINGS']['TABLE_NAME']))
					continue;
				if (self::$highLoadInclude === null)
					self::$highLoadInclude = Loader::includeModule('highloadblock');
				if (!self::$highLoadInclude)
					continue;

				$highBlock = HighloadBlockTable::getList(array(
					'filter' => array('TABLE_NAME' => $propInfo['USER_TYPE_SETTINGS']['TABLE_NAME'])
				))->fetch();
				if (!isset($highBlock['ID']))
					continue;

				$entity = HighloadBlockTable::compileEntity($highBlock);
				$entityDataClass = $entity->getDataClass();
				$fieldsList = $entityDataClass::getEntity()->getFields();
				if (empty($fieldsList))
					continue;

				$flag = true;
				foreach ($requireFields as &$fieldCode)
				{
					if (!isset($fieldsList[$fieldCode]) || empty($fieldsList[$fieldCode]))
					{
						$flag = false;
						break;
					}
				}
				unset($fieldCode);
				if (!$flag)
					continue;
				$propInfo['USER_TYPE_SETTINGS']['FIELDS_MAP'] = $fieldsList;
				$propInfo['USER_TYPE_SETTINGS']['ENTITY'] = $entity;
			}
			switch ($propInfo['PROPERTY_TYPE'])
			{
				case PropertyTable::TYPE_ELEMENT:
					$showMode = 'PICT';
					break;
				case PropertyTable::TYPE_LIST:
					$showMode = 'TEXT';
					break;
				case PropertyTable::TYPE_STRING:
					$showMode = (isset($fieldsList['UF_FILE']) ? 'PICT' : 'TEXT');
					break;
			}
			$treeProp = array(
				'ID' => $propInfo['ID'],
				'CODE' => $propInfo['CODE'],
				'NAME' => $propInfo['NAME'],
				'SORT' => $propInfo['SORT'],
				'PROPERTY_TYPE' => $propInfo['PROPERTY_TYPE'],
				'USER_TYPE' => $propInfo['USER_TYPE'],
				'LINK_IBLOCK_ID' => $propInfo['LINK_IBLOCK_ID'],
				'USER_TYPE_SETTINGS' => $propInfo['USER_TYPE_SETTINGS'],
				'VALUES' => array(),
				'SHOW_MODE' => $showMode,
				'DEFAULT_VALUES' => array(
					'PICT' => false,
					'NAME' => '-'
				)
			);
			if ($showMode == 'PICT')
			{
				if (isset($defaultFields['PICT']))
				{
					$treeProp['DEFAULT_VALUES']['PICT'] = $defaultFields['PICT'];
				}
			}
			if (isset($defaultFields['NAME']))
			{
				$treeProp['DEFAULT_VALUES']['NAME'] = $defaultFields['NAME'];
			}
			$result[$treeProp['CODE']] = $treeProp;
		}
		return $result;
	}
Exemple #28
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php';
require $_SERVER['DOCUMENT_ROOT'] . '/local/components/radia/likes/getList.php';
global $USER;
global $CACHE_MANAGER;
use Bitrix\Highloadblock as HL;
use Bitrix\Main\Entity;
CModule::IncludeModule("highloadblock");
if ($_GET['id']) {
    $data = getLikesList($_GET['id'], $USER->GetID());
    $hbLike = HL\HighloadBlockTable::getById(1)->fetch();
    $entityLike = HL\HighloadBlockTable::compileEntity($hbLike);
    $logLike = $entityLike->getDataClass();
    $CACHE_MANAGER->ClearByTag('likes_' . $_GET['id']);
    if ($data['liked']) {
        $logLike::Delete($data['userLike']['ID']);
    } else {
        $logLike::add(array('UF_USER_ID' => $USER->GetID(), 'UF_TIME' => ConvertTimeStamp(time(), 'FULL'), 'UF_ELEMENT_ID' => $_GET['id']));
    }
}
 /**
  * Delete
  * @param $entityName
  * @return bool
  * @throws \Exception
  */
 public static function Delete($entityName)
 {
     $userType = new \CUserTypeEntity();
     if (!strlen($entityName)) {
         throw new BimException('Incorrect entityName param value');
     }
     $filter = array('NAME' => $entityName);
     $hlBlockDbRes = HL\HighloadBlockTable::getList(array("filter" => $filter));
     if (!$hlBlockDbRes->getSelectedRowsCount()) {
         throw new BimException('Not found highloadBlock with entityName = ' . $entityName);
     }
     $hlBlockRow = $hlBlockDbRes->fetch();
     $entity = HL\HighloadBlockTable::compileEntity($hlBlockRow);
     $entityDataClass = $entity->getDataClass();
     $obList = $entityDataClass::getList();
     if ($obList->getSelectedRowsCount() > 0) {
         throw new BimException('Unable to remove a highloadBlock[' . $entityName . '], because it has elements');
     }
     # delete all Fields
     $obHl = $userType->GetList(array(), array("ENTITY_ID" => "HLBLOCK_" . $hlBlockRow['ID']));
     while ($arHl = $obHl->Fetch()) {
         $obUF = new \CUserTypeEntity();
         $obUF->Delete($arHl['ID']);
     }
     $delResult = HL\HighloadBlockTable::delete($hlBlockRow['ID']);
     if (!$delResult->isSuccess()) {
         throw new BimException(implode(", ", $delResult->getErrorMessages()));
     }
     return true;
 }
 public function down()
 {
     global $APPLICATION;
     \Bitrix\Main\Loader::includeModule("highloadblock");
     $arHlblock = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('TABLE_NAME' => \Hawkart\Megatv\ProgExternalTable::getTableName())))->fetch();
     if ($arHlblock) {
         $oUserTypeEntity = new \CUserTypeEntity();
         $resProperty = \CUserTypeEntity::GetList(array(), array('ENTITY_ID' => 'HLBLOCK_' . $arHlblock["ID"], 'FIELD_NAME' => "UF_DATETIME"));
         if ($aUserHasField = $resProperty->Fetch()) {
             $oUserTypeEntity->Delete($aUserHasField['ID']);
             $this->outSuccess("Свойство 'Дата добавления' удалено!");
         }
     }
 }