当前位置: 首页>>代码示例>>PHP>>正文


PHP CIBlockElementRights::ChangeParents方法代码示例

本文整理汇总了PHP中CIBlockElementRights::ChangeParents方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElementRights::ChangeParents方法的具体用法?PHP CIBlockElementRights::ChangeParents怎么用?PHP CIBlockElementRights::ChangeParents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CIBlockElementRights的用法示例。


在下文中一共展示了CIBlockElementRights::ChangeParents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SetElementSection

 function SetElementSection($ID, $arSections, $bNew = false, $bRightsIBlock = 0, $sectionId = null)
 {
     global $DB;
     $ID = intval($ID);
     $min_old_id = null;
     $min_new_id = null;
     $arToDelete = array();
     $arToInsert = array();
     if (is_array($arSections)) {
         foreach ($arSections as $section_id) {
             $section_id = intval($section_id);
             if ($section_id > 0) {
                 if (!isset($min_new_id) || $section_id < $min_new_id) {
                     $min_new_id = $section_id;
                 }
                 $arToInsert[$section_id] = $section_id;
             }
         }
     } else {
         $section_id = intval($arSections);
         if ($section_id > 0) {
             $arToInsert[$section_id] = $section_id;
             $min_new_id = $section_id;
         }
     }
     $arOldParents = array();
     $arNewParents = $arToInsert;
     $bParentsChanged = false;
     //Read database
     if (!$bNew) {
         $rs = $DB->Query("\n\t\t\t\tSELECT * FROM b_iblock_section_element\n\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ID . "\n\t\t\t\tAND ADDITIONAL_PROPERTY_ID IS NULL\n\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
         while ($ar = $rs->Fetch()) {
             $section_id = intval($ar["IBLOCK_SECTION_ID"]);
             $arOldParents[] = $section_id;
             if (!isset($min_old_id) || $section_id < $min_old_id) {
                 $min_old_id = $section_id;
             }
             if (isset($arToInsert[$section_id])) {
                 unset($arToInsert[$section_id]);
                 //This already in DB
             } else {
                 $arToDelete[] = $section_id;
             }
         }
         if (!empty($arToDelete)) {
             $bParentsChanged = true;
             $DB->Query($s = "\n\t\t\t\t\tDELETE FROM b_iblock_section_element\n\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ID . "\n\t\t\t\t\tAND ADDITIONAL_PROPERTY_ID IS NULL\n\t\t\t\t\tAND IBLOCK_SECTION_ID in (" . implode(", ", $arToDelete) . ")\n\t\t\t\t", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             //And this should be deleted
         }
     }
     if (!empty($arToInsert)) {
         $bParentsChanged = true;
         $DB->Query("\n\t\t\t\tINSERT INTO b_iblock_section_element(IBLOCK_SECTION_ID, IBLOCK_ELEMENT_ID)\n\t\t\t\tSELECT S.ID, E.ID\n\t\t\t\tFROM b_iblock_section S, b_iblock_element E\n\t\t\t\tWHERE S.IBLOCK_ID = E.IBLOCK_ID\n\t\t\t\tAND S.ID IN (" . implode(", ", $arToInsert) . ")\n\t\t\t\tAND E.ID = " . $ID . "\n\t\t\t");
     }
     if ($bParentsChanged && $bRightsIBlock) {
         $obElementRights = new CIBlockElementRights($bRightsIBlock, $ID);
         if (empty($arOldParents)) {
             $arOldParents[] = 0;
         }
         if (empty($arNewParents)) {
             $arNewParents[] = 0;
         }
         $obElementRights->ChangeParents($arOldParents, $arNewParents);
     }
     if ($sectionId !== null || $min_old_id !== $min_new_id) {
         CIBlockElement::RecalcSections($ID, $sectionId);
     }
     return !empty($arToDelete) || !empty($arToInsert);
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:69,代码来源:iblockelement.php


注:本文中的CIBlockElementRights::ChangeParents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。