Beispiel #1
0
 function update($newsID, $data)
 {
     global $USER;
     $el = new CIBlockElement();
     $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_SUB_STOCK_ID, "ACTIVE_TO" => date("d.m.Y", strtotime($data['ACTIVE_TO'])), "ACTIVE_FROM" => date("d.m.Y", strtotime($data['ACTIVE_FROM'])), "NAME" => trim(strip_tags($data['NAME'])), "PREVIEW_TEXT" => trim($data['PREVIEW_TEXT']));
     return $el->update($newsID, $arLoadProductArray);
 }
Beispiel #2
0
 function update($newsID, $data)
 {
     global $USER;
     $el = new CIBlockElement();
     $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_SUB_NEWS_ID, "DATE_ACTIVE_FROM" => $data['ACTIVE_FROM'], "NAME" => trim(strip_tags($data['NAME'])), "DETAIL_TEXT" => trim($data['DETAIL_TEXT']));
     return $el->update($newsID, $arLoadProductArray);
 }
Beispiel #3
0
 /**
  * ћетод публикует документ. “о есть делает его доступным в публичной части сайта.
  *
  * @param string $documentId - код документа.
  */
 public function PublishDocument($documentId)
 {
     global $DB;
     $ID = intval($documentId);
     $db_element = CIBlockElement::getList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "TIMESTAMP_X", "MODIFIED_BY", "DATE_CREATE", "CREATED_BY", "IBLOCK_ID", "ACTIVE", "ACTIVE_FROM", "ACTIVE_TO", "SORT", "NAME", "PREVIEW_PICTURE", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "WF_STATUS_ID", "WF_PARENT_ELEMENT_ID", "WF_NEW", "WF_COMMENTS", "IN_SECTIONS", "CODE", "TAGS", "XML_ID", "TMP_ID"));
     if ($element = $db_element->fetch()) {
         $parentId = intval($element["WF_PARENT_ELEMENT_ID"]);
         if ($parentId) {
             $elementObject = new CIBlockElement();
             $element["WF_PARENT_ELEMENT_ID"] = false;
             if ($element["PREVIEW_PICTURE"]) {
                 $element["PREVIEW_PICTURE"] = CFile::makeFileArray($element["PREVIEW_PICTURE"]);
             } else {
                 $element["PREVIEW_PICTURE"] = array("tmp_name" => "", "del" => "Y");
             }
             if ($element["DETAIL_PICTURE"]) {
                 $element["DETAIL_PICTURE"] = CFile::makeFileArray($element["DETAIL_PICTURE"]);
             } else {
                 $element["DETAIL_PICTURE"] = array("tmp_name" => "", "del" => "Y");
             }
             $element["IBLOCK_SECTION"] = array();
             if ($element["IN_SECTIONS"] == "Y") {
                 $sectionsQuery = CIBlockElement::getElementGroups($element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
                 while ($section = $sectionsQuery->fetch()) {
                     $element["IBLOCK_SECTION"][] = $section["ID"];
                 }
             }
             $element["PROPERTY_VALUES"] = array();
             $props =& $element["PROPERTY_VALUES"];
             //Delete old files
             $propsQuery = CIBlockElement::getProperty($element["IBLOCK_ID"], $parentId, array("value_id" => "asc"), array("PROPERTY_TYPE" => "F", "EMPTY" => "N"));
             while ($prop = $propsQuery->fetch()) {
                 if (!array_key_exists($prop["ID"], $props)) {
                     $props[$prop["ID"]] = array();
                 }
                 $props[$prop["ID"]][$prop["PROPERTY_VALUE_ID"]] = array("VALUE" => array("tmp_name" => "", "del" => "Y"), "DESCRIPTION" => false);
             }
             //Add new proiperty values
             $propsQuery = CIBlockElement::getProperty($element["IBLOCK_ID"], $element["ID"], array("value_id" => "asc"));
             $i = 0;
             while ($prop = $propsQuery->fetch()) {
                 $i++;
                 if (!array_key_exists($prop["ID"], $props)) {
                     $props[$prop["ID"]] = array();
                 }
                 if ($prop["PROPERTY_VALUE_ID"]) {
                     if ($prop["PROPERTY_TYPE"] == "F") {
                         $props[$prop["ID"]]["n" . $i] = array("VALUE" => CFile::makeFileArray($prop["VALUE"]), "DESCRIPTION" => $prop["DESCRIPTION"]);
                     } else {
                         $props[$prop["ID"]]["n" . $i] = array("VALUE" => $prop["VALUE"], "DESCRIPTION" => $prop["DESCRIPTION"]);
                     }
                 }
             }
             $elementObject->update($parentId, $element);
             CBPDocument::mergeDocuments(array("lists", get_called_class(), $parentId), array("lists", get_called_class(), $documentId));
             CIBlockElement::delete($ID);
             CIBlockElement::wF_CleanUpHistoryCopies($parentId, 0);
             $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $parentId . " AND WF_PARENT_ELEMENT_ID IS NULL";
             $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
             CIBlockElement::updateSearch($parentId);
             return $parentId;
         } else {
             CIBlockElement::wF_CleanUpHistoryCopies($ID, 0);
             $strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $ID . " AND WF_PARENT_ELEMENT_ID IS NULL";
             $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
             CIBlockElement::updateSearch($ID);
             return $ID;
         }
     }
     return false;
 }
 protected function uniqualizeElement(array &$droppedElement, $targetSectionId)
 {
     $mainPartName = $droppedElement['NAME'];
     $newName = $mainPartName;
     $countNonUnique = 0;
     while (!$this->isUniqueName($newName, $droppedElement['IBLOCK_ID'], $targetSectionId)) {
         $this->abortIfNeeded();
         $countNonUnique++;
         $newName = strstr($mainPartName, '.', true) . " ({$countNonUnique})" . strstr($mainPartName, '.');
     }
     if ($countNonUnique) {
         $droppedElement['NAME'] = $newName;
         $updateElement = new CIBlockElement();
         $updateElement->update($droppedElement['ID'], array('NAME' => $droppedElement['NAME']));
     }
     return;
 }
Beispiel #5
0
 function published($eventID)
 {
     global $USER;
     $el = new CIBlockElement();
     $arLoadProductArray = array("MODIFIED_BY" => $USER->GetID(), "IBLOCK_ID" => IB_SUB_EVENT_ID, "ACTIVE" => "Y");
     CIBlockElement::SetPropertyValueCode($eventID, "PUBLIC", array('VALUE' => PROP_EVENT_PUBLIC));
     return $el->update($eventID, $arLoadProductArray);
 }