- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/classes/general/document.php
- Класс: CBPDocument
- Вызов: CBPDocument::getTemplatesForStart
static function getTemplatesForStart($userId, $documentType, $documentId = null, array $parameters = array())
{
if (!isset($parameters['UserGroups']))
{
$parameters['UserGroups'] = CUser::GetUserGroup($userId);
}
if (!isset($parameters['DocumentStates']))
{
$parameters['DocumentStates'] = static::GetDocumentStates($documentType, $documentId);
}
$op = CBPCanUserOperateOperation::StartWorkflow;
$templates = array();
$dbWorkflowTemplate = CBPWorkflowTemplateLoader::GetList(
array('SORT' => 'ASC', 'NAME' => 'ASC'),
array(
"DOCUMENT_TYPE" => $documentType,
"ACTIVE" => "Y",
"IS_SYSTEM" => "N",
' CBPDocumentEventType::Automation
),
false,
false,
array("ID", "NAME", "DESCRIPTION", "PARAMETERS")
);
while ($arWorkflowTemplate = $dbWorkflowTemplate->fetch())
{
$parameters['WorkflowTemplateId'] = $arWorkflowTemplate['ID'];
if ($documentId)
{
if (!CBPDocument::CanUserOperateDocument($op, $userId, $documentId, $parameters))
{
continue;
}
}
elseif (!CBPDocument::CanUserOperateDocumentType($op, $userId, $documentType, $parameters))
{
continue;
}
$templates[] = array(
'id' => $arWorkflowTemplate['ID'],
'name' => $arWorkflowTemplate['NAME'],
'description' => $arWorkflowTemplate['DESCRIPTION'],
'hasParameters' => count($arWorkflowTemplate['PARAMETERS']) > 0,
'isConstantsTuned' => CBPWorkflowTemplateLoader::isConstantsTuned($arWorkflowTemplate["ID"])
);
}
return $templates;
}