function do_startWorkflow() { $oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']); if (!empty($_REQUEST['fWorkflowId'])) { $oWorkflow =& $this->oValidator->validateWorkflow($_REQUEST['fWorkflowId']); } else { $oWorkflow = null; } $res = KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument); if (PEAR::isError($res)) { $this->errorRedirectToMain($res->message, sprintf('fDocumentId=%s', $oDocument->getId())); } $this->successRedirectToMain(_kt('Workflow started'), array('fDocumentId' => $oDocument->getId())); exit(0); }
/** * This deletes the workflow on the document. * * @author KnowledgeTree Team * @access public * @return void|PEAR_Error Returns nothing on success | a PEAR_Error on failure */ function delete_workflow() { $user = $this->can_user_access_object_requiring_permission($this->document, KTAPI_PERMISSION_WORKFLOW); if (PEAR::isError($user)) { return $user; } $workflowid = $this->document->getWorkflowId(); if (empty($workflowid)) { return new PEAR_Error(KTAPI_ERROR_WORKFLOW_NOT_IN_PROGRESS); } DBUtil::startTransaction(); $result = KTWorkflowUtil::startWorkflowOnDocument(null, $this->document); if (is_null($result) || PEAR::isError($result)) { DBUtil::rollback(); return new KTAPI_Error(KTAPI_ERROR_WORKFLOW_INVALID, $result); } DBUtil::commit(); }
<?php require_once '../../config/dmsDefaults.php'; require_once KT_LIB_DIR . '/documentmanagement/Document.inc'; require_once KT_LIB_DIR . '/workflow/workflow.inc.php'; require_once KT_LIB_DIR . '/workflow/workflowutil.inc.php'; $oDocument =& Document::get(4); $oWorkflow =& KTWorkflow::get(1); $res = KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument); if (PEAR::isError($res)) { var_dump($res); }
function changeWorkflowOnDocument($oWorkflow, $oDocument) { $oDocument =& KTUtil::getObject('Document', $oDocument); // fix for 1049: workflows reset on document move. // this was the original purpose of "changeWorkflowOnDocument". if (is_null($oWorkflow)) { if ($oDocument->getWorkflowId() == null) { return true; // no definition. } } else { if ($oDocument->getWorkflowId() == $oWorkflow->getId()) { return true; // bail out, essentially. } } return KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument); }