getRequest(); $selfFolderUrl = $adminPage->getSelfFolderUrl(); $publicMode = defined("SELF_FOLDER_URL"); /*Change any language identifiers carefully*/ /*because of user customized forms!*/ IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/iblock/admin/iblock_element_edit_compat.php"); IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/iblock/admin/iblock_element_edit.php"); IncludeModuleLangFile(__FILE__); require_once($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/iblock/classes/general/subelement.php'); if (!function_exists('tabFilter')) { function tabFilter($tab): bool { return ($tab['DIV'] != 'product_group'); } } $type = (isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : ''); $IBLOCK_ID = (isset($_REQUEST['IBLOCK_ID']) ? (int)$_REQUEST['IBLOCK_ID'] : 0); $arIBTYPE = false; // initial value $arElement = false; // initial value $prev_arElement = array(); // initial value $PROP = array(); const MODULE_ID = "iblock"; const ENTITY = "CIBlockDocument"; define("DOCUMENT_TYPE", "iblock_".$IBLOCK_ID); define("BX_SUB_SETTINGS",(isset($_REQUEST['bxsku']) && $_REQUEST['bxsku'] == 'Y')); $ajaxReload = (isset($_REQUEST['ajaxReload']) && $_REQUEST['ajaxReload'] == 'Y'); $strWarning = ''; $bVarsFromForm = false; $strProductName = ''; if (isset($_REQUEST['PRODUCT_NAME']) && trim($_REQUEST['PRODUCT_NAME']) != '') { CUtil::decodeURIComponent($_REQUEST['PRODUCT_NAME']); CUtil::decodeURIComponent($_POST['PRODUCT_NAME']); $strProductName = trim($_REQUEST['PRODUCT_NAME']); } $arShowTabs = array( 'edit_rights' => false, 'workflow' => false, 'bizproc' => false, 'sections' => false, 'catalog' => true, 'product_set' => false, 'product_group' => false ); $bCatalog = false; $arSubCatalog = false; $bCatalog = Loader::includeModule('catalog'); $catalogTabNames = []; if ($bCatalog) { $arSubCatalog = CCatalogSku::GetInfoByOfferIBlock($IBLOCK_ID); if (empty($arSubCatalog) || !is_array($arSubCatalog)) $bCatalog = false; $catalogTabNames = CCatalogAdminTools::getTabDescriptions(); } if (!$bCatalog) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage('IB_SE_GENERAL_SKU_ERROR')); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } $intProductID = 0; if (isset($_REQUEST['PRODUCT_ID'])) $intProductID = (int)$_REQUEST['PRODUCT_ID']; $strSubTMP_ID = ''; if (isset($_REQUEST['TMP_ID'])) $strSubTMP_ID = trim($_REQUEST['TMP_ID']); $ID = 0; if (isset($_REQUEST['ID'])) $ID = (int)$_REQUEST['ID']; //ID of the persistent record $bSubCopy = false; $copyID = 0; if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'copy') $bSubCopy = true; $copyID = (isset($_REQUEST['copyID']) ? (int)$_REQUEST['copyID'] : 0); $PREV_ID = (int)$request->get('PREV_ID'); $WF_ID = $ID; //This is ID of the current copy $arIBlock = CIBlock::GetArrayByID($IBLOCK_ID); $bWorkflow = ($arIBlock['WORKFLOW'] != 'N') && Loader::includeModule('workflow'); $bBizproc = ($arIBlock['BIZPROC'] != 'N') && Loader::includeModule('bizproc'); /*if(($ID <= 0 || $bSubCopy) && $bWorkflow) $WF = "Y"; elseif(!$bWorkflow) $WF = "N"; */ if($ID <= 0 && $bWorkflow) $WF = "Y"; elseif(!$bWorkflow) $WF = "N"; $view = (string)$request->get('view'); $historyId = 0; if (isset($_REQUEST['history_id']) && is_string($_REQUEST['history_id'])) { $historyId = (int)$_REQUEST['history_id']; } if ($historyId > 0 && $bBizproc) { $view = "Y"; } else { $historyId = 0; } Main\Page\Asset::getInstance()->addJs('/bitrix/js/iblock/iblock_edit.js'); $error = false; $WF = ($WF=="Y") ? "Y" : "N"; //workflow mode $view = ($view === "Y") ? "Y" : "N"; //view mode $return_url = ''; // TODO: hack for psevdo-excel export in crm (\CAdminUiList::GetSystemContextMenu) $urlBuilderManager = Iblock\Url\AdminPage\BuilderManager::getInstance(); $urlBuilder = null; $urlBuilderId = (string)$request->get('urlBuilderId') ; if ($urlBuilderId !== '') { $urlBuilder = $urlBuilderManager->getBuilder($urlBuilderId); } // TODO end if ($urlBuilder === null) { $urlBuilder = $urlBuilderManager->getBuilder(); } unset($urlBuilderManager); if ($urlBuilder === null) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage("IBLOCK_ELEMENT_ERR_BUILDER_ADSENT")); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } $urlBuilderId = $urlBuilder->getId(); $urlBuilder->setIblockId($IBLOCK_ID); $urlBuilder->setUrlParams(array()); $accessController = AccessController::getCurrent(); $allowCatalogRead = $accessController->check(ActionDictionary::ACTION_CATALOG_READ); $allowPriceEdit = $accessController->check(ActionDictionary::ACTION_PRICE_EDIT); $allowProductAdd = $accessController->check(ActionDictionary::ACTION_PRODUCT_ADD); $allowProductEdit = $accessController->check(ActionDictionary::ACTION_PRODUCT_EDIT); $allowProductDelete = $accessController->check(ActionDictionary::ACTION_PRODUCT_DELETE); CCatalogAdminTools::setSkuFormParams(); $arSubCatalogEx = array(); $arSubCatalogTabs = CCatalogAdminTools::getShowTabs($IBLOCK_ID, ($copyID > 0 && $ID == 0 ? $copyID : $ID), $arSubCatalogEx); if (!empty($arSubCatalogTabs)) { $arShowTabs['product_group'] = $arSubCatalogTabs[CCatalogAdminTools::TAB_GROUP]; } /* initial values fo bizproc */ $canWrite = false; $arDocumentStates = array(); $arBizProcParametersValues = array(); $arBizProcWorkflowId = array(); $arCurrentUserGroups = $USER->GetUserGroupArray(); $arResult = array(); /* initial values fo bizproc finish */ do{ //one iteration loop if ($historyId > 0) { $arErrorsTmp = array(); $arResult = CBPDocument::GetDocumentFromHistory($historyId, $arErrorsTmp); if (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) { $error = new _CIBlockError(1, $e["code"], $e["message"]); break; } } $canWrite = CBPDocument::CanUserOperateDocument( CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), $arResult["DOCUMENT_ID"], array("UserGroups" => $USER->GetUserGroupArray()) ); if (!$canWrite) { $error = new _CIBlockError(1, "ACCESS_DENIED", GetMessage("IBLOCK_ACCESS_DENIED_STATUS")); break; } $type = $arResult["DOCUMENT"]["FIELDS"]["IBLOCK_TYPE_ID"]; $IBLOCK_ID = $arResult["DOCUMENT"]["FIELDS"]["IBLOCK_ID"]; } $arIBTYPE = CIBlockType::GetByIDLang($type, LANGUAGE_ID); if($arIBTYPE===false) { $error = new _CIBlockError(1, "BAD_IBLOCK_TYPE", GetMessage("IBLOCK_BAD_BLOCK_TYPE_ID")); break; } $bBadBlock = true; if($arIBlock) { if (($ID > 0 && !$bSubCopy) && !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "iblock_admin_display")) $bBadBlock = true; elseif (($ID <= 0 || $bSubCopy) && !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "iblock_admin_display")) $bBadBlock = true; elseif (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit")) $bBadBlock = false; elseif ($bWorkflow && ($WF=="Y" || $view=="Y")) $bBadBlock = false; elseif ($bBizproc) $bBadBlock = false; elseif( (($ID <= 0) || $bSubCopy) && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "section_element_bind") ) $bBadBlock = false; } if($bBadBlock) { $error = new _CIBlockError(1, "BAD_IBLOCK", GetMessage("IBLOCK_BAD_IBLOCK")); $APPLICATION->SetTitle($arIBTYPE["ELEMENT_NAME"].": ".GetMessage("IBLOCK_EDIT_TITLE")); break; } $arShowTabs['workflow'] = $bWorkflow; $arShowTabs['bizproc'] = $bBizproc && ($historyId <= 0); $bEditRights = $arIBlock["RIGHTS_MODE"] === "E" && ( CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_rights_edit") || (($ID <= 0 || $bSubCopy) && CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "element_rights_edit")) ); $arShowTabs['edit_rights'] = $bEditRights; $arShowTabs['catalog'] = ($view !== 'Y') && $bCatalog && ($allowCatalogRead || $allowPriceEdit) ; $aTabs = array(); $aTabs[] = array( "DIV" => "sub_edit1", "TAB" => $arIBlock["ELEMENT_NAME"], "ICON"=>"iblock_element", "TITLE"=>htmlspecialcharsEx($arIBlock["ELEMENT_NAME"]) ); $aTabs[] = array( "DIV" => "sub_edit5", "TAB" => GetMessage("IBEL_E_TAB_PREV"), "ICON"=>"iblock_element", "TITLE"=>GetMessage("IBEL_E_TAB_PREV_TITLE") ); $aTabs[] = array( "DIV" => "sub_edit6", "TAB" => GetMessage("IBEL_E_TAB_DET"), "ICON"=>"iblock_element", "TITLE"=>GetMessage("IBEL_E_TAB_DET_TITLE") ); $aTabs[] = array( "DIV" => "sub_edit14", "TAB" => GetMessage("IBEL_E_TAB14"), "ICON" => "iblock_iprops", "TITLE" => GetMessage("IBEL_E_TAB14_TITLE"), ); if ($arShowTabs['catalog']) $aTabs[] = array( "DIV" => "sub_edit10", "TAB" => $catalogTabNames[CCatalogAdminTools::TAB_CATALOG]['NAME'], "ICON"=>"iblock_element", "TITLE" => $catalogTabNames[CCatalogAdminTools::TAB_CATALOG]['TITLE'], "required" => true, ); if ($arShowTabs['product_group']) { $aTabs[] = array( "DIV" => "product_group", "TAB" => GetMessage("IBLOCK_EL_TAB_PRODUCT_GROUP"), "ICON" => "iblock_element", "TITLE" => GetMessage("IBLOCK_EL_TAB_PRODUCT_GROUP_TITLE"), "required" => true, ); } if($arShowTabs['workflow']) $aTabs[] = array( "DIV" => "sub_edit4", "TAB" => GetMessage("IBLOCK_EL_TAB_WF"), "ICON"=>"iblock_element_wf", "TITLE"=>GetMessage("IBLOCK_EL_TAB_WF_TITLE") ); if ($arShowTabs['bizproc']) $aTabs[] = array( "DIV" => "sub_edit7", "TAB" => GetMessage("IBEL_E_TAB_BIZPROC"), "ICON"=>"iblock_element_wf", "TITLE"=>GetMessage("IBEL_E_TAB_BIZPROC") ); if($arShowTabs['edit_rights']) $aTabs[] = array( "DIV" => "sub_edit8", "TAB" => GetMessage("IBEL_E_TAB_RIGHTS"), "ICON" => "iblock_element_rights", "TITLE" => GetMessage("IBEL_E_TAB_RIGHTS_TITLE"), ); $arIBlock["EDIT_FILE_AFTER"] = (string)$arIBlock["EDIT_FILE_AFTER"]; $arIBTYPE["EDIT_FILE_AFTER"] = (string)$arIBTYPE["EDIT_FILE_AFTER"]; $bCustomForm = ( $arIBlock["EDIT_FILE_AFTER"] != '' && (mb_substr($arIBlock["EDIT_FILE_AFTER"], -4) == '.php') && is_file($_SERVER["DOCUMENT_ROOT"].$arIBlock["EDIT_FILE_AFTER"]) ) || ( $arIBTYPE["EDIT_FILE_AFTER"] != '' && (mb_substr($arIBTYPE["EDIT_FILE_AFTER"], -4) == '.php') && is_file($_SERVER["DOCUMENT_ROOT"].$arIBTYPE["EDIT_FILE_AFTER"]) ); $arPostParams = array( 'bxpublic' => 'Y' ); if (defined('BX_SUB_SETTINGS') && BX_SUB_SETTINGS == true) { $arPostParams['bxsku'] = 'Y'; } if ('' != $strProductName) { $arPostParams['PRODUCT_NAME'] = $strProductName; $arPostParams['sessid'] = bitrix_sessid(); } $arListUrl = array( 'LINK' => $APPLICATION->GetCurPageParam(), 'POST_PARAMS' => $arPostParams, ); if($ID>0) { $rsElement = CIBlockElement::GetList( array(), array("ID" => $ID, "IBLOCK_ID" => $IBLOCK_ID, "SHOW_HISTORY"=>"Y"), false, false, array("ID", "CREATED_BY") ); if(!($arElement = $rsElement->Fetch())) { $error = new _CIBlockError(1, "BAD_ELEMENT", GetMessage("IBLOCK_BAD_ELEMENT")); $APPLICATION->SetTitle($arIBTYPE["ELEMENT_NAME"].": ".GetMessage("IBLOCK_EDIT_TITLE")); break; } } $customTabber = new CAdminTabEngine("OnAdminIBlockElementEdit", array("ID" => $ID, "IBLOCK"=>$arIBlock, "IBLOCK_TYPE"=>$arIBTYPE)); // workflow mode if ($ID > 0 && $WF == "Y") { // get ID of the last record in workflow $WF_ID = CIBlockElement::WF_GetLast($ID); // check for edit permissions $STATUS_ID = CIBlockElement::WF_GetCurrentStatus($WF_ID, $STATUS_TITLE); $STATUS_PERMISSION = CIBlockElement::WF_GetStatusPermission($STATUS_ID); if($STATUS_ID>1 && $STATUS_PERMISSION<2) { $error = new _CIBlockError(1, "ACCESS_DENIED", GetMessage("IBLOCK_ACCESS_DENIED_STATUS")); break; } elseif($STATUS_ID==1) { $WF_ID = $ID; $STATUS_ID = CIBlockElement::WF_GetCurrentStatus($WF_ID, $STATUS_TITLE); $STATUS_PERMISSION = CIBlockElement::WF_GetStatusPermission($STATUS_ID); } // check if document is locked if(CIBlockElement::WF_IsLocked($ID, $locked_by, $date_lock)) { if($locked_by > 0) { $rsUser = CUser::GetList('ID', 'ASC', array("ID_EQUAL_EXACT" => $locked_by)); if($arUser = $rsUser->GetNext()) $locked_by = rtrim("[".$arUser["ID"]."] (".$arUser["LOGIN"].") ".$arUser["NAME"]." ".$arUser["LAST_NAME"]); } $error = new _CIBlockError(2, "BLOCKED", GetMessage("IBLOCK_DOCUMENT_LOCKED", array("#ID#"=>$locked_by, "#DATE#"=>$date_lock))); break; } } elseif ($bBizproc) { $arDocumentStates = CBPDocument::GetDocumentStates( array(MODULE_ID, ENTITY, DOCUMENT_TYPE), ($ID > 0) ? array(MODULE_ID, ENTITY, $ID) : null ); if ($ID > 0 && is_array($arElement)) { if ($USER->GetID() == $arElement["CREATED_BY"]) $arCurrentUserGroups[] = "Author"; } else { $arCurrentUserGroups[] = "Author"; } if ($ID > 0) { $canWrite = CBPDocument::CanUserOperateDocument( CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates) ); $canRead = CBPDocument::CanUserOperateDocument( CBPCanUserOperateOperation::ReadDocument, $USER->GetID(), array(MODULE_ID, ENTITY, $ID), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates) ); } else { $canWrite = CBPDocument::CanUserOperateDocumentType( CBPCanUserOperateOperation::WriteDocument, $USER->GetID(), array(MODULE_ID, ENTITY, DOCUMENT_TYPE), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates) ); $canRead = false; } if (!$canWrite && !$canRead) { $error = new _CIBlockError(1, "ACCESS_DENIED", GetMessage("IBLOCK_ACCESS_DENIED_STATUS")); break; } } //Find out files properties $arFileProps = array(); $propertyIterator = Iblock\PropertyTable::getList(array( 'select' => array('ID'), 'filter' => array('=IBLOCK_ID' => $IBLOCK_ID, '=PROPERTY_TYPE' => Iblock\PropertyTable::TYPE_FILE, '=ACTIVE' => 'Y') )); while ($property = $propertyIterator->fetch()) $arFileProps[] = $property['ID']; unset($property, $propertyIterator); //Assembly properties values from $_POST and $_FILES if (isset($_POST['PROP'])) $PROP = $_POST['PROP']; //Recover some user defined properties if(is_array($PROP)) { foreach($PROP as $k1 => $val1) { if(is_array($val1)) { foreach($val1 as $k2 => $val2) { $text_name = preg_replace("/([^a-z0-9])/is", "_", "PROP[".$k1."][".$k2."][VALUE][TEXT]"); if(array_key_exists($text_name, $_POST)) { $type_name = preg_replace("/([^a-z0-9])/is", "_", "PROP[".$k1."][".$k2."][VALUE][TYPE]"); $PROP[$k1][$k2]["VALUE"] = array( "TEXT" => $_POST[$text_name], "TYPE" => $_POST[$type_name], ); } } } } foreach($PROP as $k1 => $val1) { if(is_array($val1)) { foreach($val1 as $k2 => $val2) { if(!is_array($val2)) $PROP[$k1][$k2] = array("VALUE" => $val2); } } } } //transpose files array // [property id] [value id] = file array (name, type, tmp_name, error, size) $files = $_FILES["PROP"] ?? null; if(is_array($files)) { if(!is_array($PROP)) $PROP = array(); CFile::ConvertFilesToPost($_FILES["PROP"], $PROP); } foreach($arFileProps as $k1) { if (isset($PROP_del[$k1]) && is_array($PROP_del[$k1])) { foreach ($PROP_del[$k1] as $prop_value_id => $tmp) { if (!array_key_exists($prop_value_id, $PROP[$k1])) $PROP[$k1][$prop_value_id] = null; } } if (isset($PROP[$k1]) && is_array($PROP[$k1])) { foreach ($PROP[$k1] as $prop_value_id => $prop_value) { $PROP[$k1][$prop_value_id] = CIBlock::makeFilePropArray( $PROP[$k1][$prop_value_id], ($PROP_del[$k1][$prop_value_id] ?? 'N') === "Y", $_POST["DESCRIPTION_PROP"][$k1][$prop_value_id] ?? $_POST["PROP_descr"][$k1][$prop_value_id] ); } } else { $PROP[$k1] = array(); } } $DESCRIPTION_PROP = $_POST["DESCRIPTION_PROP"] ?? null; if(is_array($DESCRIPTION_PROP)) { foreach($DESCRIPTION_PROP as $k1=>$val1) { foreach($val1 as $k2=>$val2) { if(is_set($PROP[$k1], $k2) && is_array($PROP[$k1][$k2]) && is_set($PROP[$k1][$k2], "DESCRIPTION")) $PROP[$k1][$k2]["DESCRIPTION"] = $val2; else $PROP[$k1][$k2] = array("VALUE"=>$PROP[$k1][$k2], "DESCRIPTION"=>$val2); } } } function _prop_value_id_cmp($a, $b) { if(mb_substr($a, 0, 1) === "n") { $a = intval(mb_substr($a, 1)); if(mb_substr($b, 0, 1) === "n") { $b = intval(mb_substr($b, 1)); if($a < $b) return -1; elseif($a > $b) return 1; else return 0; } else { return 1; } } else { if(mb_substr($b, 0, 1) === "n") { return -1; } else { if(preg_match("/^(\d+):(\d+)$/", $a, $a_match)) $a = intval($a_match[2]); else $a = intval($a); if(preg_match("/^(\d+):(\d+)$/", $b, $b_match)) $b = intval($b_match[2]); else $b = intval($b); if($a < $b) return -1; elseif($a > $b) return 1; else return 0; } } } //Now reorder property values if( is_array($PROP) && !empty($arFileProps) && !class_exists('\Bitrix\Main\UI\FileInput', true) ) { foreach($arFileProps as $id) { if(is_array($PROP[$id])) uksort($PROP[$id], "_prop_value_id_cmp"); } } $arIBlock["EDIT_FILE_BEFORE"] = (string)$arIBlock["EDIT_FILE_BEFORE"]; $arIBTYPE["EDIT_FILE_BEFORE"] = (string)$arIBTYPE["EDIT_FILE_BEFORE"]; if ( $arIBlock["EDIT_FILE_BEFORE"] != '' && (mb_substr($arIBlock["EDIT_FILE_BEFORE"], -4) == '.php') && is_file($_SERVER["DOCUMENT_ROOT"].$arIBlock["EDIT_FILE_BEFORE"]) ) { include($_SERVER["DOCUMENT_ROOT"].$arIBlock["EDIT_FILE_BEFORE"]); } elseif ( $arIBTYPE["EDIT_FILE_BEFORE"] != '' && (mb_substr($arIBTYPE["EDIT_FILE_BEFORE"], -4) == '.php') && is_file($_SERVER["DOCUMENT_ROOT"].$arIBTYPE["EDIT_FILE_BEFORE"]) ) { include($_SERVER["DOCUMENT_ROOT"].$arIBTYPE["EDIT_FILE_BEFORE"]); } if ( $bBizproc && $canWrite && $historyId <= 0 && $ID > 0 && $_SERVER['REQUEST_METHOD']=="GET" && isset($_REQUEST["stop_bizproc"]) && $_REQUEST["stop_bizproc"] <> '' && check_bitrix_sessid() ) { CBPDocument::TerminateWorkflow( $_REQUEST["stop_bizproc"], array(MODULE_ID, ENTITY, $ID), $ar ); if (!empty($ar)) { $str = ""; foreach ($ar as $a) $str .= $a["message"]; $error = new _CIBlockError(2, "STOP_BP_ERROR", $str); } else { LocalRedirect($APPLICATION->GetCurPageParam("", array("stop_bizproc", "sessid"))); } } $changeTabs = false; if( $historyId <= 0 && $_SERVER['REQUEST_METHOD'] == 'GET' && 0 < $ID && check_bitrix_sessid() ) { if (CCatalogAdminTools::changeTabs($IBLOCK_ID, $ID, $arMainCatalog)) { $changeTabs = true; $arShowTabs['product_group'] = false; $aTabs = array_filter($aTabs, 'tabFilter'); unset($_REQUEST['SUBPRODUCT_TYPE']); } } // save and apply // change $dontsave on cancel if ( !$changeTabs && $historyId <= 0 && $_SERVER['REQUEST_METHOD'] == "POST" && (isset($_POST['Update']) && $_POST['Update'] != '') && $view != "Y" && (!$error) && empty($dontsave) ) { $DB->StartTransaction(); if (!(check_bitrix_sessid() || $_SESSION['IBLOCK_CUSTOM_FORM']===true)) { $strWarning .= GetMessage("IBLOCK_WRONG_SESSION")."
"; $error = new _CIBlockError(2, "BAD_SAVE", $strWarning); $bVarsFromForm = true; } elseif ($WF=="Y" && $bWorkflow && intval($_POST["WF_STATUS_ID"])<=0) $strWarning .= GetMessage("IBLOCK_WRONG_WF_STATUS")."
"; elseif ($WF=="Y" && $bWorkflow && CIBlockElement::WF_GetStatusPermission($_POST["WF_STATUS_ID"])<1) $strWarning .= GetMessage("IBLOCK_ACCESS_DENIED_STATUS")." [".$_POST["WF_STATUS_ID"]."]."."
"; elseif (!$customTabber->Check()) { if($ex = $APPLICATION->GetException()) $strWarning .= $ex->GetString(); else $strWarning .= "Error. "; }//if(!$customTabber->Check()) else { $arCatalogItem = array( 'IBLOCK_ID' => $IBLOCK_ID, 'SECTION_ID' => 0, 'ID' => $ID, 'PRODUCT_ID' => (0 < $ID ? CIBlockElement::GetRealElement($ID) : 0) ); if ( $arShowTabs['catalog'] && file_exists($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/subproduct_edit_validator.php") ) { // errors'll be appended to $strWarning; include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/subproduct_edit_validator.php"); } if ($arShowTabs['product_group']) { CCatalogAdminProductSetEdit::setSkuFormParams(array('TYPE' => CCatalogProductSet::TYPE_GROUP)); if (!CCatalogAdminProductSetEdit::checkFormValues($arCatalogItem)) { $strWarning .= implode('
', CCatalogAdminProductSetEdit::getErrors()); } } if ($bBizproc) { if($canWrite) { $arBizProcParametersValues = array(); foreach ($arDocumentStates as $arDocumentState) { if ($arDocumentState["ID"] == '') { $arErrorsTmp = array(); $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflowParametersValidate( $arDocumentState["TEMPLATE_ID"], $arDocumentState["TEMPLATE_PARAMETERS"], array(MODULE_ID, ENTITY, DOCUMENT_TYPE), $arErrorsTmp ); if (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) $strWarning .= $e["message"]."
"; } } } } else { $strWarning .= GetMessage("IBLOCK_ACCESS_DENIED_STATUS")."
"; } } if ($strWarning == '') { $bs = new CIBlockElement(); $arPREVIEW_PICTURE = CIBlock::makeFileArray( array_key_exists("SUB_PREVIEW_PICTURE", $_FILES)? $_FILES["SUB_PREVIEW_PICTURE"]: $_REQUEST["SUB_PREVIEW_PICTURE"], ${"SUB_PREVIEW_PICTURE_del"} === "Y", ${"SUB_PREVIEW_PICTURE_descr"} ); if ($arPREVIEW_PICTURE["error"] == 0) $arPREVIEW_PICTURE["COPY_FILE"] = "Y"; $arDETAIL_PICTURE = CIBlock::makeFileArray( array_key_exists("SUB_DETAIL_PICTURE", $_FILES)? $_FILES["SUB_DETAIL_PICTURE"]: $_REQUEST["SUB_DETAIL_PICTURE"], ${"SUB_DETAIL_PICTURE_del"} === "Y", ${"SUB_DETAIL_PICTURE_descr"} ); if ($arDETAIL_PICTURE["error"] == 0) $arDETAIL_PICTURE["COPY_FILE"] = "Y"; $textIndex = ($bSubCopy ? $copyID : $ID); $arFields = array( "ACTIVE" => (isset($_POST["SUB_ACTIVE"]) ? $_POST["SUB_ACTIVE"] : 'N'), "MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => $IBLOCK_ID, "ACTIVE_FROM" => $_POST["SUB_ACTIVE_FROM"], "ACTIVE_TO" => $_POST["SUB_ACTIVE_TO"], "SORT" => $_POST["SUB_SORT"], "NAME" => $_POST["SUB_NAME"], "CODE" => trim($_POST["SUB_CODE"], " \t\n\r"), "TAGS" => $_POST["SUB_TAGS"], "PREVIEW_PICTURE" => $arPREVIEW_PICTURE, "PREVIEW_TEXT" => $_POST["SUB_PREVIEW_TEXT_".$textIndex], "PREVIEW_TEXT_TYPE" => $_POST["SUB_PREVIEW_TEXT_TYPE_".$textIndex], "DETAIL_PICTURE" => $arDETAIL_PICTURE, "DETAIL_TEXT" => $_POST["SUB_DETAIL_TEXT_".$textIndex], "DETAIL_TEXT_TYPE" => $_POST["SUB_DETAIL_TEXT_TYPE_".$textIndex], "TMP_ID" => $strSubTMP_ID, "PROPERTY_VALUES" => $PROP, ); if (COption::GetOptionString("iblock", "show_xml_id")=="Y" && is_set($_POST, "SUB_XML_ID")) $arFields["XML_ID"] = trim($_POST["SUB_XML_ID"], " \t\n\r"); if ($arIBlock["RIGHTS_MODE"] === "E" && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_rights_edit")) { if (is_array($_POST["SUB_RIGHTS"])) $arFields["RIGHTS"] = CIBlockRights::Post2Array($_POST["SUB_RIGHTS"]); else $arFields["RIGHTS"] = array(); } if ($bWorkflow) { $arFields["WF_COMMENTS"] = $_POST["WF_COMMENTS"]; if(intval($_POST["WF_STATUS_ID"])>0) { $arFields["WF_STATUS_ID"] = $_POST["WF_STATUS_ID"]; } } if ($bBizproc) { $BP_HISTORY_NAME = $arFields["NAME"]; if ($ID <= 0) $arFields["BP_PUBLISHED"] = "N"; } if ($ID > 0) { $bCreateRecord = false; $res = $bs->Update($ID, $arFields, $WF=="Y", true, true); } else { $bCreateRecord = true; $ID = $bs->Add($arFields, $bWorkflow, true, true); $res = ($ID>0); $PARENT_ID = $ID; } if (!$res) $strWarning .= $bs->LAST_ERROR."
"; if ($strWarning == '') { $arCatalogItem = array( 'IBLOCK_ID' => $IBLOCK_ID, 'SECTION_ID' => 0, 'ID' => $ID, 'PRODUCT_ID' => CIBlockElement::GetRealElement($ID) ); if ($arShowTabs['catalog']) { include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/subproduct_edit_action.php"); } if ($arShowTabs['product_group']) { CCatalogAdminProductSetEdit::setSkuFormParams(array('TYPE' => CCatalogProductSet::TYPE_GROUP)); CCatalogAdminProductSetEdit::saveFormValues($arCatalogItem); } } } // if ($strWarning) if ($bBizproc) { if ($strWarning == '') { foreach ($arDocumentStates as $arDocumentState) { if ($arDocumentState["ID"] == '') { $arErrorsTmp = array(); $arBizProcWorkflowId[$arDocumentState["TEMPLATE_ID"]] = CBPDocument::StartWorkflow( $arDocumentState["TEMPLATE_ID"], array(MODULE_ID, ENTITY, $ID), $arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], $arErrorsTmp ); if (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) $strWarning .= $e["message"]."
"; } } } } if ($strWarning == '') { $bizprocIndex = intval($_REQUEST["bizproc_index"]); if ($bizprocIndex > 0) { for ($i = 1; $i <= $bizprocIndex; $i++) { $bpId = trim($_REQUEST["bizproc_id_".$i]); $bpTemplateId = intval($_REQUEST["bizproc_template_id_".$i]); $bpEvent = trim($_REQUEST["bizproc_event_".$i]); if ($bpEvent <> '') { if ($bpId <> '') { if (!array_key_exists($bpId, $arDocumentStates)) continue; } else { if (!array_key_exists($bpTemplateId, $arDocumentStates)) continue; $bpId = $arBizProcWorkflowId[$bpTemplateId]; } $arErrorTmp = array(); CBPDocument::SendExternalEvent( $bpId, $bpEvent, array("Groups" => $arCurrentUserGroups, "User" => $USER->GetID()), $arErrorTmp ); if (!empty($arErrorsTmp)) { foreach ($arErrorsTmp as $e) $strWarning .= $e["message"]."
"; } } } } $arDocumentStates = null; CBPDocument::AddDocumentToHistory(array(MODULE_ID, ENTITY, $ID), $BP_HISTORY_NAME, $USER->GetID()); } } } if($strWarning == '') { if(!$customTabber->Action()) { if ($ex = $APPLICATION->GetException()) $strWarning .= $ex->GetString(); else $strWarning .= "Error. "; } } if($strWarning != '') { $error = new _CIBlockError(2, "BAD_SAVE", $strWarning); $bVarsFromForm = true; $DB->Rollback(); } else { if($bWorkflow) CIBlockElement::WF_UnLock($ID); $arFields['ID'] = $ID; if(function_exists('BXIBlockAfterSave')) BXIBlockAfterSave($arFields); $DB->Commit(); // i have only savebtn and cancel if (isset($_POST['Update']) && ($_POST['Update'] <> '')) CAdminSubForm::closeSubForm(); } } // cancel vmesto dontsave if (!$changeTabs && !empty($dontsave) && check_bitrix_sessid()) { if($bWorkflow) CIBlockElement::WF_UnLock($ID); CAdminSubForm::closeSubForm(false); } }while(false); if($error && $error->err_level==1) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); CAdminMessage::ShowOldStyleError($error->GetErrorText()); } else { if(!$arIBlock["ELEMENT_NAME"]) $arIBlock["ELEMENT_NAME"] = $arIBTYPE["ELEMENT_NAME"]? $arIBTYPE["ELEMENT_NAME"]: GetMessage("IBEL_E_IBLOCK_ELEMENT"); if(!$arIBlock["SECTIONS_NAME"]) $arIBlock["SECTIONS_NAME"] = $arIBTYPE["SECTION_NAME"]? $arIBTYPE["SECTION_NAME"]: GetMessage("IBEL_E_IBLOCK_SECTIONS"); ClearVars("str_"); ClearVars("str_prev_"); ClearVars("prn_"); $str_ACTIVE="Y"; $str_SORT="500"; $str_DETAIL_TEXT_TYPE="html"; $str_PREVIEW_TEXT_TYPE="html"; if(!$error && $bWorkflow && $view!="Y") { if(!$bSubCopy) CIBlockElement::WF_Lock($ID); else CIBlockElement::WF_UnLock($ID); } if($historyId <= 0 && $view=="Y") { $WF_ID = $ID; $ID = CIBlockElement::GetRealElement($ID); if($PREV_ID) { $prev_result = CIBlockElement::GetByID($PREV_ID); $prev_arElement = $prev_result->ExtractFields("str_prev_"); if(!$prev_arElement) $PREV_ID = 0; } } $str_ACTIVE = $arIBlock["FIELDS"]["ACTIVE"]["DEFAULT_VALUE"] === "N"? "N": "Y"; $str_NAME = htmlspecialcharsbx($arIBlock["FIELDS"]["NAME"]["DEFAULT_VALUE"]); if ('' != $strProductName) $str_NAME = htmlspecialcharsbx($strProductName); $str_CODE = ''; $str_XML_ID = ''; $str_TAGS = ''; $str_ACTIVE_FROM = ''; $str_ACTIVE_TO = ''; $currentTime = time() + CTimeZone::GetOffset(); if ($arIBlock["FIELDS"]["ACTIVE_FROM"]["DEFAULT_VALUE"] === "=now") $str_ACTIVE_FROM = ConvertTimeStamp($currentTime, "FULL"); elseif ($arIBlock["FIELDS"]["ACTIVE_FROM"]["DEFAULT_VALUE"] === "=today") $str_ACTIVE_FROM = ConvertTimeStamp($currentTime, "SHORT"); $dayOffset = (int)$arIBlock["FIELDS"]["ACTIVE_TO"]["DEFAULT_VALUE"]; if ($dayOffset > 0) $str_ACTIVE_TO = ConvertTimeStamp($currentTime + $dayOffset*86400, "FULL"); unset($dayOffset); unset($currentTime); $str_PREVIEW_TEXT_TYPE = $arIBlock["FIELDS"]["PREVIEW_TEXT_TYPE"]["DEFAULT_VALUE"] !== "html"? "text": "html"; $str_PREVIEW_TEXT = htmlspecialcharsbx($arIBlock["FIELDS"]["PREVIEW_TEXT"]["DEFAULT_VALUE"]); $str_DETAIL_TEXT_TYPE = $arIBlock["FIELDS"]["DETAIL_TEXT_TYPE"]["DEFAULT_VALUE"] !== "html"? "text": "html"; $str_DETAIL_TEXT = htmlspecialcharsbx($arIBlock["FIELDS"]["DETAIL_TEXT"]["DEFAULT_VALUE"]); if ($historyId > 0) { $view = "Y"; foreach ($arResult["DOCUMENT"]["FIELDS"] as $k => $v) ${"str_".$k} = $v; } else { $result = CIBlockElement::GetByID($WF_ID); if ($arElement = $result->ExtractFields("str_")) { } else { $WF_ID=0; $ID=0; } } if ($bSubCopy) $str_XML_ID = ""; if($ID > 0 && !$bSubCopy) { if($view=="Y") $APPLICATION->SetTitle($arIBlock["NAME"].": ".$arIBlock["ELEMENT_NAME"].": ".$arElement["NAME"]." - ".GetMessage("IBLOCK_ELEMENT_EDIT_VIEW")); else $APPLICATION->SetTitle($arIBlock["NAME"].": ".$arIBlock["ELEMENT_NAME"].": ".$arElement["NAME"]." - ".GetMessage("IBLOCK_EDIT_TITLE")); } else { $APPLICATION->SetTitle($arIBlock["NAME"].": ".$arIBlock["ELEMENT_NAME"].": ".GetMessage("IBLOCK_NEW_TITLE")); } require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); $tabControl = new CAdminSubForm($bCustomForm? "tabControl_sub": "form_subelement_".$IBLOCK_ID, $aTabs, true, false, $arListUrl, BX_SUB_SETTINGS); if($bVarsFromForm) { $DB->InitTableVarsForEdit("b_iblock_element", "", "str_"); } $db_prop_values = false; //it is a db cache $arPROP_tmp = array(); $properties = CIBlockProperty::GetList( array("SORT"=>"ASC", "NAME"=>"ASC", "ID" => "ASC"), array("IBLOCK_ID"=>$IBLOCK_ID, "ACTIVE"=>"Y", "CHECK_PERMISSIONS"=>"N") ); while($prop_fields = $properties->Fetch()) { $prop_values = array(); $prop_values_with_descr = array(); if ($bVarsFromForm && $prop_fields["PROPERTY_TYPE"] == Iblock\PropertyTable::TYPE_FILE) { if ($db_prop_values === false) { $db_prop_values = array(); $rs_prop_values = CIBlockElement::GetProperty($IBLOCK_ID, $WF_ID, "id", "asc", array("EMPTY" => "N")); while ($res = $rs_prop_values->Fetch()) { $db_prop_values[$res["ID"]][] = $res; } } if (isset($db_prop_values[$prop_fields["ID"]])) { foreach ($db_prop_values[$prop_fields["ID"]] as $res) { $prop_values[$res["PROPERTY_VALUE_ID"]] = $res["VALUE"]; $prop_values_with_descr[$res["PROPERTY_VALUE_ID"]] = array("VALUE" => $res["VALUE"], "DESCRIPTION" => $res["DESCRIPTION"]); } } } elseif ($bVarsFromForm && is_array($PROP)) { if (array_key_exists($prop_fields["ID"], $PROP)) $prop_values = $PROP[$prop_fields["ID"]]; else $prop_values = $PROP[$prop_fields["CODE"]]; $prop_values_with_descr = $prop_values; } elseif ($bVarsFromForm) { $prop_values = ""; $prop_values_with_descr = $prop_values; } elseif ($historyId > 0) { $vx = $arResult["DOCUMENT"]["PROPERTIES"][(trim($prop_fields["CODE"]) <> '') ? $prop_fields["CODE"] : $prop_fields["ID"]]; $prop_values = array(); if (is_array($vx["VALUE"]) && is_array($vx["DESCRIPTION"])) { for ($i = 0, $cnt = count($vx["VALUE"]); $i < $cnt; $i++) $prop_values[] = array("VALUE" => $vx["VALUE"][$i], "DESCRIPTION" => $vx["DESCRIPTION"][$i]); } else { $prop_values[] = array("VALUE" => $vx["VALUE"], "DESCRIPTION" => $vx["DESCRIPTION"]); } $prop_values_with_descr = $prop_values; } elseif($ID>0) { if ($db_prop_values === false) { $db_prop_values = array(); $rs_prop_values = CIBlockElement::GetProperty($IBLOCK_ID, $WF_ID, "id", "asc", array("EMPTY"=>"N")); while ($res = $rs_prop_values->Fetch()) $db_prop_values[$res["ID"]][] = $res; } if (isset($db_prop_values[$prop_fields["ID"]])) { foreach ($db_prop_values[$prop_fields["ID"]] as $res) { if($res["WITH_DESCRIPTION"]=="Y") $prop_values[$res["PROPERTY_VALUE_ID"]] = array("VALUE"=>$res["VALUE"], "DESCRIPTION"=>$res["DESCRIPTION"]); else $prop_values[$res["PROPERTY_VALUE_ID"]] = $res["VALUE"]; $prop_values_with_descr[$res["PROPERTY_VALUE_ID"]] = array("VALUE"=>$res["VALUE"], "DESCRIPTION"=>$res["DESCRIPTION"]); } } } $prop_fields["VALUE"] = $prop_values; $prop_fields["~VALUE"] = $prop_values_with_descr; $arPROP_tmp[$prop_fields["ID"]] = $prop_fields; } $PROP = $arPROP_tmp; if (0 == $ID) { foreach ($PROP as $strCode => $arProperty) { if ($arSubCatalog['SKU_PROPERTY_ID'] == $arProperty['ID']) { $arProperty['VALUE'] = array( 'n0' => array( 'VALUE' => $intProductID, ), ); $arProperty['~VALUE'] = $arProperty['VALUE']; $PROP[$strCode] = $arProperty; break; } } } if($error) CAdminMessage::ShowOldStyleError($error->GetErrorText()); $bFileman = CModule::IncludeModule("fileman"); $arTranslit = $arIBlock["FIELDS"]["CODE"]["DEFAULT_VALUE"]; $bLinked = (!isset($str_TIMESTAMP_X) || $bSubCopy) && (!isset($_POST["linked_state"]) || $_POST["linked_state"]!=='N'); ////////////////////////// //START of the custom form ////////////////////////// //We have to explicitly call calendar and editor functions because //first output may be discarded by form settings $nameFormat = CSite::GetNameFormat(); $tabControl->BeginPrologContent(); CJSCore::Init(array('date')); //TODO: this code only for old html editor. Need remove after final cut old editor if ( $bFileman && (string)Main\Config\Option::get('iblock', 'use_htmledit') == 'Y' && (string)Main\Config\Option::get('fileman', 'use_editor_3', 'Y') != 'Y' ) { echo '
'; CFileMan::AddHTMLEditorFrame("SUB_SOME_TEXT", "", "SUB_SOME_TEXT_TYPE", "text", array('height' => 450, 'width' => '100%'), "N", 0, "", "", $arIBlock["LID"] ); echo '
'; } if($arTranslit["TRANSLITERATION"] == "Y") { CJSCore::Init(array('window','translit')); ?> EndPrologContent(); $tabControl->BeginEpilogContent(); echo bitrix_sessid_post(); echo GetFilterHiddens("find_");?> 0 && !$bSubCopy) { ?> EndEpilogContent(); $customTabber->SetErrorState($bVarsFromForm); $tabControl->AddTabs($customTabber); $strFormAction = CIBlock::GetAdminSubElementEditLink( $IBLOCK_ID, $intProductID, ($ID>0 && !$bSubCopy ? $ID : 0), array('WF' => $WF,), '', !BX_SUB_SETTINGS ); $tabControl->Begin(array( "FORM_ACTION" => $strFormAction, )); $tabControl->BeginNextFormTab(); if($ID > 0 && !$bSubCopy) { $p = CIblockElement::GetByID($ID); $pr = $p->ExtractFields("prn_"); } else { $pr = array(); } $tabControl->BeginCustomField("SUB_ID", "ID:"); if ($ID > 0 && !$bSubCopy) { ?> GetCustomLabelHTML()?> EndCustomField("SUB_ID", ''); $tabControl->BeginCustomField("SUB_DATE_CREATE", GetMessage("IBLOCK_SUB_FIELD_CREATED").":"); if ($ID > 0 && !$bSubCopy) { if ($str_DATE_CREATE <> ''):?> GetCustomLabelHTML() ?> 0):?> [
Warning: Undefined variable $str_CREATED_BY in D:\ktt\ttepla.com\public_html\bitrix\modules\iblock\admin\iblock_subelement_edit.php on line 1423
] [