Exemple #1
0
 public function executeComponent()
 {
     if (!$this->arParams['webdav'] instanceof CWebDavIblock) {
         ShowError('Invalid webdav property.');
         return;
     }
     CUtil::JSPostUnescape();
     $this->checkPermission();
     if ($this->getWebdav()->workflow != 'bizproc' && $this->getWebdav()->workflow != 'bizproc_limited') {
         return;
     }
     if (!CModule::IncludeModule('bizproc')) {
         return;
     }
     $entityType = $this->getEntityType();
     list($entityId, $documentUrl, $documentId) = $this->getEntityIdDocumentData($entityType);
     if ($this->isDownloadOriginal()) {
         $filter = array("DOCUMENT_ID" => $documentId);
         if ($this->arParams['MODIFIED_FROM']) {
             $filter['>=MODIFIED'] = ConvertTimeStamp($this->arParams['MODIFIED_FROM'], 'FULL');
         }
         $originalHistory = array();
         //if exist history document with date modified > than post create, then get first from this list.
         if ($this->getCountHistoryElementByDocument($filter) > 0) {
             $originalHistory = $this->getOriginalHistoryDocument(array('id' => $documentId, 'url' => $documentUrl, 'entity' => $entityType, 'entityId' => $entityId), $filter);
         } else {
         }
         if (!$originalHistory) {
             $this->getWebdav()->SendHistoryFile($this->getWebdav()->arParams['element_array']['ID'], 0);
         } else {
             $this->getWebdav()->SendHistoryFile($this->getWebdav()->arParams['element_array']['ID'], $originalHistory['ID']);
         }
     } elseif ($this->isDownloadFileVersion()) {
         $document = array('ID' => 0);
         if ($this->arParams['fileId'] != $this->getWebdav()->arParams['file_array']['ID']) {
             $document = $this->getWebdav()->findHistoryDocumentByFileId($this->getWebdav()->arParams['element_array']['ID'], $this->arParams['fileId'], $documentId);
         }
         $this->getWebdav()->SendHistoryFile($this->getWebdav()->arParams['element_array']['ID'], $document['ID']);
     } elseif ($this->isDownloadVersion()) {
         $this->getWebdav()->SendHistoryFile($this->getWebdav()->arParams['element_array']['ID'], $this->arParams['versionId']);
     } elseif ($this->isDownloadLastVersion()) {
         $this->getWebdav()->SendHistoryFile($this->getWebdav()->arParams['element_array']['ID'], 0);
     } elseif ($this->isAjax()) {
         $this->checkPermission('edit');
         $filter = array("DOCUMENT_ID" => $documentId);
         if ($this->arParams['MODIFIED_FROM']) {
             $filter['>=MODIFIED'] = ConvertTimeStamp($this->arParams['MODIFIED_FROM'], 'FULL');
         }
         $document = array('id' => $documentId, 'url' => $documentUrl, 'entity' => $entityType, 'entityId' => $entityId);
         $history = $this->getHistoryByDocument($document, $filter);
         $history = $this->runCorrectionDateHistoryByDocument($history, count($history) < static::COUNT_HISTORY_ELEMENT_ON_PAGE + 1, $this->getWebdav()->arParams['element_array']["DATE_CREATE"]);
         $history = $this->cleanHistoryList($history);
         $this->arResult['count_history_items'] = $this->getCountHistoryElementByDocument($filter);
         $this->arResult['webdav'] = $this->getWebdav();
         $this->arResult['creator'] = CUser::GetByID($this->getWebdav()->arParams['element_array']['CREATED_BY'])->fetch();
         $this->arResult['creator_name'] = CUser::FormatName(CSite::GetNameFormat(false), $this->arResult['creator'], true, false);
         $this->arResult['modifier'] = CUser::GetByID($this->getWebdav()->arParams['element_array']['MODIFIED_BY'])->fetch();
         $this->arResult['modifier_name'] = CUser::FormatName(CSite::GetNameFormat(false), $this->arResult['creator'], true, false);
         $this->arResult['date_modify'] = FormatDate('x', MakeTimeStamp($this->getWebdav()->arParams['element_array']["TIMESTAMP_X"]));
         $this->arResult['date_create'] = FormatDate('x', MakeTimeStamp($this->getWebdav()->arParams['element_array']["DATE_CREATE"]));
         $this->arResult['uri_download_original'] = $this->getUriDownloadOriginal();
         if (count($history) != static::COUNT_HISTORY_ELEMENT_ON_PAGE + 1) {
             $page = $history[0]['DETAIL_PAGE_URL'];
             //append original in history list
             array_unshift($history, array('URL_DOWNLOAD' => $this->getUriDownloadLasVersion(), 'HISTORY_PAGE_URL' => '', 'DETAIL_PAGE_URL' => $page, 'ID' => false, 'MODIFIED' => $this->getWebdav()->arParams['element_array']["TIMESTAMP_X"], 'DOCUMENT_ID' => 'DOCUMENT_ID', 'NAME' => 'NAME', 'USER_ID' => $this->arResult['modifier']['ID'], 'USER_NAME' => $this->arResult['modifier']['NAME'], 'USER_LAST_NAME' => $this->arResult['modifier']['LAST_NAME'], 'USER_SECOND_NAME' => $this->arResult['modifier']['SECOND_NAME'], 'USER_LOGIN' => $this->arResult['modifier']['LOGIN'], 'FILE_SIZE' => CFile::FormatSize(intval($this->getWebdav()->arParams["file_size"]))));
         }
         $this->arResult['history'] = $history;
         $this->arResult['editService'] = CWebDavLogOnlineEdit::getOnlineService(array('IBLOCK_ID' => $this->getWebdav()->arParams['element_array']['IBLOCK_ID'], 'SECTION_ID' => $this->getWebdav()->arParams['element_array']['IBLOCK_SECTION_ID'], 'ELEMENT_ID' => $this->getWebdav()->arParams['element_array']['ID']));
         $this->arResult['editUsers'] = $this->getOnlineUsers();
         if (!empty($filter['>=MODIFIED'])) {
             $filter['<=MODIFIED'] = $filter['>=MODIFIED'];
             unset($filter['>=MODIFIED']);
         }
         $this->includeComponentTemplate('ajax');
         return;
     }
     return;
 }
Exemple #2
0
/**
 * @param $arWDFile
 * @return bool
 */
function WDUFGetOnlineEditService($arWDFile)
{
    return CWebDavLogOnlineEdit::getOnlineService(array('IBLOCK_ID' => $arWDFile['IBLOCK_ID'], 'SECTION_ID' => $arWDFile['IBLOCK_SECTION_ID'], 'ELEMENT_ID' => $arWDFile['ID']));
}