Commit a8c5ce54fcc19ce26b57b5c2afe4dc0ab3c28226
1 parent
56951785
Merged in from DEV trunk...
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/STABLE/branches/3.4.6-Release-Branch@7902 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
56 additions
and
9 deletions
lib/plugins/plugin.inc.php
| @@ -307,7 +307,7 @@ class KTPlugin { | @@ -307,7 +307,7 @@ class KTPlugin { | ||
| 307 | */ | 307 | */ |
| 308 | function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) { | 308 | function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type) { |
| 309 | 309 | ||
| 310 | - $sql = "SELECT * FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'"; | 310 | + $sql = "SELECT id FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'"; |
| 311 | $res = DBUtil::getOneResult($sql); | 311 | $res = DBUtil::getOneResult($sql); |
| 312 | 312 | ||
| 313 | $aValues = array(); | 313 | $aValues = array(); |
| @@ -337,6 +337,13 @@ class KTPlugin { | @@ -337,6 +337,13 @@ class KTPlugin { | ||
| 337 | return true; | 337 | return true; |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | + function deRegisterPluginHelper($sNamespace, $sClass) { | ||
| 341 | + $aWhere['namespace'] = $sNamespace; | ||
| 342 | + $aWhere['classtype'] = $sClass; | ||
| 343 | + $res = DBUtil::whereDelete('plugin_helper', $aWhere); | ||
| 344 | + return $res; | ||
| 345 | + } | ||
| 346 | + | ||
| 340 | function _fixFilename($sFilename) { | 347 | function _fixFilename($sFilename) { |
| 341 | if (empty($sFilename)) { | 348 | if (empty($sFilename)) { |
| 342 | $sFilename = $this->sFilename; | 349 | $sFilename = $this->sFilename; |
| @@ -383,6 +390,13 @@ class KTPlugin { | @@ -383,6 +390,13 @@ class KTPlugin { | ||
| 383 | * | 390 | * |
| 384 | */ | 391 | */ |
| 385 | function load() { | 392 | function load() { |
| 393 | + // Include any required resources, javascript files, etc | ||
| 394 | + $res = $this->run_setup(); | ||
| 395 | + | ||
| 396 | + if(!$res){ | ||
| 397 | + return false; | ||
| 398 | + } | ||
| 399 | + | ||
| 386 | // Get actions, portlets, etc, create arrays as part of plugin | 400 | // Get actions, portlets, etc, create arrays as part of plugin |
| 387 | $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'"; | 401 | $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'"; |
| 388 | $aPluginHelpers = DBUtil::getResultArray($query); | 402 | $aPluginHelpers = DBUtil::getResultArray($query); |
| @@ -397,7 +411,7 @@ class KTPlugin { | @@ -397,7 +411,7 @@ class KTPlugin { | ||
| 397 | switch ($sClassType) { | 411 | switch ($sClassType) { |
| 398 | case 'portlet': | 412 | case 'portlet': |
| 399 | $aLocation = unserialize($aParams[0]); | 413 | $aLocation = unserialize($aParams[0]); |
| 400 | - if($aLocation !== false){ | 414 | + if($aLocation != false){ |
| 401 | $aParams[0] = $aLocation; | 415 | $aParams[0] = $aLocation; |
| 402 | } | 416 | } |
| 403 | 417 | ||
| @@ -470,7 +484,7 @@ class KTPlugin { | @@ -470,7 +484,7 @@ class KTPlugin { | ||
| 470 | 484 | ||
| 471 | case 'criterion': | 485 | case 'criterion': |
| 472 | $aInit = unserialize($aParams[3]); | 486 | $aInit = unserialize($aParams[3]); |
| 473 | - if($aInit !== false){ | 487 | + if($aInit != false){ |
| 474 | $aParams[3] = $aInit; | 488 | $aParams[3] = $aInit; |
| 475 | } | 489 | } |
| 476 | 490 | ||
| @@ -491,6 +505,7 @@ class KTPlugin { | @@ -491,6 +505,7 @@ class KTPlugin { | ||
| 491 | } | 505 | } |
| 492 | } | 506 | } |
| 493 | } | 507 | } |
| 508 | + return true; | ||
| 494 | } | 509 | } |
| 495 | 510 | ||
| 496 | /** | 511 | /** |
| @@ -626,6 +641,10 @@ class KTPlugin { | @@ -626,6 +641,10 @@ class KTPlugin { | ||
| 626 | return; | 641 | return; |
| 627 | } | 642 | } |
| 628 | 643 | ||
| 644 | + function run_setup() { | ||
| 645 | + return true; | ||
| 646 | + } | ||
| 647 | + | ||
| 629 | function stripKtDir($sFilename) { | 648 | function stripKtDir($sFilename) { |
| 630 | if (strpos($sFilename, KT_DIR) === 0 ||strpos($sFilename, realpath(KT_DIR)) === 0) { | 649 | if (strpos($sFilename, KT_DIR) === 0 ||strpos($sFilename, realpath(KT_DIR)) === 0) { |
| 631 | return substr($sFilename, strlen(KT_DIR) + 1); | 650 | return substr($sFilename, strlen(KT_DIR) + 1); |
plugins/ktstandard/workflow/FolderAssociator.php
| @@ -48,7 +48,14 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | @@ -48,7 +48,14 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | ||
| 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 | ||
| 53 | + /** | ||
| 54 | + * Method to setup the plugin on rendering it | ||
| 55 | + * | ||
| 56 | + * @return unknown | ||
| 57 | + */ | ||
| 58 | + function run_setup() { | ||
| 52 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); | 59 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); |
| 53 | $sQuery .= ' WHERE event_ns = ?'; | 60 | $sQuery .= ' WHERE event_ns = ?'; |
| 54 | $aParams = array('ktstandard.workflowassociation.handler'); | 61 | $aParams = array('ktstandard.workflowassociation.handler'); |
| @@ -57,8 +64,11 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | @@ -57,8 +64,11 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { | ||
| 57 | if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { | 64 | if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { |
| 58 | $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', | 65 | $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', |
| 59 | 'ktstandard.workflowassociation.folder.action'); | 66 | 'ktstandard.workflowassociation.folder.action'); |
| 60 | - } | 67 | + }else{ |
| 68 | + $this->deRegisterPluginHelper('ktstandard.workflowassociation.folder.action', 'action'); | ||
| 61 | } | 69 | } |
| 70 | + return true; | ||
| 71 | + } | ||
| 62 | } | 72 | } |
| 63 | 73 | ||
| 64 | class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { | 74 | class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { |
plugins/ktstandard/workflow/TypeAssociator.php
| @@ -44,19 +44,28 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { | @@ -44,19 +44,28 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { | ||
| 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 | + $this->registeri18n('knowledgeTree', KT_DIR . '/i18n'); | ||
| 48 | + } | ||
| 47 | 49 | ||
| 50 | + /** | ||
| 51 | + * Method to setup the plugin on rendering it | ||
| 52 | + * | ||
| 53 | + * @return unknown | ||
| 54 | + */ | ||
| 55 | + function run_setup() { | ||
| 48 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); | 56 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); |
| 49 | - $sQuery .= ' WHERE event_ns = ?'; | ||
| 50 | - $aParams = array('ktstandard.workflowassociation.handler'); | ||
| 51 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); | 57 | + $sQuery .= ' WHERE event_ns = ?'; |
| 58 | + $aParams = array('ktstandard.workflowassociation.handler'); | ||
| 59 | + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); | ||
| 52 | 60 | ||
| 53 | if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { | 61 | if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { |
| 54 | $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', | 62 | $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', |
| 55 | 'documents', _kt('Workflow Allocation by Document Types'), | 63 | 'documents', _kt('Workflow Allocation by Document Types'), |
| 56 | _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__); | 64 | _kt('This installation assigns workflows by Document Type. Configure this process here.'), __FILE__); |
| 57 | - $this->registeri18n('knowledgeTree', KT_DIR . '/i18n'); | 65 | + }else{ |
| 66 | + $this->deRegisterPluginHelper('documents/workflow_type_allocation', 'admin_page'); | ||
| 58 | } | 67 | } |
| 59 | - | 68 | + return true; |
| 60 | } | 69 | } |
| 61 | } | 70 | } |
| 62 | 71 | ||
| @@ -101,6 +110,15 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | @@ -101,6 +110,15 @@ class WorkflowTypeAllocationDispatcher extends KTAdminDispatcher { | ||
| 101 | $res = parent::check(); | 110 | $res = parent::check(); |
| 102 | if (!$res) { return false; } | 111 | if (!$res) { return false; } |
| 103 | 112 | ||
| 113 | + $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); | ||
| 114 | + $sQuery .= ' WHERE event_ns = ?'; | ||
| 115 | + $aParams = array('ktstandard.workflowassociation.handler'); | ||
| 116 | + $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'selection_ns'); | ||
| 117 | + | ||
| 118 | + if ($res != 'ktstandard.triggers.workflowassociation.documenttype.handler') { | ||
| 119 | + return false; | ||
| 120 | + } | ||
| 121 | + | ||
| 104 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); | 122 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); |
| 105 | 123 | ||
| 106 | return true; | 124 | return true; |