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


PHP CIBlockSectionRights::DeleteAllRights方法代码示例

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


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

示例1: Delete


//.........这里部分代码省略.........
             if (!CIBlockSection::Delete($iblocksection["ID"], $bCheckPermissions)) {
                 return false;
             }
         }
         CFile::Delete($s["PICTURE"]);
         CFile::Delete($s["DETAIL_PICTURE"]);
         static $arDelCache;
         if (!is_array($arDelCache)) {
             $arDelCache = array();
         }
         if (!is_set($arDelCache, $s["IBLOCK_ID"])) {
             $arDelCache[$s["IBLOCK_ID"]] = false;
             $db_ps = $DB->Query("SELECT ID,IBLOCK_ID,VERSION,MULTIPLE FROM b_iblock_property WHERE PROPERTY_TYPE='G' AND (LINK_IBLOCK_ID=" . $s["IBLOCK_ID"] . " OR LINK_IBLOCK_ID=0 OR LINK_IBLOCK_ID IS NULL)", false, $err_mess . __LINE__);
             while ($ar_ps = $db_ps->Fetch()) {
                 if ($ar_ps["VERSION"] == 2) {
                     if ($ar_ps["MULTIPLE"] == "Y") {
                         $strTable = "b_iblock_element_prop_m" . $ar_ps["IBLOCK_ID"];
                     } else {
                         $strTable = "b_iblock_element_prop_s" . $ar_ps["IBLOCK_ID"];
                     }
                 } else {
                     $strTable = "b_iblock_element_property";
                 }
                 $arDelCache[$s["IBLOCK_ID"]][$strTable][] = $ar_ps["ID"];
             }
         }
         if ($arDelCache[$s["IBLOCK_ID"]]) {
             foreach ($arDelCache[$s["IBLOCK_ID"]] as $strTable => $arProps) {
                 if (strncmp("b_iblock_element_prop_s", $strTable, 23) == 0) {
                     foreach ($arProps as $prop_id) {
                         $strSql = "UPDATE " . $strTable . " SET PROPERTY_" . $prop_id . "=null,DESCRIPTION_" . $prop_id . "=null WHERE PROPERTY_" . $prop_id . "=" . $s["ID"];
                         if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                             return false;
                         }
                     }
                 } elseif (strncmp("b_iblock_element_prop_m", $strTable, 23) == 0) {
                     $strSql = "SELECT IBLOCK_PROPERTY_ID, IBLOCK_ELEMENT_ID FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     $rs = $DB->Query($strSql, false, $err_mess . __LINE__);
                     while ($ar = $rs->Fetch()) {
                         $strSql = "\n\t\t\t\t\t\t\t\tUPDATE " . str_replace("prop_m", "prop_s", $strTable) . "\n\t\t\t\t\t\t\t\tSET\tPROPERTY_" . $ar["IBLOCK_PROPERTY_ID"] . "=null,\n\t\t\t\t\t\t\t\t\tDESCRIPTION_" . $ar["IBLOCK_PROPERTY_ID"] . "=null\n\t\t\t\t\t\t\t\tWHERE IBLOCK_ELEMENT_ID = " . $ar["IBLOCK_ELEMENT_ID"] . "\n\t\t\t\t\t\t\t";
                         if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                             return false;
                         }
                     }
                     $strSql = "DELETE FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                         return false;
                     }
                 } else {
                     $strSql = "DELETE FROM " . $strTable . " WHERE IBLOCK_PROPERTY_ID IN (" . implode(", ", $arProps) . ") AND VALUE_NUM=" . $s["ID"];
                     if (!$DB->Query($strSql, false, $err_mess . __LINE__)) {
                         return false;
                     }
                 }
             }
         }
         CIBlockSectionPropertyLink::DeleteBySection($ID);
         $DB->Query("DELETE FROM b_iblock_section_element WHERE IBLOCK_SECTION_ID=" . IntVal($ID), false, $err_mess . __LINE__);
         if (CModule::IncludeModule("search")) {
             CSearch::DeleteIndex("iblock", "S" . $ID);
         }
         $GLOBALS["USER_FIELD_MANAGER"]->Delete("IBLOCK_" . $s["IBLOCK_ID"] . "_SECTION", $ID);
         //Delete the hole in the tree
         $ss = $DB->Query("\n\t\t\t\tSELECT\n\t\t\t\t\tIBLOCK_ID,\n\t\t\t\t\tLEFT_MARGIN,\n\t\t\t\t\tRIGHT_MARGIN\n\t\t\t\tFROM\n\t\t\t\t\tb_iblock_section\n\t\t\t\tWHERE\n\t\t\t\t\tID = " . $s["ID"] . "\n\t\t\t");
         $ss = $ss->Fetch();
         if ($ss["RIGHT_MARGIN"] > 0 && $ss["LEFT_MARGIN"] > 0) {
             $DB->Query("\n\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN - 2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tIBLOCK_ID = " . $ss["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND RIGHT_MARGIN > " . $ss["RIGHT_MARGIN"] . "\n\t\t\t\t");
             $DB->Query("\n\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t,LEFT_MARGIN = LEFT_MARGIN - 2\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tIBLOCK_ID = " . $ss["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND LEFT_MARGIN > " . $ss["LEFT_MARGIN"] . "\n\t\t\t\t");
         }
         $obSectionRights = new CIBlockSectionRights($s["IBLOCK_ID"], $ID);
         $obSectionRights->DeleteAllRights();
         /************* QUOTA *************/
         $_SESSION["SESS_RECOUNT_DB"] = "Y";
         /************* QUOTA *************/
         $arIBlockFields = CIBlock::GetArrayByID($s["IBLOCK_ID"], "FIELDS");
         if ($arIBlockFields["LOG_SECTION_DELETE"]["IS_REQUIRED"] == "Y") {
             $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0;
             $db_events = GetModuleEvents("main", "OnBeforeEventLog");
             $arEvent = $db_events->Fetch();
             if (!$arEvent || ExecuteModuleEventEx($arEvent, array($USER_ID)) === false) {
                 $rsSection = CIBlockSection::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => $bCheckPermissions ? "Y" : "N"), false, array("LIST_PAGE_URL", "NAME", "CODE"));
                 $arSection = $rsSection->GetNext();
                 $res = array("ID" => $ID, "CODE" => $arSection["CODE"], "NAME" => $arSection["NAME"], "SECTION_NAME" => CIBlock::GetArrayByID($s["IBLOCK_ID"], "SECTION_NAME"), "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arSection["LIST_PAGE_URL"]);
                 CEventLog::Log("IBLOCK", "IBLOCK_SECTION_DELETE", "iblock", $s["IBLOCK_ID"], serialize($res));
             }
         }
         $res = $DB->Query("DELETE FROM b_iblock_section WHERE ID=" . IntVal($ID), false, $err_mess . __LINE__);
         if ($res) {
             $db_events = GetModuleEvents("iblock", "OnAfterIBlockSectionDelete");
             while ($arEvent = $db_events->Fetch()) {
                 ExecuteModuleEventEx($arEvent, array($s));
             }
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $s["IBLOCK_ID"]);
             }
         }
         return $res;
     }
     return true;
 }
开发者ID:,项目名称:,代码行数:101,代码来源:


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