/** * Gets which workflow transitions are available to be chosen from * this workflow state. * * Workflow transitions have only destination workflow states, and * it is up to the workflow state to decide which workflow * transitions it wants to allow to leave its state. * * This function optionally will return the database id numbers of * the workflow transitions using the 'ids' option. */ function getTransitionsFrom($oState, $aOptions = null) { $bIds = KTUtil::arrayGet($aOptions, 'ids'); $sTable = KTUtil::getTableName('workflow_state_transitions'); $aQuery = array("SELECT transition_id FROM {$sTable} WHERE state_id = ?", array($oState->getId())); $aTransitionIds = DBUtil::getResultArrayKey($aQuery, 'transition_id'); if (PEAR::isError($aTransitionIds)) { return $aTransitionIds; } if ($bIds) { return $aTransitionIds; } $aRet = array(); foreach ($aTransitionIds as $iId) { $aRet[] =& KTWorkflowTransition::get($iId); } return $aRet; }
function do_performquicktransition() { $oForm = $this->form_quicktransition(); $res = $oForm->validate(); if (!empty($res['errors'])) { return $oForm->handleError(); } $this->startTransaction(); $data = $res['results']; $oTransition = KTWorkflowTransition::get($_REQUEST['fTransitionId']); $res = KTWorkflowUtil::performTransitionOnDocument($oTransition, $this->oDocument, $this->oUser, $data['reason']); if (!Permission::userHasDocumentReadPermission($this->oDocument)) { $this->commitTransaction(); $_SESSION['KTInfoMessage'][] = _kt('Transition performed') . '. ' . _kt('You no longer have permission to view this document'); controllerRedirect('browse', sprintf('fFolderId=%d', $this->oDocument->getFolderId())); } else { $this->commitTransaction(); $_SESSION['KTInfoMessage'][] = _kt('Transition performed'); controllerRedirect('viewDocument', sprintf('fDocumentId=%d', $this->oDocument->getId())); } }
function predispatch() { $this->persistParams(array('fWorkflowId', 'fStateId', 'fTransitionId')); $iWorkflowId = KTUtil::arrayGet($_REQUEST, 'fWorkflowId'); $iStateId = KTUtil::arrayGet($_REQUEST, 'fStateId'); $iTransitionId = KTUtil::arrayGet($_REQUEST, 'fTransitionId'); if (!is_null($iWorkflowId)) { $oWorkflow =& KTWorkflow::get($iWorkflowId); if (!PEAR::isError($oWorkflow)) { $this->oWorkflow =& $oWorkflow; } } if (!is_null($iStateId)) { $oState =& KTWorkflowState::get($iStateId); if (!PEAR::isError($oState)) { $this->oState =& $oState; } } if (!is_null($iTransitionId)) { $oTransition =& KTWorkflowTransition::get($iTransitionId); if (!PEAR::isError($oTransition)) { $this->oTransition =& $oTransition; } } $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Workflows')); if (!is_null($this->oWorkflow)) { $this->oPage->addPortlet(new WorkflowNavigationPortlet(_kt("Workflow Administration"), $this->oWorkflow)); $this->aBreadcrumbs[] = array('url' => KTUtil::addQueryStringSelf(sprintf('action=view&fWorkflowId=%d', $iWorkflowId)), 'name' => $this->oWorkflow->getName()); } $this->HAVE_GRAPHVIZ = false; /* $dotCommand = KTUtil::findCommand("ui/dot", 'dot'); if (!empty($dotCommand)) { $this->HAVE_GRAPHVIZ = true; $this->dotCommand = $dotCommand; } */ }