本文整理汇总了PHP中CIBlockSectionRights::ChangeParents方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSectionRights::ChangeParents方法的具体用法?PHP CIBlockSectionRights::ChangeParents怎么用?PHP CIBlockSectionRights::ChangeParents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSectionRights
的用法示例。
在下文中一共展示了CIBlockSectionRights::ChangeParents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
$arUpdate = array("LEFT_MARGIN" => intval($arParents[$PARENT_ID]["LEFT_MARGIN"]) + 1, "DEPTH_LEVEL" => intval($arParents[$PARENT_ID]["DEPTH_LEVEL"]) + 1);
} else {
//We are only one/leftmost section in the iblock.
$arUpdate = array("LEFT_MARGIN" => 1, "DEPTH_LEVEL" => 1);
}
}
$move_distance = intval($db_record["LEFT_MARGIN"]) - $arUpdate["LEFT_MARGIN"];
$DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = LEFT_MARGIN + " . $distance . "\n\t\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN + " . $distance . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . $arUpdate["LEFT_MARGIN"] . "\n\t\t\t\t\t");
$DB->Query("\n\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t,LEFT_MARGIN = -LEFT_MARGIN - " . $move_distance . "\n\t\t\t\t\t\t\t,RIGHT_MARGIN = -RIGHT_MARGIN - " . $move_distance . "\n\t\t\t\t\t\t\t" . ($arUpdate["DEPTH_LEVEL"] != intval($db_record["DEPTH_LEVEL"]) ? ",DEPTH_LEVEL = DEPTH_LEVEL - " . ($db_record["DEPTH_LEVEL"] - $arUpdate["DEPTH_LEVEL"]) : "") . "\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN <= " . -intval($db_record["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . -intval($db_record["RIGHT_MARGIN"]) . "\n\t\t\t\t\t");
if (isset($arParents[$PARENT_ID])) {
$DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,RIGHT_MARGIN = RIGHT_MARGIN + " . $distance . "\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN <= " . $arParents[$PARENT_ID]["LEFT_MARGIN"] . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN >= " . $arParents[$PARENT_ID]["RIGHT_MARGIN"] . "\n\t\t\t\t\t\t");
}
}
//Check if parent was changed
if (isset($arFields["IBLOCK_SECTION_ID"]) && $arFields["IBLOCK_SECTION_ID"] != $db_record["IBLOCK_SECTION_ID"]) {
$rsSection = CIBlockSection::GetByID($ID);
$arSection = $rsSection->Fetch();
$strSql = "\n\t\t\t\t\t\tSELECT ID, GLOBAL_ACTIVE\n\t\t\t\t\t\tFROM b_iblock_section\n\t\t\t\t\t\tWHERE IBLOCK_ID = " . $arSection["IBLOCK_ID"] . "\n\t\t\t\t\t\tAND ID = " . intval($arFields["IBLOCK_SECTION_ID"]) . "\n\t\t\t\t\t";
$rsParent = $DB->Query($strSql);
$arParent = $rsParent->Fetch();
//If new parent is not globally active
//or we are not active either
//we must be not globally active too
if ($arParent && $arParent["GLOBAL_ACTIVE"] == "N" || $arFields["ACTIVE"] == "N") {
$DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,GLOBAL_ACTIVE = 'N'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $arSection["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . intval($arSection["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN <= " . intval($arSection["RIGHT_MARGIN"]) . "\n\t\t\t\t\t\t");
} elseif ($arSection["ACTIVE"] == "N" && $arFields["ACTIVE"] == "Y") {
$this->RecalcGlobalActiveFlag($arSection);
} elseif ((!$arParent || $arParent["GLOBAL_ACTIVE"] == "Y") && $arSection["GLOBAL_ACTIVE"] == "N" && ($arSection["ACTIVE"] == "Y" || $arFields["ACTIVE"] == "Y")) {
$this->RecalcGlobalActiveFlag($arSection);
}
//Otherwise we may not to change anything
} elseif (isset($arFields["ACTIVE"]) && $arFields["ACTIVE"] != $db_record["ACTIVE"]) {
//Make all children globally inactive
if ($arFields["ACTIVE"] == "N") {
$DB->Query("\n\t\t\t\t\t\t\tUPDATE b_iblock_section SET\n\t\t\t\t\t\t\t\tTIMESTAMP_X=" . ($DB->type == "ORACLE" ? "NULL" : "TIMESTAMP_X") . "\n\t\t\t\t\t\t\t\t,GLOBAL_ACTIVE = 'N'\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tIBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\t\tAND LEFT_MARGIN >= " . intval($db_record["LEFT_MARGIN"]) . "\n\t\t\t\t\t\t\t\tAND RIGHT_MARGIN <= " . intval($db_record["RIGHT_MARGIN"]) . "\n\t\t\t\t\t\t");
} else {
//Check for parent activity
$strSql = "\n\t\t\t\t\t\t\tSELECT ID, GLOBAL_ACTIVE\n\t\t\t\t\t\t\tFROM b_iblock_section\n\t\t\t\t\t\t\tWHERE IBLOCK_ID = " . $db_record["IBLOCK_ID"] . "\n\t\t\t\t\t\t\tAND ID = " . intval($db_record["IBLOCK_SECTION_ID"]) . "\n\t\t\t\t\t\t";
$rsParent = $DB->Query($strSql);
$arParent = $rsParent->Fetch();
//Parent is active
//and we changed
//so need to recalc
if (!$arParent || $arParent["GLOBAL_ACTIVE"] == "Y") {
$this->RecalcGlobalActiveFlag($db_record);
}
}
}
}
if ($arIBlock["RIGHTS_MODE"] === "E") {
$obSectionRights = new CIBlockSectionRights($arIBlock["ID"], $ID);
//Check if parent changed with extended rights mode
if (isset($arFields["IBLOCK_SECTION_ID"]) && $arFields["IBLOCK_SECTION_ID"] != $db_record["IBLOCK_SECTION_ID"]) {
$obSectionRights->ChangeParents(array($db_record["IBLOCK_SECTION_ID"]), array($arFields["IBLOCK_SECTION_ID"]));
}
if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) {
$obSectionRights->SetRights($arFields["RIGHTS"]);
}
}
$uf_updated = $GLOBALS["USER_FIELD_MANAGER"]->Update("IBLOCK_" . $db_record["IBLOCK_ID"] . "_SECTION", $ID, $arFields);
if ($uf_updated) {
$DB->Query("UPDATE b_iblock_section SET TIMESTAMP_X = " . $DB->CurrentTimeFunction() . " WHERE ID = " . $ID);
}
if (CIBlock::GetArrayByID($db_record["IBLOCK_ID"], "SECTION_PROPERTY") === "Y" && array_key_exists("SECTION_PROPERTY", $arFields) && is_array($arFields["SECTION_PROPERTY"])) {
CIBlockSectionPropertyLink::DeleteBySection($ID);
foreach ($arFields["SECTION_PROPERTY"] as $PROPERTY_ID => $arLink) {
CIBlockSectionPropertyLink::Add($ID, $PROPERTY_ID, $arLink);
}
}
if ($bUpdateSearch) {
CIBlockSection::UpdateSearch($ID);
}
if ($arIBlock["FIELDS"]["LOG_SECTION_EDIT"]["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), false, array("LIST_PAGE_URL", "NAME", "CODE"));
$arSection = $rsSection->GetNext();
$res = array("ID" => $ID, "CODE" => $arSection["CODE"], "NAME" => $arSection["NAME"], "SECTION_NAME" => $arIBlock["SECTION_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arSection["LIST_PAGE_URL"]);
CEventLog::Log("IBLOCK", "IBLOCK_SECTION_EDIT", "iblock", $arIBlock["ID"], serialize($res));
}
}
$Result = true;
/*********** QUOTA ***************/
$_SESSION["SESS_RECOUNT_DB"] = "Y";
/*********** QUOTA ***************/
}
$arFields["ID"] = $ID;
$arFields["IBLOCK_ID"] = $db_record["IBLOCK_ID"];
$arFields["RESULT"] =& $Result;
$events = GetModuleEvents("iblock", "OnAfterIBlockSectionUpdate");
while ($arEvent = $events->Fetch()) {
ExecuteModuleEventEx($arEvent, array(&$arFields));
}
if (defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]);
}
return $Result;
}