public function canRead($userId)
 {
     if (!Loader::includeModule("iblock")) {
         return false;
     }
     $elementId = $this->entityId;
     $elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_ID'));
     $element = $elementQuery->fetch();
     if (!$element['IBLOCK_ID']) {
         return false;
     }
     return \CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read");
 }
 public function canRead($userId)
 {
     if (!Loader::includeModule("lists")) {
         return false;
     }
     $elementId = $this->entityId;
     $elementQuery = \CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('IBLOCK_TYPE_ID', 'IBLOCK_ID'));
     $element = $elementQuery->fetch();
     $listPerm = \CListPermissions::checkAccess($this->getUser(), $element['IBLOCK_TYPE_ID'], $element['IBLOCK_ID']);
     if ($listPerm < 0) {
         return false;
     } elseif ($listPerm < \CListPermissions::CAN_READ && !\CIBlockElementRights::userHasRightTo($element['IBLOCK_ID'], $elementId, "element_read")) {
         return false;
     } else {
         return true;
     }
 }
Beispiel #3
0
 public function checkUserReadAccess($parameters)
 {
     global $USER;
     $parameters['listId'] = (int) $parameters['listId'];
     $parameters['elementId'] = (int) $parameters['elementId'];
     if ($parameters['listId'] == 0 || $parameters['elementId'] == 0) {
         return false;
     }
     $userPermission = \CListPermissions::CheckAccess($USER, $parameters["IBLOCK_TYPE_ID"], $parameters['listId']);
     if ($userPermission < 0) {
         return false;
     } else {
         if ($userPermission < \CListPermissions::CAN_READ && !\CIBlockElementRights::UserHasRightTo($parameters['listId'], $parameters['elementId'], "element_read")) {
             return false;
         }
     }
     return true;
 }
Beispiel #4
0
 public static function CheckElementOperation($intIBlockID, $intElementID, $strOperation, $strAccess)
 {
     $intIBlockID = intval($intIBlockID);
     if ($intIBlockID <= 0) {
         return false;
     }
     $intElementID = intval($intElementID);
     if ($intElementID <= 0) {
         return false;
     }
     if (!self::$boolCheck) {
         self::CheckExtRights();
     }
     if (self::$boolExtRights) {
         return CIBlockElementRights::UserHasRightTo($intIBlockID, $intElementID, $strOperation);
     } else {
         return CIBlock::GetPermission($intIBlockID) >= $strAccess;
     }
 }
Beispiel #5
0
 protected function terminateWorkflow($workflowId, $elementId)
 {
     $this->checkPermission();
     if (!CBPDocument::canUserOperateDocument(CBPCanUserOperateOperation::StartWorkflow, $this->getUser(), BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), array("DocumentStates" => $this->documentStates))) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     if (CIBlockElementRights::userHasRightTo($this->iblockId, $elementId, "element_rights_edit")) {
         $errors = array();
         CBPDocument::terminateWorkflow($workflowId, BizProcDocument::getDocumentComplexId($this->iblockTypeId, $elementId), $errors);
         foreach ($errors as $error) {
             $this->errorCollection->add(array(new Error($error["message"])));
         }
     } else {
         $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_LAC_ACCESS_DENIED'))));
     }
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
 }
Beispiel #6
0
                     $arStr[$vv["TEMPLATE_ID"]] .= GetMessage("IBEL_A_BP_TASK") . ":<br /><a href=\"bizproc_task.php?id=" . $arTask["ID"] . "\" title=\"" . $arTask["DESCRIPTION"] . "\">" . $arTask["NAME"] . "</a><br /><br />";
                 }
             }
         }
         $str = "";
         foreach ($arStr as $k => $v) {
             $row->AddViewField("WF_" . $k, $v);
             $str .= "<b>" . (strlen($arStr1[$k]) > 0 ? $arStr1[$k] : GetMessage("IBEL_A_BP_PROC")) . "</b>:<br />" . $v . "<br />";
         }
         $row->AddViewField("BIZPROC", $str);
     }
 }
 $boolIBlockElementAdd = CIBlockSectionRights::UserHasRightTo($intSubIBlockID, $find_section_section, "section_element_bind");
 $availQuantityTrace = COption::GetOptionString("catalog", "default_quantity_trace", 'N');
 $arQuantityTrace = array("D" => GetMessage("IBEL_DEFAULT_VALUE") . " (" . ($availQuantityTrace == 'Y' ? GetMessage("IBEL_YES_VALUE") : GetMessage("IBEL_NO_VALUE")) . ")", "Y" => GetMessage("IBEL_YES_VALUE"), "N" => GetMessage("IBEL_NO_VALUE"));
 $arElementOps = CIBlockElementRights::UserHasRightTo($intSubIBlockID, array_keys($arRows), "", CIBlockRights::RETURN_OPERATIONS);
 foreach ($arRows as $f_ID => $row) {
     $edit_url = '/bitrix/admin/iblock_subelement_edit.php?WF=Y&type=' . urlencode($strSubIBlockType) . '&IBLOCK_ID=' . $intSubIBlockID . '&lang=' . LANGUAGE_ID . '&PRODUCT_ID=' . $ID . '&ID=' . $row->arRes['orig']['ID'] . '&TMP_ID=' . $strSubTMP_ID . $sThisSectionUrl;
     if (array_key_exists("PREVIEW_PICTURE", $arSelectedFieldsMap)) {
         $row->AddViewField("PREVIEW_PICTURE", CFile::ShowFile($row->arRes['PREVIEW_PICTURE'], 100000, 50, 50, true));
     }
     if (array_key_exists("DETAIL_PICTURE", $arSelectedFieldsMap)) {
         $row->AddViewField("DETAIL_PICTURE", CFile::ShowFile($row->arRes['DETAIL_PICTURE'], 100000, 50, 50, true));
     }
     if (array_key_exists("PREVIEW_TEXT", $arSelectedFieldsMap)) {
         $row->AddViewField("PREVIEW_TEXT", $row->arRes["PREVIEW_TEXT_TYPE"] == "text" ? htmlspecialcharsex($row->arRes["PREVIEW_TEXT"]) : HTMLToTxt($row->arRes["PREVIEW_TEXT"]));
     }
     if (array_key_exists("DETAIL_TEXT", $arSelectedFieldsMap)) {
         $row->AddViewField("DETAIL_TEXT", $row->arRes["DETAIL_TEXT_TYPE"] == "text" ? htmlspecialcharsex($row->arRes["DETAIL_TEXT"]) : HTMLToTxt($row->arRes["DETAIL_TEXT"]));
     }
     if (isset($arElementOps[$f_ID]) && isset($arElementOps[$f_ID]["element_edit"])) {
Beispiel #7
0
 function UpdateSearch($ID, $bOverWrite = false)
 {
     if (!CModule::IncludeModule("search")) {
         return;
     }
     global $DB;
     $ID = Intval($ID);
     static $strElementSql = false;
     if (!$strElementSql) {
         $strElementSql = "\n\t\t\t\tSELECT BE.ID, BE.NAME, BE.XML_ID as EXTERNAL_ID,\n\t\t\t\t\tBE.PREVIEW_TEXT_TYPE, BE.PREVIEW_TEXT, BE.CODE,\n\t\t\t\t\tBE.TAGS,\n\t\t\t\t\tBE.DETAIL_TEXT_TYPE, BE.DETAIL_TEXT, BE.IBLOCK_ID, B.IBLOCK_TYPE_ID,\n\t\t\t\t\t" . $DB->DateToCharFunction("BE.TIMESTAMP_X") . " as LAST_MODIFIED,\n\t\t\t\t\t" . $DB->DateToCharFunction("BE.ACTIVE_FROM") . " as DATE_FROM,\n\t\t\t\t\t" . $DB->DateToCharFunction("BE.ACTIVE_TO") . " as DATE_TO,\n\t\t\t\t\tBE.IBLOCK_SECTION_ID,\n\t\t\t\t\tB.CODE as IBLOCK_CODE, B.XML_ID as IBLOCK_EXTERNAL_ID, B.DETAIL_PAGE_URL,\n\t\t\t\t\tB.VERSION, B.RIGHTS_MODE, B.SOCNET_GROUP_ID\n\t\t\t\tFROM b_iblock_element BE, b_iblock B\n\t\t\t\tWHERE BE.IBLOCK_ID=B.ID\n\t\t\t\t\tAND B.ACTIVE='Y'\n\t\t\t\t\tAND BE.ACTIVE='Y'\n\t\t\t\t\tAND B.INDEX_ELEMENT='Y'\n\t\t\t\t\t" . CIBlockElement::WF_GetSqlLimit("BE.", "N") . "\n\t\t\t\t\tAND BE.ID=";
     }
     $dbrIBlockElement = $DB->Query($strElementSql . $ID);
     if ($arIBlockElement = $dbrIBlockElement->Fetch()) {
         $IBLOCK_ID = $arIBlockElement["IBLOCK_ID"];
         $DETAIL_URL = "=ID=" . urlencode($arIBlockElement["ID"]) . "&EXTERNAL_ID=" . urlencode($arIBlockElement["EXTERNAL_ID"]) . "&IBLOCK_SECTION_ID=" . urlencode($arIBlockElement["IBLOCK_SECTION_ID"]) . "&IBLOCK_TYPE_ID=" . urlencode($arIBlockElement["IBLOCK_TYPE_ID"]) . "&IBLOCK_ID=" . urlencode($arIBlockElement["IBLOCK_ID"]) . "&IBLOCK_CODE=" . urlencode($arIBlockElement["IBLOCK_CODE"]) . "&IBLOCK_EXTERNAL_ID=" . urlencode($arIBlockElement["IBLOCK_EXTERNAL_ID"]) . "&CODE=" . urlencode($arIBlockElement["CODE"]);
         static $arGroups = array();
         if (!array_key_exists($IBLOCK_ID, $arGroups)) {
             $arGroups[$IBLOCK_ID] = array();
             $strSql = "SELECT GROUP_ID " . "FROM b_iblock_group " . "WHERE IBLOCK_ID= " . $IBLOCK_ID . " " . "\tAND PERMISSION>='R' " . "ORDER BY GROUP_ID";
             $dbrIBlockGroup = $DB->Query($strSql);
             while ($arIBlockGroup = $dbrIBlockGroup->Fetch()) {
                 $arGroups[$IBLOCK_ID][] = $arIBlockGroup["GROUP_ID"];
                 if ($arIBlockGroup["GROUP_ID"] == 2) {
                     break;
                 }
             }
         }
         static $arSITE = array();
         if (!array_key_exists($IBLOCK_ID, $arSITE)) {
             $arSITE[$IBLOCK_ID] = array();
             $strSql = "SELECT SITE_ID " . "FROM b_iblock_site " . "WHERE IBLOCK_ID= " . $IBLOCK_ID;
             $dbrIBlockSite = $DB->Query($strSql);
             while ($arIBlockSite = $dbrIBlockSite->Fetch()) {
                 $arSITE[$IBLOCK_ID][] = $arIBlockSite["SITE_ID"];
             }
         }
         $BODY = ($arIBlockElement["PREVIEW_TEXT_TYPE"] == "html" ? CSearch::KillTags($arIBlockElement["PREVIEW_TEXT"]) : $arIBlockElement["PREVIEW_TEXT"]) . "\r\n" . ($arIBlockElement["DETAIL_TEXT_TYPE"] == "html" ? CSearch::KillTags($arIBlockElement["DETAIL_TEXT"]) : $arIBlockElement["DETAIL_TEXT"]);
         static $arProperties = array();
         if (!array_key_exists($IBLOCK_ID, $arProperties)) {
             $arProperties[$IBLOCK_ID] = array();
             $rsProperties = CIBlockProperty::GetList(array("sort" => "asc", "id" => "asc"), array("IBLOCK_ID" => $IBLOCK_ID, "ACTIVE" => "Y", "SEARCHABLE" => "Y", "CHECK_PERMISSIONS" => "N"));
             while ($ar = $rsProperties->Fetch()) {
                 if (strlen($ar["USER_TYPE"]) > 0) {
                     $arUT = CIBlockProperty::GetUserType($ar["USER_TYPE"]);
                     if (array_key_exists("GetSearchContent", $arUT)) {
                         $ar["GetSearchContent"] = $arUT["GetSearchContent"];
                     } elseif (array_key_exists("GetPublicViewHTML", $arUT)) {
                         $ar["GetSearchContent"] = $arUT["GetPublicViewHTML"];
                     }
                 }
                 $arProperties[$IBLOCK_ID][$ar["ID"]] = $ar;
             }
         }
         //Read current property values from database
         $strProperties = "";
         if (count($arProperties[$IBLOCK_ID]) > 0) {
             if ($arIBlockElement["VERSION"] == 1) {
                 $rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_property\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID in (" . implode(", ", array_keys($arProperties[$IBLOCK_ID])) . ")\n\t\t\t\t\t");
                 while ($ar = $rs->Fetch()) {
                     $strProperties .= "\r\n";
                     $arProperty = $arProperties[$IBLOCK_ID][$ar["IBLOCK_PROPERTY_ID"]];
                     if ($arProperty["GetSearchContent"]) {
                         $strProperties .= CSearch::KillTags(call_user_func_array($arProperty["GetSearchContent"], array($arProperty, array("VALUE" => $ar["VALUE"]), array())));
                     } elseif ($arProperty["PROPERTY_TYPE"] == 'L') {
                         $arEnum = CIBlockPropertyEnum::GetByID($ar["VALUE"]);
                         if ($arEnum !== false) {
                             $strProperties .= $arEnum["VALUE"];
                         }
                     } elseif ($arProperty["PROPERTY_TYPE"] == 'F') {
                         $arFile = CIBlockElement::__GetFileContent($ar["VALUE"]);
                         if (is_array($arFile)) {
                             $strProperties .= $arFile["CONTENT"];
                             $arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
                         }
                     } else {
                         $strProperties .= $ar["VALUE"];
                     }
                 }
             } else {
                 $rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_prop_m" . $IBLOCK_ID . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t\tAND IBLOCK_PROPERTY_ID in (" . implode(", ", array_keys($arProperties[$IBLOCK_ID])) . ")\n\t\t\t\t\t");
                 while ($ar = $rs->Fetch()) {
                     $strProperties .= "\r\n";
                     $arProperty = $arProperties[$IBLOCK_ID][$ar["IBLOCK_PROPERTY_ID"]];
                     if ($arProperty["GetSearchContent"]) {
                         $strProperties .= CSearch::KillTags(call_user_func_array($arProperty["GetSearchContent"], array($arProperty, array("VALUE" => $ar["VALUE"]), array())));
                     } elseif ($arProperty["PROPERTY_TYPE"] == 'L') {
                         $arEnum = CIBlockPropertyEnum::GetByID($ar["VALUE"]);
                         if ($arEnum !== false) {
                             $strProperties .= $arEnum["VALUE"];
                         }
                     } elseif ($arProperty["PROPERTY_TYPE"] == 'F') {
                         $arFile = CIBlockElement::__GetFileContent($ar["VALUE"]);
                         if (is_array($arFile)) {
                             $strProperties .= $arFile["CONTENT"];
                             $arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
                         }
                     } else {
                         $strProperties .= $ar["VALUE"];
                     }
                 }
                 $rs = $DB->Query("\n\t\t\t\t\t\tselect *\n\t\t\t\t\t\tfrom b_iblock_element_prop_s" . $IBLOCK_ID . "\n\t\t\t\t\t\twhere IBLOCK_ELEMENT_ID=" . $arIBlockElement["ID"] . "\n\t\t\t\t\t");
                 if ($ar = $rs->Fetch()) {
                     foreach ($arProperties[$IBLOCK_ID] as $property_id => $property) {
                         if (array_key_exists("PROPERTY_" . $property_id, $ar) && $property["MULTIPLE"] == "N" && strlen($ar["PROPERTY_" . $property_id]) > 0) {
                             $strProperties .= "\r\n";
                             if ($property["GetSearchContent"]) {
                                 $strProperties .= CSearch::KillTags(call_user_func_array($property["GetSearchContent"], array($property, array("VALUE" => $ar["PROPERTY_" . $property_id]), array())));
                             } elseif ($property["PROPERTY_TYPE"] == 'L') {
                                 $arEnum = CIBlockPropertyEnum::GetByID($ar["PROPERTY_" . $property_id]);
                                 if ($arEnum !== false) {
                                     $strProperties .= $arEnum["VALUE"];
                                 }
                             } elseif ($property["PROPERTY_TYPE"] == 'F') {
                                 $arFile = CIBlockElement::__GetFileContent($ar["PROPERTY_" . $property_id]);
                                 if (is_array($arFile)) {
                                     $strProperties .= $arFile["CONTENT"];
                                     $arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
                                 }
                             } else {
                                 $strProperties .= $ar["PROPERTY_" . $property_id];
                             }
                         }
                     }
                 }
             }
         }
         $BODY .= $strProperties;
         if ($arIBlockElement["RIGHTS_MODE"] !== "E") {
             $arPermissions = $arGroups[$IBLOCK_ID];
         } else {
             $obElementRights = new CIBlockElementRights($IBLOCK_ID, $arIBlockElement["ID"]);
             $arPermissions = $obElementRights->GetGroups(array("element_read"));
         }
         $arFields = array("LAST_MODIFIED" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : $arIBlockElement["LAST_MODIFIED"], "DATE_FROM" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : false, "DATE_TO" => strlen($arIBlockElement["DATE_TO"]) > 0 ? $arIBlockElement["DATE_TO"] : false, "TITLE" => $arIBlockElement["NAME"], "PARAM1" => $arIBlockElement["IBLOCK_TYPE_ID"], "PARAM2" => $IBLOCK_ID, "SITE_ID" => $arSITE[$IBLOCK_ID], "PERMISSIONS" => $arPermissions, "URL" => $DETAIL_URL, "BODY" => $BODY, "TAGS" => $arIBlockElement["TAGS"]);
         if ($arIBlockElement["SOCNET_GROUP_ID"] > 0) {
             $arFields["PARAMS"] = array("socnet_group" => $arIBlockElement["SOCNET_GROUP_ID"]);
         }
         CSearch::Index("iblock", $ID, $arFields, $bOverWrite);
     } else {
         CSearch::DeleteIndex("iblock", $ID);
     }
 }
Beispiel #8
0
                         foreach ($arErrorsTmp as $e) {
                             $strWarning .= $e["message"] . "<br />";
                         }
                     }
                 }
             }
             $arDocumentStates = null;
             CBPDocument::AddDocumentToHistory(BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), $arElement["NAME"], $GLOBALS["USER"]->GetID());
         }
     }
     if (!$strError) {
         //Successfull update
         //And go to proper page
         if (isset($_POST["save"])) {
             LocalRedirect($arResult["~LIST_SECTION_URL"]);
         } elseif ($lists_perm < CListPermissions::CAN_READ && !CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_read")) {
             LocalRedirect($arResult["~LIST_SECTION_URL"]);
         } else {
             $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arResult["IBLOCK_ID"], intval($_POST["IBLOCK_SECTION_ID"]), $arResult["ELEMENT_ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~LIST_ELEMENT_URL"]), array($tab_name => $_POST[$tab_name]), array("skip_empty" => true, "encode" => true));
             if (isset($_GET["list_section_id"]) && strlen($_GET["list_section_id"]) == 0) {
                 $url = CHTTP::urlAddParams($url, array("list_section_id" => ""));
             }
             LocalRedirect($url);
         }
     } else {
         ShowError($strError);
         $bVarsFromForm = true;
     }
 } else {
     //Go to list section page
     LocalRedirect($arResult["~LIST_SECTION_URL"]);
Beispiel #9
0
 public static function OnSearchReindex($NS = array(), $oCallback = NULL, $callback_method = "")
 {
     /** @global CUserTypeManager $USER_FIELD_MANAGER */
     global $USER_FIELD_MANAGER;
     /** $global CDatabase $DB */
     global $DB;
     $strNSJoin1 = "";
     $strNSFilter1 = "";
     $strNSFilter2 = "";
     $strNSFilter3 = "";
     $arResult = array();
     if ($NS["MODULE"] == "iblock" && strlen($NS["ID"]) > 0) {
         $arrTmp = explode(".", $NS["ID"]);
         $strNSFilter1 = " AND B.ID>=" . IntVal($arrTmp[0]) . " ";
         if (substr($arrTmp[1], 0, 1) != 'S') {
             $strNSFilter2 = " AND BE.ID>" . IntVal($arrTmp[1]) . " ";
         } else {
             $strNSFilter2 = false;
             $strNSFilter3 = " AND BS.ID>" . IntVal(substr($arrTmp[1], 1)) . " ";
         }
     }
     if ($NS["SITE_ID"] != "") {
         $strNSJoin1 .= " INNER JOIN b_iblock_site BS ON BS.IBLOCK_ID=B.ID ";
         $strNSFilter1 .= " AND BS.SITE_ID='" . $DB->ForSQL($NS["SITE_ID"]) . "' ";
     }
     $strSql = "\n\t\t\tSELECT B.ID, B.IBLOCK_TYPE_ID, B.INDEX_ELEMENT, B.INDEX_SECTION, B.RIGHTS_MODE,\n\t\t\t\tB.IBLOCK_TYPE_ID, B.CODE as IBLOCK_CODE, B.XML_ID as IBLOCK_EXTERNAL_ID\n\t\t\tFROM b_iblock B\n\t\t\t" . $strNSJoin1 . "\n\t\t\tWHERE B.ACTIVE = 'Y'\n\t\t\t\tAND (B.INDEX_ELEMENT='Y' OR B.INDEX_SECTION='Y')\n\t\t\t\t" . $strNSFilter1 . "\n\t\t\tORDER BY B.ID\n\t\t";
     $dbrIBlock = $DB->Query($strSql);
     while ($arIBlock = $dbrIBlock->Fetch()) {
         $IBLOCK_ID = $arIBlock["ID"];
         $arGroups = array();
         $strSql = "SELECT GROUP_ID " . "FROM b_iblock_group " . "WHERE IBLOCK_ID= " . $IBLOCK_ID . " " . "\tAND PERMISSION>='R' " . "\tAND GROUP_ID>1 " . "ORDER BY GROUP_ID";
         $dbrIBlockGroup = $DB->Query($strSql);
         while ($arIBlockGroup = $dbrIBlockGroup->Fetch()) {
             $arGroups[] = $arIBlockGroup["GROUP_ID"];
             if ($arIBlockGroup["GROUP_ID"] == 2) {
                 break;
             }
         }
         $arSITE = array();
         $strSql = "SELECT SITE_ID " . "FROM b_iblock_site " . "WHERE IBLOCK_ID= " . $IBLOCK_ID;
         $dbrIBlockSite = $DB->Query($strSql);
         while ($arIBlockSite = $dbrIBlockSite->Fetch()) {
             $arSITE[] = $arIBlockSite["SITE_ID"];
         }
         if ($arIBlock["INDEX_ELEMENT"] == 'Y' && $strNSFilter2 !== false) {
             $strSql = "SELECT BE.ID, BE.NAME, BE.TAGS, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_FROM") . " as DATE_FROM, " . "\t" . $DB->DateToCharFunction("BE.ACTIVE_TO") . " as DATE_TO, " . "\t" . $DB->DateToCharFunction("BE.TIMESTAMP_X") . " as LAST_MODIFIED, " . "\tBE.PREVIEW_TEXT_TYPE, BE.PREVIEW_TEXT, " . "\tBE.DETAIL_TEXT_TYPE, BE.DETAIL_TEXT, " . "\tBE.XML_ID as EXTERNAL_ID, BE.CODE, " . "\tBE.IBLOCK_SECTION_ID " . "FROM b_iblock_element BE " . "WHERE BE.IBLOCK_ID=" . $IBLOCK_ID . " " . "\tAND BE.ACTIVE='Y' " . CIBlockElement::WF_GetSqlLimit("BE.", "N") . $strNSFilter2 . "ORDER BY BE.ID ";
             //For MySQL we have to solve client out of memory
             //problem by limiting the query
             if ($DB->type == "MYSQL") {
                 $limit = 1000;
                 $strSql .= " LIMIT " . $limit;
             } else {
                 $limit = false;
             }
             $dbrIBlockElement = $DB->Query($strSql);
             while ($arIBlockElement = $dbrIBlockElement->Fetch()) {
                 $DETAIL_URL = "=ID=" . $arIBlockElement["ID"] . "&EXTERNAL_ID=" . $arIBlockElement["EXTERNAL_ID"] . "&CODE=" . $arIBlockElement["CODE"] . "&IBLOCK_SECTION_ID=" . $arIBlockElement["IBLOCK_SECTION_ID"] . "&IBLOCK_TYPE_ID=" . $arIBlock["IBLOCK_TYPE_ID"] . "&IBLOCK_ID=" . $IBLOCK_ID . "&IBLOCK_CODE=" . $arIBlock["IBLOCK_CODE"] . "&IBLOCK_EXTERNAL_ID=" . $arIBlock["IBLOCK_EXTERNAL_ID"];
                 $BODY = ($arIBlockElement["PREVIEW_TEXT_TYPE"] == "html" ? CSearch::KillTags($arIBlockElement["PREVIEW_TEXT"]) : $arIBlockElement["PREVIEW_TEXT"]) . "\r\n" . ($arIBlockElement["DETAIL_TEXT_TYPE"] == "html" ? CSearch::KillTags($arIBlockElement["DETAIL_TEXT"]) : $arIBlockElement["DETAIL_TEXT"]);
                 $dbrProperties = CIBlockElement::GetProperty($IBLOCK_ID, $arIBlockElement["ID"], "sort", "asc", array("ACTIVE" => "Y", "SEARCHABLE" => "Y"));
                 while ($arProperties = $dbrProperties->Fetch()) {
                     $BODY .= "\r\n";
                     if (strlen($arProperties["USER_TYPE"]) > 0) {
                         $UserType = CIBlockProperty::GetUserType($arProperties["USER_TYPE"]);
                     } else {
                         $UserType = array();
                     }
                     if (array_key_exists("GetSearchContent", $UserType)) {
                         $BODY .= CSearch::KillTags(call_user_func_array($UserType["GetSearchContent"], array($arProperties['ID'], array("VALUE" => $arProperties["VALUE"]), array())));
                     } elseif (array_key_exists("GetPublicViewHTML", $UserType)) {
                         $BODY .= CSearch::KillTags(call_user_func_array($UserType["GetPublicViewHTML"], array($arProperties['ID'], array("VALUE" => $arProperties["VALUE"]), array())));
                     } elseif ($arProperties["PROPERTY_TYPE"] == 'L') {
                         $BODY .= $arProperties["VALUE_ENUM"];
                     } elseif ($arProperties["PROPERTY_TYPE"] == 'F') {
                         $arFile = CIBlockElement::__GetFileContent($arProperties["VALUE"]);
                         if (is_array($arFile)) {
                             $BODY .= $arFile["CONTENT"];
                             $arIBlockElement["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
                         }
                     } else {
                         $BODY .= $arProperties["VALUE"];
                     }
                 }
                 if ($arIBlock["RIGHTS_MODE"] !== "E") {
                     $arPermissions = $arGroups;
                 } else {
                     $obElementRights = new CIBlockElementRights($IBLOCK_ID, $arIBlockElement["ID"]);
                     $arPermissions = $obElementRights->GetGroups(array("element_read"));
                 }
                 $Result = array("ID" => $arIBlockElement["ID"], "LAST_MODIFIED" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : $arIBlockElement["LAST_MODIFIED"], "TITLE" => $arIBlockElement["NAME"], "BODY" => $BODY, "TAGS" => $arIBlockElement["TAGS"], "SITE_ID" => $arSITE, "PARAM1" => $arIBlock["IBLOCK_TYPE_ID"], "PARAM2" => $IBLOCK_ID, "DATE_FROM" => strlen($arIBlockElement["DATE_FROM"]) > 0 ? $arIBlockElement["DATE_FROM"] : false, "DATE_TO" => strlen($arIBlockElement["DATE_TO"]) > 0 ? $arIBlockElement["DATE_TO"] : false, "PERMISSIONS" => $arPermissions, "URL" => $DETAIL_URL);
                 if ($oCallback) {
                     $res = call_user_func(array($oCallback, $callback_method), $Result);
                     if (!$res) {
                         return $IBLOCK_ID . "." . $arIBlockElement["ID"];
                     }
                 } else {
                     $arResult[] = $Result;
                 }
                 if ($limit !== false) {
                     $limit--;
                     if ($limit <= 0) {
                         return $IBLOCK_ID . "." . $arIBlockElement["ID"];
                     }
                 }
             }
         }
         if ($arIBlock["INDEX_SECTION"] == 'Y') {
             $strSql = "SELECT BS.ID, BS.NAME, " . "\t" . $DB->DateToCharFunction("BS.TIMESTAMP_X") . " as LAST_MODIFIED, " . "\tBS.DESCRIPTION_TYPE, BS.DESCRIPTION, BS.XML_ID as EXTERNAL_ID, BS.CODE, " . "\tBS.IBLOCK_ID " . "FROM b_iblock_section BS " . "WHERE BS.IBLOCK_ID=" . $IBLOCK_ID . " " . "\tAND BS.GLOBAL_ACTIVE='Y' " . $strNSFilter3 . "ORDER BY BS.ID ";
             $dbrIBlockSection = $DB->Query($strSql);
             while ($arIBlockSection = $dbrIBlockSection->Fetch()) {
                 $DETAIL_URL = "=ID=" . $arIBlockSection["ID"] . "&EXTERNAL_ID=" . $arIBlockSection["EXTERNAL_ID"] . "&CODE=" . $arIBlockSection["CODE"] . "&IBLOCK_TYPE_ID=" . $arIBlock["IBLOCK_TYPE_ID"] . "&IBLOCK_ID=" . $arIBlockSection["IBLOCK_ID"] . "&IBLOCK_CODE=" . $arIBlock["IBLOCK_CODE"] . "&IBLOCK_EXTERNAL_ID=" . $arIBlock["IBLOCK_EXTERNAL_ID"];
                 $BODY = $arIBlockSection["DESCRIPTION_TYPE"] == "html" ? CSearch::KillTags($arIBlockSection["DESCRIPTION"]) : $arIBlockSection["DESCRIPTION"];
                 $BODY .= $USER_FIELD_MANAGER->OnSearchIndex("IBLOCK_" . $arIBlockSection["IBLOCK_ID"] . "_SECTION", $arIBlockSection["ID"]);
                 if ($arIBlock["RIGHTS_MODE"] !== "E") {
                     $arPermissions = $arGroups;
                 } else {
                     $obSectionRights = new CIBlockSectionRights($IBLOCK_ID, $arIBlockSection["ID"]);
                     $arPermissions = $obSectionRights->GetGroups(array("section_read"));
                 }
                 $Result = array("ID" => "S" . $arIBlockSection["ID"], "LAST_MODIFIED" => $arIBlockSection["LAST_MODIFIED"], "TITLE" => $arIBlockSection["NAME"], "BODY" => $BODY, "SITE_ID" => $arSITE, "PARAM1" => $arIBlock["IBLOCK_TYPE_ID"], "PARAM2" => $IBLOCK_ID, "PERMISSIONS" => $arPermissions, "URL" => $DETAIL_URL);
                 if ($oCallback) {
                     $res = call_user_func(array($oCallback, $callback_method), $Result);
                     if (!$res) {
                         return $IBLOCK_ID . ".S" . $arIBlockSection["ID"];
                     }
                 } else {
                     $arResult[] = $Result;
                 }
             }
         }
         $strNSFilter2 = "";
         $strNSFilter3 = "";
     }
     if ($oCallback) {
         return false;
     }
     return $arResult;
 }
Beispiel #10
0
 function IndexIBlockElement($arFields, $entity_id, $entity_type, $feature, $operation, $path_template, $arFieldList)
 {
     $ID = intval($arFields["ID"]);
     $IBLOCK_ID = intval($arFields["IBLOCK_ID"]);
     $IBLOCK_SECTION_ID = is_array($arFields["IBLOCK_SECTION"]) ? $arFields["IBLOCK_SECTION"][0] : $arFields["IBLOCK_SECTION"];
     $arItem = array();
     if ($entity_type == "G") {
         $url = str_replace(array("#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#", "#name#"), array($entity_id, "group_" . $entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"], urlencode($arFields["NAME"])), $path_template);
     } else {
         $url = str_replace(array("#user_id#", "#user_alias#", "#section_id#", "#element_id#", "#action#", "#task_id#"), array($entity_id, "user_" . $entity_id, $IBLOCK_SECTION_ID, $arFields["ID"], "view", $arFields["ID"]), $path_template);
     }
     $body = "";
     if ($feature == "wiki") {
         $CWikiParser = new CWikiParser();
     }
     foreach ($arFieldList as $field) {
         if ($field == "PREVIEW_TEXT" || $field == "DETAIL_TEXT") {
             if (isset($CWikiParser)) {
                 $arFields[$field] = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field]));
             } elseif (isset($arFields[$field . "_TYPE"]) && $arFields[$field . "_TYPE"] === "html") {
                 $arFields[$field] = HTMLToTxt($arFields[$field]);
             }
         }
         $body .= $arFields[$field] . "\n\r";
     }
     if (isset($CWikiParser)) {
         $title = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $arFields['NAME']);
     } else {
         $title = $arFields["NAME"];
     }
     $arPermissions = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation);
     if (CIBlock::GetArrayByID($IBLOCK_ID, "RIGHTS_MODE") == "E") {
         $obElementRights = new CIBlockElementRights($IBLOCK_ID, $arFields["ID"]);
         $arPermissions = $obElementRights->GetGroups(array("element_read"));
     }
     $arSearchIndexParams = $this->GetSearchParams($entity_type, $entity_id, $feature, $operation);
     CSearch::Index("socialnetwork", $ID, array("LAST_MODIFIED" => ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"), "TITLE" => $title, "BODY" => $body, "SITE_ID" => array(SITE_ID => $url), "PARAM1" => CIBlock::GetArrayByID($IBLOCK_ID, "IBLOCK_TYPE_ID"), "PARAM2" => $IBLOCK_ID, "PARAM3" => $feature, "TAGS" => $arFields["TAGS"], "PERMISSIONS" => $arPermissions, "PARAMS" => $arSearchIndexParams), true);
     if (defined("BX_COMP_MANAGED_CACHE")) {
         $GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_search_" . $entity_type . "_" . $entity_id);
     }
 }
         $arID[] = $arRes['ID'];
     }
 }
 foreach ($arID as $ID) {
     if (strlen($ID) <= 0) {
         continue;
     }
     $ID = intval($ID);
     $arRes = CIBlockElement::GetByID($ID);
     $arRes = $arRes->Fetch();
     if (!$arRes) {
         continue;
     }
     $bPermissions = false;
     //delete and modify can:
     if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit_any_wf_status ")) {
         $bPermissions = true;
     } else {
         //For delete action we have to check all statuses in element history
         $STATUS_PERMISSION = CIBlockElement::WF_GetStatusPermission($arRes["WF_STATUS_ID"], $_REQUEST['action'] == "delete" ? $ID : false);
         if ($STATUS_PERMISSION >= 2) {
             $bPermissions = true;
         }
     }
     if (!$bPermissions) {
         $lAdmin->AddGroupError(GetMessage("IBLOCK_ADM_HISTORY_UPDERR3") . " (ID:" . $ID . ")", $ID);
         continue;
     }
     switch ($_REQUEST['action']) {
         case "delete":
             $d = CIBlockElement::GetByID($ID);
Beispiel #12
0
 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;
 }
Beispiel #13
0
function CatalogRecurringCallback($productID, $userID)
{
    global $APPLICATION;
    global $DB;
    $productID = intval($productID);
    if ($productID <= 0) {
        return false;
    }
    $userID = intval($userID);
    if ($userID <= 0) {
        return false;
    }
    $arProduct = CCatalogProduct::GetByID($productID);
    if (!$arProduct) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_PRODUCT")), "NO_PRODUCT");
        return false;
    }
    if ($arProduct["PRICE_TYPE"] == "T") {
        $arProduct = CCatalogProduct::GetByID($arProduct["TRIAL_PRICE_ID"]);
        if (!$arProduct) {
            $APPLICATION->ThrowException(str_replace("#TRIAL_ID#", $productID, str_replace("#ID#", $arProduct["TRIAL_PRICE_ID"], Loc::getMessage("I_NO_TRIAL_PRODUCT"))), "NO_PRODUCT_TRIAL");
            return false;
        }
    }
    $productID = intval($arProduct["ID"]);
    if ($arProduct["PRICE_TYPE"] != "R") {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_NOT_SUBSCR")), "NO_IBLOCK_SUBSCR");
        return false;
    }
    $dbIBlockElement = CIBlockElement::GetList(array(), array("ID" => $productID, "ACTIVE" => "Y", "ACTIVE_DATE" => "Y", "CHECK_PERMISSIONS" => "N"), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
    if (!($arIBlockElement = $dbIBlockElement->GetNext())) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
        return false;
    }
    if ('E' == CIBlock::GetArrayByID($arIBlockElement['IBLOCK_ID'], "RIGHTS_MODE")) {
        $arUserRights = CIBlockElementRights::GetUserOperations($productID, $userID);
        if (empty($arUserRights)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        } elseif (!is_array($arUserRights) || !array_key_exists('element_read', $arUserRights)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        }
    } else {
        if ('R' > CIBlock::GetPermission($arIBlockElement['IBLOCK_ID'], $userID)) {
            $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_NO_IBLOCK_ELEM")), "NO_IBLOCK_ELEMENT");
            return false;
        }
    }
    $arCatalog = CCatalog::GetByID($arIBlockElement["IBLOCK_ID"]);
    if ($arCatalog["SUBSCRIPTION"] != "Y") {
        $APPLICATION->ThrowException(str_replace("#ID#", $arIBlockElement["IBLOCK_ID"], Loc::getMessage("I_CATALOG_NOT_SUBSCR")), "NOT_SUBSCRIPTION");
        return false;
    }
    if ($arProduct["CAN_BUY_ZERO"] != "Y" && ($arProduct["QUANTITY_TRACE"] == "Y" && doubleval($arProduct["QUANTITY"]) <= 0)) {
        $APPLICATION->ThrowException(str_replace("#ID#", $productID, Loc::getMessage("I_PRODUCT_SOLD")), "PRODUCT_END");
        return false;
    }
    $arUserGroups = CUser::GetUserGroup($userID);
    $arUserGroups = array_values(array_unique($arUserGroups));
    CCatalogDiscountSave::Disable();
    $arPrice = CCatalogProduct::GetOptimalPrice($productID, 1, $arUserGroups, "Y");
    if (empty($arPrice)) {
        if ($nearestQuantity = CCatalogProduct::GetNearestQuantityPrice($productID, 1, $arUserGroups)) {
            $quantity = $nearestQuantity;
            $arPrice = CCatalogProduct::GetOptimalPrice($productID, $quantity, $arUserGroups, "Y");
        }
    }
    CCatalogDiscountSave::Enable();
    if (empty($arPrice)) {
        return false;
    }
    $currentPrice = $arPrice["PRICE"]["PRICE"];
    $currentDiscount = 0.0;
    //SIGURD: logic change. see mantiss 5036.
    // discount applied to a final price with VAT already included.
    if (doubleval($arPrice['PRICE']['VAT_RATE']) > 0) {
        $currentPrice *= 1 + $arPrice['PRICE']['VAT_RATE'];
    }
    $arDiscountList = array();
    if (!empty($arPrice["DISCOUNT_LIST"])) {
        $dblStartPrice = $currentPrice;
        foreach ($arPrice["DISCOUNT_LIST"] as &$arOneDiscount) {
            switch ($arOneDiscount['VALUE_TYPE']) {
                case CCatalogDiscount::TYPE_FIX:
                    if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                        $currentDiscount = $arOneDiscount['VALUE'];
                    } else {
                        $currentDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount["VALUE"], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                    }
                    $currentPrice = $currentPrice - $currentDiscount;
                    break;
                case CCatalogDiscount::TYPE_PERCENT:
                    $currentDiscount = $currentPrice * $arOneDiscount["VALUE"] / 100.0;
                    if (0 < $arOneDiscount['MAX_DISCOUNT']) {
                        if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                            $dblMaxDiscount = $arOneDiscount['MAX_DISCOUNT'];
                        } else {
                            $dblMaxDiscount = CCurrencyRates::ConvertCurrency($arOneDiscount['MAX_DISCOUNT'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                        }
                        if ($currentDiscount > $dblMaxDiscount) {
                            $currentDiscount = $dblMaxDiscount;
                        }
                    }
                    $currentPrice = $currentPrice - $currentDiscount;
                    break;
                case CCatalogDiscount::TYPE_SALE:
                    if ($arOneDiscount['CURRENCY'] == $arPrice["PRICE"]["CURRENCY"]) {
                        $currentPrice = $arOneDiscount['VALUE'];
                    } else {
                        $currentPrice = CCurrencyRates::ConvertCurrency($arOneDiscount['VALUE'], $arOneDiscount["CURRENCY"], $arPrice["PRICE"]["CURRENCY"]);
                    }
                    break;
            }
            $arOneList = array('ID' => $arOneDiscount['ID'], 'NAME' => $arOneDiscount['NAME'], 'COUPON' => '', 'MODULE_ID' => 'catalog');
            if ($arOneDiscount['COUPON']) {
                $arOneList['COUPON'] = $arOneDiscount['COUPON'];
            }
            $arDiscountList[] = $arOneList;
        }
        if (isset($arOneDiscount)) {
            unset($arOneDiscount);
        }
        $currentDiscount = $dblStartPrice - $currentPrice;
    }
    $recurType = $arProduct["RECUR_SCHEME_TYPE"];
    $recurLength = intval($arProduct["RECUR_SCHEME_LENGTH"]);
    $recurSchemeVal = 0;
    if ($recurType == CCatalogProduct::TIME_PERIOD_HOUR) {
        $recurSchemeVal = mktime(date("H") + $recurLength, date("i"), date("s"), date("m"), date("d"), date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_DAY) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + $recurLength, date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_WEEK) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 7 * $recurLength, date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_MONTH) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + $recurLength, date("d"), date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_QUART) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + 3 * $recurLength, date("d"), date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_SEMIYEAR) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m") + 6 * $recurLength, date("d"), date("Y"));
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_YEAR) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + $recurLength);
    } elseif ($recurType == CCatalogProduct::TIME_PERIOD_DOUBLE_YEAR) {
        $recurSchemeVal = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y") + 2 * $recurLength);
    }
    $arResult = array("WEIGHT" => floatval($arProduct["WEIGHT"]), "DIMENSIONS" => serialize(array("WIDTH" => $arProduct["WIDTH"], "HEIGHT" => $arProduct["HEIGHT"], "LENGTH" => $arProduct["LENGTH"])), "VAT_RATE" => $arPrice["PRICE"]["VAT_RATE"], "QUANTITY" => 1, "PRICE" => $currentPrice, "WITHOUT_ORDER" => $arProduct["WITHOUT_ORDER"], "PRODUCT_ID" => $productID, "PRODUCT_NAME" => $arIBlockElement["~NAME"], "PRODUCT_URL" => $arIBlockElement["~DETAIL_PAGE_URL"], "PRODUCT_PRICE_ID" => $arPrice["PRICE"]["ID"], "CURRENCY" => $arPrice["PRICE"]["CURRENCY"], "NAME" => $arIBlockElement["NAME"], "MODULE" => "catalog", "PRODUCT_PROVIDER_CLASS" => "CCatalogProductProvider", "CATALOG_GROUP_NAME" => $arPrice["PRICE"]["CATALOG_GROUP_NAME"], "DETAIL_PAGE_URL" => $arIBlockElement["~DETAIL_PAGE_URL"], "PRICE_TYPE" => $arProduct["PRICE_TYPE"], "RECUR_SCHEME_TYPE" => $arProduct["RECUR_SCHEME_TYPE"], "RECUR_SCHEME_LENGTH" => $arProduct["RECUR_SCHEME_LENGTH"], "PRODUCT_XML_ID" => $arIBlockElement["~XML_ID"], "TYPE" => $arProduct["TYPE"] == CCatalogProduct::TYPE_SET ? CCatalogProductSet::TYPE_SET : NULL, "NEXT_DATE" => Date($DB->DateFormatToPHP(CLang::GetDateFormat("FULL", SITE_ID)), $recurSchemeVal));
    if (!empty($arPrice["DISCOUNT_LIST"])) {
        $arResult['DISCOUNT_LIST'] = $arDiscountList;
    }
    return $arResult;
}
            foreach ($obRights->GetRights() as $RIGHT_ID => $arRight) {
                $htmlHidden .= '
				<input type="hidden" name="SUB_RIGHTS[][RIGHT_ID]" value="' . htmlspecialcharsbx($RIGHT_ID) . '">
				<input type="hidden" name="SUB_RIGHTS[][GROUP_CODE]" value="' . htmlspecialcharsbx($arRight["GROUP_CODE"]) . '">
				<input type="hidden" name="SUB_RIGHTS[][TASK_ID]" value="' . htmlspecialcharsbx($arRight["TASK_ID"]) . '">
			';
            }
        } else {
            $obRights = new CIBlockSectionRights($IBLOCK_ID, 0);
            $htmlHidden = '';
        }
        $tabControl->BeginCustomField("RIGHTS", GetMessage("IBEL_E_RIGHTS_FIELD"));
        IBlockShowRights('element', $IBLOCK_ID, $ID, GetMessage("IBEL_E_RIGHTS_SECTION_TITLE"), "SUB_RIGHTS", $obRights->GetRightsList(), $obRights->GetRights(array("count_overwrited" => true, "parents" => array())), false, $ID <= 0 || $bCopy);
        $tabControl->EndCustomField("RIGHTS", $htmlHidden);
    }
    $bDisabled = $view == "Y" || $bWorkflow && $prn_LOCK_STATUS == "red" || ($ID <= 0 || $bCopy) && !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, 0, "section_element_bind") || $ID > 0 && !$bCopy && !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit") || $bBizproc && !$canWrite;
    if ($ID > 0 && !$bSubCopy && BX_SUB_SETTINGS) {
        if (!$ajaxReload) {
            $reloadParams = array('bxpublic' => 'Y', 'bxsku' => 'Y', 'WF' => 'Y', 'TMP_ID' => $strSubTMP_ID, 'ajaxReload' => 'Y');
            if ($arShowTabs['product_group']) {
                $reloadParams['groupdel'] = 'Y';
                $reloadParams['sessid'] = bitrix_sessid();
                $setBtn = "{\n\t\t\t\ttitle: '" . CUtil::JSEscape(GetMessage('IB_SE_SET_PRODUCT_TYPE_GROUP_DELETE')) . "',\n\t\t\t\tname: 'groupdel',\n\t\t\t\tid: 'groupdel',\n\t\t\t\tclassName: 'adm-btn-add',\n\t\t\t\taction: function () {\n\t\t\t\t\tif (confirm('" . CUtil::JSEscape(GetMessage('IB_SE_SET_PRODUCT_TYPE_GROUP_DELETE_CONFIRM')) . "'))\n\t\t\t\t\t{\n\t\t\t\t\t\ttop.BX.showWait();\n\t\t\t\t\t\ttop.BX.ajax.get(\n\t\t\t\t\t\t\t'" . CIBlock::GetAdminSubElementEditLink($IBLOCK_ID, $intProductID, $ID, $reloadParams, '', true) . "',\n\t\t\t\t\t\t\tfunction (result) {\n\t\t\t\t\t\t\t\ttop.BX.closeWait();\n\t\t\t\t\t\t\t\ttop.BX.WindowManager.Get().SetContent(result);\n\t\t\t\t\t\t\t\tif (BX('groupdel'))\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tBX.style(BX('groupdel'), 'display', 'none');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}";
            } else {
                $reloadParams['SUBPRODUCT_TYPE'] = CCatalogAdminTools::TAB_GROUP;
                $setBtn = "{\n\t\t\t\ttitle: '" . CUtil::JSEscape(GetMessage('IB_SE_SET_PRODUCT_TYPE_GROUP_ADD')) . "',\n\t\t\t\tname: 'groupset',\n\t\t\t\tid: 'groupset',\n\t\t\t\tclassName: 'adm-btn-add',\n\t\t\t\taction: function () {\n\t\t\t\t\ttop.BX.showWait();\n\t\t\t\t\ttop.BX.ajax.get('" . CIBlock::GetAdminSubElementEditLink($IBLOCK_ID, $intProductID, $ID, $reloadParams, '', true) . "',\n\t\t\t\t\tfunction (result) {\n\t\t\t\t\t\ttop.BX.closeWait();\n\t\t\t\t\t\ttop.BX.WindowManager.Get().SetContent(result);\n\t\t\t\t\t\tif (BX('groupset'))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tBX.style(BX('groupset'), 'display', 'none');\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}";
            }
            $tabControl->ButtonsPublic(array($setBtn));
            unset($setBtn, $reloadParams);
        }
    } else {
Beispiel #15
0
                            }
                        }
                    }
                    if (!empty($actionsProcess)) {
                        $listProcesses[] = array("TEXT" => $documentState["TEMPLATE_NAME"] . " (" . $documentState["STARTED"] . ")", "MENU" => $actionsProcess);
                    } else {
                        $listProcesses[] = array("TEXT" => $documentState["TEMPLATE_NAME"] . " (" . $documentState["STARTED"] . ")");
                    }
                }
            }
            if (!empty($listProcesses)) {
                $aActions[] = array("TEXT" => GetMessage("CC_BLL_ELEMENT_ACTION_MENU_RUNNING_BP"), "MENU" => $listProcesses);
            }
        }
    }
    if (!$arResult["IS_SOCNET_GROUP_CLOSED"] && ($lists_perm >= CListPermissions::CAN_WRITE || CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $data["~ID"], "element_delete"))) {
        $aActions[] = array("SEPARATOR" => true);
        $aActions[] = array("ICONCLASS" => "delete", "TEXT" => GetMessage("CC_BLL_ELEMENT_ACTION_MENU_DELETE"), "ONCLICK" => "bxGrid_" . $arResult["GRID_ID"] . ".DeleteItem('" . $data["ID"] . "', '" . GetMessage("CC_BLL_ELEMENT_ACTION_MENU_DELETE_CONF") . "')");
        $arResult["ELEMENTS_CAN_DELETE"][] = $data["ID"];
    }
    $arResult["ELEMENTS_ROWS"][] = array("id" => $data["ID"], "data" => $data, "actions" => $aActions, "columns" => $aCols);
}
if (!$arResult["CAN_READ"] && $check) {
    $arResult["CAN_READ"] = true;
}
$rsElements->bShowAll = false;
$arResult["NAV_OBJECT"] = $rsElements;
$arResult["SORT"] = $grid_sort["sort"];
$arResult["LIST_NEW_ELEMENT_URL"] = str_replace(array("#list_id#", "#section_id#", "#element_id#", "#group_id#"), array($arIBlock["ID"], intval($arResult["SECTION_ID"]), 0, $arParams["SOCNET_GROUP_ID"]), $arParams["LIST_ELEMENT_URL"]);
if ($arResult["ANY_SECTION"]) {
    $arResult["LIST_NEW_ELEMENT_URL"] = CHTTP::urlAddParams($arResult["LIST_NEW_ELEMENT_URL"], array("list_section_id" => ""));
Beispiel #16
0
 $bizProcIndex = 0;
 $arDocumentStates = CBPDocument::GetDocumentStates(BizProcDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), $arResult["ELEMENT_ID"] > 0 ? BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]) : null, "Y");
 $custom_html .= '<input type="hidden" name="stop_bizproc" id="stop_bizproc" value="">';
 $runtime = CBPRuntime::GetRuntime();
 $runtime->StartRuntime();
 $documentService = $runtime->GetService("DocumentService");
 foreach ($arDocumentStates as $arDocumentState) {
     $bizProcIndex++;
     if ($arResult["ELEMENT_ID"] > 0) {
         $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"]));
     } else {
         $canViewWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::StartWorkflow, $GLOBALS["USER"]->GetID(), BizProcDocument::generateDocumentComplexType($arParams["IBLOCK_TYPE_ID"], $arResult["IBLOCK_ID"]), array("sectionId" => intval($arResult["SECTION_ID"]), "AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"]));
     }
     if ($canViewWorkflow) {
         $arTab2Fields[] = array("id" => "BIZPROC_TITLE" . $bizProcIndex, "name" => $arDocumentState["TEMPLATE_NAME"], "type" => "section");
         if ($arParams["IBLOCK_TYPE_ID"] != COption::GetOptionString("lists", "livefeed_iblock_type_id") && strlen($arDocumentState["ID"]) && CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_rights_edit") && strlen($arDocumentState["WORKFLOW_STATUS"])) {
             $arTab2Fields[] = array("id" => "BIZPROC_STOP" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STOP_LABEL"), "type" => "label", "value" => '<a href="javascript:jsStopBP(\'' . CUtil::JSEscape('form_' . $arResult["FORM_ID"]) . '\', \'' . CUtil::JSEscape($arDocumentState["ID"]) . '\');">' . GetMessage("CT_BLEE_BIZPROC_STOP") . '</a>');
         }
         $arTab2Fields[] = array("id" => "BIZPROC_NAME" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_NAME"), "type" => "label", "value" => $arDocumentState["TEMPLATE_NAME"]);
         if ($arDocumentState["TEMPLATE_DESCRIPTION"] != '') {
             $arTab2Fields[] = array("id" => "BIZPROC_DESC" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DESC"), "type" => "label", "value" => $arDocumentState["TEMPLATE_DESCRIPTION"]);
         }
         if (strlen($arDocumentState["STATE_MODIFIED"])) {
             $arTab2Fields[] = array("id" => "BIZPROC_DATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DATE"), "type" => "label", "value" => $arDocumentState["STATE_MODIFIED"]);
         }
         if (strlen($arDocumentState["STATE_NAME"])) {
             $backUrl = CHTTP::urlAddParams($APPLICATION->GetCurPageParam("", array($arResult["FORM_ID"] . "_active_tab")), array($arResult["FORM_ID"] . "_active_tab" => "tab_bp"));
             $url = CHTTP::urlAddParams(str_replace(array("#list_id#", "#document_state_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arDocumentState["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_LOG_URL"]), array("back_url" => $backUrl), array("skip_empty" => true, "encode" => true));
             if (strlen($arDocumentState["ID"])) {
                 $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . (strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]) . '</a>');
                 $canDeleteWorkflow = false;
<?php

/** @global CUser $USER */
/** @global int $ID */
use Bitrix\Main, Bitrix\Main\Localization\Loc;
if ($USER->CanDoOperation('catalog_price')) {
    $IBLOCK_ID = intval($IBLOCK_ID);
    if (0 >= $IBLOCK_ID) {
        return;
    }
    $MENU_SECTION_ID = intval($MENU_SECTION_ID);
    $ID = (int) $ID;
    $PRODUCT_ID = 0 < $ID ? CIBlockElement::GetRealElement($ID) : 0;
    $boolPriceRights = $PRODUCT_ID > 0 ? CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $PRODUCT_ID, "element_edit_price") : CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $MENU_SECTION_ID, "element_edit_price");
    if ($boolPriceRights) {
        Loc::loadMessages($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/catalog/templates/product_edit_action.php');
        $arCatalogBasePrices = array();
        $arCatalogPrices = array();
        $CAT_ROW_COUNTER = intval($CAT_ROW_COUNTER);
        if ($CAT_ROW_COUNTER < 0) {
            $strWarning .= Loc::getMessage("C2IT_INTERNAL_ERROR") . "<br>";
        }
        $arCatalogBaseGroup = CCatalogGroup::GetBaseGroup();
        if (!$arCatalogBaseGroup) {
            $strWarning .= Loc::getMessage("C2IT_NO_BASE_TYPE") . "<br>";
        }
        $CAT_VAT_ID = intval($CAT_VAT_ID);
        $CAT_VAT_INCLUDED = !isset($CAT_VAT_INCLUDED) || $CAT_VAT_INCLUDED == 'N' ? 'N' : 'Y';
        $bUseExtForm = isset($_POST['price_useextform']) && $_POST['price_useextform'] == 'Y';
        if (!$bUseExtForm) {
            $CAT_ROW_COUNTER = 0;
Beispiel #18
0
 $bizProcIndex = 0;
 $arDocumentStates = CBPDocument::GetDocumentStates(array("iblock", "CIBlockDocument", $DOCUMENT_TYPE), $arResult["ELEMENT_ID"] > 0 ? array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]) : null, "Y");
 $custom_html .= '<input type="hidden" name="stop_bizproc" id="stop_bizproc" value="">';
 $runtime = CBPRuntime::GetRuntime();
 $runtime->StartRuntime();
 $documentService = $runtime->GetService("DocumentService");
 foreach ($arDocumentStates as $arDocumentState) {
     $bizProcIndex++;
     if ($arResult["ELEMENT_ID"] > 0) {
         $canViewWorkflow = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"]));
     } else {
         $canViewWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::ViewWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", "iblock_" . $arResult["IBLOCK_ID"]), array("AllUserGroups" => $arCurrentUserGroups, "DocumentStates" => $arDocumentStates, "WorkflowId" => $arDocumentState["ID"] > 0 ? $arDocumentState["ID"] : $arDocumentState["TEMPLATE_ID"]));
     }
     if ($canViewWorkflow) {
         $arTab2Fields[] = array("id" => "BIZPROC_TITLE" . $bizProcIndex, "name" => $arDocumentState["TEMPLATE_NAME"], "type" => "section");
         if (strlen($arDocumentState["ID"]) && strlen($arDocumentState["WORKFLOW_STATUS"]) && CIBlockElementRights::UserHasRightTo($arResult["IBLOCK_ID"], $arResult["ELEMENT_ID"], "element_rights_edit")) {
             $arTab2Fields[] = array("id" => "BIZPROC_STOP" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STOP_LABEL"), "type" => "label", "value" => '<a href="javascript:jsStopBP(\'' . CUtil::JSEscape('form_' . $arResult["FORM_ID"]) . '\', \'' . CUtil::JSEscape($arDocumentState["ID"]) . '\');">' . GetMessage("CT_BLEE_BIZPROC_STOP") . '</a>');
         }
         $arTab2Fields[] = array("id" => "BIZPROC_NAME" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_NAME"), "type" => "label", "value" => $arDocumentState["TEMPLATE_NAME"]);
         if ($arDocumentState["TEMPLATE_DESCRIPTION"] != '') {
             $arTab2Fields[] = array("id" => "BIZPROC_DESC" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DESC"), "type" => "label", "value" => $arDocumentState["TEMPLATE_DESCRIPTION"]);
         }
         if (strlen($arDocumentState["STATE_MODIFIED"])) {
             $arTab2Fields[] = array("id" => "BIZPROC_DATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_DATE"), "type" => "label", "value" => $arDocumentState["STATE_MODIFIED"]);
         }
         if (strlen($arDocumentState["STATE_NAME"])) {
             $url = str_replace(array("#list_id#", "#document_state_id#", "#group_id#"), array($arResult["IBLOCK_ID"], $arDocumentState["ID"], $arParams["SOCNET_GROUP_ID"]), $arParams["~BIZPROC_LOG_URL"]);
             if (strlen($arDocumentState["ID"])) {
                 $arTab2Fields[] = array("id" => "BIZPROC_STATE" . $bizProcIndex, "name" => GetMessage("CT_BLEE_BIZPROC_STATE"), "type" => "label", "value" => '<a href="' . htmlspecialcharsbx($url) . '">' . (strlen($arDocumentState["STATE_TITLE"]) ? $arDocumentState["STATE_TITLE"] : $arDocumentState["STATE_NAME"]) . '</a>');
                 $canDeleteWorkflow = CBPDocument::CanUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $GLOBALS["USER"]->GetID(), array("iblock", "CIBlockDocument", $arResult["ELEMENT_ID"]), array("UserGroups" => $arCurrentUserGroups));
                 if ($canDeleteWorkflow) {
Beispiel #19
0
 function CopyCommentRights($ID, $arFields)
 {
     if (empty($arFields['LOG_ID'])) {
         return false;
     }
     if (empty(self::$storedFileIdsByComment[$arFields['SOURCE_ID']])) {
         return false;
     }
     $arRights0 = array();
     $rConst = 0;
     $rs = CTask::GetList(array("LETTER" => "asc"), array("MODULE_ID" => "iblock", "LETTER" => "R"));
     if ($ar = $rs->Fetch()) {
         $rConst = $ar["ID"];
     } else {
         return false;
     }
     $dbRight = CSocNetLogRights::GetList(array(), array("LOG_ID" => $arFields["LOG_ID"]));
     $i = 1;
     while ($arRight = $dbRight->Fetch()) {
         /*$arRights0["n" .$i] = Array(
         			"GROUP_CODE" => $arRight["GROUP_CODE"],
         			"TASK_ID" => $rConst,
         		);*/
         $gc = $arRight["GROUP_CODE"];
         if (array_key_exists($gc, $arRights0) && $arRights0[$gc]["TASK_ID"] >= $rConst) {
             continue;
         }
         $arRights0[$gc] = array("KEY" => "n" . $i, "GROUP_CODE" => $gc, "TASK_ID" => $rConst);
         $i++;
     }
     $arFilesID = self::$storedFileIdsByComment[$arFields['SOURCE_ID']];
     $arFiles = array();
     foreach ($arFilesID as $id) {
         $id = intval($id);
         if (intval($id) > 0) {
             $arFiles[] = $id;
         }
     }
     if (!$arFiles) {
         return;
     }
     $ibe = new CIBlockElement();
     $dbWDFile = $ibe->GetList(array(), array('ID' => $arFiles, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
     while ($dbWDFile && ($arWDFile = $dbWDFile->Fetch())) {
         $arRights1 = $arRights0;
         $ob = new CIBlockElementRights($arWDFile['IBLOCK_ID'], $arWDFile['ID']);
         $ar = $ob->GetRights();
         foreach ($ar as $k => $v) {
             $gc = $v["GROUP_CODE"];
             if (array_key_exists($gc, $arRights1) && $arRights1[$gc]["TASK_ID"] >= $v["TASK_ID"]) {
                 continue;
             }
             $arRights1[$gc] = array("KEY" => $k, "GROUP_CODE" => $gc, "TASK_ID" => $v["TASK_ID"]);
         }
         $arRights2 = array();
         foreach ($arRights1 as $v) {
             $arRights2[$v["KEY"]] = array("GROUP_CODE" => $v["GROUP_CODE"], "TASK_ID" => $v["TASK_ID"]);
         }
         $ob->SetRights($arRights2);
     }
 }
Beispiel #20
0
 $IBLOCK_ID = (int) $IBLOCK_ID;
 if ($IBLOCK_ID <= 0) {
     return;
 }
 $MENU_SECTION_ID = (int) $MENU_SECTION_ID;
 $PRODUCT_ID = $ID > 0 ? CIBlockElement::GetRealElement($ID) : 0;
 $arBaseProduct = false;
 $periodTimeTypes = array();
 if ($arMainCatalog['SUBSCRIPTION'] == 'Y') {
     $arDefProduct = array('QUANTITY' => '', 'QUANTITY_RESERVED' => '', 'VAT_ID' => 0, 'VAT_INCLUDED' => 'N', 'QUANTITY_TRACE_ORIG' => 'D', 'CAN_BUY_ZERO_ORIG' => 'D', 'PRICE_TYPE' => '', 'RECUR_SCHEME_TYPE' => '', 'RECUR_SCHEME_LENGTH' => '', 'TRIAL_PRICE_ID' => '', 'WITHOUT_ORDER' => '', 'PURCHASING_PRICE' => '', 'PURCHASING_CURRENCY' => '', 'BARCODE_MULTI' => '', 'SUBSCRIBE_ORIG' => 'D');
     $periodTimeTypes = CCatalogProduct::GetTimePeriodTypes(true);
 } else {
     $arDefProduct = array('QUANTITY' => '', 'QUANTITY_RESERVED' => '', 'WEIGHT' => '', 'WIDTH' => '', 'LENGTH' => '', 'HEIGHT' => '', 'MEASURE' => '', 'VAT_ID' => 0, 'VAT_INCLUDED' => 'N', 'QUANTITY_TRACE_ORIG' => 'D', 'CAN_BUY_ZERO_ORIG' => 'D', 'PURCHASING_PRICE' => '', 'PURCHASING_CURRENCY' => '', 'BARCODE_MULTI' => '', 'SUBSCRIBE_ORIG' => 'D');
 }
 if ($PRODUCT_ID > 0) {
     $bReadOnly = !($USER->CanDoOperation('catalog_price') && CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $PRODUCT_ID, "element_edit_price"));
     if ($arMainCatalog['SUBSCRIPTION'] == 'Y') {
         $arProductSelect = array('ID', 'QUANTITY', 'QUANTITY_RESERVED', 'QUANTITY_TRACE_ORIG', 'VAT_ID', 'VAT_INCLUDED', 'CAN_BUY_ZERO_ORIG', 'PRICE_TYPE', 'RECUR_SCHEME_TYPE', 'RECUR_SCHEME_LENGTH', 'TRIAL_PRICE_ID', 'WITHOUT_ORDER', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'BARCODE_MULTI', 'SUBSCRIBE_ORIG', 'TYPE');
     } else {
         $arProductSelect = array('ID', 'QUANTITY', 'QUANTITY_RESERVED', 'QUANTITY_TRACE_ORIG', 'WEIGHT', 'WIDTH', 'LENGTH', 'HEIGHT', 'MEASURE', 'VAT_ID', 'VAT_INCLUDED', 'CAN_BUY_ZERO_ORIG', 'PURCHASING_PRICE', 'PURCHASING_CURRENCY', 'BARCODE_MULTI', 'SUBSCRIBE_ORIG', 'TYPE');
     }
     $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $PRODUCT_ID), false, false, $arProductSelect);
     $arBaseProduct = $rsProducts->Fetch();
     if ($bCopy) {
         $arBaseProduct['QUANTITY'] = '';
         $arBaseProduct['QUANTITY_RESERVED'] = '';
     }
 } else {
     $bReadOnly = !($USER->CanDoOperation('catalog_price') && CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $MENU_SECTION_ID, "element_edit_price"));
 }
 if (empty($arBaseProduct)) {
<?php

/** @global CUser $USER */
/** @var string $strWarning */
/** @var int $IBLOCK_ID */
/** @var int $ID */
if ($USER->CanDoOperation('catalog_price')) {
    $IBLOCK_ID = (int) $IBLOCK_ID;
    $ID = (int) $ID;
    $userId = (int) $USER->GetID();
    if (0 < $IBLOCK_ID && 0 < $ID) {
        $PRODUCT_ID = CIBlockElement::GetRealElement($ID);
        $bUseStoreControl = COption::GetOptionString('catalog', 'default_use_store_control', 'N') == "Y";
        $bEnableReservation = 'N' != COption::GetOptionString('catalog', 'enable_reservation');
        if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $PRODUCT_ID, "element_edit_price")) {
            IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/catalog/templates/product_edit_action.php');
            if ('' == $strWarning) {
                $bUseExtForm = isset($_POST['price_useextform']) && 'Y' == $_POST['price_useextform'];
                $arCatalog = CCatalog::GetByID($IBLOCK_ID);
                $arCatalogPrice_tmp = array();
                $intBasePriceCount = count($arCatalogBasePrices);
                $dbCatGroups = CCatalogGroup::GetList(array(), array("!BASE" => "Y"));
                while ($arCatGroups = $dbCatGroups->Fetch()) {
                    unset($arCatalogPrice_tmp);
                    $arCatalogPrice_tmp = array();
                    for ($i = 0; $i < $intBasePriceCount; $i++) {
                        ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} = str_replace(",", ".", ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]});
                        $arCatalogPrice_tmp[$i] = array("ID" => IntVal(${"CAT_ID_" . $arCatGroups["ID"]}[$arCatalogBasePrices[$i]["IND"]]), "EXTRA_ID" => ${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]} ? IntVal(${"CAT_EXTRA_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}) : 0, "PRICE" => ${"CAT_PRICE_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}, "CURRENCY" => Trim(${"CAT_CURRENCY_" . $arCatGroups["ID"] . "_" . $arCatalogBasePrices[$i]["IND"]}), "QUANTITY_FROM" => $arCatalogBasePrices[$i]["QUANTITY_FROM"], "QUANTITY_TO" => $arCatalogBasePrices[$i]["QUANTITY_TO"]);
                        if (strlen($arCatalogPrice_tmp[$i]["CURRENCY"]) <= 0) {
                            $arCatalogPrice_tmp[$i]["CURRENCY"] = $arCatalogBasePrices[$i]["CURRENCY"];
                        }
Beispiel #22
0
 function ReindexIBlock($iblock_id, $entity_type, $feature, $operation, $path_template, $arFieldList, $last_id)
 {
     global $DB;
     if (!CModule::IncludeModule("iblock")) {
         return false;
     }
     $arSections = array();
     $rsElements = CIBlockElement::GetList(array("ID" => "asc"), array("IBLOCK_ID" => $iblock_id, ">ID" => intval($last_id), "CHECK_PERMISSIONS" => "N"), false, false, array_merge(array("ID", "IBLOCK_ID", "IBLOCK_TYPE_ID", "NAME", "TAGS", "TIMESTAMP_X", "IBLOCK_SECTION_ID"), $arFieldList));
     while ($arFields = $rsElements->Fetch()) {
         if (!array_key_exists($arFields["IBLOCK_SECTION_ID"], $arSections)) {
             $rsPath = CIBlockSection::GetNavChain($arFields["IBLOCK_ID"], $arFields["IBLOCK_SECTION_ID"]);
             $arSection = $rsPath->Fetch();
             if ($entity_type == "G") {
                 $arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["SOCNET_GROUP_ID"]);
             } else {
                 $arSections[$arFields["IBLOCK_SECTION_ID"]] = intval($arSection["CREATED_BY"]);
             }
         }
         $entity_id = $arSections[$arFields["IBLOCK_SECTION_ID"]];
         if ($entity_id) {
             $url = str_replace(array("#user_id#", "#group_id#", "#user_alias#", "#section_id#", "#element_id#", "#task_id#", "#name#"), array($entity_id, $entity_id, ($entity_type == "G" ? "group_" : "user_") . $entity_id, $arFields["IBLOCK_SECTION_ID"], $arFields["ID"], $arFields["ID"], urlencode($arFields["NAME"])), $path_template);
             $body = "";
             if ($feature == "wiki") {
                 $CWikiParser = new CWikiParser();
             }
             foreach ($arFieldList as $field) {
                 $text = "";
                 if ($field == "PREVIEW_TEXT" || $field == "DETAIL_TEXT") {
                     if (isset($CWikiParser)) {
                         $text = HTMLToTxt($CWikiParser->parseForSearch($arFields[$field]));
                     } elseif (isset($arFields[$field . "_TYPE"]) && $arFields[$field . "_TYPE"] === "html") {
                         $text = HTMLToTxt($arFields[$field]);
                     } else {
                         $text = $arFields[$field];
                     }
                 } elseif ($field == $this->_file_property) {
                     $arFile = CIBlockElement::__GetFileContent($arFields[$this->_file_property . "_VALUE"]);
                     if (is_array($arFile)) {
                         $text = $arFile["CONTENT"];
                         $arFields["TAGS"] .= "," . $arFile["PROPERTIES"][COption::GetOptionString("search", "page_tag_property")];
                     }
                 } elseif ($field == "PROPERTY_FORUM_TOPIC_ID") {
                     $topic_id = intval($arFields["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
                     if ($topic_id) {
                         $this->UpdateForumTopicIndex($topic_id, $entity_type, $entity_id, $feature, $operation, $this->Url($url, array("MID" => "#message_id#"), "message#message_id#"));
                     }
                 }
                 $body .= $text . "\n\r";
             }
             if (isset($CWikiParser)) {
                 $title = preg_replace('/^category:/i' . BX_UTF_PCRE_MODIFIER, GetMessage('CATEGORY_NAME') . ':', $arFields['NAME']);
             } else {
                 $title = $arFields["NAME"];
             }
             $arPermissions = $this->GetSearchGroups($entity_type, $entity_id, $feature, $operation);
             if (CIBlock::GetArrayByID($arFields["IBLOCK_ID"], "RIGHTS_MODE") == "E") {
                 $obElementRights = new CIBlockElementRights($arFields["IBLOCK_ID"], $arFields["ID"]);
                 $arPermissions = $obElementRights->GetGroups(array("element_read"));
             }
             CSearch::Index("socialnetwork", $arFields["ID"], array("LAST_MODIFIED" => $arFields["TIMESTAMP_X"], "TITLE" => $title, "BODY" => $body, "SITE_ID" => array(SITE_ID => $url), "PARAM1" => $arFields["IBLOCK_TYPE_ID"], "PARAM2" => $arFields["IBLOCK_ID"], "PARAM3" => $entity_id, "TAGS" => $arFields["TAGS"], "PERMISSIONS" => $arPermissions, "PARAMS" => $this->GetSearchParams($entity_type, $entity_id, $feature, $operation), "REINDEX_FLAG" => true), true, $this->_sess_id);
             $this->_counter++;
         }
         if ($this->_end_time && $this->_end_time <= time()) {
             return $arFields["ID"];
         }
     }
     return false;
 }
Beispiel #23
0
 public function SetPermissions($documentId, $workflowId, $arPermissions, $bRewrite = true)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $documentType = self::GetDocumentType($documentId);
     $iblockId = intval(substr($documentType, strlen("iblock_")));
     if ($iblockId <= 0) {
         throw new CBPArgumentOutOfRangeException("documentType", $documentType);
     }
     if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") !== "E") {
         return;
     }
     $ob = new CIBlockElementRights($iblockId, $documentId);
     $ar = $ob->GetRights();
     if ($bRewrite) {
         foreach ($ar as $i => $arRight) {
             if ($arRight["XML_ID"] == $workflowId) {
                 unset($ar[$i]);
             }
         }
     }
     $i = 0;
     $l = strlen("user_");
     foreach ($arPermissions as $taskId => $arUsers) {
         foreach ($arUsers as $user) {
             $gc = null;
             if ($user == 'author') {
                 $u = self::GetUsersFromUserGroup('author', $documentId);
                 foreach ($u as $u1) {
                     $gc = "U" . $u1;
                 }
             } else {
                 $gc = substr($user, 0, $l) == "user_" ? "U" . substr($user, $l) : "G" . $user;
             }
             if ($gc != null) {
                 $ar["n" . $i] = array("GROUP_CODE" => $gc, "TASK_ID" => $taskId, "XML_ID" => $workflowId);
                 $i++;
             }
         }
     }
     $ob->SetRights($ar);
 }
Beispiel #24
0
 /**
  * Add rights for reading files by given users.
  * @deprecated
  */
 private static function addFilesRights($taskId, $arFilesIds)
 {
     $arFilesIds = array_unique(array_filter($arFilesIds));
     // Nothing to do?
     if (empty($arFilesIds)) {
         return;
     }
     if (!CModule::IncludeModule('webdav')) {
         return;
     }
     $arRightsTasks = CWebDavIblock::GetTasks();
     // tasks-operations
     $oTask = new CTaskItem((int) $taskId, 1);
     $arTask = $oTask->getData(false);
     $arTaskMembers = array_unique(array_merge(array($arTask['CREATED_BY'], $arTask['RESPONSIBLE_ID']), $arTask['AUDITORS'], $arTask['ACCOMPLICES']));
     $ibe = new CIBlockElement();
     $dbWDFile = $ibe->GetList(array(), array('ID' => $arFilesIds, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'NAME', 'SECTION_ID', 'IBLOCK_ID', 'WF_NEW'));
     if ($dbWDFile) {
         $i = 0;
         $arRightsForTaskMembers = array();
         foreach ($arTaskMembers as $userId) {
             // For intranet users and their managers
             $arRightsForTaskMembers['n' . $i++] = array('GROUP_CODE' => 'IU' . $userId, 'TASK_ID' => $arRightsTasks['R']);
             // For extranet users
             $arRightsForTaskMembers['n' . $i++] = array('GROUP_CODE' => 'U' . $userId, 'TASK_ID' => $arRightsTasks['R']);
         }
         $iNext = $i;
         while ($arWDFile = $dbWDFile->Fetch()) {
             if (!$arWDFile['IBLOCK_ID']) {
                 continue;
             }
             $fileId = $arWDFile['ID'];
             if (CIBlock::GetArrayByID($arWDFile['IBLOCK_ID'], "RIGHTS_MODE") === "E") {
                 $ibRights = new CIBlockElementRights($arWDFile['IBLOCK_ID'], $fileId);
                 $arCurRightsRaw = $ibRights->getRights();
                 // Preserve existing rights
                 $i = $iNext;
                 $arRights = $arRightsForTaskMembers;
                 foreach ($arCurRightsRaw as $arRightsData) {
                     $arRights['n' . $i++] = array('GROUP_CODE' => $arRightsData['GROUP_CODE'], 'TASK_ID' => $arRightsData['TASK_ID']);
                 }
                 $ibRights->setRights($arRights);
             }
         }
     }
 }
Beispiel #25
0
				)))
			);
		}

		if(strlen($f_DETAIL_PAGE_URL) > 0)
		{
			$tmpVar = CIBlock::ReplaceDetailUrl($arRes["DETAIL_PAGE_URL"], $arRes_orig, true, "E");
			$arActions[] = array(
				"ICON" => "view",
				"TEXT" => GetMessage("IBLIST_A_ADMIN_VIEW"),
				"TITLE" => GetMessage("IBLIST_A_VIEW_WF_ALT"),
				"ACTION" => $lAdmin->ActionRedirect(htmlspecialcharsbx($tmpVar)),
			);
		}

		if (CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $f_ID, "element_delete"))
		{
			if (!empty($arActions))
				$arActions[] = array("SEPARATOR"=>true);
			$arActions[] = array(
				"ICON" => "delete",
				"TEXT" => GetMessage('MAIN_DELETE'),
				"TITLE" => GetMessage("IBLOCK_DELETE_ALT"),
				"ACTION" => "if(confirm('".GetMessageJS('IBLOCK_CONFIRM_DEL_MESSAGE')."')) ".$lAdmin->ActionDoGroup($f_TYPE.$arRes_orig['ID'], "delete", $sThisSectionUrl),
			);
		}
	}
	$row->AddActions($arActions);
}
if ($bCatalog)
{
Beispiel #26
0
    if (CModule::IncludeModule('iblock')) {
        CIBlockElement::Delete(intval($absenceID));
    }
}
if (!CModule::IncludeModule('iblock')) {
    echo GetMessage("INTR_ABSENCE_BITRIX24_MODULE");
} else {
    if ($_SERVER["REQUEST_METHOD"] === "GET" && isset($_GET["action"]) && $_GET["action"] == "delete" && check_bitrix_sessid()) {
        if (CIBlockElementRights::UserHasRightTo($iblockID, intval($_GET["absenceID"]), "element_delete")) {
            DeleteAbsence($_GET["absenceID"]);
        }
        die;
    }
    $ID = 1;
    if ($_SERVER["REQUEST_METHOD"] === "POST" && check_bitrix_sessid()) {
        if (isset($_POST['absence_element_id']) && CIBlockElementRights::UserHasRightTo($iblockID, intval($_POST['absence_element_id']), 'element_edit')) {
            $ID = EditAbsence($_POST);
        } elseif (!isset($_POST['absence_element_id']) && CIBlockSectionRights::UserHasRightTo($iblockID, 0, "section_element_bind")) {
            $ID = AddAbsence($_POST);
        } else {
            die('error:<li>' . GetMessage('INTR_USER_ERR_NO_RIGHT') . '</li>');
        }
        if (is_array($ID)) {
            $arErrors = $ID;
            foreach ($arErrors as $key => $val) {
                if (strlen($val) <= 0) {
                    unset($arErrors[$key]);
                }
            }
            $ID = 0;
            die('error:<li>' . implode('</li><li>', $arErrors)) . '</li>';
Beispiel #27
0
} elseif ($lists_perm < 0) {
    switch ($lists_perm) {
        case CListPermissions::WRONG_IBLOCK_TYPE:
            ShowError(GetMessage("CC_BLF_WRONG_IBLOCK_TYPE"));
            return;
        case CListPermissions::WRONG_IBLOCK:
            ShowError(GetMessage("CC_BLF_WRONG_IBLOCK"));
            return;
        case CListPermissions::LISTS_FOR_SONET_GROUP_DISABLED:
            ShowError(GetMessage("CC_BLF_LISTS_FOR_SONET_GROUP_DISABLED"));
            return;
        default:
            ShowError(GetMessage("CC_BLF_UNKNOWN_ERROR"));
            return;
    }
} elseif ($ELEMENT_ID > 0 && $lists_perm <= CListPermissions::CAN_READ && !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ELEMENT_ID, "element_read")) {
    ShowError(GetMessage("CC_BLF_ACCESS_DENIED"));
    return;
} elseif ($SECTION_ID > 0 && $lists_perm <= CListPermissions::CAN_READ && !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $SECTION_ID, "section_read")) {
    ShowError(GetMessage("CC_BLF_ACCESS_DENIED"));
    return;
}
$arIBlock = CIBlock::GetArrayByID(intval($arParams["~IBLOCK_ID"]));
$arResult["FILES"] = array();
$arResult["ELEMENT"] = false;
$arResult["SECTION"] = false;
if ($ELEMENT_ID > 0) {
    $rsElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arIBlock["ID"], "=ID" => $ELEMENT_ID, "CHECK_PERMISSIONS" => "N"), false, false, array("ID", $arParams["FIELD_ID"]));
    while ($ar = $rsElement->GetNext()) {
        if (isset($ar[$arParams["FIELD_ID"]])) {
            $arResult["FILES"][] = $ar[$arParams["FIELD_ID"]];
 /**
  * @param $productId
  * @param null $userId
  * @return bool
  * @throws Main\ArgumentException
  */
 public static function getProductAvailableQuantity($productId, $userId = null)
 {
     $adminSection = defined('ADMIN_SECTION') && ADMIN_SECTION === true;
     $userId = isset($userId) ? (int) $userId : 0;
     if ($userId < 0) {
         $userId = 0;
     }
     static $arUserCache = array();
     if ($adminSection) {
         if ($userId == 0) {
             return false;
         }
         if (!isset($arUserCache[$userId])) {
             $userIterator = Main\UserTable::getList(array('select' => array('ID'), 'filter' => array('=ID' => $userId)));
             if ($userDat = $userIterator->fetch()) {
                 $userDat['ID'] = (int) $userDat['ID'];
                 $arUserCache[$userDat['ID']] = CUser::GetUserGroup($userDat['ID']);
             } else {
                 return false;
             }
         }
         $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productId, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSION' => 'N'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
         if (!($arProduct = $dbIBlockElement->GetNext())) {
             return false;
         }
         $iblockRights = null;
         if (!($iblockRights = static::getHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID']))) {
             if ($iblockRights = CIBlock::GetArrayByID($arProduct['IBLOCK_ID'], 'RIGHTS_MODE')) {
                 static::setHitCache('IBLOCK_RIGHT', $arProduct['IBLOCK_ID'], $iblockRights);
             }
         }
         if ($iblockRights == 'E') {
             $proxyUserPermissionKey = $productId . "|" . $userId;
             if (!($arUserRights = static::getHitCache('USER_RIGHT', $proxyUserPermissionKey))) {
                 if ($arUserRights = CIBlockElementRights::GetUserOperations($productId, $userId)) {
                     static::setHitCache('USER_RIGHT', $proxyUserPermissionKey, $arUserRights);
                 }
             }
             if (empty($arUserRights) || !isset($arUserRights['element_read'])) {
                 return false;
             }
             unset($arUserRights);
         } else {
             if (CIBlock::GetPermission($arProduct['IBLOCK_ID'], $userId) < 'R') {
                 return false;
             }
         }
     } else {
         $dbIBlockElement = CIBlockElement::GetList(array(), array('ID' => $productId, 'ACTIVE' => 'Y', 'ACTIVE_DATE' => 'Y', 'CHECK_PERMISSIONS' => 'Y', 'MIN_PERMISSION' => 'R'), false, false, array('ID', 'IBLOCK_ID', 'NAME', 'DETAIL_PAGE_URL'));
         if (!($arProduct = $dbIBlockElement->GetNext())) {
             return false;
         }
     }
     $rsProducts = CCatalogProduct::GetList(array(), array('ID' => $productId), false, false, array('ID', 'QUANTITY'));
     if ($arCatalogProduct = $rsProducts->Fetch()) {
         return $arCatalogProduct['QUANTITY'];
     }
     return false;
 }
Beispiel #29
0
 function CanUserOperateDocument($operation, $userId, $documentId, $parameters = array())
 {
     $documentId = trim($documentId);
     if (strlen($documentId) <= 0) {
         return false;
     }
     if (!array_key_exists("IBlockId", $parameters) && (!array_key_exists("IBlockPermission", $parameters) || !array_key_exists("DocumentStates", $parameters) || !array_key_exists("IBlockRightsMode", $parameters) || array_key_exists("IBlockRightsMode", $parameters) && $parameters["IBlockRightsMode"] === "E") || !array_key_exists("CreatedBy", $parameters) && !array_key_exists("AllUserGroups", $parameters)) {
         $elementListQuery = CIBlockElement::getList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("ID", "IBLOCK_ID", "CREATED_BY"));
         $elements = $elementListQuery->fetch();
         if (!$elements) {
             return false;
         }
         $parameters["IBlockId"] = $elements["IBLOCK_ID"];
         $parameters["CreatedBy"] = $elements["CREATED_BY"];
     }
     if (!array_key_exists("IBlockRightsMode", $parameters)) {
         $parameters["IBlockRightsMode"] = CIBlock::getArrayByID($parameters["IBlockId"], "RIGHTS_MODE");
     }
     if ($parameters["IBlockRightsMode"] === "E") {
         if ($operation === CBPCanUserOperateOperation::ReadDocument) {
             return CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_read");
         } elseif ($operation === CBPCanUserOperateOperation::WriteDocument) {
             return CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_edit");
         } elseif ($operation === CBPCanUserOperateOperation::StartWorkflow || $operation === CBPCanUserOperateOperation::ViewWorkflow) {
             if (CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_edit")) {
                 return true;
             }
             if (!array_key_exists("WorkflowId", $parameters)) {
                 return false;
             }
             if (!CIBlockElementRights::userHasRightTo($parameters["IBlockId"], $documentId, "element_read")) {
                 return false;
             }
             $userId = intval($userId);
             if (!array_key_exists("AllUserGroups", $parameters)) {
                 if (!array_key_exists("UserGroups", $parameters)) {
                     $parameters["UserGroups"] = CUser::getUserGroup($userId);
                 }
                 $parameters["AllUserGroups"] = $parameters["UserGroups"];
                 if ($userId == $parameters["CreatedBy"]) {
                     $parameters["AllUserGroups"][] = "Author";
                 }
             }
             if (!array_key_exists("DocumentStates", $parameters)) {
                 if ($operation === CBPCanUserOperateOperation::StartWorkflow) {
                     $parameters["DocumentStates"] = CBPWorkflowTemplateLoader::getDocumentTypeStates(array('lists', get_called_class(), self::generateDocumentType($parameters["IBlockId"])));
                 } else {
                     $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array('lists', get_called_class(), self::generateDocumentType($parameters["IBlockId"])), array('lists', get_called_class(), $documentId));
                 }
             }
             if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
                 $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
             } else {
                 return false;
             }
             $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"], true);
             if (!is_array($allowableOperations)) {
                 return false;
             }
             if ($operation === CBPCanUserOperateOperation::ViewWorkflow && in_array("read", $allowableOperations) || $operation === CBPCanUserOperateOperation::StartWorkflow && in_array("write", $allowableOperations)) {
                 return true;
             }
             $chop = $operation === CBPCanUserOperateOperation::ViewWorkflow ? "element_read" : "element_edit";
             $tasks = self::getRightsTasks();
             foreach ($allowableOperations as $op) {
                 if (isset($tasks[$op])) {
                     $op = $tasks[$op]['ID'];
                 }
                 $ar = CTask::getOperations($op, true);
                 if (in_array($chop, $ar)) {
                     return true;
                 }
             }
         } elseif ($operation === CBPCanUserOperateOperation::CreateWorkflow) {
             return CBPDocument::canUserOperateDocumentType(CBPCanUserOperateOperation::CreateWorkflow, $userId, array('lists', get_called_class(), $documentId), $parameters);
         }
         return false;
     }
     if (!array_key_exists("IBlockPermission", $parameters)) {
         if (CModule::includeModule('lists')) {
             $parameters["IBlockPermission"] = CLists::getIBlockPermission($parameters["IBlockId"], $userId);
         } else {
             $parameters["IBlockPermission"] = CIBlock::getPermission($parameters["IBlockId"], $userId);
         }
     }
     if ($parameters["IBlockPermission"] <= "R") {
         return false;
     } elseif ($parameters["IBlockPermission"] >= "W") {
         return true;
     }
     $userId = intval($userId);
     if (!array_key_exists("AllUserGroups", $parameters)) {
         if (!array_key_exists("UserGroups", $parameters)) {
             $parameters["UserGroups"] = CUser::getUserGroup($userId);
         }
         $parameters["AllUserGroups"] = $parameters["UserGroups"];
         if ($userId == $parameters["CreatedBy"]) {
             $parameters["AllUserGroups"][] = "Author";
         }
     }
     if (!array_key_exists("DocumentStates", $parameters)) {
         $parameters["DocumentStates"] = CBPDocument::getDocumentStates(array("lists", get_called_class(), "iblock_" . $parameters["IBlockId"]), array('lists', get_called_class(), $documentId));
     }
     if (array_key_exists("WorkflowId", $parameters)) {
         if (array_key_exists($parameters["WorkflowId"], $parameters["DocumentStates"])) {
             $parameters["DocumentStates"] = array($parameters["WorkflowId"] => $parameters["DocumentStates"][$parameters["WorkflowId"]]);
         } else {
             return false;
         }
     }
     $allowableOperations = CBPDocument::getAllowableOperations($userId, $parameters["AllUserGroups"], $parameters["DocumentStates"]);
     if (!is_array($allowableOperations)) {
         return false;
     }
     $r = false;
     switch ($operation) {
         case CBPCanUserOperateOperation::ViewWorkflow:
             $r = in_array("read", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::StartWorkflow:
             $r = in_array("write", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::CreateWorkflow:
             $r = false;
             break;
         case CBPCanUserOperateOperation::WriteDocument:
             $r = in_array("write", $allowableOperations);
             break;
         case CBPCanUserOperateOperation::ReadDocument:
             $r = in_array("read", $allowableOperations) || in_array("write", $allowableOperations);
             break;
         default:
             $r = false;
     }
     return $r;
 }
			$obRights->GetRights(array("count_overwrited" => true, "parents" => $str_IBLOCK_ELEMENT_SECTION)),
			false, /*$bForceInherited=*/($ID <= 0) || $bCopy
		);
	$tabControl->EndCustomField("RIGHTS", $htmlHidden);
endif;

$bDisabled =
	($view=="Y")
	|| ($bWorkflow && $prn_LOCK_STATUS=="red")
	|| (
		(($ID <= 0) || $bCopy)
		&& !CIBlockSectionRights::UserHasRightTo($IBLOCK_ID, $MENU_SECTION_ID, "section_element_bind")
	)
	|| (
		(($ID > 0) && !$bCopy)
		&& !CIBlockElementRights::UserHasRightTo($IBLOCK_ID, $ID, "element_edit")
	)
	|| (
		$bBizproc
		&& !$canWrite
	)
;

if (!defined('BX_PUBLIC_MODE') || BX_PUBLIC_MODE != 1):
	ob_start();
	?>
	<input <?if ($bDisabled) echo "disabled";?> type="submit" class="adm-btn-save" name="save" id="save" value="<?echo GetMessage("IBLOCK_EL_SAVE")?>">
	<? if (!$bAutocomplete)
	{
		?><input <?if ($bDisabled) echo "disabled";?> type="submit" class="button" name="apply" id="apply" value="<?echo GetMessage('IBLOCK_APPLY')?>"><?
	}