public static function CheckExtRights() { if (!self::$boolCheck) { $iblockVersion = CASDiblockVersion::getIblockVersion(); if (!empty($iblockVersion)) { self::$boolExtRights = version_compare($iblockVersion, '11.0.5', '>='); self::$boolCheck = true; } } }
public static function OnAdminListDisplayHandler(&$list) { $strCurPage = $GLOBALS['APPLICATION']->GetCurPage(); $bElemPage = $strCurPage == '/bitrix/admin/iblock_element_admin.php' || $strCurPage == '/bitrix/admin/cat_product_admin.php'; $bSectPage = $strCurPage == '/bitrix/admin/iblock_section_admin.php' || $strCurPage == '/bitrix/admin/cat_section_admin.php'; $bMixPage = $strCurPage == '/bitrix/admin/iblock_list_admin.php'; $bRightPage = $bElemPage || $bSectPage || $bMixPage; if ($bRightPage && !empty($list->arActions)) { CJSCore::Init(array('asd_iblock')); $strSomeScripts = '<script type="text/javascript">sListTable = \'' . $list->table_id . '\';</script>'; $list->arActions['asd_checkbox_manager'] = array('type' => 'html', 'value' => $strSomeScripts); } if ($bMixPage || $strCurPage == '/bitrix/admin/iblock_element_admin.php' || $strCurPage == '/bitrix/admin/iblock_section_admin.php') { $list->context->additional_items[] = array('TEXT' => GetMessage('ASD_IBLOCK_SETT_SECT_MODE'), 'TITLE' => GetMessage('ASD_IBLOCK_SETT_SECT_MODE_TITLE'), 'GLOBAL_ICON' => 'adm-menu-setting', 'ONCLICK' => "location.href='" . htmlspecialcharsbx($GLOBALS['APPLICATION']->GetCurPageParam('action=asd_reverse&' . bitrix_sessid_get(), array('action'))) . "'"); } if ($bRightPage && CModule::IncludeModule('iblock')) { if (strlen(CASDiblock::$error)) { $message = new CAdminMessage(array('TYPE' => 'ERROR', 'MESSAGE' => CASDiblock::$error)); echo $message->Show(); } $lAdmin = new CAdminList($list->table_id, $list->sort); $IBLOCK_ID = intval($_REQUEST['IBLOCK_ID']); $find_section = intval($_REQUEST['find_section_section']); if ($find_section < 0) { $find_section = 0; } $boolSectionCopy = CASDIblockRights::IsSectionSectionCreate($IBLOCK_ID, $find_section); $boolElementCopy = CASDIblockRights::IsSectionElementCreate($IBLOCK_ID, $find_section); $copyMessageId = 'ASD_ACTION_POPUP_COPY'; $copyContextMessageId = 'ASD_ACTION_COPY'; $moveContextMessageId = 'ASD_ACTION_MOVE'; if (CModule::IncludeModule('catalog')) { $productIBlock = CCatalog::GetList(array(), array('PRODUCT_IBLOCK_ID' => $IBLOCK_ID), false, false, array('IBLOCK_ID'))->Fetch(); if (!empty($productIBlock)) { $copyMessageId = 'ASD_ACTION_POPUP_COPY_WITHOUT_SKU'; $copyContextMessageId = 'ASD_ACTION_COPY_WITHOUT_SKU'; $moveContextMessageId = 'ASD_ACTION_MOVE_WITHOUT_SKU'; } unset($productIBlock); } if ($bElemPage) { if ($boolElementCopy) { foreach ($list->aRows as $id => $v) { $arnewActions = array(); foreach ($v->aActions as $i => $act) { $arnewActions[] = $act; if ($act['ICON'] == 'copy') { $arnewActions[] = array('ICON' => 'copy', 'TEXT' => GetMessage($copyMessageId), 'ACTION' => $lAdmin->ActionDoGroup($v->id, 'asd_copy_in_list', '&type=' . urlencode($_REQUEST['type']) . '&lang=' . LANGUAGE_ID . '&IBLOCK_ID=' . $IBLOCK_ID . '&find_section_section=' . $find_section)); } } $v->aActions = $arnewActions; } } } elseif ($bSectPage) { if ($boolSectionCopy) { foreach ($list->aRows as $id => $v) { $arnewActions = array(); foreach ($v->aActions as $i => $act) { $arnewActions[] = $act; if ($act['ICON'] == 'edit') { $arnewActions[] = array('ICON' => 'copy', 'TEXT' => GetMessage('ASD_ACTION_POPUP_COPY'), 'ACTION' => $lAdmin->ActionDoGroup($v->id, 'asd_copy_in_list', '&type=' . urlencode($_REQUEST['type']) . '&lang=' . LANGUAGE_ID . '&IBLOCK_ID=' . $IBLOCK_ID . '&find_section_section=' . $find_section)); } } $v->aActions = $arnewActions; } } } else { foreach ($list->aRows as $id => $v) { $strPrefix = substr($v->id, 0, 1); if ($strPrefix == 'E') { if ($boolElementCopy) { $arnewActions = array(); foreach ($v->aActions as $i => $act) { $arnewActions[] = $act; if ($act['ICON'] == 'copy') { $arnewActions[] = array('ICON' => 'copy', 'TEXT' => GetMessage($copyMessageId), 'ACTION' => $lAdmin->ActionDoGroup($v->id, 'asd_copy_in_list', '&type=' . urlencode($_REQUEST['type']) . '&IBLOCK_ID=' . $IBLOCK_ID . '&find_section_section=' . $find_section)); } } $v->aActions = $arnewActions; } } elseif ($strPrefix == 'S') { if ($boolSectionCopy) { $arnewActions = array(); foreach ($v->aActions as $i => $act) { $arnewActions[] = $act; if ($act['ICON'] == 'edit') { $arnewActions[] = array('ICON' => 'copy', 'TEXT' => GetMessage('ASD_ACTION_POPUP_COPY'), 'ACTION' => $lAdmin->ActionDoGroup($v->id, 'asd_copy_in_list', '&type=' . urlencode($_REQUEST['type']) . '&lang=' . LANGUAGE_ID . '&IBLOCK_ID=' . $IBLOCK_ID . '&find_section_section=' . $find_section)); } } $v->aActions = $arnewActions; } } } } $arIBtypes = array(); $rsIBtype = CIBlockType::GetList(); while ($arIBtype = $rsIBtype->Fetch()) { if ($arIBTypeLang = CIBlockType::GetByIDLang($arIBtype['ID'], LANGUAGE_ID)) { $arIBtypes[$arIBTypeLang['IBLOCK_TYPE_ID']] = $arIBTypeLang['NAME']; } } $arIBblocks = array(); $rsIB = CIBlock::GetList(); while ($arIB = $rsIB->GetNext(true, false)) { if (!isset($arIBblocks[$arIB['IBLOCK_TYPE_ID']])) { $arIBblocks[$arIB['IBLOCK_TYPE_ID']] = array('NAME' => $arIBtypes[$arIB['IBLOCK_TYPE_ID']], 'ITEMS' => array()); } $arIBblocks[$arIB['IBLOCK_TYPE_ID']]['ITEMS'][] = array('ID' => $arIB['ID'], 'NAME' => $arIB['NAME']); } $boolAccess = false; $strIBlocksCp = '<div id="asd_ib_dest_cont" style="display:none; "><select class="typeselect" name="asd_ib_dest" id="asd_ib_dest">'; foreach ($arIBblocks as &$arType) { $strIBlocksCpGr = ''; foreach ($arType['ITEMS'] as &$arIB) { if (CASDIblockRights::IsIBlockDisplay($arIB['ID'])) { $boolAccess = true; $strIBlocksCpGr .= '<option value="' . $arIB['ID'] . '">' . $arIB['NAME'] . '</option>'; } } if (isset($arIB)) { unset($arIB); } if ($strIBlocksCpGr != '') { $strIBlocksCp .= '<optgroup label="' . $arType['NAME'] . '">'; $strIBlocksCp .= $strIBlocksCpGr; $strIBlocksCp .= '</optgroup>'; } } if (isset($arType)) { unset($arType); } $strIBlocksCp .= '</select></div>'; $strSectionSelect = '<div id="asd_ib_dest_sect" class="asd-sect-cont" style="display:none;" title="' . htmlspecialcharsbx(GetMessage('ASD_SELECT_SECTION_DESCR')) . '">' . htmlspecialcharsex(GetMessage('ASD_SELECT_SECTION')) . ' <input class="asd-sect-input" type="text" id="asd_sect_id" value="" name="asd_sect_dest" size="4" title="">' . '<span id="sp_asd_sect_id" class="asd-sect-descr"></span>' . '<input type="button" onclick="ASDSelIBShow(\'' . LANGUAGE_ID . '\');" value="' . htmlspecialcharsbx(GetMessage('ASD_SELECT_BUTTON')) . '" title="' . htmlspecialcharsbx(GetMessage('ASD_SELECT_BUTTON_DESCR')) . '"></div>'; if (CASDIblockRights::IsSectionElementEdit($IBLOCK_ID, $find_section) && ($bElemPage || $bMixPage)) { $list->arActions['asd_remove'] = GetMessage('ASD_ACTION_REMOVE'); } if ($boolAccess) { $list->arActions['asd_copy'] = GetMessage($copyContextMessageId); if ($bElemPage || $bMixPage) { $list->arActions['asd_move'] = GetMessage($moveContextMessageId); } $list->arActions['asd_copy_move'] = array('type' => 'html', 'value' => $strIBlocksCp); $list->arActions['asd_copy_move_sect'] = array('type' => 'html', 'value' => $strSectionSelect); $list->arActionsParams['select_onchange'] .= "ASDSelIBChange(this.value);"; } } }
public static function OnAfterIBlockUpdateHandler($arFields) { if ($arFields['RESULT'] && CASDIblockRights::IsIBlockEdit($arFields['ID'])) { global $USER_FIELD_MANAGER, $HTTP_POST_FILES; $PROPERTY_ID = CASDiblock::$UF_IBLOCK; $USER_FIELD_MANAGER->EditFormAddFields($PROPERTY_ID, $arFields); $USER_FIELD_MANAGER->Update($PROPERTY_ID, $arFields['ID'], $arFields); } }