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 | 307 | */ |
| 308 | 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 | 311 | $res = DBUtil::getOneResult($sql); |
| 312 | 312 | |
| 313 | 313 | $aValues = array(); |
| ... | ... | @@ -337,6 +337,13 @@ class KTPlugin { |
| 337 | 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 | 347 | function _fixFilename($sFilename) { |
| 341 | 348 | if (empty($sFilename)) { |
| 342 | 349 | $sFilename = $this->sFilename; |
| ... | ... | @@ -383,6 +390,13 @@ class KTPlugin { |
| 383 | 390 | * |
| 384 | 391 | */ |
| 385 | 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 | 400 | // Get actions, portlets, etc, create arrays as part of plugin |
| 387 | 401 | $query = "SELECT * FROM plugin_helper h WHERE plugin = '{$this->sNamespace}'"; |
| 388 | 402 | $aPluginHelpers = DBUtil::getResultArray($query); |
| ... | ... | @@ -397,7 +411,7 @@ class KTPlugin { |
| 397 | 411 | switch ($sClassType) { |
| 398 | 412 | case 'portlet': |
| 399 | 413 | $aLocation = unserialize($aParams[0]); |
| 400 | - if($aLocation !== false){ | |
| 414 | + if($aLocation != false){ | |
| 401 | 415 | $aParams[0] = $aLocation; |
| 402 | 416 | } |
| 403 | 417 | |
| ... | ... | @@ -470,7 +484,7 @@ class KTPlugin { |
| 470 | 484 | |
| 471 | 485 | case 'criterion': |
| 472 | 486 | $aInit = unserialize($aParams[3]); |
| 473 | - if($aInit !== false){ | |
| 487 | + if($aInit != false){ | |
| 474 | 488 | $aParams[3] = $aInit; |
| 475 | 489 | } |
| 476 | 490 | |
| ... | ... | @@ -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 | 641 | return; |
| 627 | 642 | } |
| 628 | 643 | |
| 644 | + function run_setup() { | |
| 645 | + return true; | |
| 646 | + } | |
| 647 | + | |
| 629 | 648 | function stripKtDir($sFilename) { |
| 630 | 649 | if (strpos($sFilename, KT_DIR) === 0 ||strpos($sFilename, realpath(KT_DIR)) === 0) { |
| 631 | 650 | return substr($sFilename, strlen(KT_DIR) + 1); | ... | ... |
plugins/ktstandard/workflow/FolderAssociator.php
| ... | ... | @@ -48,7 +48,14 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { |
| 48 | 48 | function setup() { |
| 49 | 49 | $this->registerTrigger('workflow', 'objectModification', 'FolderWorkflowAssociator', |
| 50 | 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 | 59 | $sQuery = 'SELECT selection_ns FROM ' . KTUtil::getTableName('trigger_selection'); |
| 53 | 60 | $sQuery .= ' WHERE event_ns = ?'; |
| 54 | 61 | $aParams = array('ktstandard.workflowassociation.handler'); |
| ... | ... | @@ -57,8 +64,11 @@ class KTFolderWorkflowAssociationPlugin extends KTPlugin { |
| 57 | 64 | if ($res == 'ktstandard.triggers.workflowassociation.folder.handler') { |
| 58 | 65 | $this->registerAction('folderaction', 'FolderWorkflowAssignmentFolderAction', |
| 59 | 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 | 74 | class FolderWorkflowAssociator extends KTWorkflowAssociationHandler { | ... | ... |
plugins/ktstandard/workflow/TypeAssociator.php
| ... | ... | @@ -44,19 +44,28 @@ class KTDocTypeWorkflowAssociationPlugin extends KTPlugin { |
| 44 | 44 | function setup() { |
| 45 | 45 | $this->registerTrigger('workflow', 'objectModification', 'DocumentTypeWorkflowAssociator', |
| 46 | 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 | 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 | 61 | if ($res == 'ktstandard.triggers.workflowassociation.documenttype.handler') { |
| 54 | 62 | $this->registerAdminPage('workflow_type_allocation', 'WorkflowTypeAllocationDispatcher', |
| 55 | 63 | 'documents', _kt('Workflow Allocation by Document Types'), |
| 56 | 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 | 110 | $res = parent::check(); |
| 102 | 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 | 122 | $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name'=> _kt('Workflow Allocation by Document Types')); |
| 105 | 123 | |
| 106 | 124 | return true; | ... | ... |