CBPAllWorkflowPersister::UnlockWorkflow: Bitrix method

      
<?php 
//  CBPAllWorkflowPersister :: UnlockWorkflow()
//  /dist/bitrix/modules/bizproc/classes/general/workflowpersister.php:218

    
public function UnlockWorkflow(CBPActivity $rootActivity)
    {
        global 
$DB;

        if (
$rootActivity == null)
            throw new 
Exception("rootActivity");

        
$DB->Query(
            
"UPDATE b_bp_workflow_instance SET ".
            
"    OWNER_ID = NULL, ".
            
"    OWNED_UNTIL = NULL ".
            
"WHERE ID = '".$DB->ForSql($rootActivity->GetWorkflowInstanceId())."' ".
            
"    AND ( ".
            
"        (OWNER_ID = '".$DB->ForSql($this->serviceInstanceId)."' ".
            
"            AND OWNED_UNTIL >= ".$DB->CurrentTimeFunction().") ".
            
"        OR ".
            
"        (OWNER_ID IS NULL) ".
            
"        OR ".
            
"        (OWNER_ID IS NOT NULL ".
            
"            AND OWNED_UNTIL < ".$DB->CurrentTimeFunction().") ".
            
"    )"
        
);
    }