예제 #1
1
 protected function getElementFields($iblockId, $elementId)
 {
     $totalResult = array();
     $list = new CList($iblockId);
     $listFields = $list->getFields();
     foreach ($listFields as $fieldId => $field) {
         $totalResult[$fieldId] = $field;
     }
     $elementQuery = CIBlockElement::getList(array(), array("IBLOCK_ID" => $iblockId, "=ID" => $elementId), false, false, array('*'));
     $elementObject = $elementQuery->getNextElement();
     $elementNewData = $elementObject->getFields();
     if (is_array($elementNewData)) {
         foreach ($elementNewData as $fieldId => $fieldValue) {
             if (!$list->is_field($fieldId)) {
                 continue;
             }
             if (isset($totalResult[$fieldId]["NAME"])) {
                 $totalResult[$fieldId]["VALUE"] = $fieldValue;
             }
         }
     }
     $query = \CIblockElement::getPropertyValues($iblockId, array('ID' => $elementId));
     if ($propertyValues = $query->fetch()) {
         foreach ($propertyValues as $id => $values) {
             if ($id == "IBLOCK_ELEMENT_ID") {
                 continue;
             }
             $fieldId = "PROPERTY_" . $id;
             $totalResult[$fieldId]["VALUE"] = $values;
         }
     }
     return $totalResult;
 }
예제 #2
0
 /** @return \CDBResult */
 public function getData()
 {
     $iblockId = $this->getFieldValue('IBLOCK', null);
     $propertyNameId = $this->getFieldValue('PROPERTY_NAME', null);
     $propertyEmailId = $this->getFieldValue('PROPERTY_EMAIL', null);
     if ($iblockId && $propertyEmailId) {
         // if property is property with code like '123'
         $propertyNameValue = null;
         $propertyEmailValue = null;
         if (is_numeric($propertyEmailId)) {
             $propertyEmailId = "PROPERTY_" . $propertyEmailId;
             $propertyEmailValue = $propertyEmailId . "_VALUE";
         }
         $selectFields = array($propertyEmailValue);
         if ($propertyNameId) {
             if (is_numeric($propertyNameId)) {
                 $propertyNameId = "PROPERTY_" . $propertyNameId;
                 $propertyNameValue = $propertyNameId . "_VALUE";
             }
             $selectFields[] = $propertyNameValue;
         }
         $filter = array('IBLOCK_ID' => $iblockId, '!' . $propertyEmailId => false);
         $iblockElementListDb = \CIBlockElement::getList(array('id' => 'asc'), $filter, false, false, $selectFields);
         // replace property names from PROPERTY_123_VALUE to EMAIL, NAME
         $iblockElementDb = new CDBResultSenderConnector($iblockElementListDb);
         $iblockElementDb->senderConnectorFieldEmail = $propertyEmailValue;
         $iblockElementDb->senderConnectorFieldName = $propertyNameValue;
     } else {
         $iblockElementDb = new \CDBResult();
         $iblockElementDb->InitFromArray(array());
     }
     return $iblockElementDb;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function getFiles($insertId, array $attachFields)
 {
     $filesList = array();
     $iblockElement = new \CIBlockElement();
     $builderData = $this->builder->getBuilderData();
     $filter = array('ID' => $insertId, 'IBLOCK_ID' => $builderData['DATA']['ID']);
     $elementDb = $iblockElement->getList(array(), $filter, false, false, array());
     if (!($element = $elementDb->getNextElement())) {
         return $filesList;
     }
     $fields = $element->getFields();
     foreach ($fields as $key => $value) {
         if (in_array($key, $attachFields) && is_numeric($value)) {
             $filesList[] = $value;
         }
     }
     $propertyList = $element->getProperties();
     foreach ($propertyList as $key => $property) {
         if (!in_array($key, $attachFields)) {
             continue;
         }
         if (is_numeric($property['VALUE'])) {
             $filesList[] = $property['VALUE'];
         } elseif (is_array($property['VALUE'])) {
             $filesList = array_merge_recursive($filesList, $property['VALUE']);
         }
     }
     return $filesList;
 }
 /**
  * Получение элементов инфоблока по тегам
  * @param unknown_type $aTags
  */
 public function getMaterialsByTags($aTags)
 {
     $mResult = array();
     if (!is_array($aTags)) {
         $aTags = (array) $aTags;
     }
     $aFilter = $this->getTagsFilter();
     if (isset($this->aOptions['FILTER'])) {
         $aFilter = array_merge($this->aOptions['FILTER'], $aFilter);
     }
     $aTagFilter = array();
     foreach ($aTags as $sTag) {
         $aTagFilter[] = array('TAGS' => '%' . $sTag . '%');
     }
     $aFilter[] = $aTagFilter;
     $oElements = CIBlockElement::getList(array('NAME' => 'ASC'), array($aFilter), false, false, array('ID', 'NAME', 'IBLOCK_ID', 'TAGS'));
     while ($aElement = $oElements->Fetch()) {
         $aElemTags = array_map('trim', explode(',', $aElement['TAGS']));
         $bGood = true;
         foreach ($aTags as $sTag) {
             $sTag = trim($sTag);
             if (!in_array($sTag, $aElemTags)) {
                 $bGood = false;
             }
         }
         if ($bGood) {
             $aElement['FORMATTED_LINK'] = $this->getElementLink($aElement);
             $mResult[] = $aElement;
         }
     }
     return $mResult;
 }
예제 #5
0
 public function fetch($filter, $params = array())
 {
     // ����������� ������
     //        ksort($filter);
     // ��������� � id ���� ��� ��������� ���������
     $cacheId = serialize($filter);
     //        if (isset($params['count'])) {
     //            $cacheId .= '+cnt'.$params['count'];
     //        }
     //
     //        if (isset($params['pageSize'])) {
     //            $cacheId .= '+ps'.$params['pageSize'].'-'.\CDBResult::navStringForCache($params['pageSize']);
     //        }
     //
     //        if (isset($params['sort'])) {
     //            $cacheId .= '+s'.  serialize($params['sort']);
     //        } else {
     //            $params['sort'] = array('id'=> 'desc');
     //        }
     //
     //        // ��������� ���
     $cache = new \CPhpCache();
     //        if (false && $cache->initCache($this->_cacheTime, $cacheId, $this->_cacheDir)) {
     //
     //            $vars = $cache->getVars();
     //
     //            // ��� ����, ����� ������������ ����������� ���������, ��������� CDBResult
     //            $this->_dbResult = new \CDBResult;
     //            if (isset($params['pageSize'])) {
     //                $this->_dbResult->InitFromArray(
     //                    (int)$vars['total'] > 0 ? array_fill(0, $vars['total'], 0) : array()
     //                );
     //                if (isset($params['pageSize'])) {
     //                    $this->_dbResult->navStart($params['pageSize'], true, $vars['page']);
     //                }
     //            }
     //            return $vars['items'];
     //        }
     // � ���� ���
     \CMOdule::includeModule('iblock');
     //$filter['IBLOCK_ID'] = isset($filter['IBLOCK_ID']) ? $filter['IBLOCK_ID'] : $this->_iblockId;
     //        $filter['ACTIVE'] = 'Y';
     $this->_dbResult = \CIBlockElement::getList($params['sort'], $filter, false, isset($params['count']) ? array('nTopCount' => $params['count']) : false, $this->_commonSelect);
     if (isset($params['pageSize'])) {
         $this->_dbResult->navStart($params['pageSize']);
     }
     $result = array();
     while ($row = $this->_dbResult->fetch()) {
         $result[$row['ID']] = $row;
     }
     if ($cache->startDataCache()) {
         $cache->endDataCache(array('items' => $result, 'total' => $this->_dbResult->NavRecordCount, 'page' => $this->_dbResult->NavPageNomer));
     }
     return $result;
 }
예제 #6
0
 /**
  * Common function, used to update/insert any product.
  *
  * @param int $productId			Id of product.
  * @param int $fuserId				User basket id.
  * @param string $siteId			Site id.
  * @param int $elementId			Parent id.
  * @param string $recommendationId	Bigdata recommendation id.
  *
  * @return int
  */
 public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '')
 {
     $productId = (int) $productId;
     if ($productId <= 0) {
         return -1;
     }
     $fuserId = (int) $fuserId;
     if ($fuserId <= 0) {
         return -1;
     }
     $siteId = (string) $siteId;
     if ($siteId == '') {
         return -1;
     }
     $elementId = (int) $elementId;
     $filter = array('FUSER_ID' => $fuserId, '=SITE_ID' => $siteId);
     $connection = Application::getConnection();
     $helper = $connection->getSqlHelper();
     $sqlSiteId = $helper->forSql($siteId);
     if ($elementId > 0) {
         $filter["ELEMENT_ID"] = $elementId;
         // Delete parent product id (for capability)
         if ($elementId != $productId) {
             $connection->query("delete from b_catalog_viewed_product\n\t\t\t\t\t\t\t\t\twhere PRODUCT_ID = " . $elementId . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
         }
     } else {
         $productInfo = \CCatalogSKU::getProductInfo($productId);
         // Real SKU ID
         if (!empty($productInfo)) {
             $elementId = $productInfo['ID'];
             $siblings = array();
             // Delete parent product id (for capability)
             $connection->query("delete from b_catalog_viewed_product\n\t\t\t\t\t\t\t\t\twhere PRODUCT_ID = " . $productInfo['ID'] . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
             $skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $productInfo['OFFER_IBLOCK_ID'], 'PROPERTY_' . $productInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
             while ($oneSku = $skus->fetch()) {
                 $siblings[] = $oneSku['ID'];
             }
             $filter['PRODUCT_ID'] = $siblings;
         } else {
             $elementId = $productId;
             $filter['PRODUCT_ID'] = $productId;
         }
     }
     $iterator = static::getList(array('select' => array('ID', 'FUSER_ID', 'DATE_VISIT', 'PRODUCT_ID', 'SITE_ID', 'VIEW_COUNT'), 'filter' => $filter));
     if ($row = $iterator->fetch()) {
         static::update($row['ID'], array("PRODUCT_ID" => $productId, "DATE_VISIT" => new Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId, "RECOMMENDATION" => $recommendationId));
         return $row['ID'];
     } else {
         $result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId));
         return $result->getId();
     }
 }
 public function canRead($userId)
 {
     if (!Loader::includeModule("iblock")) {
         return false;
     }
     $elementId = $this->entityId;
     $elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_ID'));
     $element = $elementQuery->fetch();
     if (!$element['IBLOCK_ID']) {
         return false;
     }
     return \CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read");
 }
예제 #8
0
 public function canRead($userId)
 {
     if (!Loader::includeModule("lists")) {
         return false;
     }
     $elementId = $this->entityId;
     $elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_TYPE_ID', 'IBLOCK_ID'));
     $element = $elementQuery->fetch();
     $listPerm = \CListPermissions::checkAccess($this->getUser(), $element['IBLOCK_TYPE_ID'], $element['IBLOCK_ID']);
     if ($listPerm < 0) {
         return false;
     } elseif ($listPerm < \CListPermissions::CAN_READ && !\CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read")) {
         return false;
     } else {
         return true;
     }
 }
예제 #9
0
 protected function _determineModules(array $ids)
 {
     sort($ids);
     $cache = new CPhpCache();
     if ($cache->initCache($this->_cacheTime, serialize($ids), $this->_cacheDir)) {
         return $cache->getVars();
     }
     CModule::includeModule('iblock');
     $res = CIBlockElement::getList(array(), array('ID' => $ids), false, array('nTopCount' => count($ids)), array('ID', 'IBLOCK_ID'));
     $result = array();
     while ($row = $res->fetch()) {
         $module = $this->_getModule($row['IBLOCK_ID']);
         if (!array_key_exists($module, $result)) {
             $result[$module] = array();
         }
         $result[$module][] = $row['ID'];
     }
     if ($cache->startDataCache()) {
         $cache->endDataCache($result);
     }
     return $result;
 }
예제 #10
0
 public function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         $this->fields = array();
         $select = array_values($this->fieldMap);
         $elementList = \Freetrix\Iblock\ElementTable::getList(array("select" => $select, "filter" => array("=ID" => $this->id)));
         $this->elementFields = $elementList->fetch();
         if ($this->elementFields) {
             $arCatalog = \CCatalogSKU::getInfoByProductIBlock($this->elementFields["IBLOCK_ID"]);
             if (is_array($arCatalog)) {
                 $this->skuIblockId = $arCatalog["IBLOCK_ID"];
                 $skuList = \CIBlockElement::getList(array(), array("IBLOCK_ID" => $arCatalog["IBLOCK_ID"], "=PROPERTY_" . $arCatalog["SKU_PROPERTY_ID"] => $this->id), false, false, $select);
                 while ($sku = $skuList->fetch()) {
                     $this->skuList[] = $sku;
                     foreach ($sku as $fieldName => $fieldValue) {
                         $this->fields[$fieldName][] = $fieldValue;
                     }
                 }
             }
         }
     }
     return is_array($this->fields);
 }
예제 #11
0
 /**
  * @param FieldType $fieldType
  * @param string $callbackFunctionName
  * @param mixed $value
  * @return string
  */
 public static function renderControlOptions(FieldType $fieldType, $callbackFunctionName, $value)
 {
     if (is_array($value)) {
         reset($value);
         $valueTmp = (int) current($value);
     } else {
         $valueTmp = (int) $value;
     }
     $iblockId = 0;
     if ($valueTmp > 0) {
         $elementIterator = \CIBlockElement::getList(array(), array('ID' => $valueTmp), false, false, array('ID', 'IBLOCK_ID'));
         if ($element = $elementIterator->fetch()) {
             $iblockId = $element['IBLOCK_ID'];
         }
     }
     if ($iblockId <= 0 && (int) $fieldType->getOptions() > 0) {
         $iblockId = (int) $fieldType->getOptions();
     }
     $defaultIBlockId = 0;
     $result = '<select id="WFSFormOptionsX" onchange="' . htmlspecialcharsbx($callbackFunctionName) . '(this.options[this.selectedIndex].value)">';
     $iblockTypeIterator = \CIBlockParameters::getIBlockTypes();
     foreach ($iblockTypeIterator as $iblockTypeId => $iblockTypeName) {
         $result .= '<optgroup label="' . htmlspecialcharsbx($iblockTypeName) . '">';
         $iblockIterator = \CIBlock::getList(array('SORT' => 'ASC'), array('TYPE' => $iblockTypeId, 'ACTIVE' => 'Y'));
         while ($iblock = $iblockIterator->fetch()) {
             $result .= '<option value="' . $iblock['ID'] . '"' . ($iblock['ID'] == $iblockId ? ' selected' : '') . '>' . htmlspecialcharsbx($iblock['NAME']) . '</option>';
             if ($defaultIBlockId <= 0 || $iblock['ID'] == $iblockId) {
                 $defaultIBlockId = $iblock['ID'];
             }
         }
         $result .= '</optgroup>';
     }
     $result .= '</select><!--__defaultOptionsValue:' . $defaultIBlockId . '--><!--__modifyOptionsPromt:' . Loc::getMessage('UTP_ELIST_DOCUMENT_MOPROMT') . '-->';
     $fieldType->setOptions($defaultIBlockId);
     return $result;
 }
예제 #12
0
파일: class.php 프로젝트: ASDAFF/entask.ru
 /**
  * Return converted product ids map. Additionally creates sku tree from input products.
  * (see description form above).
  *
  * @param array $ids source product ids
  *
  * @return mixed[]      array("MAP" => array(...), "TREE" => array(...))
  */
 private function getProductIdsMap(array $ids = array())
 {
     if (empty($ids)) {
         return array(array(), array());
     }
     $newIds = array();
     $skuTree = array();
     $catalogs = $this->data['CATALOG'];
     foreach ($catalogs as $catalog) {
         if ($catalog['CATALOG_TYPE'] == CCatalogSKU::TYPE_OFFERS) {
             $elementIterator = CIBlockElement::getList(array(), array("ID" => $ids, "IBLOCK_ID" => $catalog['IBLOCK_ID']), false, false, array("ID", "IBLOCK_ID", "PROPERTY_" . $catalog['SKU_PROPERTY_ID']));
             while ($item = $elementIterator->fetch()) {
                 $propertyName = "PROPERTY_" . $catalog['SKU_PROPERTY_ID'] . "_VALUE";
                 $parentId = $item[$propertyName];
                 if (!empty($parentId)) {
                     $newIds[$item['ID']] = $parentId;
                     if (!isset($skuTree[$parentId])) {
                         $skuTree[$parentId] = array();
                     }
                     $skuTree[$parentId][] = $item['ID'];
                 } else {
                     $newIds[$item['ID']] = $item['ID'];
                 }
             }
         }
     }
     // Push missing
     foreach ($ids as $id) {
         if (!isset($newIds[$id])) {
             $newIds[$id] = $id;
         }
     }
     // Resort map
     $tmpMap = array();
     foreach ($ids as $id) {
         $tmpMap[$id . ""] = $newIds[$id];
     }
     return array($tmpMap, $skuTree);
 }
예제 #13
0
         if ($res) {
             $arResult["ELEMENT_ID"] = $res;
         } else {
             $strError = $obElement->LAST_ERROR;
         }
     }
 }
 if ($bBizproc) {
     if (!$strError) {
         /* Find the new or modified field. */
         if ($ELEMENT_ID && $templatesOnStartup) {
             $modifiedFields = array();
             /* We get the new data element. */
             $elementNewData = array();
             $elementOldData = array();
             $elementQuery = CIBlockElement::getList(array(), array("IBLOCK_ID" => $arResult["IBLOCK_ID"], "=ID" => $arResult["ELEMENT_ID"]), false, false, $arSelect);
             $elementObject = $elementQuery->getNextElement();
             if (is_object($elementObject)) {
                 $elementNewData = $elementObject->getFields();
             }
             $elementOldData = $arResult["ELEMENT_FIELDS"];
             unset($elementNewData["TIMESTAMP_X"]);
             unset($elementOldData["TIMESTAMP_X"]);
             $elementNewData["PROPERTY_VALUES"] = array();
             if (is_object($elementObject)) {
                 $propertyQuery = CIBlockElement::getProperty($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], array("sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc"), array("ACTIVE" => "Y", "EMPTY" => "N"));
                 while ($property = $propertyQuery->fetch()) {
                     $propertyId = $property["ID"];
                     if (!array_key_exists($propertyId, $elementNewData["PROPERTY_VALUES"])) {
                         $elementNewData["PROPERTY_VALUES"][$propertyId] = $property;
                         unset($elementNewData["PROPERTY_VALUES"][$propertyId]["DESCRIPTION"]);
예제 #14
0
파일: class.php 프로젝트: Satariall/izurit
 public function executeComponent()
 {
     if (!empty($this->arParams['ERROR'])) {
         ShowError(array_shift($this->arParams['ERROR']));
         return;
     }
     $this->arResult['USER_ID'] = $this->arParams['USER_ID'];
     $this->arResult['GRID_ID'] = 'lists_processes';
     $selectFields = array('ID', 'IBLOCK_TYPE_ID', 'IBLOCK_ID', 'NAME');
     $gridOptions = new CGridOptions($this->arResult['GRID_ID']);
     $gridColumns = $gridOptions->getVisibleColumns();
     $gridSort = $gridOptions->getSorting(array('sort' => array('ID' => 'desc')));
     $this->arResult['HEADERS'] = array(array("id" => "ID", "name" => "ID", "default" => false, "sort" => "ID"), array('id' => 'DOCUMENT_NAME', 'name' => Loc::getMessage('CC_BLL_DOCUMENT_NAME'), 'default' => true, 'sort' => 'DOCUMENT_NAME'), array('id' => 'COMMENTS', 'name' => Loc::getMessage('CC_BLL_COMMENTS'), 'default' => true, 'sort' => '', 'hideName' => true, 'iconCls' => 'bp-comments-icon'), array('id' => 'WORKFLOW_PROGRESS', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_PROGRESS'), 'default' => true, 'sort' => ''), array('id' => 'WORKFLOW_STATE', 'name' => Loc::getMessage('CC_BLL_WORKFLOW_STATE'), 'default' => false, 'sort' => ''));
     $this->arResult['FILTER'] = array(array("id" => "NAME", "name" => GetMessage("BPATL_NAME"), "type" => "string"), array('id' => 'TIMESTAMP_X', 'name' => Loc::getMessage('CC_BLL_MODIFIED'), 'type' => 'date'), array('id' => 'DATE_CREATE', 'name' => Loc::getMessage('CC_BLL_CREATED'), 'type' => 'date', 'default' => true));
     $gridFilter = $gridOptions->getFilter($this->arResult['FILTER']);
     foreach ($gridFilter as $key => $value) {
         if (substr($key, -5) == "_from") {
             $op = ">=";
             $newKey = substr($key, 0, -5);
         } elseif (substr($key, -3) == "_to") {
             $op = "<=";
             $newKey = substr($key, 0, -3);
             if (in_array($newKey, array("TIMESTAMP_X", 'DATE_CREATE'))) {
                 if (!preg_match("/\\d\\d:\\d\\d:\\d\\d\$/", $value)) {
                     $value .= " 23:59:59";
                 }
             }
         } else {
             $op = "";
             $newKey = $key;
         }
         $filter[$op . $newKey] = $value;
     }
     $this->arResult['SORT'] = $gridSort['sort'];
     $useComments = (bool) CModule::includeModule("forum");
     $workflows = array();
     $this->arResult['DATA'] = array();
     $this->arResult["COMMENTS_COUNT"] = array();
     $filter['CREATED_BY'] = $this->arParams['USER_ID'];
     $iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id");
     $filter['IBLOCK_TYPE'] = $iblockTypeId;
     $filter['CHECK_PERMISSIONS'] = $this->arParams['LIST_PERM'] >= CListPermissions::CAN_READ ? "N" : "Y";
     $elementObject = CIBlockElement::getList($gridSort['sort'], $filter, false, $gridOptions->getNavParams(), $selectFields);
     $documentState = true;
     $path = rtrim(SITE_DIR, '/');
     while ($element = $elementObject->fetch()) {
         $documentState = CBPDocument::GetDocumentStates(BizprocDocument::generateDocumentComplexType($iblockTypeId, $element['IBLOCK_ID']), BizprocDocument::getDocumentComplexId($iblockTypeId, $element['ID']));
         $this->arResult['DATA'][$element['ID']]['ID'] = $element['ID'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_NAME'] = $element['NAME'];
         $this->arResult['DATA'][$element['ID']]['DOCUMENT_URL'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $element['ID'];
         if (!empty($documentState)) {
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = true;
             $documentState = current($documentState);
             $this->arResult['DATA'][$element['ID']]['WORKFLOW_ID'] = $documentState['ID'];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_NAME"] = $documentState["TEMPLATE_NAME"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STATE"] = $documentState["STATE_TITLE"];
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED"] = FormatDateFromDB($documentState["STARTED_FORMATTED"]);
             $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = "";
             if (intval($documentState["STARTED_BY"]) > 0) {
                 $dbUserTmp = CUser::getByID($documentState["STARTED_BY"]);
                 $arUserTmp = $dbUserTmp->fetch();
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] = CUser::FormatName($this->arParams["NAME_TEMPLATE"], $arUserTmp, true);
                 $this->arResult['DATA'][$element['ID']]["WORKFLOW_STARTED_BY"] .= " [" . $documentState["STARTED_BY"] . "]";
             }
             $this->arResult['DATA'][$element['ID']]['MODULE_ID'] = $documentState["DOCUMENT_ID"][0];
             $this->arResult['DATA'][$element['ID']]['ENTITY'] = $documentState["DOCUMENT_ID"][1];
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_ID'] = $documentState["DOCUMENT_ID"][2];
         } else {
             $documentState = false;
             $this->arResult['DATA'][$element['ID']]['DOCUMENT_STATE'] = false;
         }
     }
     foreach ($this->arResult['DATA'] as $data) {
         if ($documentState) {
             if ($useComments) {
                 $workflows[] = 'WF_' . $data['WORKFLOW_ID'];
             }
         }
         $actions = array();
         if (strlen($data["DOCUMENT_URL"]) > 0) {
             $actions[] = array('ICONCLASS' => '', 'DEFAULT' => false, 'TEXT' => Loc::getMessage('CC_BLL_C_DOCUMENT'), 'ONCLICK' => 'window.open("' . $data["DOCUMENT_URL"] . '");');
         }
         $this->arResult['RECORDS'][] = array('data' => $data, 'actions' => $actions);
     }
     if ($useComments && $documentState) {
         $workflows = array_unique($workflows);
         if ($workflows) {
             $iterator = CForumTopic::getList(array(), array("@XML_ID" => $workflows));
             while ($row = $iterator->fetch()) {
                 $this->arResult["COMMENTS_COUNT"][$row['XML_ID']] = $row['POSTS'];
             }
         }
     }
     $this->arResult['COUNTERS'] = array('all' => 0);
     $this->arResult["ROWS_COUNT"] = $elementObject->selectedRowsCount();
     $this->arResult["NAV_RESULT"] = $elementObject;
     if ($this->arParams['SET_TITLE'] == 'Y') {
         $this->getApplication()->setTitle(Loc::getMessage('CC_BLL_TITLE'));
     }
     $this->includeComponentTemplate();
 }
예제 #15
0
    public static function setMessageLiveFeed($users, $elementId, $workflowId, $flagCompleteProcess)
    {
        $elementId = intval($elementId);
        $elementObject = CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('ID', 'CREATED_BY', 'IBLOCK_NAME', 'NAME', 'IBLOCK_ID', 'LANG_DIR'));
        $element = $elementObject->fetch();
        if (!CLists::getLiveFeed($element["IBLOCK_ID"])) {
            return false;
        }
        $params = serialize(array("ELEMENT_NAME" => $element['NAME']));
        $element['NAME'] = preg_replace_callback('#^[^\\[\\]]+?\\[(\\d+)\\]#i', function ($matches) {
            $userId = $matches[1];
            $db = CUser::GetByID($userId);
            if ($ar = $db->GetNext()) {
                $ix = randString(5);
                return '<a class="feed-post-user-name" id="bp_' . $userId . '_' . $ix . '" href="/company/personal/user/' . $userId . '/"
						bx-post-author-id="' . $userId . '">' . CUser::FormatName(CSite::GetNameFormat(false), $ar, false, false) . '</a>
						<script type="text/javascript">if (BX.tooltip) BX.tooltip(\'' . $userId . '\', "bp_' . $userId . '_' . $ix . '", "");</script>';
            }
            return $matches[0];
        }, $element['NAME']);
        $path = rtrim($element['LANG_DIR'], '/');
        $urlElement = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $elementId;
        $createdBy = $element['CREATED_BY'];
        if (!Loader::includeModule('socialnetwork') || $createdBy <= 0) {
            return false;
        }
        $sourceId = CBPStateService::getWorkflowIntegerId($workflowId);
        $logId = 0;
        $userObject = CUser::getByID($createdBy);
        $siteId = array();
        $siteObject = CSite::getList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));
        while ($site = $siteObject->fetch()) {
            $siteId[] = $site['LID'];
        }
        if ($userObject->fetch()) {
            global $DB;
            $soFields = array('ENTITY_TYPE' => SONET_LISTS_NEW_POST_ENTITY, 'EVENT_ID' => 'lists_new_element', 'ENTITY_ID' => 1, '=LOG_UPDATE' => $DB->currentTimeFunction(), 'SOURCE_ID' => $sourceId, 'USER_ID' => $createdBy, 'MODULE_ID' => 'lists', 'TITLE_TEMPLATE' => $urlElement, 'TITLE' => $element['IBLOCK_NAME'], 'PARAMS' => $params, 'MESSAGE' => $workflowId, 'CALLBACK_FUNC' => false, 'SITE_ID' => $siteId, 'ENABLE_COMMENTS' => 'Y', 'RATING_TYPE_ID' => 'LISTS_NEW_ELEMENT', 'RATING_ENTITY_ID' => $sourceId, 'URL' => '#SITE_DIR#' . COption::GetOptionString('socialnetwork', 'user_page', false, SITE_ID) . 'log/');
            $logObject = CSocNetLog::getList(array(), array('ENTITY_TYPE' => $soFields['ENTITY_TYPE'], 'ENTITY_ID' => $soFields['ENTITY_ID'], 'EVENT_ID' => $soFields['EVENT_ID'], 'SOURCE_ID' => $soFields['SOURCE_ID']));
            $iblockPicture = CIBlock::getArrayByID($element['IBLOCK_ID'], 'PICTURE');
            $imageFile = CFile::getFileArray($iblockPicture);
            if ($imageFile !== false) {
                $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
            }
            if (empty($imageFile['src'])) {
                $imageFile['src'] = '/bitrix/images/lists/default.png';
            }
            $soFields['TEXT_MESSAGE'] = '
				<span class="bp-title-desc">
					<span class="bp-title-desc-icon">
						<img src="' . $imageFile['src'] . '" width="36" height="30" border="0" />
					</span>
					' . $element['NAME'] . '
				</span>
			';
            if ($log = $logObject->fetch()) {
                if (intval($log['ID']) > 0) {
                    if (empty($users)) {
                        CSocNetLog::update($log['ID'], $soFields);
                    } else {
                        $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                        $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
                        $usersRight = self::getUserIdForRight($rights);
                        self::setSocnetFollow($usersRight, $log['ID'], 'Y', true);
                        /* Recipients tasks bp */
                        CSocNetLog::update($log['ID'], $soFields);
                        /* Increment the counter for participants */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
                        CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
                        CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
                        /* Return previous state rights */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        CSocNetLogRights::add($log['ID'], $rights, false, false);
                        self::setSocnetFollow($users, $log['ID'], 'Y');
                        self::setSocnetFollow($users, $log['ID'], 'N');
                    }
                    /* Completion of the process for the author */
                    if ($flagCompleteProcess) {
                        $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                        $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post');
                        $usersRight = self::getUserIdForRight($rights);
                        /* Increment the counter for author */
                        $users[] = $createdBy;
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter');
                        CSocNetLogRights::add($log['ID'], $rightsCounter, false, false);
                        CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false);
                        /* Return previous state rights */
                        CSocNetLogRights::deleteByLogID($log['ID']);
                        CSocNetLogRights::add($log['ID'], $rights, false, false);
                        self::setSocnetFollow($users, $log['ID'], 'Y');
                        self::setSocnetFollow($usersRight, $log['ID'], 'N');
                    }
                }
            } else {
                $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId);
                $soFields['=LOG_DATE'] = $DB->currentTimeFunction();
                $logId = CSocNetLog::add($soFields, false);
                if (intval($logId) > 0) {
                    $rights = self::getRights($activeUsers, $logId, $createdBy, 'post');
                    CSocNetLogRights::add($logId, $rights, false, false);
                    $usersRight = self::getUserIdForRight($rights);
                    self::setSocnetFollow($usersRight, $logId, 'N');
                }
                CSocNetLog::counterIncrement($logId, $soFields['EVENT_ID'], false, 'L', false);
            }
        }
        return $logId;
    }
예제 #16
0
         $userId = array();
         $userQuery = CUser::GetList($by = 'ID', $order = 'ASC', array("NAME" => $value), array("FIELDS" => array("ID")));
         while ($user = $userQuery->fetch()) {
             $userId[] = $user["ID"];
         }
         if (!empty($userId)) {
             $value = $userId;
         }
     }
 }
 foreach ($arResult["FILTER"] as $filterArray) {
     if (array_search($key, $filterArray)) {
         if (isset($filterArray["fieldsType"]) && ($filterArray["fieldsType"] == "E" || $filterArray["fieldsType"] == "E:EList")) {
             if (!intval($value)) {
                 $elementId = array();
                 $elementQuery = CIBlockElement::getList(array("SORT" => "ASC"), array("NAME" => "%" . $value . "%"));
                 while ($element = $elementQuery->fetch()) {
                     $elementId[] = $element["ID"];
                 }
                 if (!empty($elementId)) {
                     $value = $elementId;
                 }
             }
         }
     }
 }
 if (array_key_exists($new_key, $arFilterable)) {
     if ($op == "") {
         $op = $arFilterable[$new_key];
     }
     $arFilter[$op . $new_key] = $value;
예제 #17
0
 protected function findEngine()
 {
     list($arFilter, $arOrder, $relations, $arPager) = func_get_args();
     $arFilter['IBLOCK_ID'] = $this->iblockId();
     if (!empty($arPager)) {
         $arPager = array('iNumPage' => $arPager[0], 'nPageSize' => $arPager[1]);
     }
     $arSelected = array_merge(self::$mainFields, $relations ?: array());
     foreach ($this->getFieldsAssoc() as $attr => $field) {
         // Price and relations already set
         if ($this->isPriceRelation($attr)) {
             continue;
         }
         $arSelected[] = $this->fieldByAttrForRequest($attr);
     }
     return \CIBlockElement::getList($arOrder, $arFilter, false, $arPager, $arSelected);
 }
예제 #18
0
 protected function getBizProcData(BaseObject $object, SecurityContext $securityContext, array $actions, array $columnsBizProc, array $bizprocIcon, array $exportData)
 {
     $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($object->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($object->getId())));
     $listBpTemplates = array();
     foreach ($this->arParams['TEMPLATE_BIZPROC'] as $idTemplate => $valueTemplate) {
         $url = CComponentEngine::MakePathFromTemplate($valueTemplate['URL'], array("ELEMENT_ID" => $object->getId()));
         $listBpTemplates[] = array("ICONCLASS" => "", "TEXT" => $valueTemplate['NAME'], "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');");
     }
     if ($object->canStartBizProc($securityContext) && !empty($listBpTemplates)) {
         $actions[] = array("ICONCLASS" => "bizproc_start", "TEXT" => Loc::getMessage("DISK_FOLDER_LIST_ACT_START_BIZPROC"), "MENU" => $listBpTemplates);
     }
     $webdavFileId = $object->getXmlId();
     if (!empty($webdavFileId)) {
         if (Loader::includeModule("iblock")) {
             if ($this->storage->getProxyType() instanceof ProxyType\Group) {
                 $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                 $entity = 'CIBlockDocumentWebdavSocnet';
             } else {
                 $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                 $entity = 'CIBlockDocumentWebdav';
             }
             if (!empty($iblock)) {
                 $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID']));
             }
         }
     }
     foreach ($documentData as $nameModuleId => $data) {
         $temporary[$nameModuleId] = CBPDocument::getDocumentStates($data['DOCUMENT_TYPE'], $data['DOCUMENT_ID']);
     }
     if (isset($temporary['OLD_FILE'])) {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV'], $temporary['OLD_FILE']);
     } else {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV']);
     }
     foreach ($documentStates as $key => $documentState) {
         if (empty($documentState['ID'])) {
             unset($documentStates[$key]);
         }
     }
     $columnsBizProc['BIZPROC'] = "";
     $bizprocIcon['BIZPROC'] = "";
     if (!empty($documentStates)) {
         if (count($documentStates) == 1) {
             $documentState = reset($documentStates);
             if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                 $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                 $columnsBizProc["BIZPROC"] = '<div class="bizproc-item-title">' . htmlspecialcharsbx($documentState["TEMPLATE_NAME"]) . ': ' . '<span class="bizproc-item-title bizproc-state-title" style="">' . '<a href="' . $exportData["OPEN_URL"] . '#tab-bp">' . (strlen($documentState["STATE_TITLE"]) > 0 ? htmlspecialcharsbx($documentState["STATE_TITLE"]) : htmlspecialcharsbx($documentState["STATE_NAME"])) . '</a>' . '</span>' . '</div>';
                 $columnsBizProc['BIZPROC'] = str_replace("'", "\"", $columnsBizProc['BIZPROC']);
                 $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . (!(strlen($documentState["ID"]) <= 0 || strlen($documentState["WORKFLOW_STATUS"]) <= 0) ? 'bizproc-status-' . (empty($tasksWorkflow) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc["BIZPROC"]) . "\")'></div>";
                 if (!empty($tasksWorkflow)) {
                     $tmp = array();
                     foreach ($tasksWorkflow as $val) {
                         $url = CComponentEngine::makePathFromTemplate($this->arParams["PATH_TO_DISK_TASK"], array("ID" => $val["ID"]));
                         $url .= "?back_url=" . urlencode($this->getApplication()->getCurPageParam());
                         $tmp[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>';
                     }
                     $columnsBizProc["BIZPROC"] .= '<div class="bizproc-tasks">' . implode(", ", $tmp) . '</div>';
                     return array($actions, $columnsBizProc, $bizprocIcon);
                 }
                 return array($actions, $columnsBizProc, $bizprocIcon);
             }
             return array($actions, $columnsBizProc, $bizprocIcon);
         } else {
             $tasks = array();
             $inprogress = false;
             foreach ($documentStates as $key => $documentState) {
                 if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                     $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                     if (!$inprogress) {
                         $inprogress = strlen($documentState['ID']) > 0 && strlen($documentState['WORKFLOW_STATUS']) > 0;
                     }
                     if (!empty($tasksWorkflow)) {
                         foreach ($tasksWorkflow as $val) {
                             $tasks[] = $val;
                         }
                     }
                 }
             }
             $columnsBizProc["BIZPROC"] = '<span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC") . ': <a href="' . $exportData["OPEN_URL"] . '#tab-bp" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TITLE") . '">' . count($documentStates) . '</a></span>' . (!empty($tasks) ? '<br /><span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS") . ': <a href="' . $this->arParams["PATH_TO_DISK_TASK_LIST"] . '" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS_TITLE") . '">' . count($tasks) . '</a></span>' : '');
             $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . ($inprogress ? ' bizproc-status-' . (empty($tasks) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc['BIZPROC']) . "\")'></div>";
             return array($actions, $columnsBizProc, $bizprocIcon);
         }
     }
     return array($actions, $columnsBizProc, $bizprocIcon);
 }
예제 #19
0
 /**
  * Common function, used to update/insert any product.
  *
  * @param int $productId			Id of product.
  * @param int $fuserId				User basket id.
  * @param string $siteId			Site id.
  * @param int $elementId			Parent id.
  * @param string $recommendationId	Bigdata recommendation id.
  *
  * @return int
  */
 public static function refresh($productId, $fuserId, $siteId = SITE_ID, $elementId = 0, $recommendationId = '')
 {
     $productId = (int) $productId;
     $fuserId = (int) $fuserId;
     $siteId = (string) $siteId;
     $elementId = (int) $elementId;
     $recommendationId = (string) $recommendationId;
     if ($productId <= 0 || $fuserId <= 0 || $siteId == '') {
         return -1;
     }
     if (Main\Loader::includeModule('statictic') && isset($_SESSION['SESS_SEARCHER_ID']) && (int) $_SESSION['SESS_SEARCHER_ID'] > 0) {
         return -1;
     }
     $filter = array('=FUSER_ID' => $fuserId, '=SITE_ID' => $siteId);
     $connection = Application::getConnection();
     $helper = $connection->getSqlHelper();
     $sqlSiteId = $helper->forSql($siteId);
     if ($elementId > 0) {
         $filter["=ELEMENT_ID"] = $elementId;
         // Delete parent product id (for capability)
         if ($elementId != $productId) {
             $connection->query("delete from b_catalog_viewed_product where PRODUCT_ID = " . $elementId . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
         }
     } else {
         $productInfo = \CCatalogSKU::getProductInfo($productId);
         // Real SKU ID
         if (!empty($productInfo)) {
             $elementId = $productInfo['ID'];
             $siblings = array();
             // Delete parent product id (for capability)
             $connection->query("delete from b_catalog_viewed_product\n\t\t\t\t\t\t\t\t\twhere PRODUCT_ID = " . $productInfo['ID'] . " and FUSER_ID = " . $fuserId . " and SITE_ID = '" . $sqlSiteId . "'");
             $skus = \CIBlockElement::getList(array(), array('IBLOCK_ID' => $productInfo['OFFER_IBLOCK_ID'], '=PROPERTY_' . $productInfo['SKU_PROPERTY_ID'] => $productInfo['ID']), false, false, array('ID', 'IBLOCK_ID'));
             while ($oneSku = $skus->fetch()) {
                 $siblings[] = $oneSku['ID'];
             }
             unset($oneSku, $skus);
             $filter['@PRODUCT_ID'] = $siblings;
         } else {
             $elementId = $productId;
             $filter['=PRODUCT_ID'] = $productId;
         }
     }
     // recommendation
     if (!empty($elementId)) {
         global $APPLICATION;
         $recommendationCookie = $APPLICATION->get_cookie(Main\Analytics\Catalog::getCookieLogName());
         if (!empty($recommendationCookie)) {
             $recommendations = Main\Analytics\Catalog::decodeProductLog($recommendationCookie);
             if (is_array($recommendations) && isset($recommendations[$elementId])) {
                 $recommendationId = $recommendations[$elementId][0];
             }
         }
     }
     $iterator = static::getList(array('select' => array('ID', 'FUSER_ID', 'DATE_VISIT', 'PRODUCT_ID', 'SITE_ID', 'VIEW_COUNT'), 'filter' => $filter));
     if ($row = $iterator->fetch()) {
         $update = array("PRODUCT_ID" => $productId, "DATE_VISIT" => new Main\Type\DateTime(), 'VIEW_COUNT' => $row['VIEW_COUNT'] + 1, "ELEMENT_ID" => $elementId);
         if (!empty($recommendationId)) {
             $update["RECOMMENDATION"] = $recommendationId;
         }
         $result = static::update($row['ID'], $update);
         return $result->isSuccess(true) ? $row['ID'] : -1;
     } else {
         $result = static::add(array("FUSER_ID" => $fuserId, "DATE_VISIT" => new Main\Type\DateTime(), "PRODUCT_ID" => $productId, "ELEMENT_ID" => $elementId, "SITE_ID" => $siteId, "VIEW_COUNT" => 1, "RECOMMENDATION" => $recommendationId));
         return $result->isSuccess(true) ? $result->getId() : -1;
     }
 }
예제 #20
0
 public function getDocumentAdminPage($documentId)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $db = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("ID", "IBLOCK_ID", "IBLOCK_TYPE_ID", "DETAIL_PAGE_URL"));
     if ($ar = $db->Fetch()) {
         return COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $ar["IBLOCK_ID"] . '&element_id=' . $documentId;
     }
     return null;
 }
예제 #21
0
파일: product.php 프로젝트: rasuldev/torino
 /**
  * The function select viewed product
  *
  * @param array $arOrder - array to sort
  * @param array $arFilter - array to filter
  * @param array $arGroupBy - array to group records
  * @param array $arNavStartParams - array to parameters
  * @param array $arSelectFields - array to selectes fields
  * @return object $dbRes - object result
  */
 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     global $DB;
     if (array_key_exists("DATE_FROM", $arFilter)) {
         $arFilter[">=DATE_VISIT"] = trim($arFilter["DATE_FROM"]);
         unset($arFilter["DATE_FROM"]);
     }
     if (array_key_exists("DATE_TO", $arFilter)) {
         $arFilter["<=DATE_VISIT"] = trim($arFilter["DATE_TO"]);
         unset($arFilter["DATE_TO"]);
     }
     if (!$arSelectFields || count($arSelectFields) <= 0 || in_array("*", $arSelectFields)) {
         $arSelectFields = array("ID", "FUSER_ID", "DATE_VISIT", "PRODUCT_ID", "MODULE", "LID", "NAME", "DETAIL_PAGE_URL", "CURRENCY", "PRICE", "NOTES", "PREVIEW_PICTURE", "DETAIL_PICTURE", "CALLBACK_FUNC", "PRODUCT_PROVIDER_CLASS");
     }
     if (\Bitrix\Main\Loader::includeModule("catalog")) {
         if (\Bitrix\Main\Config\Option::get("sale", "viewed_capability", "") == "Y") {
             foreach ($arFilter as $key => $value) {
                 if ($key == "LID") {
                     $arFilter['SITE_ID'] = $value;
                     unset($arFilter['LID']);
                 }
             }
             $limit = 100;
             if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) >= 0) {
                 $limit = IntVal($arNavStartParams["nTopCount"]);
             }
             $viewedIterator = \Bitrix\Catalog\CatalogViewedProductTable::getList(array("filter" => $arFilter, "select" => array("ID", "PRODUCT_ID", "DATE_VISIT", "LID" => "SITE_ID", "NAME" => "ELEMENT.NAME"), "order" => array("DATE_VISIT" => "DESC"), "limit" => $limit));
             $viewed = array();
             while ($row = $viewedIterator->fetch()) {
                 $row['MODULE'] = "catalog";
                 $row['DATE_VISIT'] = $row['DATE_VISIT']->toString();
                 $viewed[$row['PRODUCT_ID']] = $row;
             }
             if (count($viewed)) {
                 // Map to parent sku
                 $newIds = array();
                 $ids = array_keys($viewed);
                 $catalogIterator = CCatalog::getList();
                 while ($catalog = $catalogIterator->fetch()) {
                     if ($catalog['IBLOCK_TYPE_ID'] == "offers") {
                         $elementIterator = CIBlockElement::getList(array(), array("ID" => $ids, "IBLOCK_ID" => $catalog['IBLOCK_ID']), false, false, array("ID", "IBLOCK_ID", "PROPERTY_" . $catalog['SKU_PROPERTY_ID']));
                         while ($item = $elementIterator->fetch()) {
                             $propertyName = "PROPERTY_" . $catalog['SKU_PROPERTY_ID'] . "_VALUE";
                             $parentId = $item[$propertyName];
                             if (!empty($parentId)) {
                                 $newIds[$item['ID']] = $parentId;
                             } else {
                                 $newIds[$item['ID']] = $item['ID'];
                             }
                         }
                     }
                 }
                 // Push missing
                 foreach ($ids as $id) {
                     if (!isset($newIds[$id])) {
                         $newIds[$id] = $id;
                     }
                 }
                 $filter = array("ID" => array_values($newIds));
                 if (!count($filter['ID'])) {
                     $filter = array("ID" => -1);
                 }
                 $mapped = array();
                 if (in_array("DETAIL_PAGE_URL", $arSelectFields) || in_array("PREVIEW_PICTURE", $arSelectFields) || in_array("DETAIL_PICTURE", $arSelectFields)) {
                     $elementIterator = CIBlockElement::GetList(array(), $filter);
                     while ($elementObj = $elementIterator->GetNextElement()) {
                         $fields = $elementObj->GetFields();
                         $mapped[$fields['ID']]['PREVIEW_PICTURE'] = $fields['PREVIEW_PICTURE'];
                         $mapped[$fields['ID']]['DETAIL_PICTURE'] = $fields['DETAIL_PICTURE'];
                     }
                 }
                 foreach ($newIds as $natural => $tr) {
                     $viewed[$natural]['PREVIEW_PICTURE'] = $mapped[$tr]['DETAIL_PICTURE'];
                     $viewed[$natural]['DETAIL_PICTURE'] = $mapped[$tr]['PREVIEW_PICTURE'];
                     $viewed[$natural]['PRODUCT_ID'] = $tr;
                 }
                 if (in_array("CURRENCY", $arSelectFields) || in_array("PRICE", $arSelectFields)) {
                     // Prices
                     $priceIterator = CPrice::getList(array(), array("PRODUCT_ID" => $ids), false, false, array("PRODUCT_ID", "PRICE", "CURRENCY"));
                     while ($price = $priceIterator->fetch()) {
                         if (!isset($viewed[$price['PRODUCT_ID']]['PRICE'])) {
                             $viewed[$price['PRODUCT_ID']]['PRICE'] = $price['PRICE'];
                             $viewed[$price['PRODUCT_ID']]['CURRENCY'] = $price['CURRENCY'];
                         }
                     }
                 }
             }
             // resort
             $dbresult = new CDBResult();
             $dbresult->InitFromArray(array_values($viewed));
             return $dbresult;
         }
     }
     $arFields = array("ID" => array("FIELD" => "V.ID", "TYPE" => "int"), "FUSER_ID" => array("FIELD" => "V.FUSER_ID", "TYPE" => "int"), "DATE_VISIT" => array("FIELD" => "V.DATE_VISIT", "TYPE" => "datetime"), "PRODUCT_ID" => array("FIELD" => "V.PRODUCT_ID", "TYPE" => "int"), "MODULE" => array("FIELD" => "V.MODULE", "TYPE" => "string"), "LID" => array("FIELD" => "V.LID", "TYPE" => "string"), "NAME" => array("FIELD" => "V.NAME", "TYPE" => "string"), "DETAIL_PAGE_URL" => array("FIELD" => "V.DETAIL_PAGE_URL", "TYPE" => "string"), "CURRENCY" => array("FIELD" => "V.CURRENCY", "TYPE" => "string"), "PRICE" => array("FIELD" => "V.PRICE", "TYPE" => "double"), "NOTES" => array("FIELD" => "V.NOTES", "TYPE" => "string"), "PREVIEW_PICTURE" => array("FIELD" => "V.PREVIEW_PICTURE", "TYPE" => "string"), "DETAIL_PICTURE" => array("FIELD" => "V.DETAIL_PICTURE", "TYPE" => "string"), "CALLBACK_FUNC" => array("FIELD" => "V.CALLBACK_FUNC", "TYPE" => "string"), "PRODUCT_PROVIDER_CLASS" => array("FIELD" => "V.PRODUCT_PROVIDER_CLASS", "TYPE" => "string"));
     $arSqls = CSaleOrder::PrepareSql($arFields, $arOrder, $arFilter, $arGroupBy, $arSelectFields);
     $arSqls["SELECT"] = str_replace("%%_DISTINCT_%%", "", $arSqls["SELECT"]);
     $strSql = "SELECT " . $arSqls["SELECT"] . " " . "FROM b_sale_viewed_product V ";
     if (strlen($arSqls["WHERE"]) > 0) {
         $strSql .= "WHERE " . $arSqls["WHERE"] . " ";
     }
     if (strlen($arSqls["GROUPBY"]) > 0) {
         $strSql .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
     }
     if (strlen($arSqls["ORDERBY"]) > 0) {
         $strSql .= "ORDER BY " . $arSqls["ORDERBY"] . " ";
     }
     if (is_array($arGroupBy) && count($arGroupBy) == 0) {
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         if ($arRes = $dbRes->Fetch()) {
             return $arRes["CNT"];
         } else {
             return false;
         }
     }
     if (is_array($arNavStartParams) && IntVal($arNavStartParams["nTopCount"]) <= 0) {
         $strSql_tmp = "SELECT COUNT('x') as CNT " . "FROM b_sale_viewed_product B ";
         if (strlen($arSqls["WHERE"]) > 0) {
             $strSql_tmp .= "WHERE " . $arSqls["WHERE"] . " ";
         }
         if (strlen($arSqls["GROUPBY"]) > 0) {
             $strSql_tmp .= "GROUP BY " . $arSqls["GROUPBY"] . " ";
         }
         $dbRes = $DB->Query($strSql_tmp, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         $cnt = 0;
         if (strlen($arSqls["GROUPBY"]) <= 0) {
             if ($arRes = $dbRes->Fetch()) {
                 $cnt = $arRes["CNT"];
             }
         } else {
             $cnt = $dbRes->SelectedRowsCount();
         }
         $dbRes = new CDBResult();
         $dbRes->NavQuery($strSql, $cnt, $arNavStartParams);
     } else {
         $strSql = $DB->TopSql($strSql, $arNavStartParams["nTopCount"]);
         $dbRes = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     return $dbRes;
 }
예제 #22
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;
 }
예제 #23
0
 /**
  * Method return array with all information about document. Array used for method RecoverDocumentFromHistory.
  *
  * @param string $documentId - document id.
  * @return array - document information array.
  */
 public function GetDocumentForHistory($documentId, $historyIndex)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $result = null;
     $dbDocumentList = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"));
     if ($objDocument = $dbDocumentList->getNextElement()) {
         $fields = $objDocument->getFields();
         $properties = $objDocument->getProperties();
         $result["NAME"] = $fields["~NAME"];
         $result["FIELDS"] = array();
         foreach ($fields as $fieldKey => $fieldValue) {
             if ($fieldKey == "~PREVIEW_PICTURE" || $fieldKey == "~DETAIL_PICTURE") {
                 $result["FIELDS"][substr($fieldKey, 1)] = CBPDocument::prepareFileForHistory(array("lists", get_called_class(), $documentId), $fieldValue, $historyIndex);
             } elseif (substr($fieldKey, 0, 1) == "~") {
                 $result["FIELDS"][substr($fieldKey, 1)] = $fieldValue;
             }
         }
         $result["PROPERTIES"] = array();
         foreach ($properties as $propertyKey => $propertyValue) {
             if (strlen($propertyValue["USER_TYPE"]) > 0) {
                 $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
             } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                 $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE_ENUM_ID"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
             } elseif ($propertyValue["PROPERTY_TYPE"] == "F") {
                 $result["PROPERTIES"][$propertyKey] = array("VALUE" => CBPDocument::prepareFileForHistory(array("lists", get_called_class(), $documentId), $propertyValue["VALUE"], $historyIndex), "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
             } else {
                 $result["PROPERTIES"][$propertyKey] = array("VALUE" => $propertyValue["VALUE"], "DESCRIPTION" => $propertyValue["DESCRIPTION"]);
             }
         }
     }
     return $result;
 }
예제 #24
0
    public static function getFieldInputControlOptions($documentType, &$fieldType, $functionNameJs, &$value)
    {
        $result = "";
        static $documentFieldTypes = array();
        if (!array_key_exists($documentType, $documentFieldTypes)) {
            $documentFieldTypes[$documentType] = self::getDocumentFieldTypes($documentType);
        }
        if (!array_key_exists($fieldType["Type"], $documentFieldTypes[$documentType]) || !$documentFieldTypes[$documentType][$fieldType["Type"]]["Complex"]) {
            return "";
        }
        if ($fieldType["Type"] == "E:EList") {
            if (is_array($value)) {
                reset($value);
                $valueTmp = intval(current($value));
            } else {
                $valueTmp = intval($value);
            }
            $iblockId = 0;
            if ($valueTmp > 0) {
                $queryResult = \CIBlockElement::getList(array(), array("ID" => $valueTmp), false, false, array("ID", "IBLOCK_ID"));
                if ($fetchResult = $queryResult->fetch()) {
                    $iblockId = $fetchResult["IBLOCK_ID"];
                }
            }
            if ($iblockId <= 0 && intval($fieldType["Options"]) > 0) {
                $iblockId = intval($fieldType["Options"]);
            }
            $defaultIBlockId = 0;
            $result .= '<select id="WFSFormOptionsX" onchange="' . htmlspecialcharsbx($functionNameJs) . '(this.options[this.selectedIndex].value)">';
            $iblockType = \CIBlockParameters::getIBlockTypes();
            foreach ($iblockType as $iblockTypeId => $iblockTypeName) {
                $result .= '<optgroup label="' . $iblockTypeName . '">';
                $dbIBlock = \CIBlock::getList(array("SORT" => "ASC"), array("TYPE" => $iblockTypeId, "ACTIVE" => "Y"));
                while ($iblock = $dbIBlock->getNext()) {
                    $result .= '<option value="' . $iblock["ID"] . '"' . ($iblock["ID"] == $iblockId ? " selected" : "") . '>' . $iblock["NAME"] . '</option>';
                    if ($defaultIBlockId <= 0 || $iblock["ID"] == $iblockId) {
                        $defaultIBlockId = $iblock["ID"];
                    }
                }
                $result .= '</optgroup>';
            }
            $result .= '</select><!--__defaultOptionsValue:' . $defaultIBlockId . '--><!--__modifyOptionsPromt:' . GetMessage("IBD_DOCUMENT_MOPROMT") . '-->';
            $fieldType["Options"] = $defaultIBlockId;
        } elseif ($fieldType["Type"] == "select") {
            $valueTmp = $fieldType["Options"];
            if (!is_array($valueTmp)) {
                $valueTmp = array($valueTmp => $valueTmp);
            }
            $str = '';
            foreach ($valueTmp as $k => $v) {
                if (is_array($v) && count($v) == 2) {
                    $v1 = array_values($v);
                    $k = $v1[0];
                    $v = $v1[1];
                }
                if ($k != $v) {
                    $str .= '[' . $k . ']' . $v;
                } else {
                    $str .= $v;
                }
                $str .= "\n";
            }
            $result .= '<textarea id="WFSFormOptionsX" rows="5" cols="30">' . htmlspecialcharsbx($str) . '</textarea><br />';
            $result .= Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS1") . '<br />';
            $result .= Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS2") . '<br />';
            $result .= '<script type="text/javascript">
				function WFSFormOptionsXFunction()
				{
					var result = {};
					var i, id, val, str = document.getElementById("WFSFormOptionsX").value;

					var arr = str.split(/[\\r\\n]+/);
					var p, re = /\\[([^\\]]+)\\].+/;
					for (i in arr)
					{
						str = arr[i].replace(/^\\s+|\\s+$/g, \'\');
						if (str.length > 0)
						{
							id = str.match(re);
							if (id)
							{
								p = str.indexOf(\']\');
								id = id[1];
								val = str.substr(p + 1);
							}
							else
							{
								val = str;
								id = val;
							}
							result[id] = val;
						}
					}

					return result;
				}
				</script>';
            $result .= '<input type="button" onclick="' . htmlspecialcharsbx($functionNameJs) . '(WFSFormOptionsXFunction())" value="' . Loc::getMessage("DISK_IBD_DOCUMENT_XFORMOPTIONS3") . '">';
        }
        return $result;
    }
예제 #25
0
         }
         if (!empty($userId)) {
             $value = $userId;
         }
     }
 }
 foreach ($arResult["FILTER"] as $filterArray) {
     if (array_search($key, $filterArray)) {
         if (isset($filterArray["fieldsType"]) && $filterArray["fieldsType"] == "E:EList") {
             if (intval($value)) {
                 $filter = array("ID" => $value);
             } else {
                 $filter = array("NAME" => "%" . $value . "%");
             }
             $elementId = array();
             $elementQuery = CIBlockElement::getList(array("SORT" => "ASC"), $filter, false, false, array("ID"));
             while ($element = $elementQuery->fetch()) {
                 $elementId[] = $element["ID"];
             }
             if (!empty($elementId)) {
                 $value = $elementId;
             }
         }
     }
 }
 if (array_key_exists($new_key, $arFilterable)) {
     if ($op == "") {
         $op = $arFilterable[$new_key];
     }
     $arFilter[$op . $new_key] = $value;
 }
예제 #26
0
 /**
  * Get Linked product ids
  *
  * @param $productId
  * @param $propertyName
  *
  * @return array
  */
 protected function getRecommendedIds($productId, $propertyName)
 {
     if (!$productId) {
         return array();
     }
     $elementIterator = CIBlockElement::getList(array(), array("ID" => $productId), false, false, array("ID", "IBLOCK_ID"));
     $linked = array();
     if ($element = $elementIterator->getNextElement()) {
         $props = $element->getProperties();
         $linked = $props[$propertyName]['VALUE'];
     }
     if (empty($linked)) {
         $linked = -1;
     }
     $productIterator = CIBlockElement::getList(array(), array("ID" => $linked), false, array("nTopCount" => $this->arParams['PAGE_ELEMENT_COUNT']), array("ID"));
     $ids = array();
     while ($item = $productIterator->fetch()) {
         $ids[] = $item['ID'];
     }
     return $ids;
 }
예제 #27
0
파일: CDev.php 프로젝트: Hawkart/megatv
 public static function getNotEmptySections($filter = array('sections' => array(), 'elements' => array()), $sort = array())
 {
     CModule::includeModule('iblock');
     $sections = array();
     $rsSections = CIBlockSection::getList($sort, $filter['sections']);
     while ($section = $rsSections->getNext()) {
         $sections[$section['ID']] = $section;
     }
     $tmpSections = $sections;
     $sections = array();
     $rsElements = CIBlockElement::getList(array('SORT'), $filter['elements'], array('IBLOCK_SECTION_ID'));
     while ($element = $rsElements->getNext()) {
         if ($element['CNT'] > 0) {
             $sections[$element['IBLOCK_SECTION_ID']] = $tmpSections[$element['IBLOCK_SECTION_ID']];
         }
     }
     return $sections;
 }
예제 #28
0
 public static function getCountProcessesUser($userId, $iblockTypeId)
 {
     $userId = intval($userId);
     return CIBlockElement::getList(array(), array('CREATED_BY' => $userId, 'IBLOCK_TYPE' => $iblockTypeId), true, false, array('ID'));
 }
예제 #29
0
    protected function createPreparedFields()
    {
        $this->lists['PREPARED_FIELDS'] = array();
        $this->lists['ELEMENT_ID'] = 0;
        $this->createFormData();
        $this->getElementFields();
        foreach ($this->lists['FIELDS'] as $fieldId => $field) {
            if ($fieldId == 'ACTIVE_FROM' || $fieldId == 'ACTIVE_TO') {
                $this->lists['PREPARED_FIELDS'][$fieldId] = array('id' => $fieldId . '[' . $this->iblockId . ']', 'name' => $field['NAME'], 'required' => $field['IS_REQUIRED'] == 'Y' ? true : false, 'type' => 'date', 'value' => $this->lists['FORM_DATA'][$fieldId]);
            } elseif ($fieldId == 'PREVIEW_PICTURE' || $fieldId == 'DETAIL_PICTURE') {
                $this->lists['PREPARED_FIELDS'][$fieldId] = array('id' => $fieldId, 'name' => $field['NAME'], 'required' => $field['IS_REQUIRED'] == 'Y' ? true : false, 'type' => 'file');
            } elseif ($fieldId == 'PREVIEW_TEXT' || $fieldId == 'DETAIL_TEXT') {
                if ($field['SETTINGS']['USE_EDITOR'] == 'Y') {
                    $params = array('width' => '100%', 'height' => '200px', 'iblockId' => $this->iblockId);
                    $match = array();
                    if (preg_match('/\\s*(\\d+)\\s*(px|%|)/', $field['SETTINGS']['WIDTH'], $match) && $match[1] > 0) {
                        $params['width'] = $match[1] . $match[2];
                    }
                    if (preg_match('/\\s*(\\d+)\\s*(px|%|)/', $field['SETTINGS']['HEIGHT'], $match) && $match[1] > 0) {
                        $params['height'] = $match[1] . $match[2];
                    }
                    $html = $this->connectionHtmlEditor($fieldId, $fieldId, $params, $this->lists['FORM_DATA'][$fieldId]);
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array('id' => $fieldId, 'name' => $field['NAME'], 'required' => $field['IS_REQUIRED'] == 'Y' ? true : false, 'type' => 'custom', 'value' => $html);
                } else {
                    $params = array('style' => '');
                    if (preg_match('/\\s*(\\d+)\\s*(px|%|)/', $field['SETTINGS']['WIDTH'], $match) && $match[1] > 0) {
                        if ($match[2] == '') {
                            $params['cols'] = $match[1];
                        } else {
                            $params['style'] .= 'width:' . $match[1] . $match[2] . ';';
                        }
                    }
                    if (preg_match('/\\s*(\\d+)\\s*(px|%|)/', $field['SETTINGS']['HEIGHT'], $match) && $match[1] > 0) {
                        if ($match[2] == "") {
                            $params['rows'] = $match[1];
                        } else {
                            $params['style'] .= 'height:' . $match[1] . $match[2] . ';';
                        }
                    }
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array('id' => $fieldId, 'name' => $field['NAME'], 'required' => $field['IS_REQUIRED'] == 'Y' ? true : false, 'type' => 'textarea', 'params' => $params);
                }
            } elseif ($fieldId == "DATE_CREATE" || $fieldId == "TIMESTAMP_X") {
                if ($this->lists['ELEMENT_FIELDS'][$fieldId]) {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $this->lists['ELEMENT_FIELDS'][$fieldId]);
                }
            } elseif ($fieldId == "CREATED_BY") {
                if ($this->lists['ELEMENT_FIELDS']["CREATED_BY"]) {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => "[" . $this->lists['ELEMENT_FIELDS']["CREATED_BY"] . "] " . $this->lists['ELEMENT_FIELDS']["CREATED_USER_NAME"]);
                }
            } elseif ($fieldId == "MODIFIED_BY") {
                if ($this->lists['ELEMENT_FIELDS']["MODIFIED_BY"]) {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => "[" . $this->lists['ELEMENT_FIELDS']["MODIFIED_BY"] . "] " . $this->lists['ELEMENT_FIELDS']["USER_NAME"]);
                }
            } elseif (is_array($field["PROPERTY_USER_TYPE"]) && array_key_exists("GetPublicEditHTMLMulty", $field["PROPERTY_USER_TYPE"]) && $field["MULTIPLE"] == "Y" && $field["PROPERTY_TYPE"] != "E") {
                $html = call_user_func_array($field["PROPERTY_USER_TYPE"]["GetPublicEditHTMLMulty"], array($field, $this->lists['FORM_DATA'][$fieldId], array("VALUE" => $fieldId, "DESCRIPTION" => '', "FORM_NAME" => $this->formId, "MODE" => "FORM_FILL")));
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
            } elseif (is_array($field["PROPERTY_USER_TYPE"]) && array_key_exists("GetPublicEditHTML", $field["PROPERTY_USER_TYPE"])) {
                $params = array('width' => '100%', 'height' => '200px', 'iblockId' => '');
                if ($field["MULTIPLE"] == "Y") {
                    $checkHtml = false;
                    $html = '<table id="tbl' . $fieldId . '">';
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        if ($field["TYPE"] == "S:HTML") {
                            $checkHtml = true;
                            $fieldIdForHtml = 'id_' . $fieldId . '__' . $key . '_';
                            $fieldNameForHtml = $fieldId . "[" . $key . "][VALUE]";
                            $html .= '<tr><td>' . $this->connectionHtmlEditor($fieldIdForHtml, $fieldNameForHtml, $params, is_array($value['VALUE']) ? $value['VALUE']['TEXT'] : '') . '</td></tr>';
                        } elseif ($field['TYPE'] == 'S:DateTime') {
                            $html .= '<tr><td>
								<input class="bx-lists-input-calendar" type="text" name="' . $fieldId . '[' . $key . '][VALUE]" onclick="BX.calendar({node: this.parentNode, field: this, bTime: true, bHideTime: false});" value="' . $value['VALUE'] . '">
								<span class="bx-lists-calendar-icon" onclick="BX.calendar({node:this, field:\'' . $fieldId . '[' . $key . '][VALUE]\', form: \'\', bTime: true, bHideTime: false});"
									  onmouseover="BX.addClass(this, \'calendar-icon-hover\');" onmouseout="BX.removeClass(this, \'calendar-icon-hover\');" border="0"></span>
							</td></tr>';
                        } elseif ($field['TYPE'] == 'S:Date') {
                            $html .= '<tr><td>
								<input class="bx-lists-input-calendar" type="text" name="' . $fieldId . '[' . $key . '][VALUE]" onclick="BX.calendar({node: this.parentNode, field: this, bTime: false, bHideTime: false});" value="' . $value['VALUE'] . '">
								<span class="bx-lists-calendar-icon" onclick="BX.calendar({node:this, field:\'' . $fieldId . '[' . $key . '][VALUE]\', form: \'\', bTime: false, bHideTime: false});"
									  onmouseover="BX.addClass(this, \'calendar-icon-hover\');" onmouseout="BX.removeClass(this, \'calendar-icon-hover\');" border="0"></span>
							</td></tr>';
                        } else {
                            $html .= '<tr><td>' . call_user_func_array($field["PROPERTY_USER_TYPE"]["GetPublicEditHTML"], array($field, $value, array("VALUE" => $fieldId . "[" . $key . "][VALUE]", "DESCRIPTION" => '', "FORM_NAME" => $this->formId, "MODE" => "FORM_FILL", "COPY" => false))) . '</td></tr>';
                        }
                    }
                    $html .= '</table>';
                    if ($checkHtml) {
                        $html .= '<span class="bx-lists-input-add-button"><input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].createAdditionalHtmlEditor(\'tbl' . $fieldId . '\', \'' . $fieldId . '\', \'' . $this->formId . '\');" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '"></span>';
                    } else {
                        $html .= '<span class="bx-lists-input-add-button"><input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2)" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '"></span>';
                    }
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
                } else {
                    $html = '';
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        if ($field["TYPE"] == "S:HTML") {
                            $html = $this->connectionHtmlEditor($fieldId, $fieldId, $params, is_array($value['VALUE']) ? $value['VALUE']['TEXT'] : '');
                        } elseif ($field['TYPE'] == 'S:DateTime') {
                            $html = '
								<input class="bx-lists-input-calendar" type="text" name="' . $fieldId . '[n0][VALUE]" onclick="BX.calendar({node: this.parentNode, field: this, bTime: true, bHideTime: false});" value="' . $value['VALUE'] . '">
								<span class="bx-lists-calendar-icon" onclick="BX.calendar({node:this, field:\'' . $fieldId . '[n0][VALUE]\', form: \'\', bTime: true, bHideTime: false});"
									  onmouseover="BX.addClass(this, \'calendar-icon-hover\');" onmouseout="BX.removeClass(this, \'calendar-icon-hover\');" border="0"></span>
							';
                        } elseif ($field['TYPE'] == 'S:Date') {
                            $html = '
								<input class="bx-lists-input-calendar" type="text" name="' . $fieldId . '[n0][VALUE]" onclick="BX.calendar({node: this.parentNode, field: this, bTime: false, bHideTime: false});" value="' . $value['VALUE'] . '">
								<span class="bx-lists-calendar-icon" onclick="BX.calendar({node:this, field:\'' . $fieldId . '[n0][VALUE]\', form: \'\', bTime: false, bHideTime: false});"
									  onmouseover="BX.addClass(this, \'calendar-icon-hover\');" onmouseout="BX.removeClass(this, \'calendar-icon-hover\');" border="0"></span>
							';
                        } else {
                            $html = call_user_func_array($field['PROPERTY_USER_TYPE']['GetPublicEditHTML'], array($field, $value, array('VALUE' => $fieldId . '[' . $key . '][VALUE]', 'DESCRIPTION' => '', 'FORM_NAME' => $this->formId, 'MODE' => 'FORM_FILL', 'COPY' => false)));
                        }
                        break;
                    }
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array('id' => $fieldId, 'name' => $field['NAME'], 'required' => $field['IS_REQUIRED'] == 'Y' ? true : false, 'type' => 'custom', 'value' => $html);
                }
            } elseif ($field["PROPERTY_TYPE"] == "N") {
                $html = '';
                if ($field["MULTIPLE"] == "Y") {
                    $html = '<table id="tbl' . $fieldId . '">';
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        $html .= '<tr><td><input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '"></td></tr>';
                    }
                    $html .= '</table>';
                    $html .= '<span class="bx-lists-input-add-button"><input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2)" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '"></span>';
                } else {
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        $html = '<input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '">';
                    }
                }
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
            } elseif ($field["PROPERTY_TYPE"] == "S") {
                $html = '';
                if ($field["MULTIPLE"] == "Y") {
                    $html = '<table id="tbl' . $fieldId . '">';
                    if ($field["ROW_COUNT"] > 1) {
                        foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                            $html .= '<tr><td><textarea name="' . $fieldId . '[' . $key . '][VALUE]" rows="' . intval($field["ROW_COUNT"]) . '" cols="' . intval($field["COL_COUNT"]) . '">' . $value["VALUE"] . '</textarea></td></tr>';
                        }
                    } else {
                        foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                            $html .= '<tr><td><input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '"></td></tr>';
                        }
                    }
                    $html .= '</table>';
                    $html .= '<span class="bx-lists-input-add-button"><input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2)" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '"></span>';
                } else {
                    if ($field["ROW_COUNT"] > 1) {
                        foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                            $html = '<textarea name="' . $fieldId . '[' . $key . '][VALUE]" rows="' . intval($field["ROW_COUNT"]) . '" cols="' . intval($field["COL_COUNT"]) . '">' . $value["VALUE"] . '</textarea>';
                        }
                    } else {
                        foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                            $html = '<input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '" size="' . intval($field["COL_COUNT"]) . '">';
                        }
                    }
                }
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
            } elseif ($field["PROPERTY_TYPE"] == "L") {
                $items = array("" => Loc::getMessage("LISTS_SEAC_NO_VALUE"));
                $propEnums = CIBlockProperty::getPropertyEnum($field["ID"]);
                while ($enum = $propEnums->fetch()) {
                    $items[$enum["ID"]] = $enum["VALUE"];
                }
                if ($field["MULTIPLE"] == "Y") {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId], "params" => array("size" => 5, "multiple" => "multiple"));
                } else {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId]);
                }
            } elseif ($field['PROPERTY_TYPE'] == 'F') {
                $html = '
					<script>
						var wrappers = document.getElementsByClassName("bx-lists-input-file");
						for (var i = 0; i < wrappers.length; i++)
						{
							var inputs = wrappers[i].getElementsByTagName("input");
							for (var j = 0; j < inputs.length; j++)
							{
								inputs[j].onchange = getName;
							}
						}
						function getName ()
						{
							var str = this.value, i;
							if (str.lastIndexOf("\\\\"))
							{
								i = str.lastIndexOf("\\\\")+1;
							}
							else
							{
								i = str.lastIndexOf("\\\\")+1;
							}
							str = str.slice(i);
							var uploaded = this.parentNode.parentNode.getElementsByClassName("fileformlabel")[0];
							uploaded.innerHTML = str;
						}
					</script>
				';
                if ($field['MULTIPLE'] == 'Y') {
                    $html .= '<table id="tbl' . $fieldId . '">';
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        $html .= '<tr><td><span class="file-wrapper"><span class="bx-lists-input-file">
								<span class="webform-small-button bx-lists-small-button">' . Loc::getMessage('LISTS_SEAC_FILE_ADD') . '</span>';
                        $html .= $this->connectionFile($fieldId, $key, $value, $field['PROPERTY_TYPE']);
                        $html .= '</span><span class="fileformlabel bx-lists-input-file-name"></span></span></td></tr>';
                    }
                    $html .= '</table>';
                    $html .= '
						<span class="bx-lists-input-add-button">
							<input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2);
							BX[\'LiveFeedClass_' . $this->randomString . '\'].getNameInputFile();" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '">
						</span>';
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
                } else {
                    foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                        $html .= '<span class="file-wrapper"><span class="bx-lists-input-file">
								<span class="webform-small-button bx-lists-small-button">' . Loc::getMessage('LISTS_SEAC_FILE_ADD') . '</span>';
                        $html .= $this->connectionFile($fieldId, $key, $value, $field['PROPERTY_TYPE']);
                        $html .= '</span><span class="fileformlabel bx-lists-input-file-name"></span></span>';
                        $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[' . $key . '][VALUE]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "file", "value" => $html);
                    }
                }
            } elseif ($field["PROPERTY_TYPE"] == "G") {
                if ($field["IS_REQUIRED"] == "Y") {
                    $items = array();
                } else {
                    $items = array("" => Loc::getMessage("LISTS_SEAC_NO_VALUE"));
                }
                $rsSections = CIBlockSection::GetTreeList(array("IBLOCK_ID" => $field["LINK_IBLOCK_ID"]));
                while ($res = $rsSections->GetNext()) {
                    $items[$res["ID"]] = str_repeat(" . ", $res["DEPTH_LEVEL"]) . $res["NAME"];
                }
                if ($field["MULTIPLE"] == "Y") {
                    $params = array("size" => 4, "multiple" => "multiple");
                } else {
                    $params = array();
                }
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId], "params" => $params);
            } elseif ($field["PROPERTY_TYPE"] == "E") {
                if ($field["IS_REQUIRED"] == "Y") {
                    $items = array();
                } else {
                    $items = array("" => Loc::getMessage("LISTS_SEAC_NO_VALUE"));
                }
                $elements = CIBlockElement::getList(array("NAME" => "ASC"), array("IBLOCK_ID" => $field["LINK_IBLOCK_ID"]), false, false, array("ID", "NAME"));
                while ($res = $elements->fetch()) {
                    $items[$res["ID"]] = $res["NAME"];
                }
                if ($field["MULTIPLE"] == "Y") {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId], "params" => array("size" => 5, "multiple" => "multiple"));
                } else {
                    $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => 'list', "items" => $items, "value" => $this->lists['FORM_DATA'][$fieldId]);
                }
            } elseif ($field["MULTIPLE"] == "Y") {
                $html = '<table id="tbl' . $fieldId . '"><tr><td>';
                foreach ($this->lists['FORM_DATA'][$fieldId] as $key => $value) {
                    $html .= '<tr><td><input type="text" name="' . $fieldId . '[' . $key . '][VALUE]" value="' . $value["VALUE"] . '"></td></tr>';
                }
                $html .= '</td></tr></table>';
                $html .= '
				<span class="bx-lists-input-add-button">
					<input type="button" onclick="javascript:BX[\'LiveFeedClass_' . $this->randomString . '\'].addNewTableRow(\'tbl' . $fieldId . '\', 1, /' . $fieldId . '\\[(n)([0-9]*)\\]/g, 2)" value="' . Loc::getMessage("LISTS_SEAC_ADD_BUTTON") . '">
				</span>';
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "custom", "value" => $html);
            } elseif (is_array($this->lists['FORM_DATA'][$fieldId]) && array_key_exists("VALUE", $this->lists['FORM_DATA'][$fieldId])) {
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId . '[VALUE]', "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "text", "value" => $this->lists['FORM_DATA'][$fieldId]["VALUE"]);
            } else {
                $this->lists['PREPARED_FIELDS'][$fieldId] = array("id" => $fieldId, "name" => $field["NAME"], "required" => $field["IS_REQUIRED"] == "Y" ? true : false, "type" => "text");
            }
            if (!($fieldId == 'DATE_CREATE' || $fieldId == 'TIMESTAMP_X' || $fieldId == 'CREATED_BY' || $fieldId == 'MODIFIED_BY')) {
                if (isset($field['SETTINGS']['SHOW_ADD_FORM'])) {
                    $this->lists['PREPARED_FIELDS'][$fieldId]['show'] = $field['SETTINGS']['SHOW_ADD_FORM'] == 'Y' ? 'Y' : 'N';
                } else {
                    $this->lists['PREPARED_FIELDS'][$fieldId]['show'] = 'Y';
                }
            }
        }
    }
예제 #30
0
 public static function getProductIdsByOfferIds($offerIds)
 {
     if (empty($offerIds)) {
         return array();
     }
     $bestList = array();
     $iblockGroup = array();
     $itemIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID', 'IBLOCK_ID'), 'filter' => array('ID' => $offerIds, 'ACTIVE' => 'Y')));
     while ($item = $itemIterator->fetch()) {
         if (!isset($iblockGroup[$item['IBLOCK_ID']])) {
             $iblockGroup[$item['IBLOCK_ID']] = array();
         }
         $iblockGroup[$item['IBLOCK_ID']][] = $item['ID'];
         $bestList[$item['ID']] = array();
     }
     if (empty($iblockGroup)) {
         return array();
     }
     $iblockSku = array();
     $iblockOffers = array();
     if (!empty($iblockGroup)) {
         $iblockIterator = \Bitrix\Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID', 'PRODUCT_IBLOCK_ID', 'SKU_PROPERTY_ID', 'VERSION' => 'IBLOCK.VERSION'), 'filter' => array('=IBLOCK_ID' => array_keys($iblockGroup), '!PRODUCT_IBLOCK_ID' => 0)));
         while ($iblock = $iblockIterator->fetch()) {
             $iblock['IBLOCK_ID'] = (int) $iblock['IBLOCK_ID'];
             $iblock['PRODUCT_IBLOCK_ID'] = (int) $iblock['PRODUCT_IBLOCK_ID'];
             $iblock['SKU_PROPERTY_ID'] = (int) $iblock['SKU_PROPERTY_ID'];
             $iblock['VERSION'] = (int) $iblock['VERSION'];
             $iblockSku[$iblock['IBLOCK_ID']] = $iblock;
             $iblockOffers[$iblock['IBLOCK_ID']] = $iblockGroup[$iblock['IBLOCK_ID']];
         }
         unset($iblock, $iblockIterator);
     }
     if (empty($iblockOffers)) {
         return array();
     }
     $offerLink = array();
     foreach ($iblockOffers as $iblockId => $items) {
         $skuProperty = 'PROPERTY_' . $iblockSku[$iblockId]['SKU_PROPERTY_ID'];
         $iblockFilter = array('IBLOCK_ID' => $iblockId, '=ID' => $items);
         $iblockFields = array('ID', 'IBLOCK_ID', $skuProperty);
         $skuProperty .= '_VALUE';
         $offersIterator = \CIBlockElement::getList(array('ID' => 'ASC'), $iblockFilter, false, false, $iblockFields);
         while ($offer = $offersIterator->Fetch()) {
             $productId = (int) $offer[$skuProperty];
             if ($productId <= 0) {
                 unset($bestList[$offer['ID']]);
             } else {
                 $bestList[$offer['ID']]['PARENT_ID'] = $productId;
                 $bestList[$offer['ID']]['PARENT_IBLOCK'] = $iblockSku[$iblockId]['PRODUCT_IBLOCK_ID'];
                 if (!isset($offerLink[$productId])) {
                     $offerLink[$productId] = array();
                 }
                 $offerLink[$productId][] = $offer['ID'];
             }
         }
     }
     if (!empty($offerLink)) {
         $productIterator = \Bitrix\Iblock\ElementTable::getList(array('select' => array('ID'), 'filter' => array('@ID' => array_keys($offerLink), 'ACTIVE' => 'N')));
         while ($product = $productIterator->fetch()) {
             if (empty($offerLink[$product['ID']])) {
                 continue;
             }
             foreach ($offerLink[$product['ID']] as $value) {
                 unset($bestList[$value]);
             }
         }
     }
     if (empty($bestList)) {
         return array();
     }
     $finalIds = array();
     $dublicate = array();
     foreach ($bestList as $id => $info) {
         if (empty($info)) {
             if (!isset($dublicate[$id])) {
                 $finalIds[] = $id;
             }
             $dublicate[$id] = true;
         } else {
             if (!isset($dublicate[$id])) {
                 $finalIds[] = $info['PARENT_ID'];
             }
             $dublicate[$info['PARENT_ID']] = true;
         }
     }
     unset($id, $info, $dublicate);
     return $finalIds;
 }