• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/workflowpersister.php
  • Класс: CBPWorkflowPersister
  • Вызов: CBPWorkflowPersister::retrieveWorkflow
private function retrieveWorkflow($instanceId, $silent = false)
{
	global $DB;

	$queryCondition = $this->getLockerQueryCondition();

	if (!$silent && !$this->lock($instanceId))
	{
		throw new Exception(GetMessage("BPCGWP_WF_LOCKED"), CBPRuntime::EXCEPTION_CODE_INSTANCE_LOCKED);
	}

	$dbResult = $DB->Query(
		"SELECT WORKFLOW, WORKFLOW_RO, IF (".$queryCondition.", 'Y', 'N') as UPDATEABLE ".
		"FROM b_bp_workflow_instance ".
		"WHERE ID = '".$DB->ForSql($instanceId)."' "
	);
	if ($arResult = $dbResult->Fetch())
	{
		if ($arResult["UPDATEABLE"] == "Y" && !$silent)
		{
			$DB->Query(
				"UPDATE b_bp_workflow_instance SET ".
				"	OWNER_ID = '".$DB->ForSql($this->serviceInstanceId)."', ".
				"	OWNED_UNTIL = ".$DB->CharToDateFunction(date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $this->GetOwnershipTimeout()))." ".
				"WHERE ID = '".$DB->ForSql($instanceId)."'"
			);
		}
		elseif (!$silent)
		{
			$this->unlock($instanceId);
			throw new Exception(GetMessage("BPCGWP_WF_LOCKED"), CBPRuntime::EXCEPTION_CODE_INSTANCE_LOCKED);
		}

		if (!$silent)
		{
			$this->unlock($instanceId);
		}

		return [$arResult["WORKFLOW"], $arResult["WORKFLOW_RO"]];
	}

	if (!$silent)
	{
		$this->unlock($instanceId);
	}

	throw new Exception(GetMessage("BPCGWP_INVALID_WF"), CBPRuntime::EXCEPTION_CODE_INSTANCE_NOT_FOUND);
}