Esempio n. 1
0
 /**
  * Генерация создания
  *
  * generateAddCode
  * @param array $hlBlockId
  * @return string
  * @throws \Exception
  */
 public function generateAddCode($hlBlockId)
 {
     $return = array();
     $hlBlock = HL\HighloadBlockTable::getById($hlBlockId)->fetch();
     if (!$hlBlock) {
         throw new BimException('Not found highload block with id = ' . $hlBlockId);
     }
     $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\HighloadblockIntegrate', 'Add', array($hlBlock['NAME'], $hlBlock['TABLE_NAME']));
     $hlQuery = $this->userType->GetList(array(), array("ENTITY_ID" => "HLBLOCK_" . $hlBlockId));
     while ($hlData = $hlQuery->Fetch()) {
         $fullData = $this->userType->GetByID($hlData['ID']);
         unset($fullData['ID']);
         unset($fullData['ENTITY_ID']);
         if (($fullData['USER_TYPE_ID'] == "iblock_element" || $fullData['USER_TYPE_ID'] == "iblock_section") && isset($fullData['SETTINGS']['IBLOCK_ID'])) {
             if (!empty($fullData['SETTINGS']['IBLOCK_ID'])) {
                 $iblockId = $fullData['SETTINGS']['IBLOCK_ID'];
                 unset($fullData['SETTINGS']['IBLOCK_ID']);
                 $blockQuery = $this->iblock->GetList(array(), array('ID' => $iblockId, 'CHECK_PERMISSIONS' => 'N'));
                 if ($iBlockData = $blockQuery->Fetch()) {
                     $fullData['SETTINGS']['IBLOCK_CODE'] = $iBlockData['CODE'];
                 } else {
                     throw new BimException(' Not found iblock with id ' . $iblockId);
                 }
             }
         }
         $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\HighloadblockFieldIntegrate', 'Add', array($hlBlock['NAME'], $fullData));
     }
     return implode(PHP_EOL, $return);
 }
Esempio n. 2
0
 /**
  * Генерация создания
  *
  * generateAddCode
  * @param array $params
  * @return string
  * @throws \Exception
  */
 public function generateAddCode($params)
 {
     $this->checkParams($params);
     $return = "";
     $hlBlockData = $this->ownerItemDbData['hlblockData'];
     if ($hlFieldData = $this->ownerItemDbData['hlFieldData']) {
         unset($hlFieldData['ID']);
         unset($hlFieldData['ENTITY_ID']);
         # add iblock code to
         if (($hlFieldData['USER_TYPE_ID'] == "iblock_element" || $hlFieldData['USER_TYPE_ID'] == "iblock_section") && isset($hlFieldData['SETTINGS']['IBLOCK_ID'])) {
             if (!empty($hlFieldData['SETTINGS']['IBLOCK_ID'])) {
                 $iblockId = $hlFieldData['SETTINGS']['IBLOCK_ID'];
                 unset($hlFieldData['SETTINGS']['IBLOCK_ID']);
                 $rsIBlock = $this->iblock->GetList(array(), array('ID' => $iblockId, 'CHECK_PERMISSIONS' => 'N'));
                 if ($arIBlock = $rsIBlock->Fetch()) {
                     $hlFieldData['SETTINGS']['IBLOCK_CODE'] = $arIBlock['CODE'];
                 } else {
                     throw new BimException(' Not found iblock with id ' . $iblockId);
                 }
             }
         }
         $return = $this->getMethodContent('Bim\\Db\\Iblock\\HighloadblockFieldIntegrate', 'Add', array($hlBlockData['NAME'], $hlFieldData));
     }
     return $return;
 }
Esempio n. 3
0
 /**
  * Генерация создания
  *
  * generateAddCode
  * @param array $IblockTypeId
  * @return bool|string
  */
 public function generateAddCode($IblockTypeId)
 {
     $iBlock = new \CIBlock();
     $CIblockType = new \CIBlockType();
     $lang = new \CLanguage();
     $return = array();
     $dbIblockType = $CIblockType->GetByID($IblockTypeId);
     if ($arIblockType = $dbIblockType->GetNext()) {
         $Iblock = new \CIBlock();
         $dbIblock = $Iblock->GetList(array(), array('TYPE' => $IblockTypeId, 'CHECK_PERMISSIONS' => 'N'));
         while ($arIblock = $dbIblock->GetNext()) {
             $IblockProperty = new \CIBlockProperty();
             $dbIblockProperty = $IblockProperty->GetList(array(), array('IBLOCK_CODE' => $arIblock['CODE'], 'CHECK_PERMISSIONS' => 'N'));
             while ($arIblockProperty = $dbIblockProperty->GetNext()) {
                 $dbPropertyValues = \CIBlockPropertyEnum::GetList(array(), array("IBLOCK_ID" => $arIblockProperty['IBLOCK_ID'], "CODE" => $arIblockProperty['CODE']));
                 while ($arPropertyValues = $dbPropertyValues->Fetch()) {
                     $arIblockProperty['VALUES'][$arPropertyValues['ID']] = $arPropertyValues;
                 }
                 Helper::unsetFields(array('ID', '~ID', 'IBLOCK_ID', '~IBLOCK_ID'), $arIblockProperty);
                 $arIblockProperty['IBLOCK_CODE'] = $arIblock['CODE'];
                 foreach ($arIblockProperty as $k => $v) {
                     if (strstr($k, "~") || is_null($v)) {
                         unset($arIblockProperty[$k]);
                     }
                 }
                 if (isset($arIblockProperty['LINK_IBLOCK_ID'])) {
                     $res = $iBlock->GetList(array(), array("ID" => $arIblockProperty['LINK_IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'));
                     if ($ar_res = $res->GetNext()) {
                         unset($arIblockProperty['LINK_IBLOCK_ID']);
                         $arIblockProperty['LINK_IBLOCK_CODE'] = $ar_res['CODE'];
                     }
                 }
                 $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockPropertyIntegrate', 'Add', array($arIblockProperty));
             }
             foreach ($arIblock as $k => $v) {
                 if (strstr($k, "~") || $k == 'ID') {
                     unset($arIblock[$k]);
                 }
             }
             $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockIntegrate', 'Add', array($arIblock));
         }
         foreach ($arIblockType as $k => $v) {
             if (strstr($k, "~") || is_null($v)) {
                 unset($arIblockType[$k]);
             }
         }
         $rsLang = $lang->GetList($by = "lid", $order = "desc");
         while ($arLang = $rsLang->Fetch()) {
             $arTypeLang = $CIblockType->GetByIDLang($IblockTypeId, $arLang['LID']);
             $arIblockType["LANG"][$arLang['LID']] = array('NAME' => $arTypeLang['NAME'], 'SECTION_NAME' => $arTypeLang['SECTION_NAME'], 'ELEMENT_NAME' => $arTypeLang['ELEMENT_NAME']);
         }
         $return[] = $this->getMethodContent('Bim\\Db\\Iblock\\IblockTypeIntegrate', 'Add', array($arIblockType));
         $return = array_reverse($return);
         return implode(PHP_EOL, $return);
     } else {
         return false;
     }
 }
 /**
  * Add
  * @param $arFields
  * @return bool
  * @throws \Exception
  */
 public static function Add($arFields)
 {
     $iblock = new \CIBlock();
     if (isset($arFields['SORT'])) {
         if (!is_int($arFields['SORT'])) {
             if (intval($arFields['SORT'])) {
                 $arFields['SORT'] = intval($arFields['SORT']);
             } else {
                 $arFields['SORT'] = 500;
             }
         }
     } else {
         $arFields['SORT'] = 500;
     }
     # default
     $arDefaultValues = array('MULTIPLE' => false, 'IS_REQUIRED' => false, 'ACTIVE' => true, 'PROPERTY_TYPE' => 'S', 'USER_TYPE' => false, 'FILE_TYPE' => '', 'LIST_TYPE' => 'L', 'ROW_COUNT' => 1, 'COL_COUNT' => 30, 'LINK_IBLOCK_ID' => null, 'DEFAULT_VALUE' => null, 'WITH_DESCRIPTION' => 'N', 'SEARCHABLE' => 'N', 'FILTRABLE' => 'N', 'MULTIPLE_CNT' => 5, 'HINT' => '', 'SECTION_PROPERTY' => 'Y', 'SMART_FILTER' => 'N', 'USER_TYPE_SETTINGS' => array(), 'VALUES' => array());
     if ($arFields['IBLOCK_CODE']) {
         unset($arFields['IBLOCK_ID']);
         $rsIBlock = $iblock->GetList(array(), array('CODE' => $arFields['IBLOCK_CODE'], 'CHECK_PERMISSIONS' => 'N'));
         if ($arIBlock = $rsIBlock->Fetch()) {
             $arFields['IBLOCK_ID'] = $arIBlock['ID'];
         } else {
             throw new BimException(__METHOD__ . ' Not found iblock with code ' . $arFields['IBLOCK_CODE']);
         }
     }
     if (!strlen($arFields['CODE'])) {
         throw new BimException(__METHOD__ . ' Not found property code');
     }
     $iblockPropDbRes = \CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $arFields['IBLOCK_ID'], 'CODE' => $arFields['CODE']));
     if ($iblockPropDbRes !== false && $iblockPropDbRes->SelectedRowsCount()) {
         throw new BimException(__METHOD__ . 'Property with code = "' . $arFields['CODE'] . '" ');
     }
     if ($arFields['LINK_IBLOCK_CODE']) {
         unset($arFields['LINK_IBLOCK_ID']);
         $rsIBlock = $iblock->GetList(array(), array('CODE' => $arFields['LINK_IBLOCK_CODE'], 'CHECK_PERMISSIONS' => 'N'));
         if ($arIBlock = $rsIBlock->Fetch()) {
             $arFields['LINK_IBLOCK_ID'] = $arIBlock['ID'];
         }
     }
     foreach ($arDefaultValues as $DefaultName => $DefaultValue) {
         if (!isset($arFields[$DefaultName]) || empty($arFields[$DefaultName])) {
             $arFields[$DefaultName] = $DefaultValue;
         }
     }
     $objCIBlockProperty = new \CIBlockProperty();
     unset($arFields['ID']);
     $iId = $objCIBlockProperty->Add($arFields);
     if ($iId) {
         return $iId;
     } else {
         throw new BimException(__METHOD__ . ' ' . $objCIBlockProperty->LAST_ERROR);
     }
 }
Esempio n. 5
0
 function __IRM_InitReservation($iblockId)
 {
     $arResult = array();
     $arResult["ALLOWED_FIELDS"] = array("ID" => array("NAME" => GetMessage("INAF_F_ID"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "int", "IS_FIELD" => true), "NAME" => array("NAME" => GetMessage("INAF_F_NAME"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "string", "IS_FIELD" => true), "DESCRIPTION" => array("NAME" => GetMessage("INAF_F_DESCRIPTION"), "ORDERABLE" => false, "FILTERABLE" => false, "TYPE" => "text", "IS_FIELD" => true), "UF_FLOOR" => array("NAME" => GetMessage("INAF_F_FLOOR"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "integer", "IS_FIELD" => false), "UF_PLACE" => array("NAME" => GetMessage("INAF_F_PLACE"), "ORDERABLE" => true, "FILTERABLE" => true, "TYPE" => "integer", "IS_FIELD" => false), "UF_PHONE" => array("NAME" => GetMessage("INAF_F_PHONE"), "ORDERABLE" => false, "FILTERABLE" => false, "TYPE" => "string", "IS_FIELD" => false));
     $arUserFields = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("IBLOCK_" . $iblockId . "_SECTION", 0, LANGUAGE_ID);
     $arKeys = Array_Keys($arResult["ALLOWED_FIELDS"]);
     foreach ($arKeys as $key) {
         if (!$arResult["ALLOWED_FIELDS"][$key]["IS_FIELD"]) {
             if (!Array_Key_Exists($key, $arUserFields)) {
                 $arFields = array("ENTITY_ID" => "IBLOCK_" . $iblockId . "_SECTION", "FIELD_NAME" => $key, "USER_TYPE_ID" => $arResult["ALLOWED_FIELDS"][$key]["TYPE"]);
                 $obUserField = new CUserTypeEntity();
                 $obUserField->Add($arFields);
             }
         }
     }
     $arResult["ALLOWED_ITEM_PROPERTIES"] = array("UF_PERSONS" => array("NAME" => GetMessage("INTASK_C29_UF_PERSONS"), "ACTIVE" => "Y", "SORT" => 300, "CODE" => "UF_PERSONS", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "ROW_COUNT" => 1, "COL_COUNT" => 5, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "Y", "SEARCHABLE" => "Y", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "UF_RES_TYPE" => array("NAME" => GetMessage("INTASK_C29_UF_RES_TYPE"), "ACTIVE" => "Y", "SORT" => 200, "CODE" => "UF_RES_TYPE", "PROPERTY_TYPE" => "L", "USER_TYPE" => false, "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "Y", "SEARCHABLE" => "Y", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "Y", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId, "VALUES" => array(array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEA"), "DEF" => "Y", "SORT" => 100, "XML_ID" => "A"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEB"), "DEF" => "N", "SORT" => 200, "XML_ID" => "B"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPEC"), "DEF" => "N", "SORT" => 200, "XML_ID" => "C"), array("VALUE" => GetMessage("INTASK_C29_UF_RES_TYPED"), "DEF" => "N", "SORT" => 300, "XML_ID" => "D"))), "UF_PREPARE_ROOM" => array("NAME" => GetMessage("INTASK_C29_UF_PREPARE_ROOM"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "UF_PREPARE_ROOM", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "Y", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_TYPE" => array("NAME" => GetMessage("INTASK_C29_PERIOD_TYPE"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_TYPE", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "NONE", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_COUNT" => array("NAME" => GetMessage("INTASK_C29_PERIOD_COUNT"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_COUNT", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "EVENT_LENGTH" => array("NAME" => GetMessage("INTASK_C29_EVENT_LENGTH"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "EVENT_LENGTH", "PROPERTY_TYPE" => "N", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId), "PERIOD_ADDITIONAL" => array("NAME" => GetMessage("INTASK_C29_PERIOD_ADDITIONAL"), "ACTIVE" => "Y", "SORT" => 500, "CODE" => "PERIOD_ADDITIONAL", "PROPERTY_TYPE" => "S", "USER_TYPE" => false, "DEFAULT_VALUE" => "", "ROW_COUNT" => 1, "COL_COUNT" => 30, "LINK_IBLOCK_ID" => 0, "WITH_DESCRIPTION" => "N", "FILTRABLE" => "N", "SEARCHABLE" => "N", "MULTIPLE" => "N", "MULTIPLE_CNT" => 5, "IS_REQUIRED" => "N", "FILE_TYPE" => "jpg, gif, bmp, png, jpeg", "LIST_TYPE" => "L", "IBLOCK_ID" => $iblockId));
     $dbIBlockProps = CIBlock::GetProperties($iblockId);
     while ($arIBlockProps = $dbIBlockProps->Fetch()) {
         if (Array_Key_Exists($arIBlockProps["CODE"], $arResult["ALLOWED_ITEM_PROPERTIES"])) {
             $arResult["ALLOWED_ITEM_PROPERTIES"][$arIBlockProps["CODE"]]["ID"] = $arIBlockProps["ID"];
         }
     }
     $keys = Array_Keys($arResult["ALLOWED_ITEM_PROPERTIES"]);
     foreach ($keys as $key) {
         if (IntVal($arResult["ALLOWED_ITEM_PROPERTIES"][$key]["ID"]) <= 0) {
             $ibp = new CIBlockProperty();
             $arResult["ALLOWED_ITEM_PROPERTIES"][$key]["ID"] = $ibp->Add($arResult["ALLOWED_ITEM_PROPERTIES"][$key]);
         }
     }
     return $arResult;
 }
Esempio n. 6
0
 public function onPrepareComponentParams($params)
 {
     $this->arIBlock = CIBlock::GetArrayByID($params["IBLOCK_ID"]);
     $this->arResult["IBLOCK"] = htmlspecialcharsex($this->arIBlock);
     $this->arResult["IBLOCK_ID"] = $this->arIBlock["ID"];
     $this->arResult["GRID_ID"] = "lists_list_elements_" . $this->arResult["IBLOCK_ID"];
     $this->arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0;
     $this->arResult["SECTIONS"] = array();
     $this->arResult["SECTION_ID"] = false;
     $this->arResult["LIST_SECTIONS"] = array();
     if (isset($_GET["list_section_id"])) {
         $sectionId = intval($_GET["list_section_id"]);
     } else {
         $sectionId = intval($params["SECTION_ID"]);
     }
     $rsSections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $this->arIBlock["ID"], "GLOBAL_ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"));
     while ($arSection = $rsSections->GetNext()) {
         $this->arResult["SECTIONS"][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => $arSection["NAME"]);
         if ($arSection["ID"] == $sectionId) {
             $this->arResult["SECTION"] = $arSection;
             $this->arResult["SECTION_ID"] = $arSection["ID"];
         }
         $this->arResult["LIST_SECTIONS"][$arSection["ID"]] = str_repeat(" . ", $arSection["DEPTH_LEVEL"]) . $arSection["NAME"];
     }
     return $params;
 }
function storeResult($arResult, $arParams) {
    $iblock = CIBlock::GetList(
        array(),
        array(
            'TYPE' => $arParams['IBLOCK_TYPE'],
            'CODE' => $arParams['IBLOCK_CODE'],
        )
    );
    $iblock = $iblock->Fetch();
    
    $el = new CIBlockElement;

    $props = array();
    foreach ($arResult['FIELDS_LIST'] as $arField) {
        if ($arField['FIELD_TYPE'] == 'TEXT' || $arField['FIELD_TYPE'] == 'NUMBER') {
            $props[$arField['CODE']] = array(
                'VALUE' => $arResult['POST_DATA']['~'.$arField['CODE']],
            );
        } elseif ($arField['FIELD_TYPE'] == 'TEXTAREA') {
            $props[$arField['CODE']] = array(
                'VALUE' => array(
                    'TYPE' => 'text',
                    'TEXT' => $arResult['POST_DATA']['~'.$arField['CODE']],
                ),
            );
        } elseif ($arField['FIELD_TYPE'] == 'LIST') {
            $propEnum = CIBlockPropertyEnum::GetList(
                array(),
                array(
                    'XML_ID' => $arResult['POST_DATA']['~'.$arField['CODE']],
                    'CODE' => $arField['CODE'],
                    'IBLOCK_ID' => $iblock['ID'],
                )
            );
            $propEnum = $propEnum->Fetch();
            if ( ! $propEnum) return false;

            $props[$arField['CODE']] = array(
                'VALUE' => $propEnum['ID'],
            );
        }
    }

    $res = $el->Add(array(
        'IBLOCK_TYPE' => $arParams['IBLOCK_TYPE'],
        'IBLOCK_ID' => $iblock['ID'],
        'ACTIVE' => 'Y',
        'PROPERTY_VALUES' => $props,
        'ACTIVE_FROM' => ConvertTimeStamp(time()+CTimeZone::GetOffset(), 'FULL'),
        'NAME' => 'Form result', # !!! NEED TO REPLACE TO DEFAULT VALUE
    ));

    if (!$res) {
        return array(
            'MESSAGE' => $el->LAST_ERROR,
        );
    }

    return true;
}
Esempio n. 8
0
 function GetByIDEx($ID, $boolAllValues = false)
 {
     global $DB, $USER;
     $boolAllValues = true == $boolAllValues ? true : false;
     $ID = intval($ID);
     if (0 >= $ID) {
         return false;
     }
     $arFilter = array("ID" => $ID, "ACTIVE_DATE" => "Y", "ACTIVE" => "Y");
     $dbIBlockElement = CIBlockElement::GetList(array(), $arFilter);
     if ($arIBlockElement = $dbIBlockElement->GetNext()) {
         if ($arIBlock = CIBlock::GetArrayByID($arIBlockElement["IBLOCK_ID"])) {
             $arIBlockElement["IBLOCK_ID"] = $arIBlock["ID"];
             $arIBlockElement["IBLOCK_NAME"] = htmlspecialcharsbx($arIBlock["NAME"]);
             $arIBlockElement["~IBLOCK_NAME"] = $arIBlock["NAME"];
             $arIBlockElement["PROPERTIES"] = false;
             $dbProps = CIBlockElement::GetProperty($arIBlock["ID"], $ID, "sort", "asc", array("ACTIVE" => "Y", "NON_EMPTY" => "Y"));
             if ($arProp = $dbProps->Fetch()) {
                 $arAllProps = array();
                 do {
                     $strID = strlen($arProp["CODE"]) > 0 ? $arProp["CODE"] : $arProp["ID"];
                     if (is_array($arProp["VALUE"])) {
                         foreach ($arProp["VALUE"] as &$strOneValue) {
                             $strOneValue = htmlspecialcharsbx($strOneValue);
                         }
                         if (isset($strOneValue)) {
                             unset($strOneValue);
                         }
                     } else {
                         $arProp["VALUE"] = htmlspecialcharsbx($arProp["VALUE"]);
                     }
                     if ($boolAllValues && 'Y' == $arProp['MULTIPLE']) {
                         if (!isset($arAllProps[$strID])) {
                             $arAllProps[$strID] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => array($arProp["VALUE"]), "VALUE_ENUM" => array(htmlspecialcharsbx($arProp["VALUE_ENUM"])), "VALUE_XML_ID" => array(htmlspecialcharsbx($arProp["VALUE_XML_ID"])), "DEFAULT_VALUE" => htmlspecialcharsbx($arProp["DEFAULT_VALUE"]), "SORT" => htmlspecialcharsbx($arProp["SORT"]), "MULTIPLE" => $arProp['MULTIPLE']);
                         } else {
                             $arAllProps[$strID]['VALUE'][] = $arProp["VALUE"];
                             $arAllProps[$strID]['VALUE_ENUM'][] = htmlspecialcharsbx($arProp["VALUE_ENUM"]);
                             $arAllProps[$strID]['VALUE_XML_ID'][] = htmlspecialcharsbx($arProp["VALUE_XML_ID"]);
                         }
                     } else {
                         $arAllProps[$strID] = array("NAME" => htmlspecialcharsbx($arProp["NAME"]), "VALUE" => $arProp["VALUE"], "VALUE_ENUM" => htmlspecialcharsbx($arProp["VALUE_ENUM"]), "VALUE_XML_ID" => htmlspecialcharsbx($arProp["VALUE_XML_ID"]), "DEFAULT_VALUE" => htmlspecialcharsbx($arProp["DEFAULT_VALUE"]), "SORT" => htmlspecialcharsbx($arProp["SORT"]), "MULTIPLE" => $arProp['MULTIPLE']);
                     }
                 } while ($arProp = $dbProps->Fetch());
                 $arIBlockElement["PROPERTIES"] = $arAllProps;
             }
             // bugfix: 2007-07-31 by Sigurd
             $arIBlockElement["PRODUCT"] = CCatalogProduct::GetByID(intval($ID));
             $dbPrices = CPrice::GetList(array("SORT" => "ASC"), array("PRODUCT_ID" => $ID));
             if ($arPrices = $dbPrices->Fetch()) {
                 $arAllPrices = array();
                 do {
                     $arAllPrices[$arPrices["CATALOG_GROUP_ID"]] = array("EXTRA_ID" => intval($arPrices["EXTRA_ID"]), "PRICE" => doubleval($arPrices["PRICE"]), "CURRENCY" => htmlspecialcharsbx($arPrices["CURRENCY"]));
                 } while ($arPrices = $dbPrices->Fetch());
                 $arIBlockElement["PRICES"] = $arAllPrices;
             }
             return $arIBlockElement;
         }
     }
     return false;
 }
Esempio n. 9
0
 /** Returns an array, containing information about the product block on its ID.
  * @param $elementId
  * @return array|string
  */
 public static function getProductInfo($elementId)
 {
     $elementId = intval($elementId);
     $result = "";
     if ($elementId <= 0) {
         return $result;
     }
     $dbProduct = CIBlockElement::GetList(array(), array("ID" => $elementId), false, false, array('ID', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'DETAIL_PICTURE', 'PREVIEW_PICTURE', 'NAME', 'XML_ID'));
     while ($arProduct = $dbProduct->GetNext()) {
         $imgCode = "";
         if ($arProduct["IBLOCK_ID"] > 0) {
             $arProduct["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arProduct["IBLOCK_ID"], $elementId, array("find_section_section" => $arProduct["IBLOCK_SECTION_ID"]));
         }
         if ($arProduct["DETAIL_PICTURE"] > 0) {
             $imgCode = $arProduct["DETAIL_PICTURE"];
         } elseif ($arProduct["PREVIEW_PICTURE"] > 0) {
             $imgCode = $arProduct["PREVIEW_PICTURE"];
         }
         $arProduct["NAME"] = $arProduct["NAME"];
         $arProduct["DETAIL_PAGE_URL"] = htmlspecialcharsex($arProduct["DETAIL_PAGE_URL"]);
         if ($imgCode > 0) {
             $arFile = CFile::GetFileArray($imgCode);
             $arImgProduct = CFile::ResizeImageGet($arFile, array('width' => 80, 'height' => 80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
             $arProduct["IMG_URL"] = $arImgProduct['src'];
         }
         return $arProduct;
     }
     return $result;
 }
Esempio n. 10
0
 function OnSearchGetURL($arFields)
 {
     global $DB, $BX_NEWS_DETAIL_URL, $BX_NEWS_SECTION_URL;
     static $arIBlockCache = array();
     if ($arFields["MODULE_ID"] !== "iblock" || substr($arFields["URL"], 0, 1) !== "=") {
         return $arFields["URL"];
     }
     if (!CModule::IncludeModule('iblock')) {
         return "";
     }
     $IBLOCK_ID = IntVal($arFields["PARAM2"]);
     if (!array_key_exists($IBLOCK_ID, $arIBlockCache)) {
         $res = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tDETAIL_PAGE_URL,\n\t\t\t\t\tSECTION_PAGE_URL,\n\t\t\t\t\tCODE as IBLOCK_CODE,\n\t\t\t\t\tXML_ID as IBLOCK_EXTERNAL_ID,\n\t\t\t\t\tIBLOCK_TYPE_ID\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock\n\t\t\t\tWHERE ID = " . $IBLOCK_ID . "\n\t\t\t");
         $arIBlockCache[$IBLOCK_ID] = $res->Fetch();
     }
     if (!is_array($arIBlockCache[$IBLOCK_ID])) {
         return "";
     }
     $arFields["URL"] = LTrim($arFields["URL"], " =");
     parse_str($arFields["URL"], $arr);
     $arr = $arIBlockCache[$IBLOCK_ID] + $arr;
     $arr["LANG_DIR"] = $arFields["DIR"];
     if (substr($arFields["ITEM_ID"], 0, 1) !== 'S') {
         return CIBlock::ReplaceDetailUrl($BX_NEWS_DETAIL_URL, $arr, true, "E");
     } else {
         return CIBlock::ReplaceDetailUrl($BX_NEWS_SECTION_URL, $arr, true, "S");
     }
 }
 function AddProduct($NAME)
 {
     $iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
     if ($iblock_permission < "W") {
         $GLOBALS["USER"]->RequiredHTTPAuthBasic();
         return new CSOAPFault('Server Error', 'Unable to authorize user.');
     }
     $code = self::translit($NAME);
     $i = 1;
     while (true) {
         $res = CIBlockElement::Getlist(array(), array("CODE" => $code), false, array("CODE"));
         if ($res->Fetch()) {
             $code = self::translit($NAME) . $i;
         } else {
             break;
         }
         $i++;
     }
     $arFields = array("IBLOCK_ID" => IBLOCK_ID, "NAME" => $NAME);
     $ib_element = new CIBlockElement();
     $result = $ib_element->Add($arFields);
     if ($result > 0) {
         return $result;
     }
     return new CSOAPFault('Server Error', 'Error: ' . $ib_element->LAST_ERROR);
 }
Esempio n. 12
0
 /**
  * Delete
  * @param $IblockTypeCode
  * @return bool
  * @throws \Exception
  */
 public static function Delete($IblockTypeCode)
 {
     $Iblock = new \CIBlock();
     $iblockEl = new \CIBlockElement();
     $dbIblock = $Iblock->GetList(array(), array('TYPE' => $IblockTypeCode));
     while ($dbRow = $dbIblock->Fetch()) {
         $iblockElDbRes = $iblockEl->GetList(array(), array('IBLOCK_ID' => $dbRow['ID']));
         if ($iblockElDbRes !== false && $iblockElDbRes->SelectedRowsCount()) {
             throw new BimException('Can not delete iblock type: iblock id =' . $dbRow['ID'] . ' have elements');
         }
     }
     if (!\CIBlockType::Delete($IblockTypeCode)) {
         throw new BimException('Delete iblock type error!');
     }
     return true;
 }
Esempio n. 13
0
 function _getIBlockMode($ib, $object = false, $object_id = false)
 {
     if ($object === false) {
         $arIBlock = CIBlock::GetArrayByID($ib);
         if ($arIBlock["WORKFLOW"] == "Y") {
             return "WF";
         } elseif ($arIBlock["BIZPROC"] == "Y") {
             return "BP";
         } else {
             return "";
         }
     } else {
         $arFilter = array("IBLOCK_ID" => $ib, "SOCNET_GROUP_ID" => false, "CHECK_PERMISSIONS" => "N", "SECTION_ID" => 0);
         if ($object == "user") {
             $arFilter["CREATED_BY"] = $object_id;
         } else {
             $arFilter["SOCNET_GROUP_ID"] = $object_id;
         }
         $arLibrary = array();
         $db_res = CIBlockSection::GetList(array(), $arFilter, false, array("ID", "UF_USE_BP"));
         if ($db_res && ($arLibrary = $db_res->GetNext())) {
             return $arLibrary["UF_USE_BP"] == "N" ? "" : "BP";
         } else {
             return "";
         }
     }
 }
Esempio n. 14
0
 function Init(&$next_step, $files_dir, $arParams = array())
 {
     $this->next_step =& $next_step;
     $this->files_dir = $files_dir;
     $this->arParams = $arParams;
     //if (is_array($this->next_step['_TEMPORARY']['DEPARTMENTS']))
     $this->arSectionCache =& $this->next_step['_TEMPORARY']['DEPARTMENTS'];
     $this->DEPARTMENTS_IBLOCK_ID = $this->arParams['DEPARTMENTS_IBLOCK_ID'];
     $this->ABSENCE_IBLOCK_ID = $this->arParams['ABSENCE_IBLOCK_ID'];
     $this->STATE_HISTORY_IBLOCK_ID = $this->arParams['STATE_HISTORY_IBLOCK_ID'];
     $dbRes = CIBlock::GetList(array(), array('TYPE' => $arParams['IBLOCK_TYPE'] ? $arParams['IBLOCK_TYPE'] : 'STRUCTURE', 'ID' => array($this->DEPARTMENTS_IBLOCK_ID, $this->ABSENCE_IBLOCK_ID, $this->STATE_HISTORY_IBLOCK_ID)));
     $bError = false;
     if (intval($dbRes->SelectedRowsCount()) < 3) {
         if (ToUpper($GLOBALS['DBType']) != 'MYSQL') {
             $i = 0;
             while ($arRes = $dbRes->Fetch()) {
                 $i++;
             }
             $bError = $i < 3;
         } else {
             $bError = true;
         }
     }
     if ($bError) {
         $GLOBALS['APPLICATION']->ThrowException(GetMessage('IBLOCK_XML2_USER_ERROR_IBLOCK_MISSING'));
         return false;
     }
     $def_group = COption::GetOptionString("main", "new_user_registration_def_group", "");
     if ($def_group != "") {
         $this->arUserGroups = explode(",", $def_group);
     }
     return true;
 }
Esempio n. 15
0
 public function onPrepareComponentParams($params)
 {
     $this->arIBlock = CIBlock::GetArrayByID($params["IBLOCK_ID"]);
     $this->arResult["IBLOCK"] = htmlspecialcharsex($this->arIBlock);
     $this->arResult["IBLOCK_ID"] = $this->arIBlock["ID"];
     $this->arResult["GRID_ID"] = "lists_list_elements_" . $this->arResult["IBLOCK_ID"];
     $this->arResult["ANY_SECTION"] = isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0;
     $this->arResult["SECTIONS"] = array();
     $this->arResult["SECTION_ID"] = false;
     $this->arResult["LIST_SECTIONS"] = array();
     if (isset($_GET["list_section_id"])) {
         $sectionId = intval($_GET["list_section_id"]);
     } else {
         $sectionId = intval($params["SECTION_ID"]);
     }
     $rsSections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $this->arIBlock["ID"], "GLOBAL_ACTIVE" => "Y", "CHECK_PERMISSIONS" => "Y"));
     while ($arSection = $rsSections->GetNext()) {
         $this->arResult["SECTIONS"][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => $arSection["NAME"]);
         if ($arSection["ID"] == $sectionId) {
             $this->arResult["SECTION"] = $arSection;
             $this->arResult["SECTION_ID"] = $arSection["ID"];
         }
         $this->arResult["LIST_SECTIONS"][$arSection["ID"]] = str_repeat(" . ", $arSection["DEPTH_LEVEL"]) . $arSection["NAME"];
     }
     $this->arResult["IS_SOCNET_GROUP_CLOSED"] = false;
     if (intval($params["~SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule("socialnetwork")) {
         $arSonetGroup = CSocNetGroup::GetByID(intval($params["~SOCNET_GROUP_ID"]));
         if (is_array($arSonetGroup) && $arSonetGroup["CLOSED"] == "Y" && !CSocNetUser::IsCurrentUserModuleAdmin() && ($arSonetGroup["OWNER_ID"] != $GLOBALS["USER"]->GetID() || COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y")) {
             $this->arResult["IS_SOCNET_GROUP_CLOSED"] = true;
         }
     }
     return $params;
 }
Esempio n. 16
0
 function __wd_get_root_section($IBLOCK_ID, $object, $object_id)
 {
     $result = CIBlockWebdavSocnet::GetSectionID($IBLOCK_ID, $object, $object_id);
     if (intval($result) > 0) {
         return $result;
     } else {
         __wd_check_uf_use_bp_property($arParams["IBLOCK_ID"]);
         $arFields = array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SOCNET_GROUP_ID" => false, "IBLOCK_SECTION_ID" => 0, "UF_USE_BP" => "N");
         if ($object == "user") {
             $dbUser = CUser::GetByID($object_id);
             $arUser = $dbUser->Fetch();
             $arFields["NAME"] = trim($arUser['LAST_NAME'] . " " . $arUser['FIRST_NAME']);
             $arFields["NAME"] = trim(!empty($arFields["NAME"]) ? $arFields["NAME"] : $arUser['LOGIN']);
             $arFields['CREATED_BY'] = $arUser['ID'];
             $arFields['MODIFIED_BY'] = $arUser['ID'];
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $object_id, 'TASK_ID' => $arTasks['X']));
             }
         } else {
             /*		$res = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]);
             				if (!$res)
             				{
             					$arParams["ERROR_MESSAGE"] = GetMessage("SONET_GROUP_NOT_EXISTS");
             					return 0;
             				} */
             $arFields["SOCNET_GROUP_ID"] = $object_id;
             //$arGroup = CSocNetGroup::GetByID($object_id);
             $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $object_id;
             $dbGroup = CSocNetGroup::GetList(array(), array("ID" => (int) $object_id), false, false, array("ID", "SITE_ID", "NAME"));
             if ($arGroup = $dbGroup->Fetch()) {
                 $arFields["NAME"] = GetMessage("SONET_GROUP_PREFIX") . $arGroup["NAME"];
             }
             if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") {
                 $arTasks = CWebDavIblock::GetTasks();
                 $arFields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_A', 'TASK_ID' => $arTasks['X']), 'n1' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_E', 'TASK_ID' => $arTasks['W']), 'n2' => array('GROUP_CODE' => 'SG' . $arFields["SOCNET_GROUP_ID"] . '_K', 'TASK_ID' => $arTasks['W']));
             }
         }
         if (\Bitrix\Main\Config\Option::get('disk', 'successfully_converted', false) && CModule::includeModule('disk')) {
             \Bitrix\Disk\Driver::getInstance()->addGroupStorage($arFields["SOCNET_GROUP_ID"]);
         }
         $GLOBALS["UF_USE_BP"] = $arFields["UF_USE_BP"];
         $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("IBLOCK_" . $IBLOCK_ID . "_SECTION", $arFields);
         $bs = new CIBlockSection();
         $sectionID = $bs->Add($arFields);
         if (!$sectionID) {
             $arParams["ERROR_MESSAGE"] = $bs->LAST_ERROR;
             return 0;
         }
         WDClearComponentCache(array("webdav.element.edit", "webdav.element.hist", "webdav.element.upload", "webdav.element.view", "webdav.menu", "webdav.section.edit", "webdav.section.list"));
         return true;
         /*
         	if ($ob->workflow == 'bizproc')
         	{
         		__wd_create_default_bp_user_and_groups($arBizProcParameters);
         	}
         */
     }
 }
Esempio n. 17
0
	public static function DeleteByIBlock($IBLOCK_ID)
	{
		global $DB;
		$IBLOCK_ID = intval($IBLOCK_ID);
		$DB->Query("DELETE FROM b_iblock_section_property WHERE IBLOCK_ID = ".$IBLOCK_ID);
		$DB->Query("UPDATE b_iblock SET SECTION_PROPERTY = 'N' WHERE ID = ".$IBLOCK_ID);
		CIBlock::CleanCache($IBLOCK_ID);
	}
 static function showIblockListSelect()
 {
     $res = CIBlock::GetList(array("ID" => "ASC"), array(), false);
     echo '<select name="IBLOCK_ID">';
     while ($ar_res = $res->Fetch()) {
         echo "<option value='{$ar_res['ID']}'>[{$ar_res['ID']}] {$ar_res['NAME']}</option>";
     }
     echo '</select>';
 }
Esempio n. 19
0
/**
 * Собирает массив индентификаторов инфоблоков CODE => ID
 * @return array Массив идентификаторов инфоблоков в виде array(CODE => ID)
 */
function _getIblocks()
{
    $resIblocks = \CIBlock::GetList(array('ID' => 'ASC'), array());
    $arIb = array();
    while ($ar = $resIblocks->Fetch()) {
        $arIb[$ar['CODE']] = $ar['ID'];
    }
    return $arIb;
}
 public function getElementLink($aElement)
 {
     static $aIBTypeCache = array();
     if (!isset($aIBTypeCache[$aElement['IBLOCK_ID']])) {
         $aIBTypeCache[$aElement['IBLOCK_ID']] = CIBlock::GetByID($aElement['IBLOCK_ID'])->Fetch();
         $aIBTypeCache[$aElement['IBLOCK_ID']] = $aIBTypeCache[$aElement['IBLOCK_ID']]['IBLOCK_TYPE_ID'];
     }
     return '<a href="/bitrix/admin/iblock_element_edit.php?WF=Y&ID=' . $aElement['ID'] . '&type=' . $aIBTypeCache[$aElement['IBLOCK_ID']] . '&lang=ru&IBLOCK_ID=' . $aElement['IBLOCK_ID'] . '&find_section_section=-1">' . @$aElement['NAME'] . ' </a>';
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $type = $input->getArgument('type');
     \CModule::IncludeModule('iblock');
     $resIBlocks = \CIBlock::GetList(array('NAME' => 'asc'), array('TYPE' => $type));
     while ($arIBlock = $resIBlocks->Fetch()) {
         $output->writeln("<info>" . $arIBlock['NAME'] . " (" . $arIBlock['ID'] . ") </info>");
     }
 }
Esempio n. 22
0
 /**
  * @param string $code код инфблока
  * @return int ID инфоблока
  */
 public static function GetIdByCode($code)
 {
     $res = CIBlock::GetList(array(), array('TYPE' => 'bizproc_iblockx', 'SITE_ID' => SITE_ID, 'ACTIVE' => 'Y', "CODE" => $code), true);
     if (empty($res)) {
         ShowError("Инфоблок с кодом=" . $code . " не найден");
         return 0;
     }
     $data = $res->GetNext();
     return $data["ID"];
 }
Esempio n. 23
0
 function AttachUsersToIBlock($iblockID)
 {
     $iblockID = intval($iblockID);
     if (CModule::IncludeModule("iblock") && $iblockID > 0) {
         $dbIblock = CIBlock::GetByID($iblockID);
         if ($dbIblock->Fetch()) {
             $this->attachIBlockID = $iblockID;
         }
     }
 }
Esempio n. 24
0
 public static function resolveComponentEngine(CComponentEngine $engine, $pageCandidates, &$arVariables)
 {
     /** @global CMain $APPLICATION */
     global $APPLICATION, $CACHE_MANAGER;
     $component = $engine->GetComponent();
     if ($component) {
         $iblock_id = intval($component->arParams["IBLOCK_ID"]);
     } else {
         $iblock_id = 0;
     }
     $requestURL = $APPLICATION->GetCurPage(true);
     $cacheId = $requestURL . implode("|", array_keys($pageCandidates));
     $cache = new CPHPCache();
     if ($cache->startDataCache(3600, $cacheId, "iblock_find")) {
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->StartTagCache("iblock_find");
             CIBlock::registerWithTagCache($iblock_id);
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (isset($arVariablesTmp["ELEMENT_ID"]) || isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkElement($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         foreach ($pageCandidates as $pageID => $arVariablesTmp) {
             if ($arVariablesTmp["SECTION_CODE_PATH"] != "" && (!isset($arVariablesTmp["ELEMENT_ID"]) && !isset($arVariablesTmp["ELEMENT_CODE"]))) {
                 if (CIBlockFindTools::checkSection($iblock_id, $arVariablesTmp)) {
                     $arVariables = $arVariablesTmp;
                     if (defined("BX_COMP_MANAGED_CACHE")) {
                         $CACHE_MANAGER->EndTagCache();
                     }
                     $cache->endDataCache(array($pageID, $arVariablesTmp));
                     return $pageID;
                 }
             }
         }
         if (defined("BX_COMP_MANAGED_CACHE")) {
             $CACHE_MANAGER->AbortTagCache();
         }
         $cache->abortDataCache();
     } else {
         $vars = $cache->getVars();
         $pageID = $vars[0];
         $arVariables = $vars[1];
         return $pageID;
     }
     list($pageID, $arVariables) = each($pageCandidates);
     return $pageID;
 }
Esempio n. 25
0
 /**
  * Функция получения ID инфоблока по его коду
  */
 public static function getIBlockIDbyCode($code)
 {
     $strCode = trim($code);
     if (!empty($strCode)) {
         $res = CIBlock::GetList(array(), array('ACTIVE' => 'Y', "=CODE" => $strCode), true);
         while ($ar_res = $res->Fetch()) {
             $IBLOCK_ID = $ar_res["ID"];
         }
     }
     return $IBLOCK_ID;
 }
Esempio n. 26
0
function get_iblocks_by_type($id)
{
    $arIBlocks = array();
    $result = CIBlock::GetList(array('SORT' => 'ASC'), array('ACTIVE' => 'Y'));
    while ($iblock = $result->GetNext()) {
        if ($iblock['IBLOCK_TYPE_ID'] == $id) {
            $arIBlocks[] = $iblock;
        }
    }
    return $arIBlocks;
}
Esempio n. 27
0
 /**
  * Получить ID инфоблока по коду
  *
  * @param string $code
  * @return int|bool
  */
 public static function getIblockId($code)
 {
     if (!empty(self::$iblockId[$code])) {
         return self::$iblockId[$code];
     }
     if ($iblock = \CIBlock::GetList([], ['CODE' => $code])->fetch()) {
         self::$iblockId[$code] = $iblock['ID'];
         return $iblock['ID'];
     }
     return false;
 }
 function GetIBlockCatalog()
 {
     $iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
     if ($iblock_permission < "W") {
         $GLOBALS["USER"]->RequiredHTTPAuthBasic();
         return new CSOAPFault('Server Error', 'Unable to authorize user.');
     }
     $result = IBLOCK_ID;
     return $result;
     return new CSOAPFault('Server Error', 'Error');
 }
Esempio n. 29
0
 /**
  * Установка групп пользователей
  *
  * @param $id : ID Информационного блока
  * @param $item : Формируемый массив
  */
 private function setUserGroupId($id, &$item)
 {
     $item['GROUP_ID'] = $this->iblock->GetGroupPermissions($id);
     $arGroups = Helper::getUserGroups();
     foreach ($item['GROUP_ID'] as $groupId => $right) {
         $groupCode = Helper::getUserGroupCode($groupId, $arGroups);
         if ($groupCode != null && strlen($groupCode) > 0) {
             $item['GROUP_ID'][$groupCode] = $item['GROUP_ID'][$groupId];
             unset($item['GROUP_ID'][$groupId]);
         }
     }
 }
Esempio n. 30
0
 function getIblockNames($arIblockIDs)
 {
     $str = "";
     if (CModule::IncludeModule("iblock")) {
         $res = CIBlock::GetList(array(), array("ID" => $arIblockIDs, "ACTIVE" => "Y"), true);
         while ($ar_res = $res->Fetch()) {
             $str .= "\"" . $ar_res["NAME"] . "\", ";
         }
         $str .= "#";
     }
     return str_replace(", #", "", $str);
 }