• Модуль: wiki
  • Путь к файлу: ~/bitrix/modules/wiki/classes/general/wiki.php
  • Класс: CWiki
  • Вызов: CWiki::Rename
function Rename($ID, $arFields, $bUpdateSearch=true)
{
	$arFilter = array('IBLOCK_ID' => $arFields['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N');

	// checking for the existence of a page with this name
	$arElement = self::GetElementByName($arFields['NAME'], $arFilter);
	$arOldElement = self::GetElementById($ID, $arFilter);

	$bRename = false;
	if ($arOldElement != false)
	{
		if ($arElement == false)
			$bRename = true;
		else if($arElement['ID'] == $ID)
			$bRename = true;
	}

	if ($bRename)
	{
		$this->CleanCacheById($ID, $arFields['IBLOCK_ID']);

		$arFields['XML_ID'] = $arFields['NAME'];
		$this->cIB_E->Update($ID, $arFields, false, $bUpdateSearch);

		$sCatName = '';
		if(CWikiUtils::IsCategoryPage($arFields['NAME'], $sCatName))
		{
			$sCatNameOld = '';
			if (CWikiUtils::IsCategoryPage($arOldElement['NAME'], $sCatNameOld))
			{
				// rename a category
				$arFilter =  array('NAME' => $sCatNameOld, 'IBLOCK_ID' => $arFields['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N');
				if (CWikiSocnet::IsSocNet())
				{
					$arFilter['>LEFT_BORDER'] = CWikiSocnet::$iCatLeftBorder;
					$arFilter['GetNext();

				if ($arCat != false)
				{
					$CIB_S = new CIBlockSection();

					$_arFields = array();
					$_arFields['IBLOCK_ID'] = $arFields['IBLOCK_ID'];
					$_arFields['NAME'] = $sCatName;
					$_arFields['XML_ID'] = $sCatName;
					$_arFields['CHECK_PERMISSIONS'] = 'N';

					$CIB_S->Update($arCat['ID'], $_arFields);
				}
			}
		}

		$arOldElement['NAME'] = CWikiUtils::htmlspecialcharsback($arOldElement['NAME']);

		if (self::GetDefaultPage($arFields['IBLOCK_ID']) == false
			|| (self::GetDefaultPage($arFields['IBLOCK_ID']) == $arOldElement['NAME']
				&& $arOldElement['NAME'] != $arFields['NAME']))
			self::SetDefaultPage($arFields['IBLOCK_ID'], $arFields['NAME']);

		return true;
	}

	return false;
}