documentWorkflow.php
2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
require_once("../../../../config/dmsDefaults.php");
require_once(KT_DIR . "/presentation/Html.inc");
require_once(KT_LIB_DIR . "/templating/templating.inc.php");
require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc");
$sectionName = "Manage Documents";
require_once(KT_DIR . "/presentation/webpageTemplate.inc");
require_once(KT_LIB_DIR . "/dispatcher.inc.php");
require_once(KT_LIB_DIR . "/validation/dispatchervalidation.inc.php");
require_once(KT_LIB_DIR . '/workflow/workflow.inc.php');
require_once(KT_LIB_DIR . '/workflow/workflowutil.inc.php');
class DocumentWorkflowDispatcher extends KTStandardDispatcher {
var $bAutomaticTransaction = true;
function do_main() {
$oTemplate =& $this->oValidator->validateTemplate("ktcore/workflow/documentWorkflow");
$oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
$oWorkflow = KTWorkflowUtil::getWorkflowForDocument($oDocument);
$oWorkflowState = KTWorkflowUtil::getWorkflowStateForDocument($oDocument);
$oUser =& User::get($_SESSION['userID']);
$aTransitions = KTWorkflowUtil::getTransitionsForDocumentUser($oDocument, $oUser);
$aWorkflows = KTWorkflow::getList();
$aTemplateData = array(
'oDocument' => $oDocument,
'oWorkflow' => $oWorkflow,
'oState' => $oWorkflowState,
'aTransitions' => $aTransitions,
'aWorkflows' => $aWorkflows,
);
return $oTemplate->render($aTemplateData);
}
function do_startWorkflow() {
$oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
$oWorkflow =& $this->oValidator->validateWorkflow($_REQUEST['fWorkflowId']);
$res = KTWorkflowUtil::startWorkflowOnDocument($oWorkflow, $oDocument);
$this->successRedirectToMain('Workflow started',
array('fDocumentId' => $oDocument->getId()));
exit(0);
}
function do_performTransition() {
$oDocument =& $this->oValidator->validateDocument($_REQUEST['fDocumentId']);
$oTransition =& $this->oValidator->validateWorkflowTransition($_REQUEST['fTransitionId']);
$sComments =& $this->oValidator->notEmpty($_REQUEST['fComments']);
$oUser =& User::get($_SESSION['userID']);
$res = KTWorkflowUtil::performTransitionOnDocument($oTransition, $oDocument, $oUser, $sComments);
$this->successRedirectToMain('Transition performed',
array('fDocumentId' => $oDocument->getId()));
}
}
$oDispatcher = new DocumentWorkflowDispatcher;
$oDispatcher->dispatch();
?>