本文整理匯總了PHP中CBPDocument::MergeDocuments方法的典型用法代碼示例。如果您正苦於以下問題:PHP CBPDocument::MergeDocuments方法的具體用法?PHP CBPDocument::MergeDocuments怎麽用?PHP CBPDocument::MergeDocuments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CBPDocument
的用法示例。
在下文中一共展示了CBPDocument::MergeDocuments方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: PublishDocument
/**
* Метод публикует документ. То есть делает его доступным в публичной части сайта.
*
* @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;
}
示例2: PublishDocument
/**
* ћетод публикует документ. “о есть делает его доступным в публичной части сайта.
*
* @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 ($ar_element = $db_element->Fetch()) {
$PARENT_ID = intval($ar_element["WF_PARENT_ELEMENT_ID"]);
if ($PARENT_ID) {
// TODO: ≈сли в документе $documentId поле WF_PARENT_ELEMENT_ID не NULL, то при публикации нужно перенести данные
// (скопировать документ) из документа $documentId в документ WF_PARENT_ELEMENT_ID,
$obElement = new CIBlockElement();
$ar_element["WF_PARENT_ELEMENT_ID"] = false;
if ($ar_element["PREVIEW_PICTURE"]) {
$ar_element["PREVIEW_PICTURE"] = CFile::MakeFileArray($ar_element["PREVIEW_PICTURE"]);
} else {
$ar_element["PREVIEW_PICTURE"] = array("tmp_name" => "", "del" => "Y");
}
if ($ar_element["DETAIL_PICTURE"]) {
$ar_element["DETAIL_PICTURE"] = CFile::MakeFileArray($ar_element["DETAIL_PICTURE"]);
} else {
$ar_element["DETAIL_PICTURE"] = array("tmp_name" => "", "del" => "Y");
}
$ar_element["IBLOCK_SECTION"] = array();
if ($ar_element["IN_SECTIONS"] == "Y") {
$rsSections = CIBlockElement::GetElementGroups($ar_element["ID"], true, array('ID', 'IBLOCK_ELEMENT_ID'));
while ($arSection = $rsSections->Fetch()) {
$ar_element["IBLOCK_SECTION"][] = $arSection["ID"];
}
}
$ar_element["PROPERTY_VALUES"] = array();
$arProps =& $ar_element["PROPERTY_VALUES"];
//Delete old files
$rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $PARENT_ID, array("value_id" => "asc"), array("PROPERTY_TYPE" => "F", "EMPTY" => "N"));
while ($arProp = $rsProps->Fetch()) {
if (!array_key_exists($arProp["ID"], $arProps)) {
$arProps[$arProp["ID"]] = array();
}
$arProps[$arProp["ID"]][$arProp["PROPERTY_VALUE_ID"]] = array("VALUE" => array("tmp_name" => "", "del" => "Y"), "DESCRIPTION" => false);
}
//Add new proiperty values
$rsProps = CIBlockElement::GetProperty($ar_element["IBLOCK_ID"], $ar_element["ID"], array("value_id" => "asc"));
$i = 0;
while ($arProp = $rsProps->Fetch()) {
$i++;
if (!array_key_exists($arProp["ID"], $arProps)) {
$arProps[$arProp["ID"]] = array();
}
if ($arProp["PROPERTY_VALUE_ID"]) {
if ($arProp["PROPERTY_TYPE"] == "F") {
$arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => CFile::MakeFileArray($arProp["VALUE"]), "DESCRIPTION" => $arProp["DESCRIPTION"]);
} else {
$arProps[$arProp["ID"]]["n" . $i] = array("VALUE" => $arProp["VALUE"], "DESCRIPTION" => $arProp["DESCRIPTION"]);
}
}
}
$obElement->Update($PARENT_ID, $ar_element);
// вызвать CBPDocument::MergeDocuments(WF_PARENT_ELEMENT_ID, $documentId) дл¤ переноса состо¤ний и истории Ѕѕ,
CBPDocument::MergeDocuments(array("iblock", "CIBlockDocument", $PARENT_ID), array("iblock", "CIBlockDocument", $documentId));
// грохнуть документ $documentId,
CIBlockElement::Delete($ID);
// опубликовать документ WF_PARENT_ELEMENT_ID
CIBlockElement::WF_CleanUpHistoryCopies($PARENT_ID, 0);
$strSql = "update b_iblock_element set WF_STATUS_ID='1', WF_NEW=NULL WHERE ID=" . $PARENT_ID . " AND WF_PARENT_ELEMENT_ID IS NULL";
$DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
CIBlockElement::UpdateSearch($PARENT_ID);
return $PARENT_ID;
} else {
// ≈сли WF_PARENT_ELEMENT_ID равно NULL, то все как раньше.
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;
}
示例3: PublishDocument
/**
* Метод публикует документ. То есть делает его доступным в публичной части сайта.
*
* @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;
}