protected static function getGroupsIds(array $productIds) { $groupsIds = array(); $res = \CIBlockElement::GetElementGroups($productIds, true, array('ID')); while ($group = $res->Fetch()) { if (!in_array($group['ID'], $groupsIds)) { $groupsIds[] = $group['ID']; } } return $groupsIds; }
function SendRemindEventAgent($iblockId, $taskId, $pathTemplate) { if (!CModule::IncludeModule("socialnetwork") && !CModule::IncludeModule("iblock")) { return; } $iblockId = IntVal($iblockId); $taskId = IntVal($taskId); if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) { $bTmpUser = True; $GLOBALS["USER"] = new CUser(); } $arTasksCustomProps = array(); $dbTasksCustomProps = CIBlockProperty::GetList(array("sort" => "asc", "name" => "asc"), array("ACTIVE" => "Y", "IBLOCK_ID" => $iblockId, "CHECK_PERMISSIONS" => "N")); while ($arTasksCustomProp = $dbTasksCustomProps->Fetch()) { $ind = StrLen($arTasksCustomProp["CODE"]) > 0 ? $arTasksCustomProp["CODE"] : $arTasksCustomProp["ID"]; $arTasksCustomProps[StrToUpper($ind)] = $arTasksCustomProp; } $dbTasksList = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "ID" => $taskId, "CHECK_PERMISSIONS" => "N"), false, false, array("ID", "NAME", "IBLOCK_ID", "CREATED_BY", "PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"])); while ($arTask = $dbTasksList->GetNext()) { $ar = array(); $dbElementSections = CIBlockElement::GetElementGroups($arTask["ID"]); while ($arElementSection = $dbElementSections->Fetch()) { if ($arElementSection["IBLOCK_ID"] == $iblockId) { $ar[] = $arElementSection["ID"]; } } if (Count($ar) <= 0) { continue; } $taskType = ""; $taskOwnerId = 0; $dbSectionsChain = CIBlockSection::GetNavChain($iblockId, $ar[0]); if ($arSect = $dbSectionsChain->Fetch()) { $taskType = $arSect["XML_ID"] == "users_tasks" ? "user" : "group"; $taskOwnerId = IntVal($taskType == "user" ? $arTask["PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"] . "_VALUE"] : $arSect["XML_ID"]); } if (!In_Array($taskType, array("user", "group")) || $taskOwnerId <= 0) { continue; } $path2view = ($GLOBALS["APPLICATION"]->IsHTTPS() ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . CComponentEngine::MakePathFromTemplate($pathTemplate, array("owner_id" => $taskOwnerId, "task_id" => $arTask["ID"], "action" => "view")); $arMessageFields = array("=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE_TYPE" => SONET_MESSAGE_SYSTEM, "FROM_USER_ID" => $arTask["CREATED_BY"], "TO_USER_ID" => $arTask["PROPERTY_" . $arTasksCustomProps["TASKASSIGNEDTO"]["ID"] . "_VALUE"], "MESSAGE" => str_replace(array("#URL_VIEW#", "#NAME#"), array($path2view, $arTask["NAME"]), GetMessage("INTE_REMIND_TASK_MESSAGE"))); CSocNetMessages::Add($arMessageFields); //CIBlockElement::SetPropertyValueCode($arTask["ID"], $arTasksCustomProps["TASKREMIND"]["ID"], false); } if ($bTmpUser) { unset($GLOBALS["USER"]); } //return "CIntranetTasks::SendRemindEventAgent($iblockId, $taskId, \"$pathTemplate\");"; }
function __InTaskDeleteTask($delTaskId, $iblockId, $taskType, $ownerId, $arParams) { $delTaskId = IntVal($delTaskId); $iblockId = IntVal($iblockId); $ownerId = IntVal($ownerId); if ($delTaskId <= 0 || $iblockId <= 0 || $ownerId <= 0) { return ""; } $errorMessage = ""; if (StrLen($errorMessage) <= 0) { $sectionId = 0; $dbElementSections = CIBlockElement::GetElementGroups($delTaskId); while ($arElementSection = $dbElementSections->Fetch()) { if ($arElementSection["IBLOCK_ID"] == $iblockId) { $sectionId = $arElementSection["ID"]; break; } } if ($sectionId <= 0) { $errorMessage .= GetMessage("INTL_TASK_NOT_FOUND") . "."; } } if (StrLen($errorMessage) <= 0) { $dbSectionsChain = CIBlockSection::GetNavChain($iblockId, $sectionId); if ($arSect = $dbSectionsChain->GetNext()) { if ($taskType == 'group' && $arSect["XML_ID"] != $ownerId) { $errorMessage .= GetMessage("INTL_TASK_INTERNAL_ERROR") . " GTK003" . ". "; } elseif ($taskType != 'group' && $arSect["XML_ID"] != "users_tasks") { $errorMessage .= GetMessage("INTL_TASK_INTERNAL_ERROR") . " GTK004" . ". "; } } else { $errorMessage .= GetMessage("INTL_FOLDER_NOT_FOUND") . ". "; } } if (StrLen($errorMessage) <= 0) { if (!CIBlockElement::Delete($delTaskId)) { $errorMessage .= GetMessage("INTL_ERROR_DELETE_TASK") . ". "; } CAgent::RemoveAgent("CIntranetTasks::SendRemindEventAgent(" . $iblockId . ", " . $delTaskId . ", \"" . $arParams[$taskType == "user" ? "PATH_TO_USER_TASKS_TASK" : "PATH_TO_GROUP_TASKS_TASK"] . "\");", "intranet"); } return $errorMessage; }
/** * ћетод публикует документ. “о есть делает его доступным в публичной части сайта. * * @param string $documentId - код документа. */ public function PublishDocument($documentId) { global $DB; $ID = intval($documentId); $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID")); if ($ar_element = $db_element->Fetch()) { $PARENT_ID = intval($ar_element["WF_PARENT_ELEMENT_ID"]); if ($PARENT_ID) { // TODO: ≈сли в документе $documentId поле WF_PARENT_ELEMENT_ID не NULL, то при публикации нужно перенести данные // (скопировать документ) из документа $documentId в документ WF_PARENT_ELEMENT_ID, $obElement = new CIBlockElement(); $ar_element["WF_PARENT_ELEMENT_ID"] = false; if ($ar_element["PREVIEW_PICTURE"]) { $ar_element["PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element["PREVIEW_PICTURE"]); } else { $ar_element["PREVIEW_PICTURE"] = array("tmp_name" => "", "del" => "Y"); } if ($ar_element["DETAIL_PICTURE"]) { $ar_element["DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element["DETAIL_PICTURE"]); } else { $ar_element["DETAIL_PICTURE"] = array("tmp_name" => "", "del" => "Y"); } $ar_element["IBLOCK_SECTION"] = array(); if ($ar_element["IN_SECTIONS"] == "Y") { $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $ar_element["IBLOCK_SECTION"][] = $arSection["ID"]; } } $ar_element["PROPERTY_VALUES"] = array(); $arProps =& $ar_element["PROPERTY_VALUES"]; //Delete old files $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $PARENT_ID, array("value_id" => "asc"), array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $rsProps->Fetch()) { if (!array_key_exists($arProp["ID"], $arProps)) { $arProps[$arProp["ID"]] = array(); } $arProps[$arProp["ID"]][$arProp["PROPERTY_VALUE_ID"]] = array("VALUE" => array("tmp_name" => "", "del" => "Y"), "DESCRIPTION" => false); } //Add new proiperty values $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_element["ID"], array("value_id" => "asc")); $i = 0; while ($arProp = $rsProps->Fetch()) { $i++; if (!array_key_exists($arProp["ID"], $arProps)) { $arProps[$arProp["ID"]] = array(); } if ($arProp["PROPERTY_VALUE_ID"]) { if ($arProp["PROPERTY_TYPE"] == "F") { $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => CFile::MakeFileArray($arProp["VALUE"]), "DESCRIPTION" => $arProp["DESCRIPTION"]); } else { $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } $obElement->Update($PARENT_ID, $ar_element); // вызвать CBPDocument::MergeDocuments(WF_PARENT_ELEMENT_ID, $documentId) дл¤ переноса состо¤ний и истории Ѕѕ, CBPDocument::MergeDocuments(array("lists", "BizprocDocument", $PARENT_ID), array("lists", "BizprocDocument", $documentId)); // грохнуть документ $documentId, CIBlockElement::Delete($ID); // опубликовать документ WF_PARENT_ELEMENT_ID CIBlockElement::WF_CleanUpHistoryCopies($PARENT_ID, 0); $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $PARENT_ID . " AND WF_PARENT_ELEMENT_ID IS NULL"; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__); CIBlockElement::UpdateSearch($PARENT_ID); return $PARENT_ID; } else { // ≈сли WF_PARENT_ELEMENT_ID равно NULL, то все как раньше. CIBlockElement::WF_CleanUpHistoryCopies($ID, 0); $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $ID . " AND WF_PARENT_ELEMENT_ID IS NULL"; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__); CIBlockElement::UpdateSearch($ID); return $ID; } } return false; }
$arValues = ""; } } } else { $arValues = ""; } } else { $arValues = $arProperty["~VALUE"]; } $arPropsValues[$arProperty["ID"]] = $arValues; } } $arResSections = array(); if ($bNeedGroups) { $i = 0; $rsSections = CIBlockElement::GetElementGroups($arIBlockElement["ID"], false, array('ID', 'ADDITIONAL_PROPERTY_ID')); while ($arSection = $rsSections->Fetch()) { if (0 < intval($arSection['ADDITIONAL_PROPERTY_ID'])) { continue; } if (!isset($arCacheChains[$arSection['ID']])) { $arPath = array(); $j = 0; $rsPath = CIBlockSection::GetNavChain($IBLOCK_ID, $arSection["ID"]); while ($arPathSection = $rsPath->Fetch()) { if (!empty($arGroupProps[$j])) { foreach ($arGroupProps[$j] as &$key) { $field = $arAvailGroupFields_names[$key]['field']; if ('IC_PICTURE' == $key || 'IC_DETAIL_PICTURE' == $key) { if ('Y' == $export_files) { $arPathSection[$field] = __CSVExportFile($arPathSection[$field], $strExportPath, $strFilePath);
function GetGroups() { $res = CIBlockElement::GetElementGroups($this->fields["ID"]); return $res; }
public static function GetProductSections($ID) { global $stackCacheManager; $ID = intval($ID); if (0 >= $ID) return false; $cacheTime = CATALOG_CACHE_DEFAULT_TIME; if (defined("CATALOG_CACHE_TIME")) $cacheTime = intval(CATALOG_CACHE_TIME); $arProductSections = array(); $dbElementSections = CIBlockElement::GetElementGroups($ID, false, array("ID", "ADDITIONAL_PROPERTY_ID")); while ($arElementSections = $dbElementSections->Fetch()) { if (0 < intval($arElementSections['ADDITIONAL_PROPERTY_ID'])) continue; $arSectionsTmp = array(); $strCacheKey = "p".$arElementSections["ID"]; $stackCacheManager->SetLength("catalog_group_parents", 50); $stackCacheManager->SetTTL("catalog_group_parents", $cacheTime); if ($stackCacheManager->Exist("catalog_group_parents", $strCacheKey)) { $arSectionsTmp = $stackCacheManager->Get("catalog_group_parents", $strCacheKey); } else { $dbSection = CIBlockSection::GetList( array(), array('ID' => $arElementSections["ID"]), false, $arSelect = array( 'ID', 'IBLOCK_ID', 'LEFT_MARGIN', 'RIGHT_MARGIN', ) ); if ($arSection = $dbSection->Fetch()) { $dbSectionTree = CIBlockSection::GetList( array("LEFT_MARGIN" => "DESC"), array( "IBLOCK_ID" => $arSection["IBLOCK_ID"], "ACTIVE" => "Y", "GLOBAL_ACTIVE" => "Y", "IBLOCK_ACTIVE" => "Y", "<=LEFT_BORDER" => $arSection["LEFT_MARGIN"], ">=RIGHT_BORDER" => $arSection["RIGHT_MARGIN"] ) ); while ($arSectionTree = $dbSectionTree->Fetch()) { if (!in_array($arSectionTree["ID"], $arProductSections)) $arSectionsTmp[] = $arSectionTree["ID"]; } } $stackCacheManager->Set("catalog_group_parents", $strCacheKey, $arSectionsTmp); } $arProductSections = array_merge($arProductSections, $arSectionsTmp); } $arProductSections = array_unique($arProductSections); return $arProductSections; }
function exportElementFields($arElement, $SECTION_MAP) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_NAME") . ">" . htmlspecialcharsbx($arElement["NAME"]) . "</" . GetMessage("IBLOCK_XML2_NAME") . ">\n"); if ($this->bExtended) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_BX_TAGS") . ">" . htmlspecialcharsbx($arElement["TAGS"]) . "</" . GetMessage("IBLOCK_XML2_BX_TAGS") . ">\n"); } $arSections = array(); $rsSections = CIBlockElement::GetElementGroups($arElement["ID"], true); while ($arSection = $rsSections->Fetch()) { if (array_key_exists($arSection["ID"], $SECTION_MAP)) { $arSections[] = $SECTION_MAP[$arSection["ID"]]; } } fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_GROUPS") . ">\n"); foreach ($arSections as $xml_id) { fwrite($this->fp, "\t\t\t\t\t<" . GetMessage("IBLOCK_XML2_ID") . ">" . htmlspecialcharsbx($xml_id) . "</" . GetMessage("IBLOCK_XML2_ID") . ">\n"); } fwrite($this->fp, "\t\t\t\t</" . GetMessage("IBLOCK_XML2_GROUPS") . ">\n"); if (!$this->bExtended) { fwrite($this->fp, "\t\t\t\t<" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">" . htmlspecialcharsbx(FormatText($arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"])) . "</" . GetMessage("IBLOCK_XML2_DESCRIPTION") . ">\n"); } fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_PICTURE"), $this->ExportFile($arElement["DETAIL_PICTURE"]))); }
function Update($ID, $arFields, $bWorkFlow = false, $bUpdateSearch = true, $bResizePictures = false, $bCheckDiskQuota = true) { global $DB, $USER; $ID = intval($ID); $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID")); if (!($ar_element = $db_element->Fetch())) { return false; } $arIBlock = CIBlock::GetArrayByID($ar_element["IBLOCK_ID"]); $bWorkFlow = $bWorkFlow && is_array($arIBlock) && $arIBlock["WORKFLOW"] != "N" && CModule::IncludeModule("workflow"); $ar_wf_element = $ar_element; $LAST_ID = 0; if ($bWorkFlow) { $LAST_ID = CIBlockElement::WF_GetLast($ID); if ($LAST_ID != $ID) { $db_element = CIBlockElement::GetByID($LAST_ID); if (!($ar_wf_element = $db_element->Fetch())) { return false; } } $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (!array_key_exists("PROPERTY_VALUES", $arFields) || !is_array($arFields["PROPERTY_VALUES"])) { $arFields["PROPERTY_VALUES"] = array(); } $bFieldProps = array(); foreach ($arFields["PROPERTY_VALUES"] as $k => $v) { $bFieldProps[$k] = true; } $arFieldProps =& $arFields['PROPERTY_VALUES']; $props = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_wf_element["ID"]); while ($arProp = $props->Fetch()) { $pr_val_id = $arProp['PROPERTY_VALUE_ID']; if ($arProp['PROPERTY_TYPE'] == 'F' && strlen($pr_val_id) > 0) { if (strlen($arProp["CODE"]) > 0 && is_set($arFieldProps, $arProp["CODE"])) { $pr_id = $arProp["CODE"]; } else { $pr_id = $arProp['ID']; } if (array_key_exists($pr_id, $arFieldProps) && array_key_exists($pr_val_id, $arFieldProps[$pr_id]) && is_array($arFieldProps[$pr_id][$pr_val_id])) { $new_value = $arFieldProps[$pr_id][$pr_val_id]; if (strlen($new_value['name']) <= 0 && $new_value['del'] != "Y" && strlen($new_value['VALUE']['name']) <= 0 && $new_value['VALUE']['del'] != "Y") { if (array_key_exists('DESCRIPTION', $new_value) && $new_value['DESCRIPTION'] != $arProp['DESCRIPTION']) { $p = array("VALUE" => CFile::MakeFileArray($arProp['VALUE'])); $p["DESCRIPTION"] = $new_value["DESCRIPTION"]; $p["MODULE_ID"] = "iblock"; $arFieldProps[$pr_id][$pr_val_id] = $p; } elseif ($arProp['VALUE'] > 0) { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } else { $arFieldProps[$pr_id][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } continue; } if (strlen($pr_val_id) <= 0 || array_key_exists($arProp["ID"], $bFieldProps) || strlen($arProp["CODE"]) > 0 && array_key_exists($arProp["CODE"], $bFieldProps)) { continue; } $arFieldProps[$arProp["ID"]][$pr_val_id] = array("VALUE" => $arProp['VALUE'], "DESCRIPTION" => $arProp["DESCRIPTION"]); } if ($ar_wf_element["IN_SECTIONS"] == "Y") { $ar_wf_element["IBLOCK_SECTION"] = array(); $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $ar_wf_element["IBLOCK_SECTION"][] = $arSection["ID"]; } } unset($ar_wf_element["DATE_ACTIVE_FROM"]); unset($ar_wf_element["DATE_ACTIVE_TO"]); unset($ar_wf_element["EXTERNAL_ID"]); unset($ar_wf_element["TIMESTAMP_X"]); unset($ar_wf_element["ID"]); $arFields = $arFields + $ar_wf_element; } $arFields["WF"] = $bWorkFlow ? "Y" : "N"; $bBizProc = is_array($arIBlock) && $arIBlock["BIZPROC"] == "Y" && IsModuleInstalled("bizproc"); if (array_key_exists("BP_PUBLISHED", $arFields)) { if ($bBizProc) { if ($arFields["BP_PUBLISHED"] == "Y") { $arFields["WF_STATUS_ID"] = 1; $arFields["WF_NEW"] = false; } else { $arFields["WF_STATUS_ID"] = 2; $arFields["WF_NEW"] = "Y"; $arFields["BP_PUBLISHED"] = "N"; } } else { $arFields["WF_NEW"] = false; unset($arFields["BP_PUBLISHED"]); } } else { $arFields["WF_NEW"] = false; } if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") { $arFields["ACTIVE"] = "N"; } if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") { $arFields["PREVIEW_TEXT_TYPE"] = "text"; } if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") { $arFields["DETAIL_TEXT_TYPE"] = "text"; } $strWarning = ""; if ($bResizePictures) { $arDef = $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]; if ($arDef["DELETE_WITH_DETAIL"] === "Y" && $arFields["DETAIL_PICTURE"]["del"] === "Y") { $arFields["PREVIEW_PICTURE"]["del"] = "Y"; } if ($arDef["FROM_DETAIL"] === "Y" && ($arFields["PREVIEW_PICTURE"]["size"] <= 0 || $arDef["UPDATE_WITH_DETAIL"] === "Y") && is_array($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["size"] > 0) { if ($arFields["PREVIEW_PICTURE"]["del"] !== "Y" && $arDef["UPDATE_WITH_DETAIL"] !== "Y") { $rsElement = CIBlockElement::GetList(array("ID" => "DESC"), array("ID" => $ar_wf_element["ID"], "IBLOCK_ID" => $ar_wf_element["IBLOCK_ID"], "SHOW_HISTORY" => "Y"), false, false, array("ID", "PREVIEW_PICTURE")); $arOldElement = $rsElement->Fetch(); } else { $arOldElement = false; } if (!$arOldElement || !$arOldElement["PREVIEW_PICTURE"]) { $arNewPreview = $arFields["DETAIL_PICTURE"]; $arNewPreview["COPY_FILE"] = "Y"; $arNewPreview["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPreview; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["size"] > 0 && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["PREVIEW_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arFields["PREVIEW_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["PREVIEW_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_PREVIEW_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["PREVIEW_PICTURE"]["tmp_name"]) > 0 && ($arFields["PREVIEW_PICTURE"]["tmp_name"] === $arFields["DETAIL_PICTURE"]["tmp_name"] || $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["PREVIEW_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["PREVIEW_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["PREVIEW_PICTURE"]["tmp_name"], $tmp_name); $arFields["PREVIEW_PICTURE"]["copy"] = true; $arFields["PREVIEW_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["PREVIEW_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } $arDef = $arIBlock["FIELDS"]["DETAIL_PICTURE"]["DEFAULT_VALUE"]; if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["SCALE"] === "Y") { $arNewPicture = CIBlock::ResizePicture($arFields["DETAIL_PICTURE"], $arDef); if (is_array($arNewPicture)) { $arNewPicture["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arFields["DETAIL_PICTURE"] = $arNewPicture; } elseif ($arDef["IGNORE_ERRORS"] !== "Y") { unset($arFields["DETAIL_PICTURE"]); $strWarning .= GetMessage("IBLOCK_FIELD_DETAIL_PICTURE") . ": " . $arNewPicture . "<br>"; } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_FILE"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_FILE_POSITION"], "type" => "file", "size" => "real", "alpha_level" => 100 - min(max($arDef["WATERMARK_FILE_ALPHA"], 0), 100), "file" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_FILE"]))); } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"]) && $arDef["USE_WATERMARK_TEXT"] === "Y") { if (strlen($arFields["DETAIL_PICTURE"]["tmp_name"]) > 0 && ($arFields["DETAIL_PICTURE"]["tmp_name"] === $arFields["PREVIEW_PICTURE"]["tmp_name"] || $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && !$arFields["DETAIL_PICTURE"]["copy"])) { $tmp_name = CTempFile::GetFileName(basename($arFields["DETAIL_PICTURE"]["tmp_name"])); CheckDirPath($tmp_name); copy($arFields["DETAIL_PICTURE"]["tmp_name"], $tmp_name); $arFields["DETAIL_PICTURE"]["copy"] = true; $arFields["DETAIL_PICTURE"]["tmp_name"] = $tmp_name; } CIBLock::FilterPicture($arFields["DETAIL_PICTURE"]["tmp_name"], array("name" => "watermark", "position" => $arDef["WATERMARK_TEXT_POSITION"], "type" => "text", "coefficient" => $arDef["WATERMARK_TEXT_SIZE"], "text" => $arDef["WATERMARK_TEXT"], "font" => $_SERVER["DOCUMENT_ROOT"] . Rel2Abs("/", $arDef["WATERMARK_TEXT_FONT"]), "color" => $arDef["WATERMARK_TEXT_COLOR"])); } } $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($ar_element["IBLOCK_ID"], $ar_element["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields) && is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0 && !is_set($arFields["PREVIEW_PICTURE"], "description")) { unset($arFields["PREVIEW_PICTURE"]); } else { $arFields["PREVIEW_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"]["old_file"] = $ar_wf_element["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_PREVIEW_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["PREVIEW_PICTURE"]); } } if (array_key_exists("DETAIL_PICTURE", $arFields) && is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0 && !is_set($arFields["DETAIL_PICTURE"], "description")) { unset($arFields["DETAIL_PICTURE"]); } else { $arFields["DETAIL_PICTURE"]["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"]["old_file"] = $ar_wf_element["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"]["name"] = \Bitrix\Iblock\Template\Helper::makeFileName($ipropTemplates, "ELEMENT_DETAIL_PICTURE_FILE_NAME", array_merge($ar_element, $arFields), $arFields["DETAIL_PICTURE"]); } } if (is_set($arFields, "DATE_ACTIVE_FROM")) { $arFields["ACTIVE_FROM"] = $arFields["DATE_ACTIVE_FROM"]; } if (is_set($arFields, "DATE_ACTIVE_TO")) { $arFields["ACTIVE_TO"] = $arFields["DATE_ACTIVE_TO"]; } if (is_set($arFields, "EXTERNAL_ID")) { $arFields["XML_ID"] = $arFields["EXTERNAL_ID"]; } $PREVIEW_tmp = is_set($arFields, "PREVIEW_TEXT") ? $arFields["PREVIEW_TEXT"] : $ar_wf_element["PREVIEW_TEXT"]; $PREVIEW_TYPE_tmp = is_set($arFields, "PREVIEW_TEXT_TYPE") ? $arFields["PREVIEW_TEXT_TYPE"] : $ar_wf_element["PREVIEW_TEXT_TYPE"]; $DETAIL_tmp = is_set($arFields, "DETAIL_TEXT") ? $arFields["DETAIL_TEXT"] : $ar_wf_element["DETAIL_TEXT"]; $DETAIL_TYPE_tmp = is_set($arFields, "DETAIL_TEXT_TYPE") ? $arFields["DETAIL_TEXT_TYPE"] : $ar_wf_element["DETAIL_TEXT_TYPE"]; $arFields["SEARCHABLE_CONTENT"] = ToUpper((is_set($arFields, "NAME") ? $arFields["NAME"] : $ar_wf_element["NAME"]) . "\r\n" . ($PREVIEW_TYPE_tmp == "html" ? HTMLToTxt($PREVIEW_tmp) : $PREVIEW_tmp) . "\r\n" . ($DETAIL_TYPE_tmp == "html" ? HTMLToTxt($DETAIL_tmp) : $DETAIL_tmp)); if (is_set($arFields["IBLOCK_SECTION_ID"]) && !is_set($arFields, "IBLOCK_SECTION")) { $arFields["IBLOCK_SECTION"] = array($arFields["IBLOCK_SECTION_ID"]); } $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; if (!$this->CheckFields($arFields, $ID, $bCheckDiskQuota) || strlen($strWarning)) { $this->LAST_ERROR .= $strWarning; $Result = false; $arFields["RESULT_MESSAGE"] =& $this->LAST_ERROR; } else { unset($arFields["ID"]); if (array_key_exists("PREVIEW_PICTURE", $arFields)) { $SAVED_PREVIEW_PICTURE = $arFields["PREVIEW_PICTURE"]; } else { $SAVED_PREVIEW_PICTURE = false; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { $SAVED_DETAIL_PICTURE = $arFields["DETAIL_PICTURE"]; } else { $SAVED_DETAIL_PICTURE = false; } // edit was done in workflow mode if ($bWorkFlow) { $arFields["WF_PARENT_ELEMENT_ID"] = $ID; if (array_key_exists("PREVIEW_PICTURE", $arFields)) { if (is_array($arFields["PREVIEW_PICTURE"])) { if (strlen($arFields["PREVIEW_PICTURE"]["name"]) <= 0 && strlen($arFields["PREVIEW_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["PREVIEW_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["PREVIEW_PICTURE"]); if ($arFields["PREVIEW_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["PREVIEW_PICTURE"]); $arNewFile["description"] = $arFields["PREVIEW_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["PREVIEW_PICTURE"] = $arNewFile; } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { //File was not changed at all $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } } else { unset($arFields["PREVIEW_PICTURE"]["old_file"]); } } } else { $arFields["PREVIEW_PICTURE"] = $ar_wf_element["PREVIEW_PICTURE"]; } if (array_key_exists("DETAIL_PICTURE", $arFields)) { if (is_array($arFields["DETAIL_PICTURE"])) { if (strlen($arFields["DETAIL_PICTURE"]["name"]) <= 0 && strlen($arFields["DETAIL_PICTURE"]["del"]) <= 0) { if (array_key_exists("description", $arFields["DETAIL_PICTURE"])) { $arFile = CFile::GetFileArray($ar_wf_element["DETAIL_PICTURE"]); if ($arFields["DETAIL_PICTURE"]["description"] != $arFile["DESCRIPTION"]) { //Description updated, so it's new file $arNewFile = CFile::MakeFileArray($ar_wf_element["DETAIL_PICTURE"]); $arNewFile["description"] = $arFields["DETAIL_PICTURE"]["description"]; $arNewFile["MODULE_ID"] = "iblock"; $arFields["DETAIL_PICTURE"] = $arNewFile; } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { //File was not changed at all $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } } else { unset($arFields["DETAIL_PICTURE"]["old_file"]); } } } else { $arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"]; } $NID = $this->Add($arFields); if ($NID > 0) { if ($arFields["WF_STATUS_ID"] == 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE ID=" . $ID); $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE WF_PARENT_ELEMENT_ID=" . $ID); $ar_wf_element["WF_NEW"] = false; } if ($this->bWF_SetMove) { CIBlockElement::WF_SetMove($NID, $LAST_ID); } if ($ar_element["WF_STATUS_ID"] != 1 && $ar_wf_element["WF_STATUS_ID"] != $arFields["WF_STATUS_ID"] && $arFields["WF_STATUS_ID"] != 1) { $DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_STATUS_ID=" . $arFields["WF_STATUS_ID"] . " WHERE ID=" . $ID); } } //element was not published, so keep original if (is_set($arFields, "WF_STATUS_ID") && $arFields["WF_STATUS_ID"] != 1 && $ar_element["WF_STATUS_ID"] == 1 || !is_set($arFields, "WF_STATUS_ID") && $ar_wf_element["WF_STATUS_ID"] != 1) { CIBlockElement::WF_CleanUpHistoryCopies($ID); return true; } $arFields['WF_PARENT_ELEMENT_ID'] = false; $rs = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = " . $NID); $ar_new_element = $rs->Fetch(); } else { $ar_new_element = false; } if ($ar_new_element) { if (!intval($ar_new_element["PREVIEW_PICTURE"])) { $arFields["PREVIEW_PICTURE"] = false; } else { $arFields["PREVIEW_PICTURE"] = $ar_new_element["PREVIEW_PICTURE"]; } if (!intval($ar_new_element["DETAIL_PICTURE"])) { $arFields["DETAIL_PICTURE"] = false; } else { $arFields["DETAIL_PICTURE"] = $ar_new_element["DETAIL_PICTURE"]; } if (is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { $i = 0; $db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F")); while ($arProp = $db_prop->Fetch()) { $i++; unset($arFields["PROPERTY_VALUES"][$arProp["CODE"]]); unset($arFields["PROPERTY_VALUES"][$arProp["ID"]]); $arFields["PROPERTY_VALUES"][$arProp["ID"]] = array(); } if ($i > 0) { //Delete previous files $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $ID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => array("del" => "Y"), "DESCRIPTION" => false); } //Add copy from history $arDup = array(); //This is cure for files duplication bug (just save element one more time) $props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $NID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N")); while ($arProp = $props->Fetch()) { if (!array_key_exists($arProp["VALUE"], $arDup)) { $arFields["PROPERTY_VALUES"][$arProp["ID"]][$arProp['PROPERTY_VALUE_ID']] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); $arDup[$arProp["VALUE"]] = true; //This is cure for files duplication bug } } } } } else { if (array_key_exists("PREVIEW_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "PREVIEW_PICTURE", "iblock"); } if (array_key_exists("DETAIL_PICTURE", $arFields)) { CFile::SaveForDB($arFields, "DETAIL_PICTURE", "iblock"); } } unset($arFields["IBLOCK_ID"]); unset($arFields["WF_NEW"]); unset($arFields["IBLOCK_SECTION_ID"]); $bTimeStampNA = false; if (is_set($arFields, "TIMESTAMP_X") && ($arFields["TIMESTAMP_X"] === NULL || $arFields["TIMESTAMP_X"] === false)) { $bTimeStampNA = true; unset($arFields["TIMESTAMP_X"]); } $strUpdate = $DB->PrepareUpdate("b_iblock_element", $arFields, "iblock"); if (strlen($strUpdate) > 0) { $strUpdate .= ", "; } $strSql = "UPDATE b_iblock_element SET " . $strUpdate . ($bTimeStampNA ? "TIMESTAMP_X=TIMESTAMP_X" : "TIMESTAMP_X=now()") . " WHERE ID=" . $ID; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); if (array_key_exists("PROPERTY_VALUES", $arFields) && is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) { CIBlockElement::SetPropertyValues($ID, $ar_element["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]); } if (is_set($arFields, "IBLOCK_SECTION")) { CIBlockElement::SetElementSection($ID, $arFields["IBLOCK_SECTION"], false, $arIBlock["RIGHTS_MODE"] === "E" ? $arIBlock["ID"] : 0); } if ($arIBlock["RIGHTS_MODE"] === "E") { $obElementRights = new CIBlockElementRights($arIBlock["ID"], $ID); if (array_key_exists("RIGHTS", $arFields) && is_array($arFields["RIGHTS"])) { $obElementRights->SetRights($arFields["RIGHTS"]); } } if (array_key_exists("IPROPERTY_TEMPLATES", $arFields)) { $ipropTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($arIBlock["ID"], $ID); $ipropTemplates->set($arFields["IPROPERTY_TEMPLATES"]); } if ($bUpdateSearch) { CIBlockElement::UpdateSearch($ID, true); } if ($bWorkFlow) { CIBlockElement::WF_CleanUpHistoryCopies($ID); } //Restore saved values if ($SAVED_PREVIEW_PICTURE !== false) { $arFields["PREVIEW_PICTURE_ID"] = $arFields["PREVIEW_PICTURE"]; $arFields["PREVIEW_PICTURE"] = $SAVED_PREVIEW_PICTURE; } else { unset($arFields["PREVIEW_PICTURE"]); } if ($SAVED_DETAIL_PICTURE !== false) { $arFields["DETAIL_PICTURE_ID"] = $arFields["DETAIL_PICTURE"]; $arFields["DETAIL_PICTURE"] = $SAVED_DETAIL_PICTURE; } else { unset($arFields["DETAIL_PICTURE"]); } if ($arIBlock["FIELDS"]["LOG_ELEMENT_EDIT"]["IS_REQUIRED"] == "Y") { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $arEvents = GetModuleEvents("main", "OnBeforeEventLog", true); if (empty($arEvents) || ExecuteModuleEventEx($arEvents[0], array($USER_ID)) === false) { $rsElement = CIBlockElement::GetList(array(), array("=ID" => $ID, "CHECK_PERMISSIONS" => "N", "SHOW_NEW" => "Y"), false, false, array("ID", "NAME", "LIST_PAGE_URL", "CODE")); $arElement = $rsElement->GetNext(); $res = array("ID" => $ID, "CODE" => $arElement["CODE"], "NAME" => $arElement["NAME"], "ELEMENT_NAME" => $arIBlock["ELEMENT_NAME"], "USER_ID" => $USER_ID, "IBLOCK_PAGE_URL" => $arElement["LIST_PAGE_URL"]); CEventLog::Log("IBLOCK", "IBLOCK_ELEMENT_EDIT", "iblock", $arIBlock["ID"], serialize($res)); } } $Result = true; /************* QUOTA *************/ $_SESSION["SESS_RECOUNT_DB"] = "Y"; /************* QUOTA *************/ } $arFields["ID"] = $ID; $arFields["IBLOCK_ID"] = $ar_element["IBLOCK_ID"]; $arFields["RESULT"] =& $Result; if (isset($arFields["PREVIEW_PICTURE"]) && $arFields["PREVIEW_PICTURE"]["COPY_FILE"] == "Y" && $arFields["PREVIEW_PICTURE"]["copy"]) { @unlink($arFields["PREVIEW_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["PREVIEW_PICTURE"]["tmp_name"])); } if (isset($arFields["DETAIL_PICTURE"]) && $arFields["DETAIL_PICTURE"]["COPY_FILE"] == "Y" && $arFields["DETAIL_PICTURE"]["copy"]) { @unlink($arFields["DETAIL_PICTURE"]["tmp_name"]); @rmdir(dirname($arFields["DETAIL_PICTURE"]["tmp_name"])); } foreach (GetModuleEvents("iblock", "OnAfterIBlockElementUpdate", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array(&$arFields)); } if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->ClearByTag("iblock_id_" . $arIBlock["ID"]); } return $Result; }
$new_section = intval($_REQUEST["section_to_move"]); if ($new_section >= 0) { if ($TYPE == "S") { if (CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $new_section, "section_section_bind")) { $obS = new CIBlockSection(); if (!$obS->Update($ID, array("IBLOCK_SECTION_ID" => $new_section))) { $lAdmin->AddGroupError(GetMessage("IBLIST_A_SAVE_ERROR", array("#ID#" => $ID, "#ERROR_MESSAGE#" => $obS->LAST_ERROR)), $TYPE . $ID); } } else { $lAdmin->AddGroupError(GetMessage("IBLIST_A_UPDERR_ACCESS", array("#ID#" => $ID)), $TYPE . $ID); } } elseif ($TYPE == "E") { if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit") && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $new_section, "section_element_bind")) { $obE = new CIBlockElement(); $arSections = array(); $rsSections = $obE->GetElementGroups($ID, true); while ($ar = $rsSections->Fetch()) { $arSections[$ar["ID"]] = $ar["ID"]; } if ($_REQUEST['action'] == "section") { $arSections[$section_id] = $new_section; } else { $arSections[$new_section] = $new_section; } if (!$obE->Update($ID, array("IBLOCK_SECTION" => $arSections))) { $lAdmin->AddGroupError(GetMessage("IBLIST_A_SAVE_ERROR", array("#ID#" => $ID, "#ERROR_MESSAGE#" => $obE->LAST_ERROR)), $TYPE . $ID); } } else { $lAdmin->AddGroupError(GetMessage("IBLIST_A_UPDERR_ACCESS", array("#ID#" => $ID)), $TYPE . $ID); } }
} } } } else { //We will not update property values unset($arFields["PROPERTY_VALUES"]); } //All not displayed required fields from DB foreach ($arSubIBlock["FIELDS"] as $FIELD_ID => $field) { if ($field["IS_REQUIRED"] === "Y" && !array_key_exists($FIELD_ID, $arFields) && $FIELD_ID !== "DETAIL_PICTURE" && $FIELD_ID !== "PREVIEW_PICTURE") { $arFields[$FIELD_ID] = $arRes[$FIELD_ID]; } } if ($arRes["IN_SECTIONS"] == "Y") { $arFields["IBLOCK_SECTION"] = array(); $rsSections = CIBlockElement::GetElementGroups($arRes["ID"], true); while ($arSection = $rsSections->Fetch()) { $arFields["IBLOCK_SECTION"][] = $arSection["ID"]; } } $arFields["MODIFIED_BY"] = $USER->GetID(); $ib = new CIBlockElement(); $DB->StartTransaction(); if (!$ib->Update($subID, $arFields, true, true, true)) { $lAdmin->AddUpdateError(GetMessage("IBEL_A_SAVE_ERROR", array("#ID#" => $subID, "#ERROR_TEXT#" => $ib->LAST_ERROR)), $subID); $DB->Rollback(); } else { $DB->Commit(); } if ($boolSubCatalog) { if ($USER->CanDoOperation('catalog_price') && CIBlockElementRights::UserHasRightTo($intSubIBlockID, $subID, "element_edit_price")) {
$minPriceRUR = $tmpPrice; $minPrice = $arAcc["CATALOG_PRICE_" . $arPTypes[$i]]; $minPriceGroup = $arPTypes[$i]; $minPriceCurrency = $arAcc["CATALOG_CURRENCY_" . $arPTypes[$i]]; if ($minPriceCurrency != "USD" && $minPriceCurrency != "RUR") { $minPriceCurrency = "RUR"; $minPrice = $tmpPrice; } } } if ($minPrice <= 0) { continue; } $bNoActiveGroup = True; $strTmpOff_tmp = ""; $db_res1 = CIBlockElement::GetElementGroups($arAcc["ID"]); while ($ar_res1 = $db_res1->Fetch()) { if (in_array(IntVal($ar_res1["ID"]), $arSectionIDs)) { $strTmpOff_tmp .= "<categoryId>" . $ar_res1["ID"] . "</categoryId>\n"; $bNoActiveGroup = False; } } if ($bNoActiveGroup) { continue; } $strTmpOff .= "<offer id=\"" . $arAcc["ID"] . "\">\n"; $strTmpOff .= "<url>http://" . COption::GetOptionString("main", "server_name", "") . $arAcc["DETAIL_PAGE_URL"] . "&r1=<?echo \$_GET[\"referer1\"] ?>&r2=<?echo \$_GET[\"referer2\"] ?></url>\n"; $strTmpOff .= "<price>" . $minPrice . "</price>\n"; $strTmpOff .= "<currencyId>" . $minPriceCurrency . "</currencyId>\n"; $strTmpOff .= $strTmpOff_tmp; if (IntVal($arAcc["DETAIL_PICTURE"]) > 0 || IntVal($arAcc["PREVIEW_PICTURE"]) > 0) {
function ExportElements($PROPERTY_MAP, $SECTION_MAP, $start_time, $INTERVAL, $counter_limit = 0, $arElementFilter = false) { $counter = 0; $arSelect = array( "ID", "IBLOCK_ID", "XML_ID", "ACTIVE", "CODE", "NAME", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "TAGS", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "PREVIEW_PICTURE", "DETAIL_PICTURE", ); if(is_array($arElementFilter)) { $arFilter = $arElementFilter; } else { if($arElementFilter === "none") return 0; $arFilter = array ( "IBLOCK_ID"=> $this->arIBlock["ID"], "ACTIVE" => "Y", ">ID" => $this->next_step["LAST_ID"], ); if($arElementFilter === "all") unset($arFilter["ACTIVE"]); } $arOrder = array( "ID" => "ASC", ); $arPropOrder = array( "sort" => "asc", "id" => "asc", "enum_sort" => "asc", "value_id" => "asc", ); $rsElements = CIBlockElement::GetList($arOrder, $arFilter, false, false, $arSelect); while($arElement = $rsElements->Fetch()) { if($this->next_step["catalog"]) fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_OFFER").">\n"); else fwrite($this->fp, "\t\t\t<".GetMessage("IBLOCK_XML2_POSITION").">\n"); if(strlen($arElement["XML_ID"])>0) $xml_id = $arElement["XML_ID"]; else $xml_id = $arElement["ID"]; if($this->PRODUCT_IBLOCK_ID > 0) { $rsLink = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y", "CODE" => "CML2_LINK")); $arLink = $rsLink->Fetch(); if(is_array($arLink) && !is_array($arLink["VALUE"]) && $arLink["VALUE"] > 0) $xml_id = $this->GetElementXML_ID($this->PRODUCT_IBLOCK_ID, $arLink["VALUE"])."#".$xml_id; } fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."</".GetMessage("IBLOCK_XML2_ID").">\n"); if(!$this->only_price) { fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_NAME").">".htmlspecialcharsbx($arElement["NAME"])."</".GetMessage("IBLOCK_XML2_NAME").">\n"); if($this->bExtended) fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_BX_TAGS").">".htmlspecialcharsbx($arElement["TAGS"])."</".GetMessage("IBLOCK_XML2_BX_TAGS").">\n"); $arSections = array(); $rsSections = CIBlockElement::GetElementGroups($arElement["ID"], true); while($arSection = $rsSections->Fetch()) if(array_key_exists($arSection["ID"], $SECTION_MAP)) $arSections[] = $SECTION_MAP[$arSection["ID"]]; fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_GROUPS").">\n"); foreach($arSections as $xml_id) fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($xml_id)."</".GetMessage("IBLOCK_XML2_ID").">\n"); fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_GROUPS").">\n"); if(!$this->bExtended) fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx(FormatText($arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]))."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n"); fwrite($this->fp, $this->formatXMLNode(4, GetMessage("IBLOCK_XML2_PICTURE"), $this->ExportFile($arElement["DETAIL_PICTURE"]))); fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n"); if($this->bExtended) { $this->ExportPropertyValue("CML2_ACTIVE", ($arElement["ACTIVE"]=="Y"? "true": "false")); $this->ExportPropertyValue("CML2_CODE", $arElement["CODE"]); $this->ExportPropertyValue("CML2_SORT", intval($arElement["SORT"])); $this->ExportPropertyValue("CML2_ACTIVE_FROM", CDatabase::FormatDate($arElement["ACTIVE_FROM"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_ACTIVE_TO", CDatabase::FormatDate($arElement["ACTIVE_TO"], CLang::GetDateFormat("FULL"), "YYYY-MM-DD HH:MI:SS")); $this->ExportPropertyValue("CML2_PREVIEW_TEXT", $arElement["PREVIEW_TEXT"], $arElement["PREVIEW_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_DETAIL_TEXT", $arElement["DETAIL_TEXT"], $arElement["DETAIL_TEXT_TYPE"]); $this->ExportPropertyValue("CML2_PREVIEW_PICTURE", $this->ExportFile($arElement["PREVIEW_PICTURE"])); } $rsProps = CIBlockElement::GetProperty($this->arIBlock["ID"], $arElement["ID"], $arPropOrder, array("ACTIVE"=>"Y")); $arProps = array(); while($arProp = $rsProps->Fetch()) { $pid = $arProp["ID"]; if(!array_key_exists($pid, $arProps)) $arProps[$pid] = array( "PROPERTY_TYPE" => $arProp["PROPERTY_TYPE"], "LINK_IBLOCK_ID" => $arProp["LINK_IBLOCK_ID"], "VALUES" => array(), ); if($arProp["PROPERTY_TYPE"] == "L") $arProps[$pid]["VALUES"][] = array( "VALUE" => $arProp["VALUE_ENUM"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE"], ); else $arProps[$pid]["VALUES"][] = array( "VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"], "VALUE_ENUM_ID" => $arProp["VALUE_ENUM_ID"], ); } foreach($arProps as $pid => $arProp) { $bEmpty = true; fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n"); fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_ID").">".htmlspecialcharsbx($PROPERTY_MAP[$pid])."</".GetMessage("IBLOCK_XML2_ID").">\n"); foreach($arProp["VALUES"] as $arValue) { $value = $arValue["VALUE"]; if(is_array($value) || strlen($value)) { $bEmpty = false; $bSerialized = false; if($this->bExtended) { if($arProp["PROPERTY_TYPE"]=="L") { $value = CIBlockPropertyEnum::GetByID($arValue["VALUE_ENUM_ID"]); $value = $value["XML_ID"]; } elseif($arProp["PROPERTY_TYPE"]=="F") { $value = $this->ExportFile($value); } elseif($arProp["PROPERTY_TYPE"]=="G") { $value = $this->GetSectionXML_ID($arProp["LINK_IBLOCK_ID"], $value); } elseif($arProp["PROPERTY_TYPE"]=="E") { $value = $this->GetElementXML_ID($arProp["LINK_IBLOCK_ID"], $value); } if(is_array($value) && $arProp["PROPERTY_TYPE"]!=="F") { $bSerialized = true; $value = serialize($value); } } fwrite($this->fp, $this->formatXMLNode(6, GetMessage("IBLOCK_XML2_VALUE"), $value)); if($this->bExtended) { fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n"); if($bSerialized) fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_SERIALIZED").">true</".GetMessage("IBLOCK_XML2_SERIALIZED").">\n"); fwrite($this->fp, $this->formatXMLNode(7, GetMessage("IBLOCK_XML2_VALUE"), $value)); fwrite($this->fp, "\t\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_DESCRIPTION").">".htmlspecialcharsbx($arValue["DESCRIPTION"])."</".GetMessage("IBLOCK_XML2_DESCRIPTION").">\n"); fwrite($this->fp, "\t\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUE").">\n"); } } } if($bEmpty) fwrite($this->fp, "\t\t\t\t\t\t<".GetMessage("IBLOCK_XML2_VALUE")."></".GetMessage("IBLOCK_XML2_VALUE").">\n"); fwrite($this->fp, "\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTY_VALUES").">\n"); } fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_PROPERTIES_VALUES").">\n"); } if($this->next_step["catalog"]) { $arPrices = array(); $rsPrices = CPrice::GetList(array(), array("PRODUCT_ID" => $arElement["ID"])); while($arPrice = $rsPrices->Fetch()) { if(!$arPrice["QUANTITY_FROM"] && !$arPrice["QUANTITY_TO"]) { $arPrices[] = array( GetMessage("IBLOCK_XML2_PRICE_TYPE_ID") => $this->prices[$arPrice["CATALOG_GROUP_ID"]], GetMessage("IBLOCK_XML2_PRICE_FOR_ONE") => $arPrice["PRICE"], GetMessage("IBLOCK_XML2_CURRENCY") => $arPrice["CURRENCY"], GetMessage("IBLOCK_XML2_MEASURE") => GetMessage("IBLOCK_XML2_PCS"), ); } } if(count($arPrices)>0) { fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_PRICES").">\n"); foreach($arPrices as $arPrice) { fwrite($this->fp, "\t\t\t\t\t<".GetMessage("IBLOCK_XML2_PRICE").">\n"); foreach($arPrice as $key=>$value) { fwrite($this->fp, "\t\t\t\t\t\t<".$key.">".htmlspecialcharsbx($value)."</".$key.">\n"); } fwrite($this->fp, "\t\t\t\t\t</".GetMessage("IBLOCK_XML2_PRICE").">\n"); } fwrite($this->fp, "\t\t\t\t</".GetMessage("IBLOCK_XML2_PRICES").">\n"); $arCatalogProduct = CCatalogProduct::GetByID($arElement["ID"]); if($arCatalogProduct) fwrite($this->fp, "\t\t\t\t<".GetMessage("IBLOCK_XML2_AMOUNT").">".htmlspecialcharsbx($arCatalogProduct["QUANTITY"])."</".GetMessage("IBLOCK_XML2_AMOUNT").">\n"); } } if($this->next_step["catalog"]) fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_OFFER").">\n"); else fwrite($this->fp, "\t\t\t</".GetMessage("IBLOCK_XML2_POSITION").">\n"); $this->next_step["LAST_ID"] = $arElement["ID"]; $counter++; if($INTERVAL > 0 && (time()-$start_time) > $INTERVAL) break; if($counter_limit > 0 && ($counter >= $counter_limit)) break; } return $counter; }
protected function __GetSectionList($intIBlockID, $intProductID) { $mxResult = false; $intIBlockID = intval($intIBlockID); $intProductID = intval($intProductID); if (0 < $intIBlockID && 0 < $intProductID) { $mxResult = array(); $rsSections = CIBlockElement::GetElementGroups($intProductID, true); while ($arSection = $rsSections->Fetch()) { $mxResult[] = intval($arSection['ID']); if (0 < intval($arSection['IBLOCK_SECTION_ID'])) { $rsParents = CIBlockSection::GetNavChain($intIBlockID, $arSection['ID']); while ($arParent = $rsParents->Fetch()) { $mxResult[] = intval($arParent["ID"]); } } } if (!empty($mxResult)) { $mxResult = array_values(array_unique($mxResult)); sort($mxResult); } } return $mxResult; }
public static function SetProductSectionsCache($arItemIDs) { if (empty($arItemIDs) || !is_array($arItemIDs)) { return; } CatalogClearArray($arItemIDs); if (empty($arItemIDs)) { return; } if (empty(self::$arCacheProductSections)) { self::$arCacheProductSections = array_fill_keys($arItemIDs, array()); } else { foreach ($arItemIDs as &$intOneID) { self::$arCacheProductSections[$intOneID] = array(); } unset($intOneID); } $rsSections = CIBlockElement::GetElementGroups($arItemIDs, true, array("ID", "IBLOCK_SECTION_ID", "IBLOCK_ELEMENT_ID")); while ($arSection = $rsSections->Fetch()) { $arSection['ID'] = (int) $arSection['ID']; $arSection['IBLOCK_SECTION_ID'] = (int) $arSection['IBLOCK_SECTION_ID']; $arSection['IBLOCK_ELEMENT_ID'] = (int) $arSection['IBLOCK_ELEMENT_ID']; self::$arCacheProductSections[$arSection['IBLOCK_ELEMENT_ID']][] = $arSection; } unset($arSection, $rsSections); }
private function basket_items() { CModule::IncludeModule("iblock"); CModule::IncludeModule("sale"); CSaleBasket::UpdateBasketPrices(CSaleBasket::GetBasketUserID(), SITE_ID); /* Check Values Begin */ $arSelFields = array("ID", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "NAME", "CURRENCY", "CATALOG_XML_ID", "VAT_RATE", "NOTES", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "DIMENSIONS", "TYPE", "SET_PARENT_ID", "DETAIL_PAGE_URL" ); $dbBasketItems = CSaleBasket::GetList( array("ID" => "ASC"), array( "FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL" ), false, false, $arSelFields ); while ($arItem = $dbBasketItems->GetNext()) { if ($arItem["DELAY"] == "N" && $arItem["CAN_BUY"] == "Y") { $arItem["PRICE"] = roundEx($arItem["PRICE"], SALE_VALUE_PRECISION); $arItem["QUANTITY"] = DoubleVal($arItem["QUANTITY"]); $arItem["WEIGHT"] = DoubleVal($arItem["WEIGHT"]); $arItem["VAT_RATE"] = DoubleVal($arItem["VAT_RATE"]); $arDim = unserialize($arItem["~DIMENSIONS"]); if(is_array($arDim)) { $arItem["DIMENSIONS"] = $arDim; unset($arItem["~DIMENSIONS"]); $arResult["MAX_DIMENSIONS"] = CSaleDeliveryHelper::getMaxDimensions( array( $arDim["WIDTH"], $arDim["HEIGHT"], $arDim["LENGTH"] ), $arResult["MAX_DIMENSIONS"]); $arResult["ITEMS_DIMENSIONS"][] = $arDim; } if($arItem["VAT_RATE"] > 0 && !CSaleBasketHelper::isSetItem($arItem)) { $arResult["bUsingVat"] = "Y"; if($arItem["VAT_RATE"] > $arResult["VAT_RATE"]) $arResult["VAT_RATE"] = $arItem["VAT_RATE"]; //$arItem["VAT_VALUE"] = roundEx((($arItem["PRICE"] / ($arItem["VAT_RATE"] +1)) * $arItem["VAT_RATE"]), SALE_VALUE_PRECISION); $arItem["VAT_VALUE"] = (($arItem["PRICE"] / ($arItem["VAT_RATE"] +1)) * $arItem["VAT_RATE"]); $arResult["VAT_SUM"] += roundEx($arItem["VAT_VALUE"] * $arItem["QUANTITY"], SALE_VALUE_PRECISION); } $arItem["PRICE_FORMATED"] = SaleFormatCurrency($arItem["PRICE"], $arItem["CURRENCY"]); $arItem["WEIGHT_FORMATED"] = roundEx(DoubleVal($arItem["WEIGHT"]/$arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"]; if($arItem["DISCOUNT_PRICE"] > 0) { $arItem["DISCOUNT_PRICE_PERCENT"] = $arItem["DISCOUNT_PRICE"]*100 / ($arItem["DISCOUNT_PRICE"] + $arItem["PRICE"]); $arItem["DISCOUNT_PRICE_PERCENT_FORMATED"] = roundEx($arItem["DISCOUNT_PRICE_PERCENT"], 0)."%"; } $arItem["PROPS"] = Array(); $dbProp = CSaleBasket::GetPropsList(Array("SORT" => "ASC", "ID" => "ASC"), Array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID"))); while($arProp = $dbProp -> GetNext()) { if (array_key_exists('BASKET_ID', $arProp)) { unset($arProp['BASKET_ID']); } if (array_key_exists('~BASKET_ID', $arProp)) { unset($arProp['~BASKET_ID']); } $arProp = array_filter($arProp, array("CSaleBasketHelper", "filterFields")); $arItem["PROPS"][] = $arProp; } if (!CSaleBasketHelper::isSetItem($arItem)) { $DISCOUNT_PRICE_ALL += $arItem["DISCOUNT_PRICE"] * $arItem["QUANTITY"]; $arItem["DISCOUNT_PRICE"] = roundEx($arItem["DISCOUNT_PRICE"], SALE_VALUE_PRECISION); $arResult["ORDER_PRICE"] += $arItem["PRICE"] * $arItem["QUANTITY"]; } $arResult["ORDER_WEIGHT"] += $arItem["WEIGHT"] * $arItem["QUANTITY"]; if (CSaleBasketHelper::isSetItem($arItem)) $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem['QUANTITY']; //get product section $db_groups = CIBlockElement::GetElementGroups($arItem["PRODUCT_ID"], true); while($ar_group = $db_groups->Fetch()) $arItem["IBLOCK_SECTION_ID"][] = $ar_group["ID"]; if(!$arItem["IBLOCK_SECTION_ID"]){ $arItem["PARENT"] = CCatalogSku::GetProductInfo( $arItem["PRODUCT_ID"] ); $db_groups = CIBlockElement::GetElementGroups($arItem["PARENT"]["ID"], true); while($ar_group = $db_groups->Fetch()) $arItem["IBLOCK_SECTION_ID"][] = $ar_group["ID"]; } if($arItem["IBLOCK_SECTION_ID"]){ foreach($arItem["IBLOCK_SECTION_ID"] as $section){ $res_1 = CIBlockSection::GetByID($section); if($ar_res_1 = $res_1->GetNext()){ $arItem["SECTION_NAME"][] = $ar_res_1["NAME"]; } } } $arResult["BASKET_ITEMS"][] = $arItem; } $arResult["PRICE_WITHOUT_DISCOUNT"] = SaleFormatCurrency($arResult["ORDER_PRICE"] + $DISCOUNT_PRICE_ALL, $allCurrency); // count weight for set parent products foreach ($arResult["BASKET_ITEMS"] as &$arItem) { if (CSaleBasketHelper::isSetParent($arItem)) { $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"]; $arItem["WEIGHT_FORMATED"] = roundEx(doubleval($arItem["WEIGHT"] / $arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"]; } } $arResult["ORDER_WEIGHT_FORMATED"] = roundEx(DoubleVal($arResult["ORDER_WEIGHT"]/$arResult["WEIGHT_KOEF"]), SALE_WEIGHT_PRECISION)." ".$arResult["WEIGHT_UNIT"]; $arResult["ORDER_PRICE_FORMATED"] = SaleFormatCurrency($arResult["ORDER_PRICE"], $arResult["BASE_LANG_CURRENCY"]); $arResult["VAT_SUM_FORMATED"] = SaleFormatCurrency($arResult["VAT_SUM"], $arResult["BASE_LANG_CURRENCY"]); $arElementId[] = $arItem["PRODUCT_ID"]; if ($bUseCatalog) { $arParent = CCatalogSku::GetProductInfo($arItem["PRODUCT_ID"]); if ($arParent) { $arElementId[] = $arParent["ID"]; $arSku2Parent[$arItem["PRODUCT_ID"]] = $arParent["ID"]; } } unset($arItem); } return $arResult["BASKET_ITEMS"]; }
foreach ($arResult["DOCUMENT"]["FIELDS"] as $k => $v) ${"str_".$k} = $v; } else { $result = CIBlockElement::GetByID($WF_ID); if($arElement = $result->ExtractFields("str_")) { if($str_IN_SECTIONS=="N") { $str_IBLOCK_ELEMENT_SECTION[] = 0; } else { $result = CIBlockElement::GetElementGroups($WF_ID, true, array('ID', 'IBLOCK_ELEMENT_ID')); while($ar = $result->Fetch()) $str_IBLOCK_ELEMENT_SECTION[] = $ar["ID"]; } $ipropTemlates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($IBLOCK_ID, $WF_ID); } else { $WF_ID=0; $ID=0; if(is_array($IBLOCK_SECTION_ID)) { foreach($IBLOCK_SECTION_ID as $id) if($id > 0) $str_IBLOCK_ELEMENT_SECTION[] = $id; }
if (!$bNeedPrices) { $bNeedCounts = false; $arCountFields = array(); } } uasort($arSortFields, '__sortCSVOrder'); $arNeedFields = array_keys($arSortFields); if ($first_line_names) { $csvFile->SaveFile($_SERVER["DOCUMENT_ROOT"] . $SETUP_FILE_NAME, $arNeedFields); } $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'), false, false, $selectArray); while ($res1 = $res->Fetch()) { $arResSections = array(); if ($bNeedGroups) { $indreseg = 0; $reseg = CIBlockElement::GetElementGroups($res1["ID"], true); while ($reseg1 = $reseg->Fetch()) { $sections_path = GetIBlockSectionPath($IBLOCK_ID, $reseg1["ID"]); while ($arSection = $sections_path->Fetch()) { $arResSectionTmp = array(); foreach ($arAvailGroupFields_names as $key => $value) { $arResSectionTmp[$key] = $arSection[$value["field"]]; } $arResSections[$indreseg][] = $arResSectionTmp; } $indreseg++; } if (count($arResSections) <= 0) { $arResSections[0] = array(); } } else {
$sRedirectUrl = $APPLICATION->GetCurPageParam("edit=Y&CODE=" . $arParams["ID"], array("edit", "CODE"), $get_index_page = false); } } $sAction = $sAction == "ADD" ? "ADD" : "EDIT"; $sRedirectUrl .= (strpos($sRedirectUrl, "?") === false ? "?" : "&") . "strIMessage="; $sRedirectUrl .= urlencode($arParams["USER_MESSAGE_" . $sAction]); //echo $sRedirectUrl; LocalRedirect($sRedirectUrl); exit; } } //prepare data for form $arResult["PROPERTY_REQUIRED"] = is_array($arParams["PROPERTY_CODES_REQUIRED"]) ? $arParams["PROPERTY_CODES_REQUIRED"] : array(); if ($arParams["ID"] > 0) { // $arElement is defined before in elements rights check $rsElementSections = CIBlockElement::GetElementGroups($arElement["ID"]); $arElement["IBLOCK_SECTION"] = array(); while ($arSection = $rsElementSections->GetNext()) { $arElement["IBLOCK_SECTION"][] = array("VALUE" => $arSection["ID"]); } $arResult["ELEMENT"] = array(); foreach ($arElement as $key => $value) { $arResult["ELEMENT"]["~" . $key] = $value; if (!is_array($value) && !is_object($value)) { $arResult["ELEMENT"][$key] = htmlspecialcharsbx($value); } else { $arResult["ELEMENT"][$key] = $value; } } //Restore HTML if needed if ($arParams["DETAIL_TEXT_USE_HTML_EDITOR"] && array_key_exists("DETAIL_TEXT", $arResult["ELEMENT"]) && strtolower($arResult["ELEMENT"]["DETAIL_TEXT_TYPE"]) == "html") {
$minPrice = $arAcc["CATALOG_PRICE_".$arPTypes[$i]]; $minPriceGroup = $arPTypes[$i]; $minPriceCurrency = $arAcc["CATALOG_CURRENCY_".$arPTypes[$i]]; if ($minPriceCurrency!="USD" && $minPriceCurrency!="RUR") { $minPriceCurrency = "RUR"; $minPrice = $tmpPrice; } } } if ($minPrice <= 0) continue; $bNoActiveGroup = true; $strTmpOff_tmp = ""; $db_res1 = CIBlockElement::GetElementGroups($arAcc["ID"], false, array('ID', 'ADDITIONAL_PROPERTY_ID')); while ($ar_res1 = $db_res1->Fetch()) { if (0 < intval($ar_res1['ADDITIONAL_PROPERTY_ID'])) continue; if (in_array(intval($ar_res1["ID"]), $arAvailGroups)) { $strTmpOff_tmp.= "<categoryId>".$ar_res1["ID"]."</categoryId>\n"; $bNoActiveGroup = false; } } if ($bNoActiveGroup) continue; if ('' == $arAcc['DETAIL_PAGE_URL']) { $arAcc['DETAIL_PAGE_URL'] = '/';
function BeforeIndexForum($arFields, $entity_type, $entity_id, $feature, $operation, $path_template) { global $USER; $SECTION_ID = ""; $ELEMENT_ID = intval($_REQUEST["photo_element_id"]); if (empty($ELEMENT_ID)) $ELEMENT_ID = intval($_REQUEST["ELEMENT_ID"]); if($ELEMENT_ID > 0 && CModule::IncludeModule('iblock')) { $rsSections = CIBlockElement::GetElementGroups($ELEMENT_ID, true); $arSection = $rsSections->Fetch(); if($arSection) $SECTION_ID = $arSection["ID"]; } foreach($arFields["LID"] as $site_id => $url) { $arFields["URL"] = $arFields["LID"][$site_id] = str_replace( array( "#user_id#", "#group_id#", "#topic_id#", "#message_id#", "#action#", "#user_alias#", "#section_id#", "#element_id#", "#task_id#", ), array( ($this->_user_id > 0 ? $this->_user_id : $USER->GetID()), $this->_group_id, $arFields["PARAM2"], $arFields["ITEM_ID"], "view", ($entity_type=="G"? "group_": "user_").$entity_id, $SECTION_ID, $ELEMENT_ID, $ELEMENT_ID, ), $path_template ); } if ( ($feature == 'tasks') && (COption::GetOptionString("intranet", "use_tasks_2_0", "N") == 'Y') && ($arFields["PARAM1"] == COption::GetOptionString("tasks", "task_forum_id", 0)) && CModule::IncludeModule('tasks') ) { $rsTask = CTasks::GetList(array(), array("FORUM_TOPIC_ID" => $arFields['PARAM2'])); if ($arTask = $rsTask->Fetch()) $arFields['PERMISSIONS'] = CTasks::__GetSearchPermissions($arTask); } else { $arFields["PERMISSIONS"] = $this->GetSearchGroups( $entity_type, $entity_id, $feature, $operation ); $arFields["PARAMS"] = $this->GetSearchParams( $entity_type, $entity_id, $feature, $operation ); } return $arFields; }
public static function OnBeforePrologHandler() { global $USER_FIELD_MANAGER; if (isset($_REQUEST['action_button']) && !isset($_REQUEST['action'])) { $_REQUEST['action'] = $_REQUEST['action_button']; } if (!isset($_REQUEST['action'])) { return; } $BID = isset($_REQUEST['ID']) ? (int) $_REQUEST['ID'] : 0; if ($_REQUEST['action'] == 'asd_prop_export' && $BID > 0 && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($BID)) { $strPath = $_SERVER['DOCUMENT_ROOT'] . '/bitrix/tmp/asd.iblock/'; $strName = 'asd_props_export_' . $BID . '_' . md5(LICENSE_KEY) . '.xml'; CheckDirPath($strPath); if ($hdlOutput = fopen($strPath . $strName, 'wb')) { fwrite($hdlOutput, '<?xml version="1.0" encoding="' . SITE_CHARSET . '"?>' . "\n"); fwrite($hdlOutput, '<asd_iblock_props>' . "\n"); fwrite($hdlOutput, CASDiblockTools::ExportPropsToXML($BID, $_REQUEST['p'])); if ($_REQUEST['forms'] == 'Y') { fwrite($hdlOutput, CASDiblockTools::ExportSettingsToXML($BID, array('forms'))); } fwrite($hdlOutput, '</asd_iblock_props>' . "\n"); fclose($hdlOutput); } ?> <script type="text/javascript"> top.BX.closeWait(); top.BX.WindowManager.Get().AllowClose(); top.BX.WindowManager.Get().Close(); window.location.href = '/bitrix/tools/asd.iblock/props_export.php?ID=<?php echo $BID; ?> '; </script><?php die; } if ($_REQUEST['action'] == 'asd_prop_import' && $BID > 0 && !$_FILES['xml_file']['error'] && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($BID)) { CASDiblockTools::ImportPropsFromXML($BID, $_FILES['xml_file']['tmp_name'], $arOldNewID); CASDiblockTools::ImportFormsFromXML($BID, $_FILES['xml_file']['tmp_name'], $arOldNewID); LocalRedirect('/bitrix/admin/iblock_edit.php?type=' . $_REQUEST['type'] . '&tabControl_active_tab=edit2&lang=' . LANGUAGE_ID . '&ID=' . $BID . '&admin=Y'); } $IBLOCK_ID = 0; if (isset($_REQUEST['IBLOCK_ID'])) { $IBLOCK_ID = (int) $_REQUEST['IBLOCK_ID']; if ($IBLOCK_ID < 0) { $IBLOCK_ID = 0; } } if ($_REQUEST['action'] == 'asd_reverse' && $IBLOCK_ID > 0 && check_bitrix_sessid() && CModule::IncludeModule('iblock') && CASDIblockRights::IsIBlockEdit($IBLOCK_ID)) { $LIST_MODE = CIBlock::GetArrayByID($IBLOCK_ID, 'LIST_MODE'); if (!strlen($LIST_MODE)) { $LIST_MODE = COption::GetOptionString('iblock', 'combined_list_mode', 'N') == 'Y' ? 'C' : 'S'; } $LIST_MODE = $LIST_MODE == 'C' ? 'S' : 'C'; $ib = new CIBlock(); $ib->Update($IBLOCK_ID, array('LIST_MODE' => $LIST_MODE)); LocalRedirect('/bitrix/admin/' . ($LIST_MODE == 'S' ? 'iblock_element_admin' : 'iblock_list_admin') . '.php?IBLOCK_ID=' . $IBLOCK_ID . '&type=' . htmlspecialcharsbx($_REQUEST['type']) . '&find_section_section=' . intval($_REQUEST['find_section_section']) . '&lang=' . LANGUAGE_ID); } $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; $successRedirect = false; if ($bRightPage && $_REQUEST['action'] == 'asd_copy_in_list' && strlen($_REQUEST['ID']) > 0) { $bDoAction = true; $_REQUEST['action'] = 'asd_copy'; $_REQUEST['asd_ib_dest'] = $IBLOCK_ID; $_REQUEST['ID'] = array($_REQUEST['ID']); } else { $bDoAction = false; } if ($bRightPage && check_bitrix_sessid() && !empty($_REQUEST['ID']) && ($_SERVER['REQUEST_METHOD'] == 'POST' || $bDoAction) && CModule::IncludeModule('iblock') && ($_REQUEST['action'] == 'asd_copy' || $_REQUEST['action'] == 'asd_move') && isset($_REQUEST['asd_ib_dest']) && (int) $_REQUEST['asd_ib_dest'] > 0 && CASDIblockRights::IsIBlockDisplay($_REQUEST['asd_ib_dest'])) { $intSrcIBlockID = $IBLOCK_ID; $intDestIBlockID = (int) $_REQUEST['asd_ib_dest']; $intSetSectID = 0; if (isset($_REQUEST['asd_sect_dest'])) { $intSetSectID = (int) $_REQUEST['asd_sect_dest']; if ($intSetSectID < 0) { $intSetSectID = 0; } } $boolCreateElement = false; $boolCreateSection = false; if ($bElemPage || $bMixPage) { $boolCreateElement = CASDIblockRights::IsSectionElementCreate($intDestIBlockID, $intSetSectID); } if ($bSectPage || $bMixPage) { $boolCreateSection = CASDIblockRights::IsSectionSectionCreate($intDestIBlockID, $intSetSectID); } if ($boolCreateElement || $boolCreateSection) { $arPropListCache = array(); $arOldPropListCache = array(); $arNamePropListCache = array(); $arOldNamePropListCache = array(); $boolUFListCache = false; $arUFListCache = array(); $arOldUFListCache = array(); $arUFEnumCache = array(); $arOldUFEnumCache = array(); $arUFNameEnumCache = array(); $arOldUFNameEnumCache = array(); $arDestIBlock = CIBlock::GetArrayByID($intDestIBlockID); $arDestIBFields = $arDestIBlock['FIELDS']; $boolCodeUnique = false; if ($arDestIBFields['CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') { $boolCodeUnique = $intSrcIBlockID == $intDestIBlockID; } $boolSectCodeUnique = false; if ($arDestIBFields['SECTION_CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') { $boolSectCodeUnique = $intSrcIBlockID == $intDestIBlockID; } $boolCatalog = CModule::IncludeModule('catalog'); $boolCopyCatalog = false; $boolNewCatalog = false; if ($boolCatalog) { $boolCopyCatalog = is_array(CCatalog::GetByID($intDestIBlockID)); $boolNewCatalog = $boolCopyCatalog; if ($boolCopyCatalog) { $boolCopyCatalog = is_array(CCatalog::GetByID($intSrcIBlockID)); } } $el = new CIBlockElement(); $sc = new CIBlockSection(); $obEnum = new CUserFieldEnum(); foreach ($_REQUEST['ID'] as $eID) { $boolCopyElem = false; $boolCopySect = false; if ($bMixPage) { if (substr($eID, 0, 1) != 'E') { $boolCopySect = true; } else { $boolCopyElem = true; } $ID = (int) substr($eID, 1); } else { $boolCopyElem = $bElemPage; $boolCopySect = $bSectPage; $ID = (int) $eID; } if ($boolCreateElement && $boolCopyElem) { if ($obSrc = CIBlockElement::GetByID($ID)->GetNextElement()) { $arSrc = $obSrc->GetFields(); $arSrcPr = $obSrc->GetProperties(false, array('EMPTY' => 'N')); $arSrc['PREVIEW_PICTURE'] = (int) $arSrc['PREVIEW_PICTURE']; if ($arSrc['PREVIEW_PICTURE'] > 0) { $arSrc['PREVIEW_PICTURE'] = CFile::MakeFileArray($arSrc['PREVIEW_PICTURE']); if (empty($arSrc['PREVIEW_PICTURE'])) { $arSrc['PREVIEW_PICTURE'] = false; } else { $arSrc['PREVIEW_PICTURE']['COPY_FILE'] = 'Y'; } } else { $arSrc['PREVIEW_PICTURE'] = false; } $arSrc['DETAIL_PICTURE'] = (int) $arSrc['DETAIL_PICTURE']; if ($arSrc['DETAIL_PICTURE'] > 0) { $arSrc['DETAIL_PICTURE'] = CFile::MakeFileArray($arSrc['DETAIL_PICTURE']); if (empty($arSrc['DETAIL_PICTURE'])) { $arSrc['DETAIL_PICTURE'] = false; } else { $arSrc['DETAIL_PICTURE']['COPY_FILE'] = 'Y'; } } else { $arSrc['DETAIL_PICTURE'] = false; } $arSrc = array('IBLOCK_ID' => $intDestIBlockID, 'ACTIVE' => $arSrc['ACTIVE'], 'ACTIVE_FROM' => $arSrc['ACTIVE_FROM'], 'ACTIVE_TO' => $arSrc['ACTIVE_TO'], 'SORT' => $arSrc['SORT'], 'NAME' => $arSrc['~NAME'], 'PREVIEW_PICTURE' => $arSrc['PREVIEW_PICTURE'], 'PREVIEW_TEXT' => $arSrc['~PREVIEW_TEXT'], 'PREVIEW_TEXT_TYPE' => $arSrc['PREVIEW_TEXT_TYPE'], 'DETAIL_TEXT' => $arSrc['~DETAIL_TEXT'], 'DETAIL_TEXT_TYPE' => $arSrc['DETAIL_TEXT_TYPE'], 'DETAIL_PICTURE' => $arSrc['DETAIL_PICTURE'], 'WF_STATUS_ID' => $arSrc['WF_STATUS_ID'], 'CODE' => $arSrc['~CODE'], 'TAGS' => $arSrc['~TAGS'], 'XML_ID' => $arSrc['~XML_ID'], 'PROPERTY_VALUES' => array()); if ($arDestIBFields['CODE']['IS_REQUIRED'] == 'Y') { if (!strlen($arSrc['CODE'])) { $arSrc['CODE'] = mt_rand(100000, 1000000); } } if ($arDestIBFields['CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') { $boolElCodeUnique = $boolCodeUnique; if (!$boolCodeUnique) { $rsCheckItems = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, '=CODE' => $arSrc['CODE'], 'CHECK_PERMISSIONS' => 'N'), false, array('nTopCount' => 1), array('ID', 'IBLOCK_ID')); if ($arCheck = $rsCheckItems->Fetch()) { $boolElCodeUnique = true; } } if ($boolElCodeUnique) { $arSrc['CODE'] .= mt_rand(100, 10000); } } if ($intSetSectID > 0) { $arSrc['IBLOCK_SECTION_ID'] = $intSetSectID; } elseif ($intSrcIBlockID == $intDestIBlockID) { $arSectionList = array(); $rsSections = CIBlockElement::GetElementGroups($ID, true); while ($arSection = $rsSections->Fetch()) { $arSectionList[] = $arSection['ID']; } $arSrc['IBLOCK_SECTION'] = $arSectionList; } if ($intSrcIBlockID != $intDestIBlockID) { if (empty($arPropListCache)) { $rsProps = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, 'PROPERTY_TYPE' => 'L', 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N')); while ($arProp = $rsProps->Fetch()) { $arValueList = array(); $arNameList = array(); $rsValues = CIBlockProperty::GetPropertyEnum($arProp['ID']); while ($arValue = $rsValues->Fetch()) { $arValueList[$arValue['XML_ID']] = $arValue['ID']; $arNameList[$arValue['ID']] = trim($arValue['VALUE']); } if (!empty($arValueList)) { $arPropListCache[$arProp['CODE']] = $arValueList; } if (!empty($arNameList)) { $arNamePropListCache[$arProp['CODE']] = $arNameList; } } } if (empty($arOldPropListCache)) { $rsProps = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $intSrcIBlockID, 'PROPERTY_TYPE' => 'L', 'ACTIVE' => 'Y', 'CHECK_PERMISSIONS' => 'N')); while ($arProp = $rsProps->Fetch()) { $arValueList = array(); $arNameList = array(); $rsValues = CIBlockProperty::GetPropertyEnum($arProp['ID']); while ($arValue = $rsValues->Fetch()) { $arValueList[$arValue['ID']] = $arValue['XML_ID']; $arNameList[$arValue['ID']] = trim($arValue['VALUE']); } if (!empty($arValueList)) { $arOldPropListCache[$arProp['CODE']] = $arValueList; } if (!empty($arNameList)) { $arOldNamePropListCache[$arProp['CODE']] = $arNameList; } } } } foreach ($arSrcPr as &$arProp) { if ($arProp['USER_TYPE'] == 'HTML') { if (is_array($arProp['~VALUE'])) { if ($arProp['MULTIPLE'] == 'N') { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array('VALUE' => array('TEXT' => $arProp['~VALUE']['TEXT'], 'TYPE' => $arProp['~VALUE']['TYPE'])); if ($arProp['WITH_DESCRIPTION'] == 'Y') { $arSrc['PROPERTY_VALUES'][$arProp['CODE']]['DESCRIPTION'] = $arProp['~DESCRIPTION']; } } else { if (!empty($arProp['~VALUE'])) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array(); foreach ($arProp['~VALUE'] as $propValueKey => $propValue) { $oneNewValue = array('VALUE' => array('TEXT' => $propValue['TEXT'], 'TYPE' => $propValue['TYPE'])); if ($arProp['WITH_DESCRIPTION'] == 'Y') { $oneNewValue['DESCRIPTION'] = $arProp['~DESCRIPTION'][$propValueKey]; } $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $oneNewValue; unset($oneNewValue); } unset($propValue, $propValueKey); } } } } elseif ($arProp['PROPERTY_TYPE'] == 'F') { if (is_array($arProp['VALUE'])) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array(); foreach ($arProp['VALUE'] as $propValueKey => $file) { if ($file > 0) { $tmpValue = CFile::MakeFileArray($file); if (!is_array($tmpValue)) { continue; } if ($arProp['WITH_DESCRIPTION'] == 'Y') { $tmpValue = array('VALUE' => $tmpValue, 'DESCRIPTION' => $arProp['~DESCRIPTION'][$propValueKey]); } $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $tmpValue; } } } elseif ($arProp['VALUE'] > 0) { $tmpValue = CFile::MakeFileArray($arProp['VALUE']); if (is_array($tmpValue)) { if ($arProp['WITH_DESCRIPTION'] == 'Y') { $tmpValue = array('VALUE' => $tmpValue, 'DESCRIPTION' => $arProp['~DESCRIPTION']); } $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $tmpValue; } } } elseif ($arProp['PROPERTY_TYPE'] == 'L') { if (!empty($arProp['VALUE_ENUM_ID'])) { if ($intSrcIBlockID == $arSrc['IBLOCK_ID']) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['VALUE_ENUM_ID']; } else { if (isset($arPropListCache[$arProp['CODE']]) && isset($arOldPropListCache[$arProp['CODE']])) { if (is_array($arProp['VALUE_ENUM_ID'])) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array(); foreach ($arProp['VALUE_ENUM_ID'] as &$intValueID) { $strValueXmlID = $arOldPropListCache[$arProp['CODE']][$intValueID]; if (isset($arPropListCache[$arProp['CODE']][$strValueXmlID])) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $arPropListCache[$arProp['CODE']][$strValueXmlID]; } else { $strValueName = $arOldNamePropListCache[$arProp['CODE']][$intValueID]; $intValueKey = array_search($strValueName, $arNamePropListCache[$arProp['CODE']]); if ($intValueKey !== false) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = $intValueKey; } } } if (isset($intValueID)) { unset($intValueID); } if (empty($arSrc['PROPERTY_VALUES'][$arProp['CODE']])) { unset($arSrc['PROPERTY_VALUES'][$arProp['CODE']]); } } else { $strValueXmlID = $arOldPropListCache[$arProp['CODE']][$arProp['VALUE_ENUM_ID']]; if (isset($arPropListCache[$arProp['CODE']][$strValueXmlID])) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arPropListCache[$arProp['CODE']][$strValueXmlID]; } else { $strValueName = $arOldNamePropListCache[$arProp['CODE']][$arProp['VALUE_ENUM_ID']]; $intValueKey = array_search($strValueName, $arNamePropListCache[$arProp['CODE']]); if ($intValueKey !== false) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $intValueKey; } } } } } } } elseif ($arProp['PROPERTY_TYPE'] == 'S' || $arProp['PROPERTY_TYPE'] == 'N') { if ($arProp['MULTIPLE'] == 'Y') { if (is_array($arProp['~VALUE'])) { if ($arProp['WITH_DESCRIPTION'] == 'Y') { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = array(); foreach ($arProp['~VALUE'] as $propValueKey => $propValue) { $arSrc['PROPERTY_VALUES'][$arProp['CODE']][] = array('VALUE' => $propValue, 'DESCRIPTION' => $arProp['~DESCRIPTION'][$propValueKey]); } unset($propValue, $propValueKey); } else { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE']; } } } else { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['WITH_DESCRIPTION'] == 'Y' ? array('VALUE' => $arProp['~VALUE'], 'DESCRIPTION' => $arProp['~DESCRIPTION']) : $arProp['~VALUE']; } } else { $arSrc['PROPERTY_VALUES'][$arProp['CODE']] = $arProp['~VALUE']; } } if (isset($arProp)) { unset($arProp); } AddMessage2Log($arSrc['PROPERTY_VALUES']); $intNewID = $el->Add($arSrc, true, true, true); if ($intNewID) { if ($boolCatalog && $boolCopyCatalog) { $priceRes = CPrice::GetListEx(array(), array('PRODUCT_ID' => $ID), false, false, array('PRODUCT_ID', 'EXTRA_ID', 'CATALOG_GROUP_ID', 'PRICE', 'CURRENCY', 'QUANTITY_FROM', 'QUANTITY_TO')); while ($arPrice = $priceRes->Fetch()) { $arPrice['PRODUCT_ID'] = $intNewID; CPrice::Add($arPrice); } } if ($boolCatalog && $boolNewCatalog) { $arProduct = array('ID' => $intNewID); if ($boolCopyCatalog) { $productRes = CCatalogProduct::GetList(array(), array('ID' => $ID), false, false, array('QUANTITY', 'QUANTITY_TRACE_ORIG', 'CAN_BUY_ZERO_ORIG', 'NEGATIVE_AMOUNT_TRACE_ORIG', 'SUBSCRIBE_ORIG', 'WEIGHT', 'PRICE_TYPE', 'RECUR_SCHEME_TYPE', 'RECUR_SCHEME_LENGTH', 'TRIAL_PRICE_ID', 'WITHOUT_ORDER', 'SELECT_BEST_PRICE', 'VAT_ID', 'VAT_INCLUDED', 'WIDTH', 'LENGTH', 'HEIGHT', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'MEASURE')); if ($arCurProduct = $productRes->Fetch()) { $arProduct = $arCurProduct; $arProduct['ID'] = $intNewID; $arProduct['QUANTITY_TRACE'] = $arProduct['QUANTITY_TRACE_ORIG']; $arProduct['CAN_BUY_ZERO'] = $arProduct['CAN_BUY_ZERO_ORIG']; $arProduct['NEGATIVE_AMOUNT_TRACE'] = $arProduct['NEGATIVE_AMOUNT_TRACE_ORIG']; if (isset($arProduct['SUBSCRIBE_ORIG'])) { $arProduct['SUBSCRIBE'] = $arProduct['SUBSCRIBE_ORIG']; } foreach ($arProduct as $productKey => $productValue) { if ($productValue === null) { unset($arProduct[$productKey]); } } } } CCatalogProduct::Add($arProduct, false); } if ($_REQUEST['action'] == 'asd_move') { if (CASDIblockRights::IsElementDelete($intSrcIBlockID, $ID)) { $el->Delete($ID); } else { CASDiblock::$error .= '[' . $ID . '] ' . GetMessage('ASD_ACTION_ERR_DELETE_ELEMENT_RIGHTS') . "\n"; } } } else { CASDiblock::$error .= '[' . $ID . '] ' . $el->LAST_ERROR . "\n"; } } } if ($boolCreateSection && $boolCopySect) { if ($_REQUEST['action'] == 'asd_move') { continue; } $rsSections = CIBlockSection::GetList(array(), array('ID' => $ID, 'IBLOCK_ID' => $intSrcIBlockID), false, array('ID', 'NAME', 'XML_ID', 'CODE', 'IBLOCK_SECTION_ID', 'IBLOCK_ID', 'ACTIVE', 'SORT', 'PICTURE', 'DESCRIPTION', 'DESCRIPTION_TYPE', 'DETAIL_PICTURE', 'SOCNET_GROUP_ID', 'UF_*')); if ($arSrcSect = $rsSections->Fetch()) { $arDestSect = $arSrcSect; unset($arDestSect['ID']); $arDestSect['IBLOCK_ID'] = $intDestIBlockID; if ($arDestIBFields['SECTION_CODE']['IS_REQUIRED'] == 'Y') { if (!strlen($arDestSect['CODE'])) { $arDestSect['CODE'] = mt_rand(100000, 1000000); } } if ($arDestIBFields['SECTION_CODE']['DEFAULT_VALUE']['UNIQUE'] == 'Y') { $boolScCodeUnique = $boolSectCodeUnique; if (!$boolSectCodeUnique) { $rsCheckItems = CIBlockElement::GetList(array(), array('IBLOCK_ID' => $intDestIBlockID, '=CODE' => $arSrc['CODE'], 'CHECK_PERMISSIONS' => 'N'), false, array('nTopCount' => 1), array('ID', 'IBLOCK_ID')); if ($arCheck = $rsCheckItems->Fetch()) { $boolScCodeUnique = true; } } if ($boolScCodeUnique) { $arDestSect['CODE'] .= mt_rand(100, 10000); } } if ($intSetSectID > 0) { $arDestSect['IBLOCK_SECTION_ID'] = $intSetSectID; } elseif ($intSrcIBlockID != $intDestIBlockID) { $arDestSect['IBLOCK_SECTION_ID'] = 0; } $arDestSect['PICTURE'] = (int) $arDestSect['PICTURE']; if ($arDestSect['PICTURE'] > 0) { $arDestSect['PICTURE'] = CFile::MakeFileArray($arDestSect['PICTURE']); if (empty($arDestSect['PICTURE'])) { $arDestSect['PICTURE'] = false; } else { $arDestSect['PICTURE']['COPY_FILE'] = 'Y'; } } else { $arDestSect['PICTURE'] = false; } $arDestSect['DETAIL_PICTURE'] = (int) $arDestSect['DETAIL_PICTURE']; if ($arDestSect['DETAIL_PICTURE'] > 0) { $arDestSect['DETAIL_PICTURE'] = CFile::MakeFileArray($arDestSect['DETAIL_PICTURE']); if (empty($arDestSect['DETAIL_PICTURE'])) { $arDestSect['DETAIL_PICTURE'] = false; } else { $arDestSect['DETAIL_PICTURE']['COPY_FILE'] = 'Y'; } } else { $arDestSect['DETAIL_PICTURE'] = false; } if (!$boolUFListCache) { $boolUFListCache = true; $arUFListCache = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $intDestIBlockID . '_SECTION'); if (!empty($arUFListCache)) { if ($intSrcIBlockID != $intDestIBlockID) { $arOldUFListCache = $USER_FIELD_MANAGER->GetUserFields('IBLOCK_' . $intSrcIBlockID . '_SECTION'); if (empty($arOldUFListCache)) { $arUFListCache = array(); } } else { $arOldUFListCache = $arUFListCache; } } if (!empty($arUFListCache)) { if ($intSrcIBlockID != $intDestIBlockID) { foreach ($arUFListCache as &$arOneUserField) { if ('enum' == $arOneUserField['USER_TYPE']['BASE_TYPE']) { $arUFEnumCache[$arOneUserField['FIELD_NAME']] = array(); $arUFNameEnumCache[$arOneUserField['FIELD_NAME']] = array(); $rsEnum = $obEnum->GetList(array(), array('USER_FIELD_ID' => $arOneUserField['ID'])); while ($arEnum = $rsEnum->Fetch()) { $arUFEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['XML_ID']] = $arEnum['ID']; $arUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = trim($arEnum['VALUE']); } } } if (isset($arOneUserField)) { unset($arOneUserField); } foreach ($arOldUFListCache as &$arOneUserField) { if ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'enum') { $arOldUFEnumCache[$arOneUserField['FIELD_NAME']] = array(); $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']] = array(); $rsEnum = $obEnum->GetList(array(), array('USER_FIELD_ID' => $arOneUserField['ID'])); while ($arEnum = $rsEnum->Fetch()) { $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = $arEnum['XML_ID']; $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arEnum['ID']] = trim($arEnum['VALUE']); } } } if (isset($arOneUserField)) { unset($arOneUserField); } } } } if (!empty($arUFListCache)) { foreach ($arUFListCache as &$arOneUserField) { if (!isset($arDestSect[$arOneUserField['FIELD_NAME']])) { continue; } if ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'file') { if (!empty($arDestSect[$arOneUserField['FIELD_NAME']])) { if (is_array($arDestSect[$arOneUserField['FIELD_NAME']])) { $arNewFileList = array(); foreach ($arDestSect[$arOneUserField['FIELD_NAME']] as &$intFileID) { $arNewFile = false; $intFileID = (int) $intFileID; if ($intFileID > 0) { $arNewFile = CFile::MakeFileArray($intFileID); } if (!empty($arNewFile)) { $arNewFileList[] = $arNewFile; } } if (isset($intFileID)) { unset($intFileID); } $arDestSect[$arOneUserField['FIELD_NAME']] = !empty($arNewFileList) ? $arNewFileList : false; } else { $arNewFile = false; $intFileID = (int) $arDestSect[$arOneUserField['FIELD_NAME']]; if ($intFileID > 0) { $arNewFile = CFile::MakeFileArray($intFileID); } $arDestSect[$arOneUserField['FIELD_NAME']] = !empty($arNewFile) ? $arNewFile : false; } } else { $arDestSect[$arOneUserField['FIELD_NAME']] = false; } } elseif ($arOneUserField['USER_TYPE']['BASE_TYPE'] == 'enum') { if (!empty($arDestSect[$arOneUserField['FIELD_NAME']])) { if ($intSrcIBlockID != $intDestIBlockID) { if (array_key_exists($arOneUserField['FIELD_NAME'], $arUFEnumCache) && array_key_exists($arOneUserField['FIELD_NAME'], $arOldUFEnumCache)) { if (is_array($arDestSect[$arOneUserField['FIELD_NAME']])) { $arNewEnumList = array(); foreach ($arDestSect[$arOneUserField['FIELD_NAME']] as &$intValueID) { $strValueXmlID = $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$intValueID]; if (array_key_exists($strValueXmlID, $arUFEnumCache[$arOneUserField['FIELD_NAME']])) { $arNewEnumList[] = $arUFEnumCache[$arOneUserField['FIELD_NAME']][$strValueXmlID]; } else { $strValueName = $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$intValueID]; $intValueKey = array_search($strValueName, $arUFNameEnumCache[$arOneUserField['FIELD_NAME']]); if ($intValueKey !== false) { $arNewEnumList[] = $intValueKey; } } } if (isset($intValueID)) { unset($intValueID); } if (!empty($arNewEnumList)) { $arDestSect[$arOneUserField['FIELD_NAME']] = $arNewEnumList; } } else { $strValueXmlID = $arOldUFEnumCache[$arOneUserField['FIELD_NAME']][$arDestSect[$arOneUserField['FIELD_NAME']]]; if (array_key_exists($strValueXmlID, $arUFEnumCache[$arOneUserField['FIELD_NAME']])) { $arDestSect[$arOneUserField['FIELD_NAME']] = $arUFEnumCache[$arOneUserField['FIELD_NAME']][$strValueXmlID]; } else { $strValueName = $arOldUFNameEnumCache[$arOneUserField['FIELD_NAME']][$arDestSect[$arOneUserField['FIELD_NAME']]]; $intValueKey = array_search($strValueName, $arUFNameEnumCache[$arOneUserField['FIELD_NAME']]); if ($intValueKey !== false) { $arDestSect[$arOneUserField['FIELD_NAME']] = $intValueKey; } } } } } } else { $arDestSect[$arOneUserField['FIELD_NAME']] = false; } } } if (isset($arOneUserField)) { unset($arOneUserField); } } $intNewID = $sc->Add($arDestSect); if (!$intNewID) { CASDiblock::$error .= '[' . $ID . '] ' . $sc->LAST_ERROR . "\n"; } } } } $successRedirect = true; } unset($_REQUEST['action']); if (isset($_REQUEST['action_button'])) { unset($_REQUEST['action_button']); } if ($successRedirect) { LocalRedirect($GLOBALS['APPLICATION']->GetCurPageParam('', array('action', 'action_button', 'asd_ib_dest', 'asd_sect_dest', 'ID'))); } } if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'asd_remove' && $IBLOCK_ID > 0 && isset($_REQUEST['find_section_section']) && check_bitrix_sessid() && CASDIblockRights::IsIBlockDisplay($IBLOCK_ID)) { $intSectionID = (int) $_REQUEST['find_section_section']; if ($intSectionID > 0) { $strCurPage = $GLOBALS['APPLICATION']->GetCurPage(); $bElemPage = $strCurPage == '/bitrix/admin/iblock_element_admin.php' || $strCurPage == '/bitrix/admin/cat_product_admin.php'; $bMixPage = $strCurPage == '/bitrix/admin/iblock_list_admin.php'; if ($bElemPage || $bMixPage) { foreach ($_REQUEST['ID'] as $eID) { if ($bMixPage) { if (substr($eID, 0, 1) != 'E') { continue; } $ID = (int) substr($eID, 1); } else { $ID = (int) $eID; } if ($ID <= 0) { continue; } if (CASDIblockRights::IsElementEdit($IBLOCK_ID, $ID)) { $arSectionList = array(); $rsSections = CIBlockElement::GetElementGroups($ID, true); while ($arSection = $rsSections->Fetch()) { $arSection['ID'] = (int) $arSection['ID']; if ($arSection['ID'] != $intSectionID) { $arSectionList[] = $arSection['ID']; } } CIBlockElement::SetElementSection($ID, $arSectionList, false); $successRedirect = true; } } } } unset($_REQUEST['action']); if (isset($_REQUEST['action_button'])) { unset($_REQUEST['action_button']); } if ($successRedirect) { LocalRedirect($GLOBALS['APPLICATION']->GetCurPageParam('', array('action', 'action_button'))); } } }
public function CloneElement($ID, $arFields = array()) { global $DB; $ID = intval($ID); $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID")); if ($ar_element = $db_element->Fetch()) { $IBLOCK_ID = $ar_element["IBLOCK_ID"]; if ($ar_element["WF_PARENT_ELEMENT_ID"] > 0) { throw new Exception(GetMessage("IBD_ELEMENT_NOT_FOUND")); } else { if ($ar_element["PREVIEW_PICTURE"]) { $ar_element["PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element["PREVIEW_PICTURE"]); } if ($ar_element["DETAIL_PICTURE"]) { $ar_element["DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element["DETAIL_PICTURE"]); } $ar_element["IBLOCK_SECTION"] = array(); if ($ar_element["IN_SECTIONS"] == "Y") { $rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $ar_element["IBLOCK_SECTION"][] = $arSection["ID"]; } } $ar_element["PROPERTY_VALUES"] = array(); foreach ($arFields as $field_id => $value) { if (array_key_exists($field_id, $ar_element)) { $ar_element[$field_id] = $value; } } $ar_element["WF_PARENT_ELEMENT_ID"] = $ID; $ar_element["IBLOCK_ID"] = $IBLOCK_ID; $arProps =& $ar_element["PROPERTY_VALUES"]; //Add new proiperty values $rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_element["ID"], array("value_id" => "asc")); $i = 0; while ($arProp = $rsProps->Fetch()) { if (array_key_exists($arProp["CODE"], $ar_element["PROPERTY_VALUES"])) { continue; } $i++; if (!array_key_exists($arProp["ID"], $arProps)) { $arProps[$arProp["ID"]] = array(); } if ($arProp["PROPERTY_VALUE_ID"]) { if ($arProp["PROPERTY_TYPE"] == "F") { $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => CFile::MakeFileArray($arProp["VALUE"]), "DESCRIPTION" => $arProp["DESCRIPTION"]); } else { $arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]); } } } if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") === "E") { $ibRights = new CIBlockElementRights(intval($IBLOCK_ID), $ID); $arRights = $ibRights->GetRights(); $arNewRights = array(); $rightIndex = 0; foreach ($arRights as $rightID => $right) { if ($right['IS_INHERITED'] !== 'Y') { $arNewRights['n' . $rightIndex++] = $right; } } $ar_element['RIGHTS'] = $arNewRights; } $obElement = new CIBlockElement(); $NEW_ID = $obElement->Add($ar_element); if (!$NEW_ID) { throw new Exception($obElement->LAST_ERROR); } else { return $NEW_ID; } } } else { throw new Exception(GetMessage("IBD_ELEMENT_NOT_FOUND")); } }
$arNeedFields = array_keys($arSortFields); if ($first_line_names) { $csvFile->SaveFile($_SERVER["DOCUMENT_ROOT"].$SETUP_FILE_NAME, $arNeedFields); } $res = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'), false, false, $selectArray); while ($res1 = $res->Fetch()) { $arResSections = array(); if ($bNeedGroups) { $indreseg = 0; $reseg = CIBlockElement::GetElementGroups($res1["ID"], false, array('ID', 'ADDITIONAL_PROPERTY_ID')); while ($reseg1 = $reseg->Fetch()) { if (0 < intval($reseg1['ADDITIONAL_PROPERTY_ID'])) continue; $sections_path = GetIBlockSectionPath($IBLOCK_ID, $reseg1["ID"]); while ($arSection = $sections_path->Fetch()) { $arResSectionTmp = array(); foreach ($arAvailGroupFields_names as $key => $value) { $arResSectionTmp[$key] = $arSection[$value["field"]]; } $arResSections[$indreseg][] = $arResSectionTmp; } $indreseg++;
} else { $lAdmin->AddGroupError(GetMessage("IBLIST_A_UPDERR_ACCESS", array("#ID#" => $ID)), $TYPE.$ID); } } elseif($TYPE=="E") { if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit") && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $new_section, "section_element_bind")) { $obE = new CIBlockElement(); $arSections = array($new_section); if($_REQUEST['action'] == "add_section") { $rsSections = $obE->GetElementGroups($ID, true, array('ID', 'IBLOCK_ELEMENT_ID')); while($ar = $rsSections->Fetch()) $arSections[] = $ar["ID"]; } if(!$obE->Update($ID, array("IBLOCK_SECTION" => $arSections))) { $lAdmin->AddGroupError(GetMessage("IBLIST_A_SAVE_ERROR", array("#ID#" => $ID, "#ERROR_MESSAGE#" => $obE->LAST_ERROR)), $TYPE.$ID); } else { $ipropValues = new \Bitrix\Iblock\InheritedProperty\ElementValues($IBLOCK_ID, $ID); $ipropValues->clearValues(); } } else
$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_")) { if ($str_IN_SECTIONS == "N") { $str_IBLOCK_ELEMENT_SECTION[] = 0; } else { $result = CIBlockElement::GetElementGroups($WF_ID); while ($ar = $result->Fetch()) { $str_IBLOCK_ELEMENT_SECTION[] = $ar["ID"]; } } } else { $WF_ID = 0; $ID = 0; if (is_array($IBLOCK_SECTION_ID)) { foreach ($IBLOCK_SECTION_ID as $id) { if ($id > 0) { $str_IBLOCK_ELEMENT_SECTION[] = $id; } } } elseif ($IBLOCK_SECTION_ID > 0) { $str_IBLOCK_ELEMENT_SECTION[] = $IBLOCK_SECTION_ID;
function BeforeIndexForum($arFields, $entity_type, $entity_id, $feature, $operation, $path_template) { global $USER; static $arSiteData; $SECTION_ID = ""; $ELEMENT_ID = intval($_REQUEST["photo_element_id"]); if (empty($ELEMENT_ID)) { $ELEMENT_ID = intval($_REQUEST["ELEMENT_ID"]); } if ($ELEMENT_ID > 0 && CModule::IncludeModule('iblock')) { $rsSections = CIBlockElement::GetElementGroups($ELEMENT_ID, true); $arSection = $rsSections->Fetch(); if ($arSection) { $SECTION_ID = $arSection["ID"]; } } if (count($arFields["LID"]) > 1 && ($entity_type == SONET_ENTITY_GROUP && CModule::IncludeModule("extranet") || $entity_type == SONET_ENTITY_USER)) { if (!$arSiteData) { $arSiteData = CSocNetLogTools::GetSiteData(); } foreach ($arSiteData as $siteId => $arUrl) { if ($entity_type == SONET_ENTITY_GROUP && strpos($path_template, $arUrl["GROUPS_PATH"]) === 0) { $path_template = str_replace($arUrl["GROUPS_PATH"], "#GROUP_PATH#", $path_template); break; } elseif ($entity_type == SONET_ENTITY_USER && strpos($path_template, $arUrl["USER_PATH"]) === 0) { $path_template = str_replace($arUrl["USER_PATH"], "#USER_PATH#", $path_template); break; } } } foreach ($arFields["LID"] as $site_id => $url) { $arFields["URL"] = $arFields["LID"][$site_id] = str_replace(array("#user_id#", "#group_id#", "#topic_id#", "#message_id#", "#action#", "#user_alias#", "#section_id#", "#element_id#", "#task_id#", "#GROUP_PATH#", "#USER_PATH#"), array($this->_user_id > 0 ? $this->_user_id : $USER->GetID(), $this->_group_id, $arFields["PARAM2"], $arFields["ITEM_ID"], "view", ($entity_type == "G" ? "group_" : "user_") . $entity_id, $SECTION_ID, $ELEMENT_ID, $ELEMENT_ID, $arSiteData ? $arSiteData[$site_id]["GROUPS_PATH"] : "", $arSiteData ? $arSiteData[$site_id]["USER_PATH"] : ""), $path_template); } if ($feature == 'tasks' && COption::GetOptionString("intranet", "use_tasks_2_0", "N") == 'Y' && $arFields["PARAM1"] == COption::GetOptionString("tasks", "task_forum_id", 0) && CModule::IncludeModule('tasks')) { if (!preg_match('/^EVENT_[0-9]+/', $arFields["TITLE"], $match)) { $rsTask = CTasks::GetList(array(), array("FORUM_TOPIC_ID" => $arFields['PARAM2'])); if ($arTask = $rsTask->Fetch()) { $arFields['PERMISSIONS'] = CTasks::__GetSearchPermissions($arTask); } } } else { $arFields["PERMISSIONS"] = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation); $paramsTmp = $this->GetSearchParams($entity_type, $entity_id, $feature, $operation); $arFields["PARAMS"] = !empty($arFields["PARAMS"]) ? array_merge($paramsTmp, $arFields["PARAMS"]) : $paramsTmp; } return $arFields; }
protected function getCategories($productId) { $boolCurrentSections = false; $result = array(); $dbElementGroups = \CIBlockElement::GetElementGroups($productId, false, array('ID', 'ADDITIONAL_PROPERTY_ID')); while ($arElementGroup = $dbElementGroups->Fetch()) { if (0 < (int) $arElementGroup['ADDITIONAL_PROPERTY_ID']) { continue; } $boolCurrentSections = true; if (in_array((int) $arElementGroup["ID"], $this->arSectionIDs)) { $result[] = $arElementGroup["ID"]; } } if (!$boolCurrentSections) { $result[] = $this->intMaxSectionID; } return $result; }
} else { $arChainBody[] = htmlspecialcharsex($arPath["NAME"]); } } $k++; } $arResult["SEARCH"][$i]["CHAIN_PATH"] = implode(' / ', $arChainBody); } if (!$file && $element_type && $element_type != "files") { if (file_exists($abs_path . $element_type . "_default.gif")) { $file = $element_type . "_default.gif"; } } //We failed. next try should be element section if (!$file) { $rsSection = CIBlockElement::GetElementGroups($arItem["ITEM_ID"], true); $arSection = $rsSection->Fetch(); if ($arSection) { $SECTION_ID = $arSection["ID"]; } } else { $SECTION_ID = false; } } else { $SECTION_ID = $arItem["ITEM_ID"]; } //If no element icon was found. We'll take chances with section if (!$file && $SECTION_ID) { $rsSection = CIBlockSection::GetList(array(), array("=ID" => $SECTION_ID, "IBLOCK_ID" => $arItem["PARAM2"])); if ($arSection = $rsSection->Fetch()) { if (strlen($arSection["CODE"]) && file_exists($abs_path . "iblock_section_" . strtolower($arSection["CODE"]) . ".gif")) {
} } } } else { //We will not update property values unset($arFields["PROPERTY_VALUES"]); } //All not displayed required fields from DB foreach ($arSubIBlock["FIELDS"] as $FIELD_ID => $field) { if ($field["IS_REQUIRED"] === "Y" && !array_key_exists($FIELD_ID, $arFields) && $FIELD_ID !== "DETAIL_PICTURE" && $FIELD_ID !== "PREVIEW_PICTURE") { $arFields[$FIELD_ID] = $arRes[$FIELD_ID]; } } if ($arRes["IN_SECTIONS"] == "Y") { $arFields["IBLOCK_SECTION"] = array(); $rsSections = CIBlockElement::GetElementGroups($arRes["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID')); while ($arSection = $rsSections->Fetch()) { $arFields["IBLOCK_SECTION"][] = $arSection["ID"]; } } $arFields["MODIFIED_BY"] = $USER->GetID(); $ib = new CIBlockElement(); $DB->StartTransaction(); if (!$ib->Update($subID, $arFields, true, true, true)) { $lAdmin->AddUpdateError(GetMessage("IBEL_A_SAVE_ERROR", array("#ID#" => $subID, "#ERROR_TEXT#" => $ib->LAST_ERROR)), $subID); $DB->Rollback(); } else { $DB->Commit(); } if ($boolSubCatalog) { if ($boolCatalogPrice && CIBlockElementRights::UserHasRightTo($intSubIBlockID, $subID, "element_edit_price")) {