Your IP : 3.138.33.15
<?
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
if(!CModule::IncludeModule('lists'))
{
ShowError(GetMessage("CC_BLS_MODULE_NOT_INSTALLED"));
return;
}
$lists_perm = CListPermissions::CheckAccess(
$USER,
$arParams["~IBLOCK_TYPE_ID"],
intval($arParams["~IBLOCK_ID"]),
$arParams["~SOCNET_GROUP_ID"]
);
if($lists_perm < 0)
{
switch($lists_perm)
{
case CListPermissions::WRONG_IBLOCK_TYPE:
ShowError(GetMessage("CC_BLS_WRONG_IBLOCK_TYPE"));
return;
case CListPermissions::WRONG_IBLOCK:
ShowError(GetMessage("CC_BLS_WRONG_IBLOCK"));
return;
default:
ShowError(GetMessage("CC_BLS_UNKNOWN_ERROR"));
return;
}
}
elseif($lists_perm < CListPermissions::CAN_WRITE)
{
ShowError(GetMessage("CC_BLS_ACCESS_DENIED"));
return;
}
$arParams["CAN_EDIT"] = $lists_perm >= CListPermissions::IS_ADMIN;
$arResult["IBLOCK_PERM"] = $lists_perm;
$arResult["USER_GROUPS"] = $USER->GetUserGroupArray();
$arIBlock = CIBlock::GetArrayByID(intval($arParams["~IBLOCK_ID"]));
$arResult["~IBLOCK"] = $arIBlock;
$arResult["IBLOCK"] = htmlspecialcharsex($arIBlock);
$arResult["IBLOCK_ID"] = $arIBlock["ID"];
if(isset($arParams["SOCNET_GROUP_ID"]) && $arParams["SOCNET_GROUP_ID"] > 0)
$arParams["SOCNET_GROUP_ID"] = intval($arParams["SOCNET_GROUP_ID"]);
else
$arParams["SOCNET_GROUP_ID"] = "";
$arResult["GRID_ID"] = "lists_list_sections";
$section_id = intval($arParams["~SECTION_ID"]);
$arSection = false;
if($section_id)
{
$rsSection = CIBlockSection::GetList(array(), array(
"IBLOCK_ID" => $arResult["IBLOCK_ID"],
"ID" => $section_id,
"GLOBAL_ACTIVE"=>"Y",
"CHECK_PERMISSIONS" => ($arParams["CAN_EDIT"] || $arParams["SOCNET_GROUP_ID"]? "N": "Y"), //This cancels iblock permissions for trusted users
));
$arSection = $rsSection->GetNext();
}
$arResult["SECTION"] = $arSection;
if($arResult["SECTION"])
{
$arResult["SECTION_ID"] = $arResult["SECTION"]["ID"];
$arResult["PARENT_SECTION_ID"] = $arResult["SECTION"]["IBLOCK_SECTION_ID"];
$arResult["SECTION_PATH"] = array();
$rsPath = CIBlockSection::GetNavChain($arResult["IBLOCK_ID"], $arResult["SECTION_ID"]);
while($arPath = $rsPath->Fetch())
{
$arResult["SECTION_PATH"][] = array(
"NAME" => htmlspecialcharsex($arPath["NAME"]),
"URL" => str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], intval($arPath["ID"]), $arParams["SOCNET_GROUP_ID"]),
$arParams["LIST_SECTIONS_URL"]
),
);
}
}
else
{
$arResult["SECTION_ID"] = false;
$arResult["PARENT_SECTION_ID"] = false;
}
$arResult["~LISTS_URL"] = str_replace(
array("#group_id#"),
array($arParams["SOCNET_GROUP_ID"]),
$arParams["~LISTS_URL"]
);
$arResult["LISTS_URL"] = htmlspecialchars($arResult["~LISTS_URL"]);
$arResult["~LIST_EDIT_URL"] = str_replace(
array("#list_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_EDIT_URL"]
);
$arResult["LIST_EDIT_URL"] = htmlspecialchars($arResult["~LIST_EDIT_URL"]);
$arResult["~LIST_URL"] = str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_URL"]
);
if(intval($arResult["SECTION_ID"]) <= 0)
$arResult["~LIST_URL"] = CHTTP::urlAddParams($arResult["~LIST_URL"], array("list_section_id" => ""));
$arResult["LIST_URL"] = htmlspecialchars($arResult["~LIST_URL"]);
$arResult["~LIST_SECTION_URL"] = str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], intval($arResult["SECTION_ID"]), $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_SECTIONS_URL"]
);
$arResult["LIST_SECTION_URL"] = htmlspecialchars($arResult["~LIST_SECTION_URL"]);
$arResult["~LIST_PARENT_URL"] = str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], intval($arResult["PARENT_SECTION_ID"]), $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_SECTIONS_URL"]
);
$arResult["LIST_PARENT_URL"] = htmlspecialchars($arResult["~LIST_PARENT_URL"]);
$obList = new CList($arIBlock["ID"]);
//Form submitted
if(
$_SERVER["REQUEST_METHOD"] == "POST"
&& check_bitrix_sessid()
&& (
isset($_POST["action_button_".$arResult["GRID_ID"]])
|| isset($_POST["new_section_name"])
)
&& $arResult["IBLOCK_PERM"] >= "W"
)
{
$obSection = new CIBlockSection;
if(isset($_POST["form_section_action"]) && $_POST["form_section_action"] == "rename")
{
$new_section_name = trim($_POST["new_section_name"], " \n\r\t");
$old_section_id = intval($_POST["old_section_id"]);
if($new_section_name && $old_section_id > 0)
{
//Check if section belongs proper iblock
$rsSection = CIBlockSection::GetList(array(), array(
"IBLOCK_ID" => $arResult["IBLOCK_ID"],
"ID" => $old_section_id,
"GLOBAL_ACTIVE"=>"Y",
"CHECK_PERMISSIONS" => ($arParams["CAN_EDIT"] || $arParams["SOCNET_GROUP_ID"]? "N": "Y"), //This cancels iblock permissions for trusted users
));
if($rsSection->GetNext())
{
$arFields = array(
"IBLOCK_ID" => $arResult["IBLOCK_ID"],
"NAME" => $new_section_name,
);
$obSection->Update($old_section_id, $arFields);
}
}
}
if(isset($_POST["form_section_action"]) && $_POST["form_section_action"] == "add")
{
$new_section_name = trim($_POST["new_section_name"], " \n\r\t");
if($new_section_name)
{
$arFields = array(
"IBLOCK_ID" => $arResult["IBLOCK_ID"],
"NAME" => $new_section_name,
"IBLOCK_SECTION_ID" => $arResult["SECTION_ID"],
"CHECK_PERMISSIONS" => "N",
);
$obSection->Add($arFields);
}
}
elseif($_POST["action_button_".$arResult["GRID_ID"]] == "delete" && isset($_POST["ID"]) && is_array($_POST["ID"]))
{
foreach($_POST["ID"] as $ID)
$obSection->Delete($ID, false);
//CIBlockSection::Resort($arResult["IBLOCK_D"]);
}
elseif($_POST["action_button_".$arResult["GRID_ID"]] == "edit" && isset($_POST["FIELDS"]) && is_array($_POST["FIELDS"]))
{
foreach($_POST["FIELDS"] as $ID => $arField)
{
$arField["CHECK_PERMISSIONS"] = "N";
$obSection->Update($ID, $arField);
}
}
if(!isset($_POST["AJAX_CALL"]))
LocalRedirect($arResult["LIST_SECTION_URL"]);
}
$grid_options = new CGridOptions($arResult["GRID_ID"]);
$rsSections = CIBlockSection::GetList(
array("left_margin" => "asc"), array(
"IBLOCK_ID" => $arResult["IBLOCK_ID"],
"GLOBAL_ACTIVE" => "Y",
"SECTION_ID" => $arResult["SECTION_ID"],
"CHECK_PERMISSIONS" => ($arParams["CAN_EDIT"] || $arParams["SOCNET_GROUP_ID"]? "N": "Y"), //This cancels iblock permissions for trusted users
));
$rsSections->NavStart($grid_options->GetNavParams(), false);
$arResult["SECTIONS_ROWS"] = array();
while($data = $rsSections->GetNext())
{
$aCols = array(
"NAME" => '<a href="'.str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($data["IBLOCK_ID"], $data["ID"], $arParams["SOCNET_GROUP_ID"]),
$arParams['LIST_SECTIONS_URL']
).'">'.$data["NAME"].'</a>',
);
if($arResult["IBLOCK_PERM"] >= "W")
{
$aActions = array(
array(
"ICONCLASS" => "edit",
"TEXT" => GetMessage("CC_BLS_SECTION_ACTION_MENU_RENAME"),
"ONCLICK" =>"renameSection('form_section_add', '".CUtil::JSEscape(GetMessage("CC_BLS_NEW_SECTION_NAME_PROMPT"))."', ".$data["ID"].", '".CUtil::JSEscape($data["NAME"])."');",
"DEFAULT" => true,
),
array("SEPARATOR" => true),
array(
"ICONCLASS" => "delete",
"TEXT" => GetMessage("CC_BLS_SECTION_ACTION_MENU_DELETE"),
"ONCLICK" => "bxGrid_".$arResult["GRID_ID"].".DeleteItem('".$data["ID"]."', '".GetMessage("CC_BLS_SECTION_DELETE_PROPMT")."')",
),
);
}
else
{
$aActions = array();
}
$arResult["SECTIONS_ROWS"][] = array("id" => $data["ID"], "data"=>$data, "actions"=>$aActions, "columns"=>$aCols);
}
$rsSections->bShowAll = false;
$arResult["NAV_OBJECT"] = $rsSections;
if(defined("BX_AJAX_PARAM_ID"))
$return_url = $APPLICATION->GetCurPageParam("", array(BX_AJAX_PARAM_ID));
else
$return_url = $APPLICATION->GetCurPageParam();
$this->IncludeComponentTemplate();
$APPLICATION->SetTitle(GetMessage("CC_BLS_PAGE_TITLE", array("#NAME#" => $arResult["IBLOCK"]["NAME"])));
$APPLICATION->AddChainItem($arResult["IBLOCK"]["NAME"], CHTTP::urlAddParams(str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], 0, $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_URL"]
), array("list_section_id" => "")));
$APPLICATION->AddChainItem(GetMessage("CC_BLS_CHAIN_TITLE", array("#NAME#" => $arResult["IBLOCK"]["NAME"])), str_replace(
array("#list_id#", "#section_id#", "#group_id#"),
array($arResult["IBLOCK_ID"], 0, $arParams["SOCNET_GROUP_ID"]),
$arParams["~LIST_SECTIONS_URL"]
));
if($arResult["SECTION"])
{
foreach($arResult["SECTION_PATH"] as $arPath)
{
$APPLICATION->AddChainItem($arPath["NAME"], $arPath["URL"]);
}
}
?>