/**
  * Save filter, requirement fields: IBLOCK_ID, FILTER
  *
  * @param array $fields
  * @return \Bitrix\Main\Entity\AddResult
  * @throws \InvalidArgumentException
  */
 public function addFilter(array $fields)
 {
     $filter = $fields['FILTER'];
     if (!is_array($filter) || sizeof($filter) <= 0) {
         throw new \InvalidArgumentException('Filter can not be empty');
     }
     $filter = $this->normalizeFilter($filter);
     $iblockId = (int) $fields['IBLOCK_ID'];
     $sectionId = (int) $fields['SECTION_ID'];
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockDataResult = $queryBuilder->setSelect(array('ID'))->setFilter(array('ID' => $iblockId))->exec()->fetch();
     if ($this->isEmptyResult($iblockDataResult)) {
         throw new \InvalidArgumentException('Invalid IBLOCK_ID');
     }
     if ($sectionId > 0) {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionDataResult = $queryBuilder->setSelect(array('ID'))->setFilter(array('IBLOCK_ID' => $iblockDataResult['ID'], 'ID' => $sectionId))->exec()->fetch();
         if ($this->isEmptyResult($sectionDataResult)) {
             throw new \InvalidArgumentException('Invalid SECTION_ID');
         }
     }
     $queryBuilder = new Entity\Query(Model\SubscribeTable::getEntity());
     $subscribe = $queryBuilder->setSelect(array('ID'))->setFilter(array('FILTER' => $filter, 'IBLOCK_ID' => $iblockDataResult['ID'], 'SECTION_ID' => isset($sectionDataResult) ? $sectionDataResult['ID'] : ''))->exec()->fetch();
     if (!empty($subscribe)) {
         $addResult = new \Bitrix\Main\Entity\AddResult();
         $addResult->setId($subscribe['ID']);
         return $addResult;
     }
     $subscribeResult = Model\SubscribeTable::add(array('FILTER' => $filter, 'IBLOCK_ID' => $iblockDataResult['ID'], 'SECTION_ID' => isset($sectionDataResult) ? $sectionDataResult['ID'] : ''));
     return $subscribeResult;
 }
Esempio n. 2
0
 public static function iblock($primary)
 {
     if (!$primary) {
         throw new ArgumentException('Не указан идентификатор инфоблока');
     }
     $cache = new \CPHPCache();
     $path = self::createPath(__METHOD__);
     $cacheId = md5($primary);
     if ($cache->InitCache(86400, $cacheId, $path)) {
         $iblock = $cache->GetVars();
     } else {
         $field = is_numeric($primary) ? 'ID' : 'CODE';
         $db = IblockTable::query()->addFilter($field, $primary)->setSelect(array('*'))->exec();
         if ($db->getSelectedRowsCount() == 0) {
             $cache->AbortDataCache();
             throw new ArgumentException('Указан идентификатор несуществующего инфоблока');
         } elseif ($db->getSelectedRowsCount() > 1) {
             $cache->AbortDataCache();
             throw new ArgumentException("Существует {$db->getSelectedRowsCount()} инфоблока(ов) с {$field} = {$primary}");
         }
         $iblock = $db->fetch();
         if ($cache->StartDataCache()) {
             $cache->EndDataCache($iblock);
         }
     }
     return $iblock;
 }
Esempio n. 3
0
 protected function loadFromDatabase()
 {
     if (!isset($this->fields)) {
         $elementList = \Bitrix\Iblock\IblockTable::getList(array("select" => array_values($this->fieldMap), "filter" => array("=ID" => $this->id)));
         $this->fields = $elementList->fetch();
     }
     return is_array($this->fields);
 }
 public function testExistsReferencesRegister()
 {
     Module::getInstance()->install();
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK)));
     $dbRsIblock = IblockTable::getList();
     $this->assertEquals($dbRsIblock->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to the information block and the information block entries must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_PROPERTY)));
     $dbRsProp = PropertyTable::getList();
     $this->assertEquals($dbRsProp->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links on the properties of information blocks and records must match'));
     $dbRsRef = DbVersionReferencesTable::getList(array('filter' => array('GROUP' => ReferenceController::GROUP_IBLOCK_SECTION)));
     $dbRsSection = SectionTable::getList();
     $this->assertEquals($dbRsSection->getSelectedRowsCount(), $dbRsRef->getSelectedRowsCount(), $this->errorMessage('number of links to information block sections and records must match'));
 }
 public function testReinitIblockReference()
 {
     $beforeApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $collector = Collector::createByFile(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'add_collection.json');
     $this->assertNotEmpty($collector->getFixes());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterApplyFix = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->rollbackLastChanges();
     $afterRollback = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     Module::getInstance()->applyFixesList($collector->getFixes());
     $afterRollbackApply = array('iblocks' => IblockTable::getList()->getSelectedRowsCount(), 'properties' => PropertyTable::getList()->getSelectedRowsCount(), 'sections' => SectionTable::getList()->getSelectedRowsCount());
     $this->assertEquals($beforeApplyFix['iblocks'], $afterApplyFix['iblocks'] - 1, $this->errorMessage('iblock not created after apply fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterApplyFix['properties'] - 2, $this->errorMessage('properties not created after apply fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterApplyFix['sections'] - 1, $this->errorMessage('sections not created after apply fix'));
     $this->assertEquals($beforeApplyFix['iblocks'], $afterRollback['iblocks'], $this->errorMessage('iblock not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['properties'], $afterRollback['properties'], $this->errorMessage('properties not removed after rollback fix'));
     $this->assertEquals($beforeApplyFix['sections'], $afterRollback['sections'], $this->errorMessage('sections not removed after rollback fix'));
     $this->assertEquals($afterRollback['iblocks'] + 1, $afterRollbackApply['iblocks'], $this->errorMessage('iblock not created after apply rollback fix'));
     $this->assertEquals($afterRollback['properties'] + 2, $afterRollbackApply['properties'], $this->errorMessage('properties not created after apply rollback fix'));
     $this->assertEquals($afterRollback['sections'] + 1, $afterRollbackApply['sections'], $this->errorMessage('sections not created after apply rollback fix'));
 }
Esempio n. 6
0
 /**
  * @inheritdoc
  */
 public function create(ParameterDictionary $parameters)
 {
     $iblockId = (int) $parameters->get('ID');
     $queryBuilder = new Entity\Query(Iblock\IblockTable::getEntity());
     $iblockData = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('ID' => $iblockId))->setOrder(array())->exec()->fetch();
     if (empty($iblockData)) {
         throw new BuilderException(sprintf('Not found iblock with id = %d', $iblockId));
     }
     // Get settings iblock
     $iblockDataFields = \CIBlock::GetArrayByID($iblockData['ID']);
     $queryBuilder = new Entity\Query(Iblock\PropertyTable::getEntity());
     $propertyResult = $queryBuilder->setSelect(array('*'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec();
     $propertyList = array();
     while ($property = $propertyResult->fetch()) {
         if (!empty($property['USER_TYPE_SETTINGS'])) {
             $property['USER_TYPE_SETTINGS'] = ($unserialize = @unserialize($property['USER_TYPE_SETTINGS'])) === false ? $property['USER_TYPE_SETTINGS'] : $unserialize;
         }
         $propertyList[$property['CODE']] = $property;
     }
     $this->iblockProperty = $propertyList;
     $this->setElementValue();
     $this->setSectionValue();
     $this->setEnumValue();
     $sectionValueList = array();
     if (in_array($iblockData['ID'], $this->getListByType('G'))) {
         foreach ($this->iblockProperty as $field) {
             if ($field['PROPERTY_TYPE'] == 'G' && $field['LINK_IBLOCK_ID'] == $iblockData['ID']) {
                 $sectionValueList = isset($field['VALUE_LIST']) ? $field['VALUE_LIST'] : array();
                 break;
             }
         }
     } else {
         $queryBuilder = new Entity\Query(Iblock\SectionTable::getEntity());
         $sectionValueList = $queryBuilder->setSelect(array('ID', 'NAME'))->setFilter(array('IBLOCK_ID' => $iblockData['ID']))->setOrder(array())->exec()->fetchAll();
     }
     $upperLevel[] = array('ID' => 0, 'NAME' => GetMessage('IBLOCK_UPPER_LEVEL'));
     $sectionValueList = $upperLevel + $sectionValueList;
     return array('DATA' => $iblockData, 'DEFAULT_FIELDS' => $this->getDefaultFields($iblockDataFields, $sectionValueList), 'FIELDS' => $this->iblockProperty);
 }
Esempio n. 7
0
 /**
  * Validation code of the info block. If code not valid (empty string or code alredy used) will be throw
  * Bitrix exception.
  *
  * @param string $type
  * @param string $code
  * @param null $iblockId
  *
  * @return bool
  */
 protected static function validateCode($type, $code, $iblockId = null)
 {
     global $APPLICATION;
     if (is_null($code)) {
         // if code of info block is not updated
         return true;
     }
     try {
         $type = trim($type);
         $code = trim($code);
         if (strlen($code) <= 0) {
             throw new \Exception('EMPTY_CODE');
         }
         $rsSimilarIblock = IblockTable::query()->setFilter(['IBLOCK_TYPE_ID' => $type, 'CODE' => $code, '!ID' => $iblockId])->setSelect(['ID'])->exec();
         if ($rsSimilarIblock->getSelectedRowsCount() > 0) {
             throw new \Exception('CODE_ALREDY_USED');
         }
         return true;
     } catch (\Exception $e) {
         Loc::loadMessages(__FILE__);
         $APPLICATION->ThrowException(Loc::getMessage('BEX_TOOLS_IBLOCK_' . $e->getMessage()));
         return false;
     }
 }
    unset($countQuery);
    $totalCount = (int) $totalCount['CNT'];
    if ($totalCount > 0) {
        $totalPages = ceil($totalCount / $navyParams['SIZEN']);
        if ($navyParams['PAGEN'] > $totalPages) {
            $navyParams['PAGEN'] = $totalPages;
        }
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
    } else {
        $navyParams['PAGEN'] = 1;
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = 0;
    }
}
$rsIBlocks = new CAdminResult(\Bitrix\Iblock\IblockTable::getList($getListParams), $sTableID);
if ($usePageNavigation) {
    $rsIBlocks->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
    $rsIBlocks->NavRecordCount = $totalCount;
    $rsIBlocks->NavPageCount = $totalPages;
    $rsIBlocks->NavPageNomer = $navyParams['PAGEN'];
} else {
    $rsIBlocks->NavStart();
}
// build list
$lAdmin->NavText($rsIBlocks->GetNavPrint(GetMessage("IBLOCK_RADM_IBLOCKS")));
$invalid = 0;
while ($iblockInfo = $rsIBlocks->Fetch()) {
    $row = $lAdmin->AddRow($iblockInfo["ID"], $iblockInfo);
    $row->AddViewField("ID", $iblockInfo["ID"]);
    $row->AddViewField("NAME", $iblockInfo["NAME"]);
 public function testDelete()
 {
     $this->_applyFixtures(self::FIXTURE_TYPE_SECTION_DELETE);
     $rsSection = SectionTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEmpty($rsSection->getSelectedRowsCount(), $this->errorMessage('section should not be'));
     $this->_applyFixtures(self::FIXTURE_TYPE_PROPERTY_DELETE);
     $rsProps = PropertyTable::getList(array('filter' => array('=IBLOCK_ID' => $this->_processIblockId)));
     $this->assertEquals($rsProps->getSelectedRowsCount(), 1, $this->errorMessage('in the information block is only one property'));
     $dbList = \CIBlock::GetList();
     $ibCountBefore = $dbList->SelectedRowsCount();
     $this->_applyFixtures(self::FIXTURE_TYPE_IBLOCK_DELETE);
     $dbList = \CIBlock::GetList();
     $ibCountAfter = $dbList->SelectedRowsCount();
     $this->assertNotEquals($ibCountBefore, $ibCountAfter, $this->errorMessage('iblock not been deleted'));
     $arIblock = IblockTable::getList(array('filter' => array('=ID' => $this->_processIblockId)))->fetch();
     $this->assertEmpty($arIblock, $this->errorMessage('iblock exists'));
 }
Esempio n. 10
0
 /**
  * Check property description before create.
  *
  * @param array $propertyDescription		Property description.
  * @return bool
  */
 public static function validatePropertyDescription($propertyDescription)
 {
     if (empty($propertyDescription) || !isset($propertyDescription['CODE'])) {
         return false;
     }
     $checkResult = true;
     switch ($propertyDescription['CODE']) {
         case self::CODE_SKU_LINK:
             if (!isset($propertyDescription['LINK_IBLOCK_ID']) || $propertyDescription['LINK_IBLOCK_ID'] <= 0 || $propertyDescription['LINK_IBLOCK_ID'] == $propertyDescription['IBLOCK_ID']) {
                 $checkResult = false;
             }
             if ($checkResult) {
                 $iblockIterator = Iblock\IblockTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $propertyDescription['LINK_IBLOCK_ID'])));
                 if (!($iblock = $iblockIterator->fetch())) {
                     $checkResult = false;
                 }
             }
             break;
         case self::CODE_MORE_PHOTO:
         case self::CODE_BLOG_POST:
         case self::CODE_BLOG_COMMENTS_COUNT:
             $checkResult = true;
             break;
         default:
             $checkResult = false;
             break;
     }
     return $checkResult;
 }
Esempio n. 11
0
 /**
  * Deletes index and mark iblock as having none.
  *
  * @param integer $iblockId Information block identifier.
  *
  * @return void
  */
 public static function deleteIndex($iblockId)
 {
     self::dropIfExists($iblockId);
     \Bitrix\Iblock\IblockTable::update($iblockId, array("PROPERTY_INDEX" => "N"));
 }
Esempio n. 12
0
$res = false;
$iblockDropDown = array();
$iblockFilter = array('=PROPERTY_INDEX' => 'I');
if (Loader::includeModule('catalog')) {
    $OfferIblocks = array();
    $offersIterator = \Bitrix\Catalog\CatalogIblockTable::getList(array('select' => array('IBLOCK_ID'), 'filter' => array('!PRODUCT_IBLOCK_ID' => 0)));
    while ($offer = $offersIterator->fetch()) {
        $OfferIblocks[] = (int) $offer['IBLOCK_ID'];
    }
    if (!empty($OfferIblocks)) {
        unset($offer);
        $iblockFilter['!ID'] = $OfferIblocks;
    }
    unset($offersIterator, $OfferIblocks);
}
$iblockList = \Bitrix\Iblock\IblockTable::getList(array('select' => array('ID', 'NAME', 'ACTIVE'), 'filter' => $iblockFilter, 'order' => array('ID' => 'asc', 'NAME' => 'asc')));
while ($iblockInfo = $iblockList->fetch()) {
    $iblockDropDown[$iblockInfo['ID']] = '[' . $iblockInfo['ID'] . '] ' . $iblockInfo['NAME'] . ($iblockInfo['ACTIVE'] == 'N' ? ' (' . GetMessage('IBLOCK_REINDEX_DEACTIVE') . ')' : '');
}
unset($iblockInfo, $iblockList);
if ($_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["Reindex"] == "Y") {
    CUtil::JSPostUnescape();
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    if (empty($iblockDropDown)) {
        $message = new CAdminMessage(array("MESSAGE" => GetMessage("IBLOCK_REINDEX_COMPLETE"), "DETAILS" => GetMessage("IBLOCK_REINDEX_TOTAL_COMPLETE"), "HTML" => true, "TYPE" => "OK"));
        echo $message->Show();
    } else {
        if (!isset($iblockDropDown[$IBLOCK_ID])) {
            $IBLOCK_ID = key($iblockDropDown);
        }
        $index = \Bitrix\Iblock\PropertyIndex\Manager::createIndexer($IBLOCK_ID);
Esempio n. 13
0
 /**
  * @see IblockFinder::getItems()
  *
  * @return array
  *
  * @throws ValueNotFoundException
  * @throws ArgumentException
  */
 protected function getItemsIblockShard()
 {
     $items = [];
     $rsIblocks = IblockTable::query()->setFilter(['ID' => $this->id])->setSelect(['IBLOCK_TYPE_ID', 'CODE'])->exec();
     if ($iblock = $rsIblocks->fetch()) {
         if ($iblock['CODE']) {
             $items['CODE'] = $iblock['CODE'];
         }
         $items['TYPE'] = $iblock['IBLOCK_TYPE_ID'];
     }
     if (empty($items)) {
         throw new ValueNotFoundException('Iblock', 'ID #' . $this->id);
     }
     $propIds = [];
     $rsProps = PropertyTable::query()->setFilter(['IBLOCK_ID' => $this->id])->setSelect(['ID', 'CODE', 'IBLOCK_ID'])->exec();
     while ($prop = $rsProps->fetch()) {
         $propIds[] = $prop['ID'];
         $items['PROPS_ID'][$prop['CODE']] = $prop['ID'];
     }
     if (!empty($propIds)) {
         $rsPropsEnum = PropertyEnumerationTable::query()->setFilter(['PROPERTY_ID' => $propIds])->setSelect(['ID', 'XML_ID', 'PROPERTY_ID', 'PROPERTY_CODE' => 'PROPERTY.CODE'])->exec();
         while ($propEnum = $rsPropsEnum->fetch()) {
             if ($propEnum['PROPERTY_CODE']) {
                 $items['PROPS_ENUM_ID'][$propEnum['PROPERTY_CODE']][$propEnum['XML_ID']] = $propEnum['ID'];
             }
         }
     }
     $this->registerCacheTag('bex_iblock_' . $this->id);
     return $items;
 }
Esempio n. 14
0
    /**
     * @return string
     * @throws \Bitrix\Main\ArgumentException
     */
    public function getForm()
    {
        /*
         * select iblock list
         */
        $iblockList = array();
        $iblockDb = IblockTable::getList(array('select' => array('ID', 'NAME')));
        while ($iblock = $iblockDb->fetch()) {
            $iblockList[] = $iblock;
        }
        if (!empty($iblockList)) {
            $iblockList = array_merge(array(array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_select'))), $iblockList);
        } else {
            $iblockList = array_merge(array(array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_empty'))), $iblockList);
        }
        /*
         * select properties from all iblocks
         */
        $propertyToIblock = array();
        $propertyList = array();
        $propertyList[''][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_select'));
        $propertyList['EMPTY'][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_prop_empty'));
        $iblockFieldsDb = PropertyTable::getList(array('select' => array('ID', 'NAME', 'IBLOCK_ID'), 'filter' => array('=PROPERTY_TYPE' => PropertyTable::TYPE_STRING)));
        while ($iblockFields = $iblockFieldsDb->fetch()) {
            // add default value
            if (!array_key_exists($iblockFields['IBLOCK_ID'], $propertyList)) {
                $propertyList[$iblockFields['IBLOCK_ID']][] = array('ID' => '', 'NAME' => Loc::getMessage('sender_connector_iblock_field_select'));
            }
            // add property
            $propertyList[$iblockFields['IBLOCK_ID']][] = array('ID' => $iblockFields['ID'], 'NAME' => $iblockFields['NAME']);
            // add property link to iblock
            $propertyToIblock[$iblockFields['ID']] = $iblockFields['IBLOCK_ID'];
        }
        /*
         * create html-control of iblock list
         */
        $iblockInput = '<select name="' . $this->getFieldName('IBLOCK') . '" id="' . $this->getFieldId('IBLOCK') . '" onChange="IblockSelect' . $this->getFieldId('IBLOCK') . '()">';
        foreach ($iblockList as $iblock) {
            $inputSelected = $iblock['ID'] == $this->getFieldValue('IBLOCK') ? 'selected' : '';
            $iblockInput .= '<option value="' . $iblock['ID'] . '" ' . $inputSelected . '>';
            $iblockInput .= htmlspecialcharsbx($iblock['NAME']);
            $iblockInput .= '</option>';
        }
        $iblockInput .= '</select>';
        /*
         * create html-control of properties list for name
         */
        $iblockPropertyNameInput = '<select name="' . $this->getFieldName('PROPERTY_NAME') . '" id="' . $this->getFieldId('PROPERTY_NAME') . '">';
        if (array_key_exists($this->getFieldValue('PROPERTY_NAME', 0), $propertyToIblock)) {
            $propSet = $propertyList[$propertyToIblock[$this->getFieldValue('PROPERTY_NAME', 0)]];
        } else {
            $propSet = $propertyList[''];
        }
        foreach ($propSet as $property) {
            $inputSelected = $property['ID'] == $this->getFieldValue('PROPERTY_NAME') ? 'selected' : '';
            $iblockPropertyNameInput .= '<option value="' . $property['ID'] . '" ' . $inputSelected . '>';
            $iblockPropertyNameInput .= htmlspecialcharsbx($property['NAME']);
            $iblockPropertyNameInput .= '</option>';
        }
        $iblockPropertyNameInput .= '</select>';
        /*
         *  create html-control of properties list for email
         */
        $iblockPropertyEmailInput = '<select name="' . $this->getFieldName('PROPERTY_EMAIL') . '" id="' . $this->getFieldId('PROPERTY_EMAIL') . '">';
        if (array_key_exists($this->getFieldValue('PROPERTY_EMAIL', 0), $propertyToIblock)) {
            $propSet = $propertyList[$propertyToIblock[$this->getFieldValue('PROPERTY_EMAIL', 0)]];
        } else {
            $propSet = $propertyList[''];
        }
        foreach ($propSet as $property) {
            $inputSelected = $property['ID'] == $this->getFieldValue('PROPERTY_EMAIL') ? 'selected' : '';
            $iblockPropertyEmailInput .= '<option value="' . $property['ID'] . '" ' . $inputSelected . '>';
            $iblockPropertyEmailInput .= htmlspecialcharsbx($property['NAME']);
            $iblockPropertyEmailInput .= '</option>';
        }
        $iblockPropertyEmailInput .= '</select>';
        $jsScript = "\n\t\t<script>\n\t\t\tfunction IblockSelect" . $this->getFieldId('IBLOCK') . "()\n\t\t\t{\n\t\t\t\tvar iblock = BX('" . $this->getFieldId('IBLOCK') . "');\n\t\t\t\tIblockPropertyAdd(iblock, BX('" . $this->getFieldId('PROPERTY_NAME') . "'));\n\t\t\t\tIblockPropertyAdd(iblock, BX('" . $this->getFieldId('PROPERTY_EMAIL') . "'));\n\t\t\t}\n\t\t\tfunction IblockPropertyAdd(iblock, iblockProperty)\n\t\t\t{\n\t\t\t\tif(iblockProperty.length>0)\n\t\t\t\t{\n\t\t\t\t\tfor (var j in iblockProperty.options)\n\t\t\t\t\t{\n\t\t\t\t\t\tiblockProperty.options.remove(j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tvar propList = {};\n\t\t\t\tif(iblockProperties[iblock.value] && iblockProperties[iblock.value].length>0)\n\t\t\t\t\tpropList = iblockProperties[iblock.value];\n\t\t\t\telse\n\t\t\t\t\tpropList = iblockProperties['EMPTY'];\n\t\t\t\tfor(var i in propList)\n\t\t\t\t{\n\t\t\t\t\tvar optionName = propList[i]['NAME'];\n\t\t\t\t\tvar optionValue = propList[i]['ID'];\n\t\t\t\t\tiblockProperty.options.add(new Option(optionName, optionValue));\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tvar iblockProperties = " . \CUtil::PhpToJSObject($propertyList) . ";\n\t\t</script>\n\t\t";
        return '
			' . Loc::getMessage('sender_connector_iblock_required_settings') . '
			<br/><br/>
			<table>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_iblock') . '</td>
					<td>' . $iblockInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_name') . '</td>
					<td>' . $iblockPropertyNameInput . '</td>
				</tr>
				<tr>
					<td>' . Loc::getMessage('sender_connector_iblock_field_email') . '</td>
					<td>' . $iblockPropertyEmailInput . '</td>
				</tr>
			</table>
			' . $jsScript . '
		';
    }
    $filterLexer->parse();
    $arResult['FILTER'] = $filterLexer->getFilter();
    $arResult['FILTER_PROPERTY'] = $filterLexer->getProperty();
    $arResult['FILTER_PRICE_TYPE'] = $filterLexer->getPriceType();
    $arResult['FILTER_VALUE'] = $filterLexer->getValue();
}
if (array_key_exists('SECTION_ID', $arResult)) {
    $queryBuilder = new Entity\Query(IBlock\SectionTable::getEntity());
    $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $arResult['SECTION_ID']));
    $sectionResult = $queryBuilder->exec();
    while ($section = $sectionResult->fetch()) {
        $arResult['SECTIONS'][$section['ID']] = $section;
    }
}
if (array_key_exists('IBLOCKS_ID', $arResult)) {
    $queryBuilder = new Entity\Query(IBlock\IblockTable::getEntity());
    $queryBuilder->setSelect(array('*'))->setFilter(array('ID' => $arResult['IBLOCKS_ID']));
    $iblockResult = $queryBuilder->exec();
    while ($iblock = $iblockResult->fetch()) {
        $arResult['IBLOCKS'][$iblock['ID']] = $iblock;
    }
}
if ($request->isPost() && $arResult['COMPONENT_ID'] == $request->getPost('COMPONENT_ID')) {
    $subscribeManager = new \Citfact\FilterSubscribe\SubscribeManager();
    $response = array();
    if ('DELETE' == $request->getPost('ACTION')) {
        $filterUserId = (int) $request->getPost('ID');
        try {
            $removeResult = $subscribeManager->removeFilterUser($filterUserId);
            $response['success'] = $removeResult->isSuccess();
            $response['errors'] = $removeResult->getErrorMessages();
Esempio n. 16
0
 public function getBlockByID($IBlockId)
 {
     $listIBlock = \Bitrix\Iblock\IblockTable::getList(array(), array('ID' => $IBlockId));
     return $IBlock = $listIBlock->Fetch();
 }
Esempio n. 17
0
Loc::loadMessages($context->getServer()->getDocumentRoot() . "/bitrix/modules/main/options.php");
Loc::loadMessages(__FILE__);
\Bitrix\Main\Loader::includeModule('iblock');
function ShowParamsHTMLByArray($arParams)
{
    foreach ($arParams as $Option) {
        __AdmSettingsDrawRow(ADMIN_MODULE_NAME, $Option);
    }
}
/*
 *
 * VALUES
 *
 * */
$debug = ['N', 'Y'];
$obIblocks = \Bitrix\Iblock\IblockTable::getList(['filter' => ['ACTIVE' => 'Y'], 'select' => ['ID', 'NAME']]);
$arIblocks = [];
while ($arIblock = $obIblocks->fetch()) {
    $arIblocks[$arIblock['ID']] = $arIblock['NAME'];
}
/**/
$tabControl = new CAdminTabControl("tabControl", [["DIV" => "edit1", "TAB" => Loc::getMessage("MAIN_TAB_SET"), "TITLE" => Loc::getMessage("MAIN_TAB_TITLE_SET")], ["DIV" => "edit2", "TAB" => Loc::getMessage("TAB_TWO"), "ICON" => "", "TITLE" => Loc::getMessage("TAB_TWO_TITLE")]]);
$arAllOptions = ["settings" => [["DEBUG", Loc::getMessage("DEBUG"), "N", ["selectbox", $debug]], ["TMP_DIR", Loc::getMessage("TMP_DIR"), "/upload/tmp_xml", ["text"]], ["XML_FILE", Loc::getMessage("XML_FILE"), "lot_info_%ID.xml", ["text"]], ["XML_DIR", Loc::getMessage("XML_DIR"), "", ["text"]], ["LOG_FILE", Loc::getMessage("LOG_FILE"), "/local/logs/lot_info", ["text"]], ["API_URL", Loc::getMessage("API_URL"), "", ["text"]], ["API_KEY", Loc::getMessage("API_KEY"), "", ["text"]], ["API_CMD", Loc::getMessage("API_CMD"), "", ["text"]], ["GET_PARAMS", Loc::getMessage("GET_PARAMS"), "", ["text"]], ["IBLOCK_ID", Loc::getMessage("IBLOCK_ID"), "N", ["selectbox", $arIblocks]], ["SITIES_ID", Loc::getMessage("SITIES_ID"), "N", ["selectbox", $arIblocks]]]];
if ($REQUEST_METHOD == "POST" && strlen($Update . $Apply . $RestoreDefaults) > 0 && check_bitrix_sessid()) {
    if (strlen($RestoreDefaults) > 0) {
        COption::RemoveOption("iblock");
    } else {
        foreach ($arAllOptions['settings'] as $arOption) {
            $name = $arOption[0];
            $val = $_REQUEST[$name];
            if ($arOption[2][0] == "checkbox" && $val != "Y") {
Esempio n. 18
0
    $propertyID = intval($_POST['selectProperties']);
    $newTypeIBlock = $_POST['new-type-property-info-block'];
    $conversionResult = $conversionProperty($propertyID, $iblockID, $newTypeIBlock);
    $conversionResult && CAdminNotify::Add(array('MESSAGE' => 'Конвертация прошла успешно', 'TAG' => 'save_property_notify', 'MODULE_ID' => 'ws.tools', 'ENABLE_CLOSE' => 'Y'));
    !$conversionResult && CAdminNotify::Error(array('MESSAGE' => 'Конвертация не прошла успешно', 'TAG' => 'save_property_notify_error', 'MODULE_ID' => 'ws.tools', 'ENABLE_CLOSE' => 'Y'));
}
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php";
$jsParams = array();
$types = array();
$rsTypes = \Bitrix\Iblock\TypeLanguageTable::getList(array('filter' => array('LANGUAGE_ID' => LANG)));
while ($type = $rsTypes->fetch()) {
    $types[$type['IBLOCK_TYPE_ID']] = $type['NAME'];
}
$jsParams['types'] = array('name' => 'selectTypes', 'list' => $types);
$iblocks = array();
$rsIblocks = \Bitrix\Iblock\IblockTable::getList();
while ($iblock = $rsIblocks->fetch()) {
    $iblocks[$iblock['ID']] = array('name' => $iblock['NAME'], 'type' => $iblock['IBLOCK_TYPE_ID']);
}
$jsParams['iblocks'] = array('name' => 'selectIblocks', 'list' => $iblocks);
$properties = array();
$rsProperties = \Bitrix\Iblock\PropertyTable::getList(array('filter' => array('PROPERTY_TYPE' => \Bitrix\Iblock\PropertyTable::TYPE_STRING, 'USER_TYPE' => NULL)));
while ($property = $rsProperties->fetch()) {
    $properties[$property['ID']] = array('name' => $property['NAME'], 'iblockId' => $property['IBLOCK_ID']);
}
$jsParams['properties'] = array('name' => 'selectProperties', 'list' => $properties);
/** @var $localization \WS\Tools\Localization */
$localization;
?>
<form method="POST"
      action="<?php 
 protected function getExistsSubjectIds()
 {
     $rs = IblockTable::getList(array('select' => array('ID')));
     $res = array();
     while ($arIblock = $rs->fetch()) {
         $res[] = $arIblock['ID'];
     }
     return $res;
 }
Esempio n. 20
0
use Bitrix\Main\Localization\Loc;
if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!\Bitrix\Main\Loader::includeModule('bex.bbc')) {
    return false;
}
Loc::loadMessages(__FILE__);
try {
    ComponentParameters::includeModules(['iblock']);
    $iblockTypes = CIBlockParameters::GetIBlockTypes([0 => '']);
    $iblocks = [0 => ''];
    $sections = [0 => ''];
    $elementProperties = [];
    if (isset($arCurrentValues['IBLOCK_TYPE']) && strlen($arCurrentValues['IBLOCK_TYPE'])) {
        $rsIblocks = Iblock\IblockTable::getList(['order' => ['SORT' => 'ASC', 'NAME' => 'ASC'], 'filter' => ['IBLOCK_TYPE_ID' => $arCurrentValues['IBLOCK_TYPE'], 'ACTIVE' => 'Y'], 'select' => ['ID', 'NAME']]);
        while ($iblock = $rsIblocks->fetch()) {
            $iblocks[$iblock['ID']] = $iblock['NAME'];
        }
    }
    if (isset($arCurrentValues['IBLOCK_ID']) && strlen($arCurrentValues['IBLOCK_ID'])) {
        $rsSections = Iblock\SectionTable::getList(['order' => ['SORT' => 'ASC', 'NAME' => 'ASC'], 'filter' => ['IBLOCK_ID' => $arCurrentValues['IBLOCK_ID'], 'ACTIVE' => 'Y'], 'select' => ['ID', 'NAME']]);
        while ($arSection = $rsSections->fetch()) {
            $sections[$arSection['ID']] = $arSection['NAME'];
        }
        $rsProperties = CIBlockProperty::GetList(['sort' => 'asc', 'name' => 'asc'], ['ACTIVE' => 'Y', 'IBLOCK_ID' => $arCurrentValues['IBLOCK_ID']]);
        while ($property = $rsProperties->Fetch()) {
            $elementProperties[$property['CODE']] = '[' . $property['CODE'] . '] ' . $property['NAME'];
        }
    }
    $paramElementsFields = CIBlockParameters::GetFieldCode(Loc::getMessage('ELEMENTS_LIST_FIELDS'), 'BASE');
Esempio n. 21
0
 /**
  * Deletes information blocks of given type
  * and language messages from TypeLanguageTable
  *
  * @param \Bitrix\Main\Entity\Event $event Contains information about iblock type being deleted.
  *
  * @return \Bitrix\Main\Entity\EventResult
  */
 public static function onDelete(\Bitrix\Main\Entity\Event $event)
 {
     $id = $event->getParameter("id");
     //Delete information blocks
     $iblockList = IblockTable::getList(array("select" => array("ID"), "filter" => array("=IBLOCK_TYPE_ID" => $id["ID"]), "order" => array("ID" => "DESC")));
     while ($iblock = $iblockList->fetch()) {
         $iblockDeleteResult = IblockTable::delete($iblock["ID"]);
         if (!$iblockDeleteResult->isSuccess()) {
             return $iblockDeleteResult;
         }
     }
     //Delete language messages
     $result = TypeLanguageTable::deleteByIblockTypeId($id["ID"]);
     return $result;
 }
Esempio n. 22
0
 /**
  * Fetches iblock metadata for further using. Uses cache.
  * Cache can be disabled with flag self::#cacheMetadata = false.
  * @param int|null $iblockId
  * @return array
  */
 public static function getMetadata($iblockId = null)
 {
     if (empty($iblockId)) {
         $iblockId = static::$IBLOCK_ID;
     }
     \Bitrix\Main\Loader::includeModule('iblock');
     $result = array();
     $obCache = new \CPHPCache();
     $cacheDir = '/' . $iblockId;
     if (static::$cacheMetadata && $obCache->InitCache(3600, 'iblockOrm', $cacheDir)) {
         $result = $obCache->GetVars();
     } else {
         $result['iblock'] = \Bitrix\Iblock\IblockTable::getRowById($iblockId);
         $result['props'] = array();
         $rs = \Bitrix\Iblock\PropertyTable::getList(array('filter' => array('IBLOCK_ID' => $iblockId)));
         while ($arProp = $rs->fetch()) {
             $result['props'][$arProp['CODE']] = $arProp;
         }
         if (static::$cacheMetadata) {
             $obCache->StartDataCache();
             $obCache->EndDataCache($result);
         }
     }
     return $result;
 }
Esempio n. 23
0
 /**
  * End of index creation. Marks iblock as indexed.
  *
  * @return boolean
  */
 public function endIndex()
 {
     \Bitrix\Iblock\IblockTable::update($this->iblockId, array("PROPERTY_INDEX" => "Y"));
     if ($this->skuIblockId) {
         \Bitrix\Iblock\IblockTable::update($this->skuIblockId, array("PROPERTY_INDEX" => "Y"));
     }
     return true;
 }