- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/undo.php
- Класс: CUndo
- Вызов: CUndo::Escape
static function Escape($ID)
{
global $USER, $CACHE_MANAGER;
if (!isset($USER) || !is_object($USER) || !$USER->IsAuthorized())
return false;
$arUndo = null;
$cacheId = mb_substr($ID, 0, 3);
if ($CACHE_MANAGER->Read(48 * 3600, $cacheId, "b_undo"))
{
$arUndoCache = $CACHE_MANAGER->Get($cacheId);
}
else
{
$arUndoCache = array();
$arUndoList = CUndo::GetList(array('arFilter' => array('%ID' => $cacheId."%")));
foreach ($arUndoList as $ar)
{
if (!isset($arUndoCache[$ar["ID"]]) && !isset($arUndoCache[$ar["ID"]][$ar["USER_ID"]]))
$arUndoCache[$ar["ID"]][$ar["USER_ID"]] = $ar;
}
$CACHE_MANAGER->Set($cacheId, $arUndoCache);
}
$arUndo = $arUndoCache[$ID][$USER->GetId()] ?? false;
if (!$arUndo)
return false;
// Include module
if ($arUndo['MODULE_ID'] && $arUndo['MODULE_ID'] <> '')
{
if (!CModule::IncludeModule($arUndo['MODULE_ID']))
return false;
}
// Get params for Escaping
$arParams = unserialize($arUndo['CONTENT'], ['allowed_classes' => false]);
// Check and call Undo handler
$p = mb_strpos($arUndo['UNDO_HANDLER'], "::");
if ($p === false)
{
if (function_exists($arUndo['UNDO_HANDLER'])) // function
{
call_user_func($arUndo['UNDO_HANDLER'], array($arParams, $arUndo['UNDO_TYPE']));
}
}
else
{
$className = mb_substr($arUndo['UNDO_HANDLER'], 0, $p);
if (class_exists($className)) //class
{
$methodName = mb_substr($arUndo['UNDO_HANDLER'], $p + 2);
if (method_exists($className, $methodName)) //static method
{
call_user_func_array(array($className, $methodName), array($arParams, $arUndo['UNDO_TYPE']));
}
}
}
// Del entry
CUndo::Delete($ID);
return true;
}