本文整理汇总了PHP中CIBlockElement::WF_CleanUpHistoryCopies方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockElement::WF_CleanUpHistoryCopies方法的具体用法?PHP CIBlockElement::WF_CleanUpHistoryCopies怎么用?PHP CIBlockElement::WF_CleanUpHistoryCopies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockElement
的用法示例。
在下文中一共展示了CIBlockElement::WF_CleanUpHistoryCopies方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Update
//.........这里部分代码省略.........
$arNewFile["description"] = $arFields["DETAIL_PICTURE"]["description"];
$arNewFile["MODULE_ID"] = "iblock";
$arFields["DETAIL_PICTURE"] = $arNewFile;
} else {
$arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"];
}
} else {
//File was not changed at all
$arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"];
}
} else {
unset($arFields["DETAIL_PICTURE"]["old_file"]);
}
}
} else {
$arFields["DETAIL_PICTURE"] = $ar_wf_element["DETAIL_PICTURE"];
}
$NID = $this->Add($arFields);
if ($NID > 0) {
if ($arFields["WF_STATUS_ID"] == 1) {
$DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE ID=" . $ID);
$DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_NEW=null WHERE WF_PARENT_ELEMENT_ID=" . $ID);
$ar_wf_element["WF_NEW"] = false;
}
if ($this->bWF_SetMove) {
CIBlockElement::WF_SetMove($NID, $LAST_ID);
}
if ($ar_element["WF_STATUS_ID"] != 1 && $ar_wf_element["WF_STATUS_ID"] != $arFields["WF_STATUS_ID"] && $arFields["WF_STATUS_ID"] != 1) {
$DB->Query("UPDATE b_iblock_element SET TIMESTAMP_X=TIMESTAMP_X, WF_STATUS_ID=" . $arFields["WF_STATUS_ID"] . " WHERE ID=" . $ID);
}
}
//element was not published, so keep original
if (is_set($arFields, "WF_STATUS_ID") && $arFields["WF_STATUS_ID"] != 1 && $ar_element["WF_STATUS_ID"] == 1 || !is_set($arFields, "WF_STATUS_ID") && $ar_wf_element["WF_STATUS_ID"] != 1) {
CIBlockElement::WF_CleanUpHistoryCopies($ID);
return true;
}
$arFields['WF_PARENT_ELEMENT_ID'] = false;
$rs = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE from b_iblock_element WHERE ID = " . $NID);
$ar_new_element = $rs->Fetch();
} else {
$ar_new_element = false;
}
if ($ar_new_element) {
if (!intval($ar_new_element["PREVIEW_PICTURE"])) {
$arFields["PREVIEW_PICTURE"] = false;
} else {
$arFields["PREVIEW_PICTURE"] = $ar_new_element["PREVIEW_PICTURE"];
}
if (!intval($ar_new_element["DETAIL_PICTURE"])) {
$arFields["DETAIL_PICTURE"] = false;
} else {
$arFields["DETAIL_PICTURE"] = $ar_new_element["DETAIL_PICTURE"];
}
if (is_array($arFields["PROPERTY_VALUES"]) && count($arFields["PROPERTY_VALUES"]) > 0) {
$i = 0;
$db_prop = CIBlockProperty::GetList(array(), array("IBLOCK_ID" => $arFields["IBLOCK_ID"], "CHECK_PERMISSIONS" => "N", "PROPERTY_TYPE" => "F"));
while ($arProp = $db_prop->Fetch()) {
$i++;
unset($arFields["PROPERTY_VALUES"][$arProp["CODE"]]);
unset($arFields["PROPERTY_VALUES"][$arProp["ID"]]);
$arFields["PROPERTY_VALUES"][$arProp["ID"]] = array();
}
if ($i > 0) {
//Delete previous files
$props = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $ID, "sort", "asc", array("PROPERTY_TYPE" => "F", "EMPTY" => "N"));
while ($arProp = $props->Fetch()) {
示例2: UnpublishDocument
/**
* ћетод снимает документ с публикации. “о есть делает его недоступным в публичной части сайта.
*
* @param string $documentId - код документа.
*/
public function UnpublishDocument($documentId)
{
global $DB;
CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
$strSql = "update b_iblock_element set WF_STATUS_ID='2', WF_NEW='Y' WHERE ID=" . intval($documentId) . " AND WF_PARENT_ELEMENT_ID IS NULL";
$z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
CIBlockElement::UpdateSearch($documentId);
}
示例3: UpdateDocument
public function UpdateDocument($documentId, $arFields)
{
$documentId = intval($documentId);
if ($documentId <= 0) {
throw new CBPArgumentNullException("documentId");
}
CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
$arFieldsPropertyValues = array();
$dbResult = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y"), false, false, array("ID", "IBLOCK_ID"));
$arResult = $dbResult->Fetch();
if (!$arResult) {
throw new Exception("Element is not found");
}
$arDocumentFields = self::GetDocumentFields("type_" . $arResult["IBLOCK_ID"]);
$arKeys = array_keys($arFields);
foreach ($arKeys as $key) {
if (!array_key_exists($key, $arDocumentFields)) {
continue;
}
if ($arDocumentFields[$key]["Multiple"] && is_string($arFields[$key])) {
$arFieldsTmp = explode(",", $arFields[$key]);
$arFields[$key] = array();
foreach ($arFieldsTmp as $value) {
$arFields[$key][] = trim($value);
}
}
$arFields[$key] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
if ($arDocumentFields[$key]["Type"] == "S:UserID") {
$ar = array();
foreach ($arFields[$key] as $v1) {
if (substr($v1, 0, strlen("user_")) == "user_") {
$ar[] = substr($v1, strlen("user_"));
} else {
$a1 = self::GetUsersFromUserGroup($v1, $documentId);
foreach ($a1 as $a11) {
$ar[] = $a11;
}
}
}
$arFields[$key] = $ar;
} elseif ($arDocumentFields[$key]["Type"] == "L") {
$realKey = substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_" ? substr($key, strlen("PROPERTY_")) : $key;
$arV = array();
$db = CIBlockProperty::GetPropertyEnum($realKey, false, array("IBLOCK_ID" => $arResult["IBLOCK_ID"]));
while ($ar = $db->GetNext()) {
$arV[$ar["XML_ID"]] = $ar["ID"];
}
foreach ($arFields[$key] as &$value) {
if (array_key_exists($value, $arV)) {
$value = $arV[$value];
}
}
} elseif ($arDocumentFields[$key]["Type"] == "F") {
foreach ($arFields[$key] as &$value) {
$value = CFile::MakeFileArray($value);
}
} elseif ($arDocumentFields[$key]["Type"] == "S:HTML") {
foreach ($arFields[$key] as &$value) {
$value = array("VALUE" => $value);
}
}
if (!$arDocumentFields[$key]["Multiple"] && is_array($arFields[$key])) {
if (count($arFields[$key]) > 0) {
$a = array_values($arFields[$key]);
$arFields[$key] = $a[0];
} else {
$arFields[$key] = null;
}
}
if (substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_") {
$realKey = substr($key, strlen("PROPERTY_"));
$arFieldsPropertyValues[$realKey] = is_array($arFields[$key]) && !CBPHelper::IsAssociativeArray($arFields[$key]) ? $arFields[$key] : array($arFields[$key]);
unset($arFields[$key]);
}
}
$iblockElement = new CIBlockElement();
if (count($arFieldsPropertyValues) > 0) {
$iblockElement->SetPropertyValuesEx($documentId, $arResult["IBLOCK_ID"], $arFieldsPropertyValues);
}
if (count($arFields) > 0) {
$res = $iblockElement->Update($documentId, $arFields, false, true, true);
if (!$res) {
throw new Exception($iblockElement->LAST_ERROR);
}
}
}
示例4: UnpublishDocument
/**
* Метод снимает документ с публикации. То есть делает его недоступным в публичной части сайта.
*
* @param string $documentId - код документа.
*/
public function UnpublishDocument($documentId)
{
global $DB;
$documentId = intval($documentId);
if ($documentId <= 0) {
return;
}
$diskId = self::processGetDiskIdByDocId((int) $documentId);
if ($diskId !== null) {
self::proxyToDisk(__FUNCTION__, array($diskId));
}
CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
$strSql = "update b_iblock_element set WF_STATUS_ID='2', WF_NEW='Y' WHERE ID=" . intval($documentId) . " AND WF_PARENT_ELEMENT_ID IS NULL";
$z = $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br>LINE: " . __LINE__);
CSocNetSearch::IBlockElementDelete(array("ID" => $documentId));
}
示例5: 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("lists", "BizprocDocument", $PARENT_ID), array("lists", "BizprocDocument", $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;
}
示例6: UpdateDocument
/**
* Метод изменяет свойства (поля) указанного документа на указанные значения.
*
* @param string $documentId - код документа.
* @param array $arFields - массив новых значений свойств документа в виде array(код_свойства => значение, ...). Коды свойств соответствуют кодам свойств, возвращаемым методом GetDocumentFields.
*/
public function UpdateDocument($documentId, $arFields)
{
$documentId = intval($documentId);
if ($documentId <= 0) {
throw new CBPArgumentNullException("documentId");
}
CIBlockElement::WF_CleanUpHistoryCopies($documentId, 0);
$db = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y"), false, false, array("ID", "IBLOCK_ID"));
$ar = $db->Fetch();
if (!$ar) {
throw new Exception("Task is not found");
}
$arFields["PROPERTY_VALUES"] = array();
$arKeys = array_keys($arFields);
foreach ($arKeys as $key) {
if (substr($key, 0, strlen("PROPERTY_")) == "PROPERTY_") {
$arFields["PROPERTY_VALUES"][substr($key, strlen("PROPERTY_"))] = $arFields[$key];
}
}
$iblockElementObject = new CIBlockElement();
if (count($arFields["PROPERTY_VALUES"]) > 0) {
$iblockElementObject->SetPropertyValuesEx($documentId, $ar["IBLOCK_ID"], $arFields["PROPERTY_VALUES"]);
}
unset($arFields["PROPERTY_VALUES"]);
$res = $iblockElementObject->Update($documentId, $arFields);
if (!$res) {
throw new Exception($iblockElement->LAST_ERROR);
}
CIBlockElement::RecalcSections($documentId);
}