CBPViewHelper::getWorkflowTasks

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPViewHelper
  4. getWorkflowTasks
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/viewhelper.php
  • Класс: CBPViewHelper
  • Вызов: CBPViewHelper::getWorkflowTasks
static function getWorkflowTasks($workflowId, $withUsers = false, $extendUserInfo = false)
{
	$withUsers = $withUsers ? 1 : 0;
	$extendUserInfo = $extendUserInfo ? 1 : 0;

	if (!$workflowId)
	{
		return ['COMPLETED' => [], 'RUNNING' => []];
	}

	if (!isset(self::$cachedTasks[$workflowId][$withUsers][$extendUserInfo]))
	{
		$tasks = array('COMPLETED' => array(), 'RUNNING' => array());
		$ids = array();
		$taskIterator = CBPTaskService::GetList(
			array('MODIFIED' => 'DESC'),
			array('WORKFLOW_ID' => $workflowId),
			false,
			array('nTopCount' => 50),
			array('ID', 'MODIFIED', 'NAME', 'DESCRIPTION', 'PARAMETERS', 'STATUS', 'IS_INLINE', 'ACTIVITY')
		);
		while ($task = $taskIterator->getNext())
		{
			$key = $task['STATUS'] == CBPTaskStatus::Running ? 'RUNNING' : 'COMPLETED';
			$tasks[$key][] = $task;
			$ids[] = $task['ID'];
		}
		if ($withUsers && sizeof($ids))
		{
			$taskUsers = CBPTaskService::getTaskUsers($ids);
			self::joinUsersToTasks($tasks['COMPLETED'], $taskUsers, $extendUserInfo);
			$tasks['RUNNING_ALL_USERS'] = self::joinUsersToTasks($tasks['RUNNING'], $taskUsers, $extendUserInfo);
		}
		$tasks['COMPLETED_CNT'] = sizeof($tasks['COMPLETED']);
		$tasks['RUNNING_CNT'] = sizeof($tasks['RUNNING']);

		self::$cachedTasks[$workflowId][$withUsers][$extendUserInfo] = $tasks;
	}

	return self::$cachedTasks[$workflowId][$withUsers][$extendUserInfo];
}

Добавить комментарий