Commit f30498f9ab63e2564eae787548bc1386d3dae257

Authored by Megan Watson
1 parent 680628a5

KTC-261

"The automatic workflow assignment by Document Type or by Folder does not work."
Fixed. Moved the check for which type was assigned into the run_setup() function. Added a deregister plugin helper function.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7818 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/plugins/plugin.inc.php
@@ -315,7 +315,7 @@ class KTPlugin { @@ -315,7 +315,7 @@ class KTPlugin {
315 */ 315 */
316 function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) { 316 function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) {
317 317
318 - $sql = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'"; 318 + $sql = "SELECT id FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'";
319 $res = DBUtil::getOneResult($sql); 319 $res = DBUtil::getOneResult($sql);
320 320
321 $aValues = array(); 321 $aValues = array();
@@ -345,6 +345,13 @@ class KTPlugin { @@ -345,6 +345,13 @@ class KTPlugin {
345 return true; 345 return true;
346 } 346 }
347 347
  348 + function deRegisterPluginHelper($sNamespace, $sClass) {
  349 + $aWhere['namespace'] = $sNamespace;
  350 + $aWhere['classtype'] = $sClass;
  351 + $res = DBUtil::whereDelete('plugin_helper', $aWhere);
  352 + return $res;
  353 + }
  354 +
348 function _fixFilename($sFilename) { 355 function _fixFilename($sFilename) {
349 if (empty($sFilename)) { 356 if (empty($sFilename)) {
350 $sFilename = $this->sFilename; 357 $sFilename = $this->sFilename;
@@ -391,13 +398,17 @@ class KTPlugin { @@ -391,13 +398,17 @@ class KTPlugin {
391 * 398 *
392 */ 399 */
393 function load() { 400 function load() {
  401 + // Include any required resources, javascript files, etc
  402 + $res = $this->run_setup();
  403 +
  404 + if(!$res){
  405 + return false;
  406 + }
  407 +
394 // Get actions, portlets, etc, create arrays as part of plugin 408 // Get actions, portlets, etc, create arrays as part of plugin
395 $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'"; 409 $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'";
396 $aPluginHelpers = DBUtil::getResultArray($query); 410 $aPluginHelpers = DBUtil::getResultArray($query);
397 411
398 - // Include any required resources, javascript files, etc  
399 - $this->run_setup();  
400 -  
401 if(!empty($aPluginHelpers)){ 412 if(!empty($aPluginHelpers)){
402 foreach ($aPluginHelpers as $plugin) { 413 foreach ($aPluginHelpers as $plugin) {
403 $sName = $plugin['namespace']; 414 $sName = $plugin['namespace'];
@@ -500,6 +511,7 @@ class KTPlugin { @@ -500,6 +511,7 @@ class KTPlugin {
500 } 511 }
501 } 512 }
502 } 513 }
  514 + return true;
503 } 515 }
504 516
505 /** 517 /**
@@ -636,7 +648,7 @@ class KTPlugin { @@ -636,7 +648,7 @@ class KTPlugin {
636 } 648 }
637 649
638 function run_setup() { 650 function run_setup() {
639 - return; 651 + return true;
640 } 652 }
641 653
642 function stripKtDir($sFilename) { 654 function stripKtDir($sFilename) {
plugins/ktstandard/workflow/FolderAssociator.php
@@ -5,32 +5,32 @@ @@ -5,32 +5,32 @@
5 * KnowledgeTree Open Source Edition 5 * KnowledgeTree Open Source Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8 - * 8 + *
9 * This program is free software; you can redistribute it and/or modify it under 9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 3 as published by the 10 * the terms of the GNU General Public License version 3 as published by the
11 * Free Software Foundation. 11 * Free Software Foundation.
12 - * 12 + *
13 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details. 16 * details.
17 - * 17 + *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 - * 20 + *
21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23 - * 23 + *
24 * The interactive user interfaces in modified source and object code versions 24 * The interactive user interfaces in modified source and object code versions
25 * of this program must display Appropriate Legal Notices, as required under 25 * of this program must display Appropriate Legal Notices, as required under
26 * Section 5 of the GNU General Public License version 3. 26 * Section 5 of the GNU General Public License version 3.
27 - * 27 + *
28 * In accordance with Section 7(b) of the GNU General Public License version 3, 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 * these Appropriate Legal Notices must retain the display of the "Powered by 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32 - * must display the words "Powered by KnowledgeTree" and retain the original  
33 - * copyright notice. 32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 * Contributor( s): ______________________________________ 34 * Contributor( s): ______________________________________
35 * 35 *
36 */ 36 */
@@ -54,7 +54,14 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { @@ -54,7 +54,14 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin {
54 function setup() { 54 function setup() {
55 $this->registerTrigger('workflow', 'objectModification', 'FolderWorkflowAssociator', 55 $this->registerTrigger('workflow', 'objectModification', 'FolderWorkflowAssociator',
56 'ktstandard.triggers.workflowassociation.folder.handler'); 56 'ktstandard.triggers.workflowassociation.folder.handler');
  57 + }
57 58
  59 + /**
  60 + * Method to setup the plugin on rendering it
  61 + *
  62 + * @return unknown
  63 + */
  64 + function run_setup() {
58 $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); 65 $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
59 $sQuery .= ' WHERE event_ns = ?'; 66 $sQuery .= ' WHERE event_ns = ?';
60 $aParams = array('ktstandard.workflowassociation.handler'); 67 $aParams = array('ktstandard.workflowassociation.handler');
@@ -63,8 +70,11 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { @@ -63,8 +70,11 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin {
63 if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { 70 if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') {
64 $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', 71 $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction',
65 'ktstandard.workflowassociation.folder.action'); 72 'ktstandard.workflowassociation.folder.action');
66 - } 73 + }else{
  74 + $this->deRegisterPluginHelper('ktstandard.workflowassociation.folder.action', 'action');
67 } 75 }
  76 + return true;
  77 + }
68 } 78 }
69 79
70 class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { 80 class FolderWorkflowAssociator extends KTWorkflowAssociationHandler {
plugins/ktstandard/workflow/TypeAssociator.php
@@ -5,32 +5,32 @@ @@ -5,32 +5,32 @@
5 * KnowledgeTree Open Source Edition 5 * KnowledgeTree Open Source Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited 7 * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited
8 - * 8 + *
9 * This program is free software; you can redistribute it and/or modify it under 9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 3 as published by the 10 * the terms of the GNU General Public License version 3 as published by the
11 * Free Software Foundation. 11 * Free Software Foundation.
12 - * 12 + *
13 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details. 16 * details.
17 - * 17 + *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 - * 20 + *
21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23 - * 23 + *
24 * The interactive user interfaces in modified source and object code versions 24 * The interactive user interfaces in modified source and object code versions
25 * of this program must display Appropriate Legal Notices, as required under 25 * of this program must display Appropriate Legal Notices, as required under
26 * Section 5 of the GNU General Public License version 3. 26 * Section 5 of the GNU General Public License version 3.
27 - * 27 + *
28 * In accordance with Section 7(b) of the GNU General Public License version 3, 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 * these Appropriate Legal Notices must retain the display of the "Powered by 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32 - * must display the words "Powered by KnowledgeTree" and retain the original  
33 - * copyright notice. 32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 * Contributor( s): ______________________________________ 34 * Contributor( s): ______________________________________
35 * 35 *
36 */ 36 */
@@ -50,19 +50,28 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { @@ -50,19 +50,28 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin {
50 function setup() { 50 function setup() {
51 $this->registerTrigger('workflow', 'objectModification', 'DocumentTypeWorkflowAssociator', 51 $this->registerTrigger('workflow', 'objectModification', 'DocumentTypeWorkflowAssociator',
52 'ktstandard.triggers.workflowassociation.documenttype.handler'); 52 'ktstandard.triggers.workflowassociation.documenttype.handler');
  53 + $this->registeri18n('knowledgeTree', KT_DIR . '/i18n');
  54 + }
53 55
  56 + /**
  57 + * Method to setup the plugin on rendering it
  58 + *
  59 + * @return unknown
  60 + */
  61 + function run_setup() {
54 $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); 62 $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
55 - $sQuery .= ' WHERE event_ns = ?';  
56 - $aParams = array('ktstandard.workflowassociation.handler');  
57 - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); 63 + $sQuery .= ' WHERE event_ns = ?';
  64 + $aParams = array('ktstandard.workflowassociation.handler');
  65 + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns');
58 66
59 if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { 67 if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') {
60 $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', 68 $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher',
61 'documents', _kt('Workflow Allocation by Document Types'), 69 'documents', _kt('Workflow Allocation by Document Types'),
62 _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__); 70 _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__);
63 - $this->registeri18n('knowledgeTree', KT_DIR . '/i18n'); 71 + }else{
  72 + $this->deRegisterPluginHelper('documents/workflow_type_allocation', 'admin_page');
64 } 73 }
65 - 74 + return true;
66 } 75 }
67 } 76 }
68 77
@@ -107,6 +116,15 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { @@ -107,6 +116,15 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher {
107 $res = parent::check(); 116 $res = parent::check();
108 if (!$res) { return false; } 117 if (!$res) { return false; }
109 118
  119 + $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection');
  120 + $sQuery .= ' WHERE event_ns = ?';
  121 + $aParams = array('ktstandard.workflowassociation.handler');
  122 + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns');
  123 +
  124 + if ($res != 'ktstandard.triggers.workflowassociation.documenttype.handler') {
  125 + return false;
  126 + }
  127 +
110 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); 128 $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types'));
111 129
112 return true; 130 return true;