예제 #1
0
 if (count($arErrorsTmp) > 0) {
     foreach ($arErrorsTmp as $e) {
         $arResult['FATAL_MESSAGE'] .= $e['message'];
     }
     $this->AbortResultCache();
     ShowError($arResult['FATAL_MESSAGE']);
     return;
 }
 $canRead = CBPDocument::CanUserOperateDocument(CBPCanUserOperateOperation::ReadDocument, $GLOBALS['USER']->GetID(), $documentId, array('UserGroups' => $GLOBALS['USER']->GetUserGroupArray()));
 if (!$canRead) {
     $this->AbortResultCache();
     ShowError(GetMessage('WIKI_ACCESS_DENIED'));
     return;
 }
 if (!empty($arHistoryResult)) {
     $history = new CBPHistoryService();
     $arFilter = array('DOCUMENT_ID' => $documentId);
     $dbResultList = $history->GetHistoryList(array('ID' => 'DESC'), $arFilter, false, false, array('ID'));
     $sTableID = 'tbl_bizproc_document_history';
     $rsHistory = new CDBResult($dbResultList, $sTableID);
     $iPrevHistoryId = 0;
     $iNextHistoryId = 0;
     $iCurHistoryId = 0;
     $arPrevHistory = array();
     $arNextHistory = array();
     $bFirst = true;
     while ($arHistory = $rsHistory->GetNext()) {
         if ($bFirst) {
             $bFirst = false;
             $iCurHistoryId = $arHistory['ID'];
         }
예제 #2
0
                 // so how could it change the name
                 $arResult['ELEMENT_NEW'] = CWiki::GetElementById($arParams['ELEMENT_ID'], $arFilter);
                 if (CWiki::GetDefaultPage($arParams['IBLOCK_ID']) == $arResult['ELEMENT']['NAME'] && $arResult['ELEMENT']['NAME'] != $arResult['ELEMENT_NEW']['NAME']) {
                     CWiki::SetDefaultPage($arParams['IBLOCK_ID'], $arResult['ELEMENT_NEW']['NAME']);
                 }
                 $CACHE_MANAGER->ClearByTag('wiki_' . $arParams['ELEMENT_ID']);
                 LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_POST'], array('wiki_name' => urlencode($arResult['ELEMENT_NEW']['NAME']), 'group_id' => CWikiSocnet::$iSocNetId)));
             } else {
                 $arResult['FATAL_MESSAGE'] = GetMessage('WIKI_PAGE_RECOVER_ERROR');
             }
         } catch (Exception $e) {
             $arResult['FATAL_MESSAGE'] = $e->getMessage();
         }
     }
 }
 $history = new CBPHistoryService();
 $arFilter = array('DOCUMENT_ID' => $documentId);
 $dbResultList = $history->GetHistoryList(array('ID' => 'DESC'), $arFilter, false, false, array('ID', 'DOCUMENT_ID', 'NAME', 'MODIFIED', 'USER_ID', 'USER_NAME', 'USER_LAST_NAME', 'USER_SECOND_NAME', 'USER_LOGIN'));
 $dbResultListFirst = $history->GetHistoryList(array('ID' => 'DESC'), $arFilter, false, false, array('ID'));
 $arResult['PAGE_VAR'] = $arParams['PAGE_VAR'];
 $arResult['OPER_VAR'] = $arParams['OPER_VAR'];
 $arResult['PATH_TO_HISTORY_DIFF'] = CHTTP::urlAddParams(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_HISTORY_DIFF'], array('wiki_name' => urlencode($arParams['ELEMENT_NAME']), 'group_id' => CWikiSocnet::$iSocNetId)), $arParams['IN_COMPLEX'] == 'Y' && $arParams['SEF_MODE'] == 'N' ? array($arParams['OPER_VAR'] => 'history_diff') : array());
 $sTableID = 'tbl_bizproc_document_history';
 $rsHistoryFirst = new CDBResult($dbResultListFirst, $sTableID);
 $arHistoryFirst = $rsHistoryFirst->GetNext();
 $rsHistory = new CDBResult($dbResultList, $sTableID);
 $rsHistory->NavStart($arParams['HISTORY_COUNT'], false);
 $arResult['DB_LIST'] =& $rsHistory;
 $arResult['HISTORY'] = array();
 if ($arResult['SOCNET']) {
     $arResult['AJAX_PAGE'] = $APPLICATION->GetCurPageParam('', array('bxajaxid', 'logout'));
예제 #3
0
 public static function GetList($arOrder = array("ID" => "DESC"), $arFilter = array(), $arGroupBy = false, $arNavStartParams = false, $arSelectFields = array())
 {
     $h = new CBPHistoryService();
     return $h->GetHistoryList($arOrder, $arFilter, $arGroupBy, $arNavStartParams, $arSelectFields);
 }
예제 #4
0
            break;
    }
    if (!empty($arError)) {
        $e = new CAdminException($arError);
        $arResult["ERROR_MESSAGE"] = $e->GetString();
    } else {
        LocalRedirect($APPLICATION->GetCurPageParam("result=" . $arParams["ACTION"], array("action", "ID", "sessid", "result")));
    }
}
/********************************************************************
				/Action
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$history = new CBPHistoryService();
$db_res = $history->GetHistoryList(array(strtoupper($by) => strtoupper($order)), array("DOCUMENT_ID" => $arParams["DOCUMENT_ID"]), false, false, array("ID", "DOCUMENT_ID", "NAME", "MODIFIED", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "DOCUMENT", "USER_SECOND_NAME"));
if ($db_res) {
    $db_res->NavStart($arParams["PAGE_ELEMENTS"], false);
    $arResult["NAV_RESULT"] = $db_res;
    $arResult["NAV_STRING"] = $db_res->GetPageNavStringEx($navComponentObject, GetMessage("BPADH_NAV_TITLE"), $arParams["PAGE_NAVIGATION_TEMPLATE"], true);
    if ($this->__parent) {
        $this->__parent->arResult["HISTORY_LENGTH"] = $db_res->NavRecordCount;
    }
    while ($res = $db_res->GetNext()) {
        if ($arParams['MODULE_ID'] == 'webdav' && isset($arParams['OBJECT'])) {
            if (isset($res["DOCUMENT"]["PROPERTIES"]['WEBDAV_SIZE']['VALUE'])) {
                $res['FILE_SIZE'] = CFile::FormatSize($res['DOCUMENT']['PROPERTIES']['WEBDAV_SIZE']['VALUE']);
            }
        }
        $res["USER"] = CUser::FormatName($arParams["NAME_TEMPLATE"], array("NAME" => $res["USER_NAME"], "LAST_NAME" => $res["USER_LAST_NAME"], "SECOND_NAME" => $res["USER_SECOND_NAME"], "LOGIN" => $res["USER_LOGIN"]), true);
예제 #5
0
 /**
  * <p>Метод удаляет Wiki-страницу. Динамичный метод.</p>
  *
  *
  * @param int $ID  Идентификатор Wiki-страницы
  *
  * @param int $IBLOCK_ID  Идентификатор Инфо.блока. <br> До версии 10.0.0 назывался <b>BLOCK_ID</b>.
  *
  * @return bool 
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?<br>// Удалим Wiki-страницу с идентификатором 13 в инфо.блоке с идентификатором 2<br>$ID = 13;<br>$IBLOCK_ID = 2;<br><br>$CWiki = new CWiki();<br>if (!$CWiki-&gt;Delete($ID, $IBLOCK_ID))<br>	echo 'Ошибка. Страница не удалена.';<br>?&gt;
  * </pre>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/wiki/classes/cwiki/Delete.php
  * @author Bitrix
  */
 public function Delete($ID, $IBLOCK_ID)
 {
     $rIBlock = CIBlock::getList(array(), array('ID' => $IBLOCK_ID, 'CHECK_PERMISSIONS' => 'N'));
     $arIBlock = $rIBlock->GetNext();
     // erase the history of changes
     if ($arIBlock['BIZPROC'] == 'Y' && CModule::IncludeModule('bizproc')) {
         $historyService = new CBPHistoryService();
         $historyService->DeleteHistoryByDocument(array('iblock', 'CWikiDocument', $ID));
     }
     $this->CleanCacheById($ID, $IBLOCK_ID);
     // delete item
     $bResult = $this->cIB_E->Delete($ID);
     return $bResult;
 }
예제 #6
0
	public static function GetDocumentFromHistory($historyId, &$arErrors)
	{
		$arErrors = array();

		try
		{
			$historyId = intval($historyId);
			if ($historyId <= 0)
				throw new CBPArgumentNullException("historyId");

			return CBPHistoryService::GetById($historyId);
		}
		catch (Exception $e)
		{
			$arErrors[] = array(
				"code" => $e->getCode(),
				"message" => $e->getMessage(),
				"file" => $e->getFile()." [".$e->getLine()."]"
			);
		}
	}
예제 #7
0
 /**
  * @param $id
  * @param $wfId
  * @param $params
  * @return array
  */
 public function getHistoryFileData($id, $wfId, &$params)
 {
     $fullpath = '';
     $options = $arFile = $arr = array();
     $io = self::GetIo();
     $arFilter = array("IBLOCK_ID" => isset($this->arParams['element_array']['ID']) && $this->arParams['element_array']['ID'] == $id ? $this->arParams['element_array']['IBLOCK_ID'] : $this->IBLOCK_ID, "ID" => $id, "SHOW_HISTORY" => "Y", "CHECK_PERMISSIONS" => "Y");
     if ($this->permission < "U") {
         $arFilter["SHOW_HISTORY"] = "N";
     }
     if (($this->workflow == 'bizproc' || $this->workflow == 'bizproc_limited') && $wfId > 0) {
         $history = new CBPHistoryService();
         $db_res = $history->GetHistoryList(array("ID" => "DESC"), array("DOCUMENT_ID" => array($this->wfParams['DOCUMENT_TYPE'][0], $this->wfParams['DOCUMENT_TYPE'][1], $id), "ID" => $wfId), false, false, array("ID", "DOCUMENT", "NAME"));
         if ($db_res && ($arr = $db_res->Fetch())) {
             $arFile = array("SRC" => $arr["DOCUMENT"]["PROPERTIES"][$this->file_prop]["VALUE"], "NAME" => $arr["DOCUMENT"]["NAME"]);
             $arr["NAME"] = $arr["DOCUMENT"]["NAME"];
             $fullpath = urldecode($arFile["SRC"]);
             if (substr($fullpath, 0, 4) != "http") {
                 $fullpath = $io->GetPhysicalName($_SERVER['DOCUMENT_ROOT'] . $arFile["SRC"]);
             } else {
                 $fullpath = CWebDavTools::urlEncode($fullpath);
             }
             $arTmpFile = CFile::MakeFileArray($fullpath);
             $fullpath = $arTmpFile['tmp_name'];
             $arFile["FILE_SIZE"] = $arTmpFile["size"];
         }
     } else {
         $arFilter['CHECK_PERMISSIONS'] = 'N';
         //check permissions manual! While infoblock perm's check by every section's (in dropped - we have error).
         $rs = CIBlockElement::GetList(array(), $arFilter, false, array("nTopCount" => 1), array("ID", "NAME", "TIMESTAMP_X", "IBLOCK_ID", "PROPERTY_" . $this->file_prop));
         if ($rs && ($arr = $rs->Fetch())) {
             if (empty($this->arParams["element_array"])) {
                 $this->arParams["element_array"] = $arr;
             }
             $arFile = CFile::GetFileArray($arr["PROPERTY_FILE_VALUE"]);
             $options["from_cloud"] = intval($arFile['HANDLER_ID']) > 0 ? "Y" : "N";
             $arTmpFile = array();
             if (CFile::IsImage($arFile["FILE_NAME"], $arFile["CONTENT_TYPE"])) {
                 if ($params["width"] > 0 || $params["height"] > 0) {
                     $arTmpFile = CFile::ResizeImageGet($arFile, array("width" => $params["width"], "height" => $params["height"]), $params["exact"] == "Y" ? BX_RESIZE_IMAGE_EXACT : BX_RESIZE_IMAGE_PROPORTIONAL, true, false, true);
                     $arTmpFile['tmp_name'] = ($options["from_cloud"] == "Y" ? "" : $_SERVER["DOCUMENT_ROOT"]) . $arTmpFile["src"];
                     $options["resized"] = "Y";
                     $arFile["FILE_SIZE"] = $arTmpFile["size"];
                     $arFile["SRC"] = $arTmpFile["src"];
                 }
                 if ($params["cache_image"] == "Y") {
                     $options["cache_time"] = 86400;
                 }
             } else {
                 $params["cache_image"] = "N";
             }
             if (empty($arTmpFile)) {
                 $arTmpFile = CFile::MakeFileArray($arr["PROPERTY_FILE_VALUE"]);
             }
             $fullpath = $arTmpFile['tmp_name'];
         }
     }
     $elementName = $arr['NAME'];
     return array($arFile, $options, $fullpath, $elementName);
 }
 protected static function getIdHistoryDocument(array $filter)
 {
     if (!CModule::IncludeModule('bizproc')) {
         return array();
     }
     $by = "modified";
     $order = "desc";
     $history = new CBPHistoryService();
     $dbDocumentHistory = $history->GetHistoryList(array(strtoupper($by) => strtoupper($order)), $filter, false, array('nTopCount' => 1), array("ID", "DOCUMENT_ID", "NAME", "MODIFIED", "USER_ID", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN", "DOCUMENT", "USER_SECOND_NAME"));
     if ($res = $dbDocumentHistory->fetch()) {
         return $res;
     } else {
         //if not exists second entry, then original is same webdav element.
     }
     return array();
 }
예제 #9
0
 static function OnBeforeDeleteFileFromHistory($historyId, $documentId)
 {
     static $arHistoryFields = array("ID", "DOCUMENT_ID", "DOCUMENT");
     $history = new CBPHistoryService();
     if ($documentId[0] != 'webdav') {
         return true;
     }
     $fileToDeleteHash = null;
     $dbDoc = $history->GetHistoryList(array("ID" => "DESC"), array("ID" => $historyId), false, false, $arHistoryFields);
     if ($dbDoc && ($arDoc = $dbDoc->Fetch())) {
         if (isset($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'])) {
             $fileToDeleteHash = $arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'];
         }
     }
     $result = true;
     // seems to be an old file without hash
     if ($fileToDeleteHash != null) {
         $dbDoc = $history->GetHistoryList(array("ID" => "DESC"), array("DOCUMENT_ID" => $documentId), false, false, $arHistoryFields);
         if ($dbDoc) {
             while ($arDoc = $dbDoc->Fetch()) {
                 if ($arDoc['ID'] == $historyId) {
                     continue;
                 }
                 if (isset($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'])) {
                     $result = !($arDoc['DOCUMENT']['PROPERTIES']['FILE']['HASH'] == $fileToDeleteHash);
                     // file used also in other historyRecord
                     if (!$result) {
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }
예제 #10
0
 /**
  * @param array $filter
  * @return integer
  */
 protected function getCountHistoryElementByDocument(array $filter)
 {
     $history = new CBPHistoryService();
     return $history->GetHistoryList(array(), $filter, array());
 }
예제 #11
0
 public static function TruncateHistory($arDocType, $docID)
 {
     $maxCount = COption::GetOptionInt("webdav", "bp_history_size", 50);
     if ($maxCount <= 0) {
         return;
     }
     $documentId = array($arDocType[0], $arDocType[1], $docID);
     $history = new CBPHistoryService();
     $db_res = $history->GetHistoryList(array("ID" => "DESC"), array("DOCUMENT_ID" => $documentId), false, false, array("ID"));
     $count = 1;
     if ($db_res) {
         while ($arr = $db_res->Fetch()) {
             if ($count++ > $maxCount) {
                 CBPHistoryService::Delete($arr["ID"], $documentId);
             }
         }
     }
 }
예제 #12
0
$arFilterFields = array("filter_modified_1", "filter_modified_2", "filter_user_id", "filter_user_id1");
$lAdmin->InitFilter($arFilterFields);
$arFilter = array("DOCUMENT_ID" => $documentId);
if (strlen($filter_modified_1) > 0) {
    $arFilter[">=MODIFIED"] = $filter_modified_1;
}
if (strlen($filter_modified_2) > 0) {
    $arFilter["<=MODIFIED"] = $filter_modified_2;
}
if (intval($filter_user_id) > 0) {
    $arFilter["USER_ID"] = $filter_user_id;
}
if (intval($filter_user_id1) > 0) {
    $arFilter["USER_ID"] = $filter_user_id1;
}
$history = new CBPHistoryService();
if ($arID = $lAdmin->GroupAction()) {
    if ($_REQUEST['action_target'] == 'selected') {
        $arID = array();
        $dbResultList = $history->GetHistoryList(array($by => $order), $arFilter, false, false, array("ID"));
        while ($arResult = $dbResultList->Fetch()) {
            $arID[] = $arResult['ID'];
        }
    }
    foreach ($arID as $ID) {
        if (strlen($ID) <= 0) {
            continue;
        }
        switch ($_REQUEST['action']) {
            case "delete":
                CBPHistoryService::Delete($ID, $documentId);
예제 #13
0
/**
 * @param $arWDFile
 * @param $postDatePublish
 * @return array
 */
function WDUFHasHistoryModify($arWDFile, $postDatePublish)
{
    if (!CModule::IncludeModule('bizproc')) {
        return false;
    }
    if (CWebDavEditDocBase::isEditable($arWDFile['NAME'])) {
        $history = new CBPHistoryService();
        $filter = array('DOCUMENT_ID' => array('webdav', 'CIBlockDocumentWebdavSocnet', $arWDFile['ID']));
        if (stripos($arWDFile['IBLOCK_CODE'], 'shared') !== false) {
            $filter = array('DOCUMENT_ID' => array('webdav', 'CIBlockDocumentWebdav', $arWDFile['ID']));
        }
        if ($postDatePublish) {
            $filter['>=MODIFIED'] = $postDatePublish;
        }
        //has history modify by file where date modify > date publish of blog post
        return (bool) $history->GetHistoryList(array(), $filter, array());
    }
    return false;
}