Commit 8033ac4c809789071a858612bc805d04fef140c3
1 parent
41171017
Merged in from DEV trunk...
BBS-1011 "Auto Workflow Assignment: When a document is move from within KTE to the assigned linked folder the correct worklfow is not initiated." Fixed. The moveTrigger was not catered for. Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@7061 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
65 additions
and
57 deletions
plugins/ktstandard/workflow/FolderAssociator.php
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 7 | * compliance with the License. You may obtain a copy of the License at | 7 | * compliance with the License. You may obtain a copy of the License at |
| 8 | * http://www.knowledgetree.com/KPL | 8 | * http://www.knowledgetree.com/KPL |
| 9 | - * | 9 | + * |
| 10 | * Software distributed under the License is distributed on an "AS IS" | 10 | * Software distributed under the License is distributed on an "AS IS" |
| 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing rights and | 12 | * See the License for the specific language governing rights and |
| @@ -17,9 +17,9 @@ | @@ -17,9 +17,9 @@ | ||
| 17 | * (ii) the KnowledgeTree copyright notice | 17 | * (ii) the KnowledgeTree copyright notice |
| 18 | * in the same form as they appear in the distribution. See the License for | 18 | * in the same form as they appear in the distribution. See the License for |
| 19 | * requirements. | 19 | * requirements. |
| 20 | - * | 20 | + * |
| 21 | * The Original Code is: KnowledgeTree Open Source | 21 | * The Original Code is: KnowledgeTree Open Source |
| 22 | - * | 22 | + * |
| 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software | 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 24 | * (Pty) Ltd, trading as KnowledgeTree. | 24 | * (Pty) Ltd, trading as KnowledgeTree. |
| 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| @@ -38,22 +38,22 @@ require_once(KT_LIB_DIR . '/actions/folderaction.inc.php'); | @@ -38,22 +38,22 @@ require_once(KT_LIB_DIR . '/actions/folderaction.inc.php'); | ||
| 38 | 38 | ||
| 39 | class KTFolderWorkflowAssociationPlugin extends KTPlugin { | 39 | class KTFolderWorkflowAssociationPlugin extends KTPlugin { |
| 40 | var $sNamespace = "ktstandard.workflowassociation.folder.plugin"; | 40 | var $sNamespace = "ktstandard.workflowassociation.folder.plugin"; |
| 41 | - | 41 | + |
| 42 | function KTFolderWorkflowAssociationPlugin($sFilename = null) { | 42 | function KTFolderWorkflowAssociationPlugin($sFilename = null) { |
| 43 | $res = parent::KTPlugin($sFilename); | 43 | $res = parent::KTPlugin($sFilename); |
| 44 | $this->sFriendlyName = _kt('Workflow allocation by location'); | 44 | $this->sFriendlyName = _kt('Workflow allocation by location'); |
| 45 | return $res; | 45 | return $res; |
| 46 | - } | 46 | + } |
| 47 | 47 | ||
| 48 | function setup() { | 48 | function setup() { |
| 49 | $this->registerTrigger('workflow', 'objectModification', 'FolderWorkflowAssociator', | 49 | $this->registerTrigger('workflow', 'objectModification', 'FolderWorkflowAssociator', |
| 50 | 'ktstandard.triggers.workflowassociation.folder.handler'); | 50 | 'ktstandard.triggers.workflowassociation.folder.handler'); |
| 51 | - | 51 | + |
| 52 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); | 52 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); |
| 53 | $sQuery .= ' WHERE event_ns = ?'; | 53 | $sQuery .= ' WHERE event_ns = ?'; |
| 54 | $aParams = array('ktstandard.workflowassociation.handler'); | 54 | $aParams = array('ktstandard.workflowassociation.handler'); |
| 55 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); | 55 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); |
| 56 | - | 56 | + |
| 57 | if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { | 57 | if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { |
| 58 | $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', | 58 | $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', |
| 59 | 'ktstandard.workflowassociation.folder.action'); | 59 | 'ktstandard.workflowassociation.folder.action'); |
| @@ -62,23 +62,27 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | @@ -62,23 +62,27 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | ||
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { | 64 | class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { |
| 65 | - function addTrigger($oDocument) { | ||
| 66 | - return $this->getWorkflowForDoc($oDocument); | 65 | + function addTrigger($oDocument) { |
| 66 | + return $this->getWorkflowForDoc($oDocument); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + function editTrigger($oDocument) { | ||
| 70 | + return $this->getWorkflowForDoc($oDocument); | ||
| 67 | } | 71 | } |
| 68 | - | ||
| 69 | - function editTrigger($oDocument) { | ||
| 70 | - return $this->getWorkflowForDoc($oDocument); | 72 | + |
| 73 | + function moveTrigger($oDocument) { | ||
| 74 | + return $this->getWorkflowForDoc($oDocument); | ||
| 71 | } | 75 | } |
| 72 | - | 76 | + |
| 73 | function getWorkflowForDoc($oDocument) { | 77 | function getWorkflowForDoc($oDocument) { |
| 74 | - | 78 | + |
| 75 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map'); | 79 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map'); |
| 76 | $sQuery .= ' WHERE `folder_id` = ?'; | 80 | $sQuery .= ' WHERE `folder_id` = ?'; |
| 77 | $aParams = array($oDocument->getFolderID()); | 81 | $aParams = array($oDocument->getFolderID()); |
| 78 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id'); | 82 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id'); |
| 79 | - | ||
| 80 | - | ||
| 81 | - if (PEAR::isError($res) || (is_null($res))) { | 83 | + |
| 84 | + | ||
| 85 | + if (PEAR::isError($res) || (is_null($res))) { | ||
| 82 | return KTWorkflowUtil::getWorkflowForDocument($oDocument); // don't remove if moved out. | 86 | return KTWorkflowUtil::getWorkflowForDocument($oDocument); // don't remove if moved out. |
| 83 | } | 87 | } |
| 84 | return KTWorkflow::get($res); | 88 | return KTWorkflow::get($res); |
| @@ -99,15 +103,15 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | @@ -99,15 +103,15 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | ||
| 99 | $this->oPage->setTitle(_kt("Configure Workflows for Folder")); | 103 | $this->oPage->setTitle(_kt("Configure Workflows for Folder")); |
| 100 | $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/folderconfigure'); | 104 | $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/folderconfigure'); |
| 101 | $fields = array(); | 105 | $fields = array(); |
| 102 | - | 106 | + |
| 103 | $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1'); | 107 | $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1'); |
| 104 | $aVocab = array(); | 108 | $aVocab = array(); |
| 105 | $aVocab[] = _kt('No automatic workflow.'); | 109 | $aVocab[] = _kt('No automatic workflow.'); |
| 106 | foreach ($aWorkflows as $oWorkflow) { | 110 | foreach ($aWorkflows as $oWorkflow) { |
| 107 | - $aVocab[$oWorkflow->getId()] = $oWorkflow->getName(); | 111 | + $aVocab[$oWorkflow->getId()] = $oWorkflow->getName(); |
| 108 | } | 112 | } |
| 109 | $fieldOptions = array("vocab" => $aVocab); | 113 | $fieldOptions = array("vocab" => $aVocab); |
| 110 | - | 114 | + |
| 111 | // grab the value. | 115 | // grab the value. |
| 112 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map'); | 116 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('folder_workflow_map'); |
| 113 | $sQuery .= ' WHERE `folder_id` = ?'; | 117 | $sQuery .= ' WHERE `folder_id` = ?'; |
| @@ -117,8 +121,8 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | @@ -117,8 +121,8 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | ||
| 117 | $res = null; | 121 | $res = null; |
| 118 | } | 122 | } |
| 119 | $fields[] = new KTLookupWidget(_kt('Automatic Workflow'), _kt('If you specify an automatic workflow, new documents will automatically enter that workflow\'s starting state. Setting this to "No Automatic Workflow" will mean that users can choose the appropriate workflow.'), 'fWorkflowId', $res, $this->oPage, true, null, $fieldErrors, $fieldOptions); | 123 | $fields[] = new KTLookupWidget(_kt('Automatic Workflow'), _kt('If you specify an automatic workflow, new documents will automatically enter that workflow\'s starting state. Setting this to "No Automatic Workflow" will mean that users can choose the appropriate workflow.'), 'fWorkflowId', $res, $this->oPage, true, null, $fieldErrors, $fieldOptions); |
| 120 | - | ||
| 121 | - | 124 | + |
| 125 | + | ||
| 122 | $oTemplate->setData(array( | 126 | $oTemplate->setData(array( |
| 123 | 'context' => &$this, | 127 | 'context' => &$this, |
| 124 | 'folder_id' => $this->oFolder->getId(), | 128 | 'folder_id' => $this->oFolder->getId(), |
| @@ -129,17 +133,17 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | @@ -129,17 +133,17 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | ||
| 129 | 133 | ||
| 130 | function do_allocate() { | 134 | function do_allocate() { |
| 131 | $fWorkflowId = KTUtil::arrayGet($_REQUEST, 'fWorkflowId', null); | 135 | $fWorkflowId = KTUtil::arrayGet($_REQUEST, 'fWorkflowId', null); |
| 132 | - | 136 | + |
| 133 | $this->startTransaction(); | 137 | $this->startTransaction(); |
| 134 | - | 138 | + |
| 135 | $sQuery = 'DELETE FROM ' . KTUtil::getTableName('folder_workflow_map') . ' WHERE folder_id = ?'; | 139 | $sQuery = 'DELETE FROM ' . KTUtil::getTableName('folder_workflow_map') . ' WHERE folder_id = ?'; |
| 136 | $aParams = array($this->oFolder->getId()); | 140 | $aParams = array($this->oFolder->getId()); |
| 137 | DBUtil::runQuery(array($sQuery, $aParams)); | 141 | DBUtil::runQuery(array($sQuery, $aParams)); |
| 138 | - | 142 | + |
| 139 | if (is_null($fWorkflowId)) { | 143 | if (is_null($fWorkflowId)) { |
| 140 | $this->successRedirectToMain(_kt('Workflow assignment removed.'), 'fFolderId='.$this->oFolder->getId()); | 144 | $this->successRedirectToMain(_kt('Workflow assignment removed.'), 'fFolderId='.$this->oFolder->getId()); |
| 141 | } | 145 | } |
| 142 | - | 146 | + |
| 143 | $aOptions = array('noid' => true); | 147 | $aOptions = array('noid' => true); |
| 144 | $sTable = KTUtil::getTableName('folder_workflow_map'); | 148 | $sTable = KTUtil::getTableName('folder_workflow_map'); |
| 145 | if ($fWorkflowId == null) { $fWorkflowId = null; } | 149 | if ($fWorkflowId == null) { $fWorkflowId = null; } |
| @@ -147,11 +151,11 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | @@ -147,11 +151,11 @@ class FolderWorkflowAssignmentFolderAction extends KTFolderAction { | ||
| 147 | 'folder_id' => $this->oFolder->getId(), | 151 | 'folder_id' => $this->oFolder->getId(), |
| 148 | 'workflow_id' => $fWorkflowId, | 152 | 'workflow_id' => $fWorkflowId, |
| 149 | ), $aOptions); | 153 | ), $aOptions); |
| 150 | - | 154 | + |
| 151 | if (PEAR::isError($res)) { | 155 | if (PEAR::isError($res)) { |
| 152 | $this->errorRedirectToMain(_kt('Error assigning workflow.'), 'fFolderId='.$this->oFolder->getId()); | 156 | $this->errorRedirectToMain(_kt('Error assigning workflow.'), 'fFolderId='.$this->oFolder->getId()); |
| 153 | } | 157 | } |
| 154 | - | 158 | + |
| 155 | $this->successRedirectToMain(_kt('Workflow assignment updated.'), 'fFolderId='.$this->oFolder->getId()); | 159 | $this->successRedirectToMain(_kt('Workflow assignment updated.'), 'fFolderId='.$this->oFolder->getId()); |
| 156 | } | 160 | } |
| 157 | 161 |
plugins/ktstandard/workflow/TypeAssociator.php
| @@ -6,7 +6,7 @@ | @@ -6,7 +6,7 @@ | ||
| 6 | * License Version 1.1.2 ("License"); You may not use this file except in | 6 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 7 | * compliance with the License. You may obtain a copy of the License at | 7 | * compliance with the License. You may obtain a copy of the License at |
| 8 | * http://www.knowledgetree.com/KPL | 8 | * http://www.knowledgetree.com/KPL |
| 9 | - * | 9 | + * |
| 10 | * Software distributed under the License is distributed on an "AS IS" | 10 | * Software distributed under the License is distributed on an "AS IS" |
| 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | 11 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing rights and | 12 | * See the License for the specific language governing rights and |
| @@ -17,9 +17,9 @@ | @@ -17,9 +17,9 @@ | ||
| 17 | * (ii) the KnowledgeTree copyright notice | 17 | * (ii) the KnowledgeTree copyright notice |
| 18 | * in the same form as they appear in the distribution. See the License for | 18 | * in the same form as they appear in the distribution. See the License for |
| 19 | * requirements. | 19 | * requirements. |
| 20 | - * | 20 | + * |
| 21 | * The Original Code is: KnowledgeTree Open Source | 21 | * The Original Code is: KnowledgeTree Open Source |
| 22 | - * | 22 | + * |
| 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software | 23 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 24 | * (Pty) Ltd, trading as KnowledgeTree. | 24 | * (Pty) Ltd, trading as KnowledgeTree. |
| 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright | 25 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| @@ -39,45 +39,49 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { | @@ -39,45 +39,49 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { | ||
| 39 | $res = parent::KTPlugin($sFilename); | 39 | $res = parent::KTPlugin($sFilename); |
| 40 | $this->sFriendlyName = _kt('Workflow allocation by document type'); | 40 | $this->sFriendlyName = _kt('Workflow allocation by document type'); |
| 41 | return $res; | 41 | return $res; |
| 42 | - } | 42 | + } |
| 43 | 43 | ||
| 44 | function setup() { | 44 | function setup() { |
| 45 | $this->registerTrigger('workflow', 'objectModification', 'DocumentTypeWorkflowAssociator', | 45 | $this->registerTrigger('workflow', 'objectModification', 'DocumentTypeWorkflowAssociator', |
| 46 | 'ktstandard.triggers.workflowassociation.documenttype.handler'); | 46 | 'ktstandard.triggers.workflowassociation.documenttype.handler'); |
| 47 | - | 47 | + |
| 48 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); | 48 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); |
| 49 | $sQuery .= ' WHERE event_ns = ?'; | 49 | $sQuery .= ' WHERE event_ns = ?'; |
| 50 | $aParams = array('ktstandard.workflowassociation.handler'); | 50 | $aParams = array('ktstandard.workflowassociation.handler'); |
| 51 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); | 51 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); |
| 52 | - | 52 | + |
| 53 | if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { | 53 | if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { |
| 54 | - $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', | ||
| 55 | - 'documents', _kt('Workflow Allocation by Document Types'), | ||
| 56 | - _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__); | 54 | + $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', |
| 55 | + 'documents', _kt('Workflow Allocation by Document Types'), | ||
| 56 | + _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__); | ||
| 57 | $this->registeri18n('knowledgeTree', KT_DIR . '/i18n'); | 57 | $this->registeri18n('knowledgeTree', KT_DIR . '/i18n'); |
| 58 | } | 58 | } |
| 59 | - | 59 | + |
| 60 | } | 60 | } |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | class DocumentTypeWorkflowAssociator extends KTWorkflowAssociationHandler { | 63 | class DocumentTypeWorkflowAssociator extends KTWorkflowAssociationHandler { |
| 64 | - function addTrigger($oDocument) { | ||
| 65 | - return $oW = $this->getWorkflowForType($oDocument->getDocumentTypeID(), $oDocument); | 64 | + function addTrigger($oDocument) { |
| 65 | + return $this->getWorkflowForType($oDocument->getDocumentTypeID(), $oDocument); | ||
| 66 | } | 66 | } |
| 67 | - | ||
| 68 | - function editTrigger($oDocument) { | ||
| 69 | - return $oW = $this->getWorkflowForType($oDocument->getDocumentTypeID(), $oDocument); | 67 | + |
| 68 | + function editTrigger($oDocument) { | ||
| 69 | + return $this->getWorkflowForType($oDocument->getDocumentTypeID(), $oDocument); | ||
| 70 | } | 70 | } |
| 71 | - | 71 | + |
| 72 | + function moveTrigger($oDocument) { | ||
| 73 | + return $this->getWorkflowForType($oDocument->getDocumentTypeID(), $oDocument); | ||
| 74 | + } | ||
| 75 | + | ||
| 72 | function getWorkflowForType($iDocTypeId, $oDocument) { | 76 | function getWorkflowForType($iDocTypeId, $oDocument) { |
| 73 | if (is_null($iDocTypeId)) { return null; } | 77 | if (is_null($iDocTypeId)) { return null; } |
| 74 | - | 78 | + |
| 75 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('type_workflow_map'); | 79 | $sQuery = 'SELECT `workflow_id` FROM ' . KTUtil::getTableName('type_workflow_map'); |
| 76 | $sQuery .= ' WHERE `document_type_id` = ?'; | 80 | $sQuery .= ' WHERE `document_type_id` = ?'; |
| 77 | $aParams = array($iDocTypeId); | 81 | $aParams = array($iDocTypeId); |
| 78 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id'); | 82 | $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'workflow_id'); |
| 79 | 83 | ||
| 80 | - if (PEAR::isError($res) || (is_null($res))) { | 84 | + if (PEAR::isError($res) || (is_null($res))) { |
| 81 | return KTWorkflowUtil::getWorkflowForDocument($oDocument); // don't remove if type changed out. | 85 | return KTWorkflowUtil::getWorkflowForDocument($oDocument); // don't remove if type changed out. |
| 82 | } | 86 | } |
| 83 | return KTWorkflow::get($res); | 87 | return KTWorkflow::get($res); |
| @@ -91,19 +95,19 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | @@ -91,19 +95,19 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | ||
| 91 | function check() { | 95 | function check() { |
| 92 | $res = parent::check(); | 96 | $res = parent::check(); |
| 93 | if (!$res) { return false; } | 97 | if (!$res) { return false; } |
| 94 | - | 98 | + |
| 95 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); | 99 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); |
| 96 | - | 100 | + |
| 97 | return true; | 101 | return true; |
| 98 | } | 102 | } |
| 99 | 103 | ||
| 100 | - function do_main() { | 104 | + function do_main() { |
| 101 | $sQuery = 'SELECT document_type_id, workflow_id FROM ' . KTUtil::getTableName('type_workflow_map'); | 105 | $sQuery = 'SELECT document_type_id, workflow_id FROM ' . KTUtil::getTableName('type_workflow_map'); |
| 102 | $aParams = array(); | 106 | $aParams = array(); |
| 103 | $res = DBUtil::getResultArray(array($sQuery, $aParams)); | 107 | $res = DBUtil::getResultArray(array($sQuery, $aParams)); |
| 104 | $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1'); | 108 | $aWorkflows = KTWorkflow::getList('start_state_id IS NOT NULL AND enabled = 1'); |
| 105 | $aTypes = DocumentType::getList(); | 109 | $aTypes = DocumentType::getList(); |
| 106 | - | 110 | + |
| 107 | $aTypeMapping = array(); | 111 | $aTypeMapping = array(); |
| 108 | if (PEAR::isError($res)) { | 112 | if (PEAR::isError($res)) { |
| 109 | $this->oPage->addError(_kt('Failed to get type mapping: ') . $res->getMessage()); | 113 | $this->oPage->addError(_kt('Failed to get type mapping: ') . $res->getMessage()); |
| @@ -112,7 +116,7 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | @@ -112,7 +116,7 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | ||
| 112 | $aTypeMapping[$aRow['document_type_id']] = $aRow['workflow_id']; | 116 | $aTypeMapping[$aRow['document_type_id']] = $aRow['workflow_id']; |
| 113 | } | 117 | } |
| 114 | } | 118 | } |
| 115 | - | 119 | + |
| 116 | $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/type_allocation'); | 120 | $oTemplate =& $this->oValidator->validateTemplate('ktstandard/workflow/type_allocation'); |
| 117 | $oTemplate->setData(array( | 121 | $oTemplate->setData(array( |
| 118 | 'context' => $this, | 122 | 'context' => $this, |
| @@ -122,24 +126,24 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | @@ -122,24 +126,24 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | ||
| 122 | )); | 126 | )); |
| 123 | return $oTemplate->render(); | 127 | return $oTemplate->render(); |
| 124 | } | 128 | } |
| 125 | - | 129 | + |
| 126 | function isActiveWorkflow($oType, $oWorkflow, $types_mapping) { | 130 | function isActiveWorkflow($oType, $oWorkflow, $types_mapping) { |
| 127 | if (!array_key_exists($oType->getId(), $types_mapping)) { return false; } | 131 | if (!array_key_exists($oType->getId(), $types_mapping)) { return false; } |
| 128 | else { | 132 | else { |
| 129 | return $types_mapping[$oType->getId()] == $oWorkflow->getId(); | 133 | return $types_mapping[$oType->getId()] == $oWorkflow->getId(); |
| 130 | } | 134 | } |
| 131 | } | 135 | } |
| 132 | - | 136 | + |
| 133 | function do_update() { | 137 | function do_update() { |
| 134 | $types_mapping = (array) KTUtil::arrayGet($_REQUEST, 'fDocumentTypeAssignment'); | 138 | $types_mapping = (array) KTUtil::arrayGet($_REQUEST, 'fDocumentTypeAssignment'); |
| 135 | - | 139 | + |
| 136 | $aWorkflows = KTWorkflow::getList(); | 140 | $aWorkflows = KTWorkflow::getList(); |
| 137 | $aTypes = DocumentType::getList(); | 141 | $aTypes = DocumentType::getList(); |
| 138 | - | 142 | + |
| 139 | $sQuery = 'DELETE FROM ' . KTUtil::getTableName('type_workflow_map'); | 143 | $sQuery = 'DELETE FROM ' . KTUtil::getTableName('type_workflow_map'); |
| 140 | $aParams = array(); | 144 | $aParams = array(); |
| 141 | DBUtil::runQuery(array($sQuery, $aParams)); | 145 | DBUtil::runQuery(array($sQuery, $aParams)); |
| 142 | - | 146 | + |
| 143 | $aOptions = array('noid' => true); | 147 | $aOptions = array('noid' => true); |
| 144 | $sTable = KTUtil::getTableName('type_workflow_map'); | 148 | $sTable = KTUtil::getTableName('type_workflow_map'); |
| 145 | foreach ($aTypes as $oType) { | 149 | foreach ($aTypes as $oType) { |
| @@ -150,7 +154,7 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | @@ -150,7 +154,7 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | ||
| 150 | 'workflow_id' => $t, | 154 | 'workflow_id' => $t, |
| 151 | ), $aOptions); | 155 | ), $aOptions); |
| 152 | } | 156 | } |
| 153 | - | 157 | + |
| 154 | $this->successRedirectToMain(_kt('Type mapping updated.')); | 158 | $this->successRedirectToMain(_kt('Type mapping updated.')); |
| 155 | } | 159 | } |
| 156 | } | 160 | } |