/**
  * Получает результат запроса для поиска списка разделов
  *
  * @param array $filter
  * @param array $orderBy
  * @param bool $calculateCount
  * @param array $selectedFields
  *
  * @return \CIBlockResult
  */
 public function rawFindBy(array $filter = array(), array $orderBy = array('sort' => 'asc'), $calculateCount = false, array $selectedFields = array('*', 'UF_*'))
 {
     if (!isset($filter['IBLOCK_ID']) && $this->iBlockId) {
         $filter['IBLOCK_ID'] = $this->iBlockId;
     }
     return $this->iBSGateway->GetList($orderBy, $filter, $calculateCount, $selectedFields);
 }
Ejemplo n.º 2
0
 public function GetSections($ib, $subsection = false)
 {
     CModule::IncludeModule("iblock");
     if (!is_array($ib) || empty($ib)) {
         return array();
     }
     $arFilter = array("IBLOCK_ID" => $ib);
     if (!$subsection) {
         $arFilter["DEPTH_LEVEL"] = 1;
     }
     $dbSection = CIBlockSection::GetList(array("NAME" => "ASC"), $arFilter);
     $sections = array();
     while ($arSection = $dbSection->Fetch()) {
         $sections[$arSection["DEPTH_LEVEL"]][$arSection["ID"]] = array("ID" => $arSection["ID"], "NAME" => "{$arSection["NAME"]} [{$arSection["ID"]}]", "LEVEL" => $arSection["DEPTH_LEVEL"], "PARENT" => $arSection["IBLOCK_SECTION_ID"], "PARENT_1" => $arSection["ID"]);
     }
     unset($dbSection);
     ksort($sections);
     foreach ($sections as $depth => &$depthSections) {
         if ($depth == 1) {
             continue;
         }
         foreach ($depthSections as $id => &$current) {
             $current["NAME"] = implode(" / ", array($sections[$depth - 1][$current["PARENT"]]["NAME"], $current["NAME"]));
             $current["PARENT_1"] = $sections[$depth - 1][$current["PARENT"]]["PARENT_1"];
         }
     }
     return $sections;
 }
Ejemplo n.º 3
0
 /**
  * Геттер
  * @param $var
  * @return int
  */
 public function __get($var)
 {
     if (strpos($var, 'printable_') === 0) {
         $varName = substr($var, strlen('printable_'));
         $param = $this->getParam($varName);
         if (!is_array($param) || !isset($param['PROPERTY_TYPE'])) {
             return $param;
         }
         switch ($param['PROPERTY_TYPE']) {
             case 'G':
                 $printable = \CIBlockSection::GetList(array(), array('ID' => $param['VALUE']), false, array("NAME"))->GetNext();
                 return $printable['NAME'];
             default:
                 $printable = \CIBlockFormatProperties::GetDisplayValue(array('NAME' => ''), $param, "");
                 return $printable['DISPLAY_VALUE'];
         }
     } else {
         switch ($var) {
             case 'id':
             case 'ID':
                 return $this->id;
             case 'IBLOCK_ID':
             case 'iblockId':
                 return $this->iblockId;
             default:
                 return $this->getParam($var);
         }
     }
 }
Ejemplo n.º 4
0
 static function onBeforeElementAddHandler($arFields)
 {
     $IBLOCK_ID = Config\Option::get("citfact.replaceurl", "IBLOCK_ID", "");
     $SECTION_ID = Config\Option::get("citfact.replaceurl", "SECTION_BREND_ID", "BRENDI");
     $CODE_PROP = Config\Option::get("citfact.replaceurl", "PROPERTY_CODE_BRENDI", "BRENDI");
     if ($IBLOCK_ID == $arFields["IBLOCK_ID"]) {
         $propertyBrand = \CIBlockProperty::GetByID($CODE_PROP, $arFields["IBLOCK_ID"]);
         if ($arResultProperty = $propertyBrand->GetNext()) {
             $propertyBrandValue = \CIBlockPropertyEnum::GetByID($arFields["PROPERTY_VALUES"][$arResultProperty["ID"]][0]["VALUE"]);
         }
         $rqParentSection = \CIBlockSection::GetByID($SECTION_ID);
         if ($arParentSection = $rqParentSection->GetNext()) {
             $arFilter = array('IBLOCK_ID' => $arParentSection['IBLOCK_ID'], '>LEFT_MARGIN' => $arParentSection['LEFT_MARGIN'], '<RIGHT_MARGIN' => $arParentSection['RIGHT_MARGIN'], '>DEPTH_LEVEL' => $arParentSection['DEPTH_LEVEL']);
             // выберет потомков без учета активности
             $rqSectChild = \CIBlockSection::GetList(array('left_margin' => 'asc'), $arFilter);
             while ($arSectChild = $rqSectChild->GetNext()) {
                 $arSections[$arSectChild["NAME"]] = $arSectChild["ID"];
             }
         }
         if (array_key_exists($propertyBrandValue["VALUE"], $arSections)) {
             $arFields["IBLOCK_SECTION"][] = $arSections[$propertyBrandValue["VALUE"]];
         } else {
             $arParams = array("replace_space" => "-", "replace_other" => "-");
             $trans = \Cutil::translit($propertyBrandValue["VALUE"], "ru", $arParams);
             $bs = new \CIBlockSection();
             $arFieldsNewSection = array("ACTIVE" => "Y", "IBLOCK_SECTION_ID" => $SECTION_ID, "IBLOCK_ID" => $IBLOCK_ID, "NAME" => $propertyBrandValue["VALUE"], "CODE" => $trans);
             $resultAdd = $bs->Add($arFieldsNewSection);
             $arFields["IBLOCK_SECTION"][] = $resultAdd;
         }
     }
     return true;
 }
Ejemplo n.º 5
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 "";
         }
     }
 }
Ejemplo n.º 6
0
function _ShowGroupPropertyField($name, $property_fields, $values)
{
    if (!is_array($values)) {
        $values = array();
    }
    foreach ($values as $key => $value) {
        if (is_array($value) && array_key_exists("VALUE", $value)) {
            $values[$key] = $value["VALUE"];
        }
    }
    $res = "";
    $bWas = false;
    $sections = CIBlockSection::GetList(array("left_margin" => "asc"), array("IBLOCK_ID" => $property_fields["LINK_IBLOCK_ID"]), false, array("ID", "DEPTH_LEVEL", "NAME"));
    while ($ar = $sections->GetNext()) {
        $res .= '<option value="' . $ar["ID"] . '"';
        if (in_array($ar["ID"], $values)) {
            $bWas = true;
            $res .= ' selected';
        }
        $res .= '>' . str_repeat(" . ", $ar["DEPTH_LEVEL"] - 1) . $ar["NAME"] . '</option>';
    }
    echo '<select name="' . $name . '[]" size="' . $property_fields["MULTIPLE_CNT"] . '" ' . ($property_fields["MULTIPLE"] == "Y" ? "multiple" : "") . '>';
    echo '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("IBLOCK_AT_NOT_SET") . '</option>';
    echo $res;
    echo '</select>';
}
 public function addVariants(&$field, $params)
 {
     if (!$params["LINK_IBLOCK_ID"]) {
         return;
     }
     $cacheDir = KFilter::$config['CACHE_DIR'] . self::$cacheSubdir;
     $obCache = new CPHPCache();
     if ($obCache->InitCache(KFilter::$config['CACHE_TIME'], md5($params["LINK_IBLOCK_ID"] . __METHOD__), $cacheDir)) {
         $field['VARIANTS'] = $obCache->GetVars();
     } elseif ($obCache->StartDataCache()) {
         CModule::IncludeModule('iblock');
         global $CACHE_MANAGER;
         $CACHE_MANAGER->StartTagCache($cacheDir);
         $CACHE_MANAGER->RegisterTag("iblock_id_" . $params["LINK_IBLOCK_ID"]);
         $CACHE_MANAGER->EndTagCache();
         $rsSect = CIBlockSection::GetList(array('sort' => 'asc', 'name' => 'asc'), array('IBLOCK_ID' => $params["LINK_IBLOCK_ID"], 'ACTIVE' => 'Y'), false, array('ID', 'NAME'));
         while ($arSect = $rsSect->GetNext()) {
             $field['VARIANTS'][] = array('ID' => $arSect['ID'], 'NAME' => $arSect['NAME']);
         }
         $obCache->EndDataCache($field['VARIANTS']);
     }
     foreach ($field['VARIANTS'] as &$section) {
         if ($_REQUEST[$field['NAME']] == $section['ID']) {
             $section['SELECTED'] = 'Y';
             $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $params["LINK_IBLOCK_ID"], "SECTION_ID" => $section['ID']), false, false, array("ID", "IBLOCK_ID"));
             $arr = array();
             while ($el = $res->GetNext()) {
                 $arr[] = $el['ID'];
             }
             $this->filter['PROPERTY_' . $field['PROPERTY']] = $arr;
             break;
         }
     }
 }
Ejemplo n.º 8
0
function getStructure($id, $section=false, $arUf=array()) {
  $id = (int)$id;
  if (!$id) { return false; }
  if ($section) {
    $res = CIBlockSection::GetByID($id);
    if ( $ar = $res->GetNext() ) {
      $res = CIBlockSection::GetList(array(), array('IBLOCK_ID'=>$ar['IBLOCK_ID'], 'ID'=>$ar['ID']), false, $arUf);
    } else { return false; }
  } else {
    $res = CIBlockElement::GetByID($id);
    if ( $ar = $res->GetNext() ) {
      $res = CIBlockSection::GetList(array(), array('IBLOCK_ID'=>$ar['IBLOCK_ID'], 'ID'=>$ar['IBLOCK_SECTION_ID']), false, $arUf);
    } else { return false; }
  }
  // херню подсунули
  if ( !$res->SelectedRowsCount() ) { return false; }
  $arSect = $res->GetNext();
  $arStructure = array();
  $res = CIBlockSection::GetList(array('LEFT_MARGIN'=>'ASC'), array(
    'IBLOCK_ID' => $arSect['IBLOCK_ID'],
    '<=LEFT_BORDER' => $arSect['LEFT_MARGIN'],
    '>=RIGHT_BORDER' => $arSect['RIGHT_MARGIN'],
    '<DEPTH_LEVEL' => $arSect['DEPTH_LEVEL'],
    ), false, $arUf);
  
  while($ar = $res->GetNext()){
    $arStructure[] = $ar;
  }
  $arStructure[] = $arSect;
  return $arStructure;
}
Ejemplo n.º 9
0
 function getSectionId($code)
 {
     $uf_arresult = CIBlockSection::GetList(array(), array('CODE' => $code), false, array('ID'));
     if ($uf_value = $uf_arresult->GetNext()) {
         $id = $uf_value['ID'];
     }
     return $id;
 }
Ejemplo n.º 10
0
 function get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL, $SECTION_ID)
 {
     $arSections = array();
     $rsSections = CIBlockSection::GetList(array("left_margin" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "SECTION_ID" => $SECTION_ID), false, array("ID", "IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"));
     while ($arSection = $rsSections->Fetch()) {
         $arSections[] = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => "cat_section_admin.php?lang=" . LANGUAGE_ID . "&type=" . $IBLOCK_TYPE_ID . "&IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"], "more_url" => array("cat_section_admin.php?IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"], "cat_section_edit.php?IBLOCK_ID=" . $IBLOCK_ID . "&find_section_section=" . $arSection["ID"]), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "items" => $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1 ? CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"]) : array());
     }
     return $arSections;
 }
Ejemplo n.º 11
0
function get_sections_by_iblock_id($id)
{
    $arSections = array();
    $result = CIBlockSection::GetList(array('CREATED' => 'DESC'), array('ACTIVE' => 'Y', 'IBLOCK_ID' => $id));
    while ($section = $result->GetNext()) {
        $arSections[] = $section;
    }
    return $arSections;
}
Ejemplo n.º 12
0
 static function existsSectionByCode($code)
 {
     $result = false;
     $bs = new CIBlockSection();
     $ob_section = $bs->GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => self::$IBLOCK_ID, "CODE" => $code), false, array("ID", "CODE"));
     if ($ar_section = $ob_section->GetNext()) {
         $result = $ar_section["ID"];
     }
     return $result;
 }
Ejemplo n.º 13
0
 static function existsSectionByExternalId($external_id)
 {
     $result = false;
     $bs = new CIBlockSection();
     $ob_section = $bs->GetList(array("SORT" => "ASC"), array("IBLOCK_ID" => self::$IBLOCK_ID, "EXTERNAL_ID" => $external_id), false, array("ID"));
     if ($ar_section = $ob_section->GetNext()) {
         $result = $ar_section["ID"];
     }
     return $result;
 }
Ejemplo n.º 14
0
 /**
  * Verify the existence of duplicate sections.
  * 
  * @param array $fields Section fields.
  * @param array $settings Internationalization settings of info block.
  * @return bool
  */
 protected static function checkDoubleSection(array $fields, $settings)
 {
     global $APPLICATION;
     $sectionModel = new \CIBlockSection();
     $rsSection = $sectionModel->GetList([], ['IBLOCK_ID' => $fields['IBLOCK_ID'], 'UF_' . $settings['PROP_CODE_PUBLIC_ID'] => $fields['UF_' . $settings['PROP_CODE_PUBLIC_ID']], 'UF_' . $settings['PROP_CODE_LANG'] => $fields['UF_' . $settings['PROP_CODE_LANG']], '!ID' => $fields['ID']], false, ['ID']);
     if ($section = $rsSection->Fetch()) {
         $APPLICATION->ThrowException(Loc::getMessage('NOTAMEDIA_I18N_IBLOCK_HANDLER_ELEMENT_ALREADY_EXIST'));
         return true;
     }
     return false;
 }
Ejemplo n.º 15
0
 public static function get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL, $SECTION_ID, $arSectionsChain = false)
 {
     global $adminMenu;
     if (false === $arSectionsChain) {
         $arSectionsChain = array();
         if (isset($_REQUEST['admin_mnu_menu_id'])) {
             $menu_id = "menu_catalog_category_" . $IBLOCK_ID . "/";
             if (0 == strncmp($_REQUEST['admin_mnu_menu_id'], $menu_id, strlen($menu_id))) {
                 $rsSections = CIBlockSection::GetNavChain($IBLOCK_ID, substr($_REQUEST['admin_mnu_menu_id'], strlen($menu_id)), array('ID', 'IBLOCK_ID'));
                 while ($arSection = $rsSections->Fetch()) {
                     $arSectionsChain[$arSection["ID"]] = $arSection["ID"];
                 }
             }
         }
         if (isset($_REQUEST["find_section_section"]) && (int) $_REQUEST["find_section_section"] > 0 && isset($_REQUEST["IBLOCK_ID"]) && $_REQUEST["IBLOCK_ID"] == $IBLOCK_ID) {
             $rsSections = CIBlockSection::GetNavChain($IBLOCK_ID, $_REQUEST["find_section_section"], array('ID', 'IBLOCK_ID'));
             while ($arSection = $rsSections->Fetch()) {
                 $arSectionsChain[$arSection["ID"]] = $arSection["ID"];
             }
         }
     }
     $urlSectionAdminPage = CIBlock::GetAdminSectionListLink($IBLOCK_ID, array('catalog' => null));
     $arSections = array();
     $rsSections = CIBlockSection::GetList(array("left_margin" => "ASC"), array("IBLOCK_ID" => $IBLOCK_ID, "SECTION_ID" => $SECTION_ID), false, array("ID", "IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"));
     $intCount = 0;
     $arOtherSectionTmp = array();
     $limit = (int) COption::GetOptionInt("iblock", "iblock_menu_max_sections");
     while ($arSection = $rsSections->Fetch()) {
         if ($limit > 0 && $intCount >= $limit) {
             if (empty($arOtherSectionTmp)) {
                 $arOtherSectionTmp = array("text" => Loc::getMessage("CAT_MENU_ALL_OTH"), "url" => $urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"], "more_url" => array(CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null))), "title" => Loc::getMessage("CAT_MENU_ALL_OTH_TITLE"), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "items" => array());
                 CCatalogAdmin::get_other_elements_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $arSection, $arOtherSectionTmp["more_url"]);
             } else {
                 $arOtherSectionTmp['more_url'][] = $urlSectionAdminPage . "&find_section_section=" . (int) $arSection["ID"];
                 $arOtherSectionTmp['more_url'][] = CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null));
             }
         } else {
             $arSectionTmp = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => $urlSectionAdminPage . "&find_section_section=" . $arSection["ID"], "more_url" => array(CIBlock::GetAdminSectionEditLink($IBLOCK_ID, $arSection["ID"], array('catalog' => null))), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"], "module_id" => "catalog", "dynamic" => $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1, "items" => array());
             if (isset($arSectionsChain[$arSection["ID"]])) {
                 $arSectionTmp["items"] = CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
             } elseif (method_exists($adminMenu, "IsSectionActive")) {
                 if ($adminMenu->IsSectionActive("menu_catalog_category_" . $IBLOCK_ID . "/" . $arSection["ID"])) {
                     $arSectionTmp["items"] = CCatalogAdmin::get_sections_menu($IBLOCK_TYPE_ID, $IBLOCK_ID, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
                 }
             }
             $arSections[] = $arSectionTmp;
         }
         $intCount++;
     }
     if (!empty($arOtherSectionTmp)) {
         $arSections[] = $arOtherSectionTmp;
     }
     return $arSections;
 }
Ejemplo n.º 16
0
 private static function EnsureProductSection($externalID, $catalogID, $arFields)
 {
     $section = new CIBlockSection();
     $rsSections = $section->GetList(array(), array('XML_ID' => $externalID, 'IBLOCK_ID' => $catalogID), false, array('ID'));
     $arSection = $rsSections->Fetch();
     if (is_array($arSection)) {
         return intval($arSection['ID']);
     }
     $sectionID = $section->Add(array('IBLOCK_ID' => $catalogID, 'ACTIVE' => 'Y', 'NAME' => $arFields['NAME'], 'IBLOCK_SECTION_ID' => 0, 'CHECK_PERMISSIONS' => 'N', 'XML_ID' => $externalID));
     return $sectionID;
 }
Ejemplo n.º 17
0
function getSections($id){
	$arFilter = Array('IBLOCK_ID'=>$IBLOCK_ID, 'GLOBAL_ACTIVE'=>'Y', "SECTION_ID" => $id);
	$db_list = CIBlockSection::GetList(Array("SORT" => "ASC"), $arFilter, true);
	while($ar_result = $db_list->GetNext())
	{
		if (($ar_result["RIGHT_MARGIN"] - $ar_result["LEFT_MARGIN"]) > 1):
			$ar_result["SECTIONS"] = getSections($ar_result["ID"]);
		endif;
		$arSections[] = $ar_result;
	}
	return $arSections;
}
Ejemplo n.º 18
0
	/**
	 * [findSection description]
	 * @param  string $name
	 * @return int
	 */
	protected function findSection($name){
		if (!CModule::IncludeModule("iblock")):
			return array("result" => false);
		endif;
		$translitParams = $this->translitParams();
		$arFilter = Array('IBLOCK_ID'=>$this->getIblockId(), "NAME" => $name, "CODE" => CUtil::translit($name, "ru", $translitParams));
		$db_list = CIBlockSection::GetList(Array(), $arFilter, true);
		while($ar_result = $db_list->GetNext())
		{
			return intval($ar_result["ID"]);
		}
	}
Ejemplo n.º 19
0
function _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL, $SECTION_ID, $arSectionsChain = false)
{
    //Determine opened sections
    if ($arSectionsChain === false) {
        $arSectionsChain = array();
        if (isset($_REQUEST['admin_mnu_menu_id'])) {
            $menu_id = "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/";
            if (strncmp($_REQUEST['admin_mnu_menu_id'], $menu_id, strlen($menu_id)) == 0) {
                $rsSections = CIBlockSection::GetNavChain($arIBlock["ID"], substr($_REQUEST['admin_mnu_menu_id'], strlen($menu_id)), array('ID', 'IBLOCK_ID'));
                while ($arSection = $rsSections->Fetch()) {
                    $arSectionsChain[$arSection["ID"]] = $arSection["ID"];
                }
            }
        }
        if (isset($_REQUEST["find_section_section"]) && (int) $_REQUEST["find_section_section"] > 0 && isset($_REQUEST["IBLOCK_ID"]) && $_REQUEST["IBLOCK_ID"] == $arIBlock["ID"]) {
            $rsSections = CIBlockSection::GetNavChain($arIBlock["ID"], $_REQUEST["find_section_section"], array('ID', 'IBLOCK_ID'));
            while ($arSection = $rsSections->Fetch()) {
                $arSectionsChain[$arSection["ID"]] = $arSection["ID"];
            }
        }
    }
    $urlSectionAdminPage = CIBlock::GetAdminSectionListLink($arIBlock["ID"], array("menu" => null));
    $arSections = array();
    if (CIBlock::GetAdminListMode($arIBlock["ID"]) == 'S') {
        $arSections[] = _get_elements_menu($arType, $arIBlock, $SECTION_ID);
    }
    $rsSections = CIBlockSection::GetList(array("left_margin" => "ASC"), array("IBLOCK_ID" => $arIBlock["ID"], "SECTION_ID" => $SECTION_ID), false, array("ID", "IBLOCK_SECTION_ID", "NAME", "LEFT_MARGIN", "RIGHT_MARGIN"));
    $sectionCount = 0;
    $limit = COption::GetOptionInt("iblock", "iblock_menu_max_sections");
    while ($arSection = $rsSections->Fetch()) {
        if ($limit > 0 && $sectionCount >= $limit) {
            $arSections[] = array("text" => GetMessage("IBLOCK_MENU_ALL_OTH"), "url" => htmlspecialcharsbx($urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"]), "more_url" => array($urlSectionAdminPage . "&find_section_section=" . (int) $arSection["IBLOCK_SECTION_ID"], $urlSectionAdminPage, "iblock_section_edit.php?" . $arIBlock["URL_PART"], "iblock_element_edit.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"], "iblock_history_list.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"]), "title" => GetMessage("IBLOCK_MENU_ALL_OTH_TITLE"), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "items_id" => "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"], "module_id" => "iblock", "items" => array());
            _get_other_elements_menu($arType, $arIBlock, $arSection, $arSections[0]["more_url"]);
            break;
        }
        $arSectionTmp = array("text" => htmlspecialcharsex($arSection["NAME"]), "url" => htmlspecialcharsbx($urlSectionAdminPage . "&find_section_section=" . $arSection["ID"]), "more_url" => array($urlSectionAdminPage . "&find_section_section=" . $arSection["ID"], "iblock_section_edit.php?" . $arIBlock["URL_PART"] . "&ID=" . $arSection["ID"], "iblock_section_edit.php?" . $arIBlock["URL_PART"] . "&ID=0&find_section_section=" . $arSection["ID"], "iblock_element_edit.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"] . "&find_section_section=" . $arSection["ID"], "iblock_history_list.php?IBLOCK_ID=" . $arIBlock["ID"] . "&type=" . $arType["ID"] . "&find_section_section=" . $arSection["ID"]), "title" => htmlspecialcharsex($arSection["NAME"]), "icon" => "iblock_menu_icon_sections", "page_icon" => "iblock_page_icon_sections", "skip_chain" => true, "dynamic" => CIBlock::GetAdminListMode($arIBlock["ID"]) == 'S' || $arSection["RIGHT_MARGIN"] - $arSection["LEFT_MARGIN"] > 1, "items_id" => "menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"], "module_id" => "iblock", "items" => array());
        if (array_key_exists($arSection["ID"], $arSectionsChain)) {
            $arSectionTmp["items"] = _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
        } elseif (method_exists($GLOBALS["adminMenu"], "IsSectionActive")) {
            if ($GLOBALS["adminMenu"]->IsSectionActive("menu_iblock_/" . $arType["ID"] . "/" . $arIBlock["ID"] . "/" . $arSection["ID"])) {
                $arSectionTmp["items"] = _get_sections_menu($arType, $arIBlock, $DEPTH_LEVEL + 1, $arSection["ID"], $arSectionsChain);
            }
        }
        $arSections[] = $arSectionTmp;
        $sectionCount++;
    }
    while ($arSection = $rsSections->Fetch()) {
        $urlElementAdminPage = CIBlock::GetAdminElementListLink($arIBlock["ID"], array("menu" => null));
        $arSections[0]["more_url"][] = $urlElementAdminPage . "&find_section_section=" . (int) $arSection["ID"];
    }
    return $arSections;
}
Ejemplo n.º 20
0
 public function GetEditFormHTML($userField, $htmlControl)
 {
     $request = Application::getInstance()->getContext()->getRequest();
     $iblockId = intval(str_replace(['IBLOCK_', '_SECTION'], '', $userField['ENTITY_ID']));
     if (empty($userField['VALUE']) && $request->get('I18N_RELATED_ID')) {
         $sectionModel = new \CIBlockSection();
         $rsRelatedSection = $sectionModel->GetList([], ['IBLOCK_ID' => $iblockId, 'ID' => $request->get('I18N_RELATED_ID')], false, ['ID', $userField['FIELD_NAME']]);
         if ($relatedSection = $rsRelatedSection->Fetch()) {
             $userField['VALUE'] = $relatedSection[$userField['FIELD_NAME']];
         }
     }
     return $userField['VALUE'] . '<input type="hidden" name="' . $htmlControl['NAME'] . '" value="' . $userField['VALUE'] . '">';
 }
Ejemplo n.º 21
0
	/**
	 * [findSection description]
	 * @param  string $id1c product->Группы->Ид
	 * @return int id catalog section
	 */
	protected function getSectionIblock($id1c){
		if (!CModule::IncludeModule("iblock")):
			return false;
		endif;
		$arSelect = array("ID");
		$arFilter = Array('IBLOCK_ID'=>$this->getIblockId(), "UF_1C_ID" => $id1c);
		$db_list = CIBlockSection::GetList(Array(), $arFilter, true, $arSelect);
		if($ar_result = $db_list->GetNext())
		{
			return intval($ar_result["ID"]);
		}
		return false;
	}
Ejemplo n.º 22
0
function getSectionsFormatted() {
	$out = '<option value="0">.Корневой каталог</option>';
	$rResult = CIBlockSection::GetList(
		array('SORT' => 'ASC'),
		array(
			'ACTIVE' => 'Y',
			'IBLOCK_ID' => filter_input(INPUT_POST, 'iblock', FILTER_SANITIZE_STRING),
		)
	);
	while (false !== ($section = $rResult->GetNext())) {
		$out .= sprintf('<option value="%s">%s</option>', $section['ID'], $section['NAME']);
	}
	return $out;
}
Ejemplo n.º 23
0
 public function getSubsections($catalogId, $sectionId)
 {
     $arSubsections = array();
     $resSection = CIBlockSection::GetList(array(), array('ID' => intval($sectionId)), false, array('ID', 'NAME', 'DEPTH_LEVEL', 'LEFT_MARGIN', 'RIGHT_MARGIN'));
     if ($resSection) {
         if ($arSection = $resSection->Fetch()) {
             $resElement = CIBlockSection::GetTreeList(array('=IBLOCK_ID' => $catalogId, '=SECTION_ID' => $arSection['ID'], '=DEPTH_LEVEL' => 1 + $arSection['DEPTH_LEVEL'], 'CHECK_PERMISSIONS' => 'N'), array('ID', 'NAME', 'LEFT_MARGIN', 'RIGHT_MARGIN'));
             while ($arElement = $resElement->Fetch()) {
                 $arSubsections[] = array('ID' => $arElement['ID'], 'NAME' => $arElement['NAME'], 'HAS_CHILDREN' => intval($arElement["RIGHT_MARGIN"]) - intval($arElement["LEFT_MARGIN"]) > 1 ? 'Y' : 'N', 'SELECTED' => 'N', 'CHILDREN' => array());
             }
         }
     }
     return $arSubsections;
 }
Ejemplo n.º 24
0
 /**
  * Получаем родителей раздела
  */
 public function getParents($getRoot = false)
 {
     $section = $this->getSection();
     $arFilter = array('IBLOCK_ID' => $section['IBLOCK_ID'], '<LEFT_BORDER' => $section['LEFT_MARGIN'], '>RIGHT_BORDER' => $section['RIGHT_MARGIN']);
     if ($getRoot !== true) {
         $arFilter['>DEPTH_LEVEL'] = 1;
     }
     $rsSect = \CIBlockSection::GetList(array('left_margin' => 'desc'), $arFilter);
     $sections = array();
     while ($arSect = $rsSect->GetNext()) {
         $sections[] = $arSect;
     }
     return $sections;
 }
Ejemplo n.º 25
0
 public function GetCompanyWorkFromEachSection()
 {
     $sectionArrayIds = \CIBlockSection::GetList(array("SORT" => "­­ASC"), array("IBLOCK_ID" => "2"));
     $companyWorks = array();
     while ($companySection = $sectionArrayIds->GetNext()) {
         $companyWorkRow = current($this->_db->fetch(array('IBLOCK_ID' => 2, 'SECTION_ID' => $companySection["ID"]), array('pageSize' => 1)));
         $companyWork = $this->_map($companyWorkRow);
         $sectionCompanyWork = new \VV\EachSectionCompanyWork\EachSectionCompanyWork();
         $sectionCompanyWork->CompanyWork = $companyWork;
         $sectionCompanyWork->SectionId = $companySection["ID"];
         array_push($companyWorks, $sectionCompanyWork);
     }
     return $companyWorks;
 }
Ejemplo n.º 26
0
 public static function GetSectionID($section_id, $section_code, $arFilter)
 {
     $section_id = intval($section_id);
     if ($section_id > 0) {
         return $section_id;
     } elseif (strlen($section_code) > 0) {
         $arFilter["=CODE"] = $section_code;
         $rsSection = CIBlockSection::GetList(array(), $arFilter, false, array("ID"));
         if ($arSection = $rsSection->Fetch()) {
             return intval($arSection["ID"]);
         }
     }
     return 0;
 }
Ejemplo n.º 27
0
 public function Execute()
 {
     if (!CModule::IncludeModule("intranet")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
     if ($iblockId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $parentSectionId = 0;
     $dbSectionsList = CIBlockSection::GetList(array(), array("GLOBAL_ACTIVE" => "Y", "XML_ID" => $this->TaskType == "group" ? $this->TaskOwnerId : "users_tasks", "IBLOCK_ID" => $iblockId, "SECTION_ID" => 0), false);
     if ($arSection = $dbSectionsList->GetNext()) {
         $parentSectionId = $arSection["ID"];
     }
     if ($parentSectionId <= 0) {
         $dbSectionsList = CIBlockSection::GetList(array(), array("GLOBAL_ACTIVE" => "Y", "XML_ID" => "users_tasks", "IBLOCK_ID" => $iblockId, "SECTION_ID" => 0), false);
         if ($arSection = $dbSectionsList->GetNext()) {
             $parentSectionId = $arSection["ID"];
         }
     }
     if ($parentSectionId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $arTaskCreatedBy = CBPHelper::ExtractUsers($this->TaskCreatedBy, $documentId, true);
     $arTaskAssignedTo = CBPHelper::ExtractUsers($this->TaskAssignedTo, $documentId, true);
     if (!$arTaskCreatedBy || !$arTaskAssignedTo) {
         return CBPActivityExecutionStatus::Closed;
     }
     if ($this->TaskType != "group") {
         $this->TaskOwnerId = $arTaskAssignedTo;
     }
     $arTaskTrackers = CBPHelper::ExtractUsers($this->TaskTrackers, $documentId);
     $arFields = array("IBLOCK_SECTION_ID" => $parentSectionId, "MODIFIED_BY" => $arTaskCreatedBy, "CREATED_BY" => $arTaskCreatedBy, "DATE_CREATE" => date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME)), "ACTIVE_FROM" => $this->TaskActiveFrom, "ACTIVE_TO" => $this->TaskActiveTo, "NAME" => $this->TaskName, "DETAIL_TEXT" => $this->TaskDetailText, "PROPERTY_TaskPriority" => $this->TaskPriority, "PROPERTY_TaskAssignedTo" => $arTaskAssignedTo, "PROPERTY_TaskTrackers" => $arTaskTrackers);
     $taskId = CIntranetTasksDocument::CreateDocument($arFields);
     if ($this->TaskType == "group") {
         $pathTemplate = str_replace(array("#GROUP_ID#", "#TASK_ID#"), array($this->TaskOwnerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_group_entry", "/workgroups/group/#GROUP_ID#/tasks/task/view/#TASK_ID#/"));
     } else {
         $pathTemplate = str_replace(array("#USER_ID#", "#TASK_ID#"), array($this->TaskOwnerId, "{=Document:ID}"), COption::GetOptionString("intranet", "path_task_user_entry", "/company/personal/user/#USER_ID#/tasks/task/view/#TASK_ID#/"));
     }
     $pathTemplate = str_replace('#HTTP_HOST#', $_SERVER['HTTP_HOST'], "http://#HTTP_HOST#" . $pathTemplate);
     $arTemplateStates = CBPWorkflowTemplateLoader::GetDocumentTypeStates(array("intranet", "CIntranetTasksDocument", "x" . $iblockId), CBPDocumentEventType::Create);
     foreach ($arTemplateStates as $arState) {
         CBPDocument::StartWorkflow($arState["TEMPLATE_ID"], array("intranet", "CIntranetTasksDocument", $taskId), array("OwnerId" => $this->TaskOwnerId, "TaskType" => $this->TaskType, "PathTemplate" => $pathTemplate, "ForumId" => intval($this->TaskForumId), "IBlockId" => $iblockId), $arErrorsTmp);
     }
     return CBPActivityExecutionStatus::Closed;
 }
Ejemplo n.º 28
0
 function getList()
 {
     $ob = CIBlockElement::GetList(array(), array("IBLOCK_ID" => IB_ARTICLE), FALSE, FALSE, array());
     $result = array();
     $section = array();
     $db_list = CIBlockSection::GetList(array(), array('IBLOCK_ID' => IB_ARTICLE));
     //        printAr($db_list);
     while ($row = $db_list->Fetch()) {
         $section[$row["ID"]] = $row;
     }
     while ($row = $ob->Fetch()) {
         $row['SECTION'] = $section[$row['IBLOCK_SECTION_ID']];
         $result[$row["ID"]] = $row;
     }
     return $result;
 }
Ejemplo n.º 29
0
function getSections()
{
    CModule::IncludeModule("iblock");
    $obCache = new CPHPCache();
    $lifeTime = 60 * 60 * 2;
    $cacheId = 'u_creative_sections';
    $data = array();
    $arFilter = array('IBLOCK_ID' => IBLOCK_ID);
    $raw = CIBlockSection::GetList(array('ID' => 'ASC'), $arFilter);
    while ($item = $raw->Fetch()) {
        $data[$item['CODE']] = $item['ID'];
    }
    $obCache->StartDataCache($lifeTime, $cacheId, "/");
    $obCache->EndDataCache(array("SECTIONS" => $data));
    return $data;
}
 function GetCategory()
 {
     $iblock_permission = CIBlock::GetPermission(IBLOCK_ID);
     if ($iblock_permission < "W") {
         $GLOBALS["USER"]->RequiredHTTPAuthBasic();
         return new CSOAPFault('Server Error', 'Unable to authorize user.');
     }
     $res = CIBlockSection::GetList(array('LEFT_MARGIN' => 'ASC'), array("IBLOCK_ID" => IBLOCK_ID), false, array("ID", "NAME", "DEPTH_LEVEL"));
     $result = array();
     while ($arres = $res->GetNext()) {
         $result[] = array("ID" => $arres['ID'], "NAME" => $arres['NAME'], "DEPTH_LEVEL" => $arres['DEPTH_LEVEL']);
     }
     if (count($result) > 0) {
         return $result;
     }
     return new CSOAPFault('Server Error', 'Error: Нет ни одной категории');
 }