Exemplo n.º 1
0
 /**
  * Метод публикует документ. То есть делает его доступным в публичной части сайта.
  *
  * @param string $documentId - код документа.
  */
 public function PublishDocument($documentId)
 {
     global $DB;
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         return;
     }
     $diskId = self::processGetDiskIdByDocId($documentId);
     if ($diskId !== null) {
         return self::proxyToDisk(__FUNCTION__, array($diskId));
     }
     $ID = intval($documentId);
     $db_element = CIBlockElement::GetByID($ID);
     $PARENT_ID = 0;
     $arParent = array();
     if ($arElement = $db_element->Fetch()) {
         $PARENT_ID = intval($arElement["WF_PARENT_ELEMENT_ID"]);
         if ($PARENT_ID > 0) {
             CBPDocument::MergeDocuments(array("webdav", "CIBlockDocumentWebdavSocnet", $PARENT_ID), array("webdav", "CIBlockDocumentWebdavSocnet", $documentId));
             $db_res = CIBlockElement::GetList(array(), array("ID" => $PARENT_ID, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("IBLOCK_ID", "ID", "NAME"));
             $arParent = $db_res->Fetch();
         }
     }
     parent::PublishDocument($documentId);
     if ($PARENT_ID > 0) {
         CBPDocument::AddDocumentToHistory(array("webdav", "CIBlockDocumentWebdavSocnet", $PARENT_ID), str_replace(array("#PARENT_ID#", "#PARENT_NAME#", "#ID#", "#NAME#"), array($PARENT_ID, $arParent["NAME"], $documentId, $arElement["NAME"]), GetMessage("IBD_TEXT_001")), $GLOBALS["USER"]->GetID());
     }
     $arElement["ID"] = $PARENT_ID > 0 ? $PARENT_ID : $arElement["ID"];
     // socnet
     $arConstructor = array("FILES_PROPERTY_CODE" => "FILE");
     $dbSectionsChain = CIBlockSection::GetNavChain($arElement["IBLOCK_ID"], $arElement["IBLOCK_SECTION_ID"]);
     $user_id = $group_id = false;
     if ($arSection = $dbSectionsChain->Fetch()) {
         if (intVal($arSection["SOCNET_GROUP_ID"]) > 0) {
             $arConstructor["FILES_GROUP_IBLOCK_ID"] = $arElement["IBLOCK_ID"];
             $arConstructor["PATH_TO_GROUP_FILES_ELEMENT"] = CIBlockDocumentWebdavSocnet::GetDocumentAdminPage($documentId);
             $group_id = $arSection["SOCNET_GROUP_ID"];
         } else {
             $arConstructor["FILES_USER_IBLOCK_ID"] = $arElement["IBLOCK_ID"];
             $arConstructor["PATH_TO_USER_FILES_ELEMENT"] = CIBlockDocumentWebdavSocnet::GetDocumentAdminPage($documentId);
             $user_id = $arSection["CREATED_BY"];
         }
     }
     $bxSocNetSearch = new CSocNetSearch($user_id, $group_id, $arConstructor);
     $bxSocNetSearch->IBlockElementUpdate($arElement);
     if ($arElement) {
         $rsEvents = GetModuleEvents("webdav", "OnBizprocPublishDocument");
         while ($arEvent = $rsEvents->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($arElement['ID']));
         }
     }
     return $PARENT_ID > 0 ? $PARENT_ID : $documentId;
 }
Exemplo n.º 2
0
 /**
  * Метод публикует документ. То есть делает его доступным в публичной части сайта.
  *
  * @param string $documentId - код документа.
  */
 public function PublishDocument($documentId)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $diskId = self::processGetDiskIdByDocId($documentId);
     if ($diskId !== null) {
         return self::proxyToDisk(__FUNCTION__, array($diskId));
     }
     global $DB;
     $ID = intval($documentId);
     $db_element = CIBlockElement::GetList(array(), array("ID" => $ID, "SHOW_HISTORY" => "Y"), false, false, array("ID", "NAME", "WF_PARENT_ELEMENT_ID"));
     $PARENT_ID = 0;
     $arParent = array();
     if ($ar_element = $db_element->Fetch()) {
         $PARENT_ID = intval($ar_element["WF_PARENT_ELEMENT_ID"]);
         if ($PARENT_ID > 0) {
             CBPDocument::MergeDocuments(array("webdav", "CIBlockDocumentWebdav", $PARENT_ID), array("webdav", "CIBlockDocumentWebdav", $documentId));
             $db_res = CIBlockElement::GetList(array(), array("ID" => $PARENT_ID, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"), false, false, array("IBLOCK_ID", "ID", "NAME"));
             $arParent = $db_res->Fetch();
         }
     }
     parent::PublishDocument($documentId);
     if ($PARENT_ID > 0) {
         CBPDocument::AddDocumentToHistory(array("webdav", "CIBlockDocumentWebdav", $PARENT_ID), str_replace(array("#PARENT_ID#", "#PARENT_NAME#", "#ID#", "#NAME#"), array($PARENT_ID, $arParent["NAME"], $documentId, $ar_element["NAME"]), GetMessage("IBD_TEXT_001")), $GLOBALS["USER"]->GetID());
     }
     if ($ar_element) {
         $rsEvents = GetModuleEvents("webdav", "OnBizprocPublishDocument");
         while ($arEvent = $rsEvents->Fetch()) {
             ExecuteModuleEventEx($arEvent, array($ar_element['ID']));
         }
     }
     return $PARENT_ID > 0 ? $PARENT_ID : $documentId;
 }