- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/lib/integration/rest/appconfiguration.php
- Класс: BitrixBizprocIntegrationRestAppConfiguration
- Вызов: AppConfiguration::clearBizproc
static function clearBizproc($option)
{
$result = [
'NEXT' => false,
'OWNER_DELETE' => [],
];
$clearFull = $option['CLEAR_FULL'];
$prefix = $option['PREFIX_NAME'];
$pattern = '/^(' . $prefix . ')/';
$res = WorkflowTemplateTable::getList(
[
'order' => [
'ID' => 'ASC',
],
'filter' => [
'=MODULE_ID' => static::$accessModules,
'>ID' => $option['NEXT'],
' CBPDocumentEventType::Script,
],
'select' => ['*'],
]
);
$errorsTmp = [];
while ($item = $res->Fetch())
{
$result['NEXT'] = $item['ID'];
if (!$clearFull && $item['DOCUMENT_TYPE'] == 'DEAL')
{
//dont off old custom deal robot
$matches = [];
preg_match(static::$customDealMatch, $item['DOCUMENT_STATUS'], $matches, PREG_OFFSET_CAPTURE);
if (!empty($matches))
{
continue;
}
}
if ($clearFull || !empty($item['DOCUMENT_STATUS']))
{
CBPDocument::DeleteWorkflowTemplate(
$item['ID'],
[
$item['MODULE_ID'],
$item['ENTITY'],
$item['DOCUMENT_TYPE'],
],
$errorsTmp
);
if (!$errorsTmp)
{
$result['OWNER_DELETE'][] = [
'ENTITY_TYPE' => self::OWNER_ENTITY_TYPE_BIZPROC,
'ENTITY' => $item['ID'],
];
}
}
else
{
$name = $item['NAME'];
if ($prefix != '' && preg_match($pattern, $name) === 0)
{
$name = "($prefix) " . $name;
}
CBPDocument::UpdateWorkflowTemplate(
$item['ID'],
[
$item['MODULE_ID'],
$item['ENTITY'],
$item['DOCUMENT_TYPE'],
],
[
'ACTIVE' => 'N',
'AUTO_EXECUTE' => CBPDocumentEventType::None,
'NAME' => $name,
],
$errorsTmp
);
}
}
return $result;
}