Commit 99ca470546a95aae12af75357aa548ba67180bd4

Authored by Megan
1 parent cb3e2915

Fixes to allow commercial plugins to be placed in their own folder. Added functi…

…on to get the full path to a plugin. Used it in all places where the path is hardcoded.

Committed by: Megan Watson
Reviewed by: Kevin Cyster
config/dmsDefaults.php
@@ -636,7 +636,8 @@ if ($checkup !== true) { @@ -636,7 +636,8 @@ if ($checkup !== true) {
636 636
637 if ($checkup !== true) { 637 if ($checkup !== true) {
638 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 638 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
639 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 639 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  640 + require_once($path . 'baobabkeyutil.inc.php');
640 $name = BaobabKeyUtil::getName(); 641 $name = BaobabKeyUtil::getName();
641 if ($name) { 642 if ($name) {
642 $default->versionName = sprintf('%s %s', $default->versionName, $name); 643 $default->versionName = sprintf('%s %s', $default->versionName, $name);
lib/plugins/pluginutil.inc.php
@@ -525,7 +525,7 @@ class KTPluginUtil { @@ -525,7 +525,7 @@ class KTPluginUtil {
525 } 525 }
526 return false; 526 return false;
527 } 527 }
528 - 528 +
529 /* Get the priority of the plugin */ 529 /* Get the priority of the plugin */
530 function getPluginPriority($sFile) { 530 function getPluginPriority($sFile) {
531 $defaultPriority = 10; 531 $defaultPriority = 10;
@@ -560,7 +560,7 @@ class KTPluginUtil { @@ -560,7 +560,7 @@ class KTPluginUtil {
560 560
561 $files = array(); 561 $files = array();
562 $plugins = array(); 562 $plugins = array();
563 - 563 +
564 KTPluginUtil::_walk(KT_DIR . '/plugins', $files); 564 KTPluginUtil::_walk(KT_DIR . '/plugins', $files);
565 foreach ($files as $sFile) { 565 foreach ($files as $sFile) {
566 $plugin_ending = "Plugin.php"; 566 $plugin_ending = "Plugin.php";
@@ -569,17 +569,17 @@ class KTPluginUtil { @@ -569,17 +569,17 @@ class KTPluginUtil {
569 $plugins[$sFile] = KTPluginUtil::getPluginPriority($sFile); 569 $plugins[$sFile] = KTPluginUtil::getPluginPriority($sFile);
570 } 570 }
571 } 571 }
572 - 572 +
573 /* Sort the plugins by priority */ 573 /* Sort the plugins by priority */
574 asort($plugins); 574 asort($plugins);
575 - 575 +
576 foreach($plugins as $sFile => $priority) { 576 foreach($plugins as $sFile => $priority) {
577 require_once($sFile); 577 require_once($sFile);
578 } 578 }
579 -  
580 -  
581 -  
582 - 579 +
  580 +
  581 +
  582 +
583 583
584 $oRegistry =& KTPluginRegistry::getSingleton(); 584 $oRegistry =& KTPluginRegistry::getSingleton();
585 $aRegistryList = $oRegistry->getPlugins(); 585 $aRegistryList = $oRegistry->getPlugins();
@@ -687,15 +687,34 @@ class KTPluginUtil { @@ -687,15 +687,34 @@ class KTPluginUtil {
687 } 687 }
688 } 688 }
689 689
690 - // utility function to detect if the plugin is loaded and active.  
691 - static function pluginIsActive($sNamespace) { 690 + /**
  691 + * Get the full path to the plugin
  692 + *
  693 + * @param string $sNamespace The namespace of the plugin
  694 + * @param bool $relative Whether the path should be relative or full
  695 + * @return string
  696 + */
  697 + static function getPluginPath($sNamespace, $relative = false)
  698 + {
  699 + $oEntity = KTPluginEntity::getByNamespace($sNamespace);
692 700
  701 + if(PEAR::isError($oEntity)){
  702 + return $oEntity;
  703 + }
  704 + $dir = dirname($oEntity->getPath()) . DIRECTORY_SEPARATOR;
693 705
  706 + if(!$relative){
  707 + $dir = KT_DIR . DIRECTORY_SEPARATOR . $dir;
  708 + }
694 709
695 - $oReg =& KTPluginRegistry::getSingleton();  
696 - $plugin = $oReg->getPlugin($sNamespace); 710 + return $dir;
  711 + }
697 712
  713 + // utility function to detect if the plugin is loaded and active.
  714 + static function pluginIsActive($sNamespace) {
698 715
  716 + $oReg =& KTPluginRegistry::getSingleton();
  717 + $plugin = $oReg->getPlugin($sNamespace);
699 718
700 if (is_null($plugin) || PEAR::isError($plugin)) { return false; } // no such plugin 719 if (is_null($plugin) || PEAR::isError($plugin)) { return false; } // no such plugin
701 else { // check if its active 720 else { // check if its active
@@ -709,4 +728,4 @@ class KTPluginUtil { @@ -709,4 +728,4 @@ class KTPluginUtil {
709 } 728 }
710 } 729 }
711 730
712 -?> 731 -?>
  732 +?>
713 \ No newline at end of file 733 \ No newline at end of file
lib/session/Session.inc
@@ -56,7 +56,8 @@ class Session { @@ -56,7 +56,8 @@ class Session {
56 // Don't need to lock a user out the web interface if KT Tools exists and has no license. 56 // Don't need to lock a user out the web interface if KT Tools exists and has no license.
57 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 57 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
58 if (!$oUser->isAnonymous()) { 58 if (!$oUser->isAnonymous()) {
59 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 59 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  60 + require_once($path . 'baobabkeyutil.inc.php');
60 $res = BaobabKeyUtil::isValidUser($oUser); 61 $res = BaobabKeyUtil::isValidUser($oUser);
61 if (PEAR::isError($res)) { 62 if (PEAR::isError($res)) {
62 return $res; 63 return $res;
@@ -236,7 +237,7 @@ class Session { @@ -236,7 +237,7 @@ class Session {
236 } 237 }
237 238
238 // this should be an existing session, so check the db 239 // this should be an existing session, so check the db
239 - $aRows = DBUtil::getResultArray(array("SELECT * FROM $default->sessions_table WHERE session_id = ?", $sessionID)); 240 + $aRows = DBUtil::getResultArray(array("SELECT * FROM $default->sessions_table WHERE session_id = ? ORDER BY id DESC", $sessionID));
240 241
241 $numrows = count($aRows); 242 $numrows = count($aRows);
242 243
lib/users/User.inc
@@ -465,7 +465,8 @@ class User extends KTEntity { @@ -465,7 +465,8 @@ class User extends KTEntity {
465 $this->setDisabled(1); 465 $this->setDisabled(1);
466 $this->update(); 466 $this->update();
467 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 467 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
468 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 468 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  469 + require_once($path . 'baobabkeyutil.inc.php');
469 BaobabKeyUtil::deallocateUser($this); 470 BaobabKeyUtil::deallocateUser($this);
470 } 471 }
471 return; 472 return;
@@ -475,7 +476,8 @@ class User extends KTEntity { @@ -475,7 +476,8 @@ class User extends KTEntity {
475 $this->setDisabled(0); 476 $this->setDisabled(0);
476 $this->update(); 477 $this->update();
477 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 478 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
478 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 479 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  480 + require_once($path . 'baobabkeyutil.inc.php');
479 BaobabKeyUtil::allocateUser($this); 481 BaobabKeyUtil::allocateUser($this);
480 } 482 }
481 return; 483 return;
@@ -483,7 +485,8 @@ class User extends KTEntity { @@ -483,7 +485,8 @@ class User extends KTEntity {
483 485
484 function create() { 486 function create() {
485 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 487 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
486 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 488 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  489 + require_once($path . 'baobabkeyutil.inc.php');
487 $res = BaobabKeyUtil::canAddUser(); 490 $res = BaobabKeyUtil::canAddUser();
488 if (PEAR::isError($res)) { 491 if (PEAR::isError($res)) {
489 return $res; 492 return $res;
@@ -516,7 +519,8 @@ class User extends KTEntity { @@ -516,7 +519,8 @@ class User extends KTEntity {
516 519
517 $this->update(); 520 $this->update();
518 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 521 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
519 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 522 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  523 + require_once($path . 'baobabkeyutil.inc.php');
520 BaobabKeyUtil::deallocateUser($this); 524 BaobabKeyUtil::deallocateUser($this);
521 } 525 }
522 return; 526 return;
plugins/ktcore/KTCorePlugin.php
@@ -108,14 +108,14 @@ class KTCorePlugin extends KTPlugin { @@ -108,14 +108,14 @@ class KTCorePlugin extends KTPlugin {
108 $this->registerDashlet('KTCheckoutDashlet', 'ktcore.dashlet.checkout', 'KTDashlets.php'); 108 $this->registerDashlet('KTCheckoutDashlet', 'ktcore.dashlet.checkout', 'KTDashlets.php');
109 $this->registerDashlet('KTMailServerDashlet', 'ktcore.dashlet.mail_server', 'KTDashlets.php'); 109 $this->registerDashlet('KTMailServerDashlet', 'ktcore.dashlet.mail_server', 'KTDashlets.php');
110 $this->registerDashlet('LuceneMigrationDashlet', 'ktcore.dashlet.lucene_migration', KT_DIR . '/plugins/search2/MigrationDashlet.php'); 110 $this->registerDashlet('LuceneMigrationDashlet', 'ktcore.dashlet.lucene_migration', KT_DIR . '/plugins/search2/MigrationDashlet.php');
111 -  
112 - 111 +
  112 +
113 // THESE THREE DASHLETS HAVE BEEN MOVED TO ADMIN PAGES 113 // THESE THREE DASHLETS HAVE BEEN MOVED TO ADMIN PAGES
114 - 114 +
115 //$this->registerDashlet('ExternalResourceStatusDashlet', 'ktcore.dashlet.resource_status', KT_DIR . '/plugins/search2/ExternalDashlet.php'); 115 //$this->registerDashlet('ExternalResourceStatusDashlet', 'ktcore.dashlet.resource_status', KT_DIR . '/plugins/search2/ExternalDashlet.php');
116 //$this->registerDashlet('IndexingStatusDashlet', 'ktcore.dashlet.indexing_status', KT_DIR . '/plugins/search2/IndexingStatusDashlet.php'); 116 //$this->registerDashlet('IndexingStatusDashlet', 'ktcore.dashlet.indexing_status', KT_DIR . '/plugins/search2/IndexingStatusDashlet.php');
117 //$this->registerDashlet('LuceneStatisticsDashlet', 'ktcore.dashlet.indexing_statss', KT_DIR . '/plugins/search2/LuceneStatisticsDashlet.php'); 117 //$this->registerDashlet('LuceneStatisticsDashlet', 'ktcore.dashlet.indexing_statss', KT_DIR . '/plugins/search2/LuceneStatisticsDashlet.php');
118 - 118 +
119 $this->registerDashlet('schedulerDashlet', 'ktcore.schedulerdashlet.plugin', 'scheduler/schedulerDashlet.php'); 119 $this->registerDashlet('schedulerDashlet', 'ktcore.schedulerdashlet.plugin', 'scheduler/schedulerDashlet.php');
120 120
121 $this->registerAdminPage('scheduler', 'manageSchedulerDispatcher', 'misc', _kt('Manage Task Scheduler'), _kt('Manage the task scheduler'), 'scheduler/taskScheduler.php'); 121 $this->registerAdminPage('scheduler', 'manageSchedulerDispatcher', 'misc', _kt('Manage Task Scheduler'), _kt('Manage the task scheduler'), 'scheduler/taskScheduler.php');
@@ -279,13 +279,6 @@ class KTCorePlugin extends KTPlugin { @@ -279,13 +279,6 @@ class KTCorePlugin extends KTPlugin {
279 _kt('Document Fieldsets'), 279 _kt('Document Fieldsets'),
280 _kt('Manage the different types of information that can be associated with classes of documents.'), 280 _kt('Manage the different types of information that can be associated with classes of documents.'),
281 'admin/documentFieldsv2.php', null); 281 'admin/documentFieldsv2.php', null);
282 - if(KTPluginUtil::pluginIsActive('ktdms.wintools'))  
283 - {  
284 - $this->registerAdminPage('emailtypemanagement', 'KTEmailDocumentTypeDispatcher', 'documents',  
285 - _kt('Email Document Types'),  
286 - _kt('Manage the addition of Email document types to the system.'),  
287 - '../wintools/email/emailDocumentTypes.php', null);  
288 - }  
289 $this->registerAdminPage('workflows_2', 'KTWorkflowAdminV2', 'documents', 282 $this->registerAdminPage('workflows_2', 'KTWorkflowAdminV2', 'documents',
290 _kt('Workflows'), _kt('Configure automated Workflows that map to document life-cycles.'), 283 _kt('Workflows'), _kt('Configure automated Workflows that map to document life-cycles.'),
291 'admin/workflowsv2.php', null); 284 'admin/workflowsv2.php', null);
@@ -322,20 +315,20 @@ class KTCorePlugin extends KTPlugin { @@ -322,20 +315,20 @@ class KTCorePlugin extends KTPlugin {
322 $this->registerAdminPage('reschedulealldocuments', 'RescheduleDocumentsDispatcher', 'search', 315 $this->registerAdminPage('reschedulealldocuments', 'RescheduleDocumentsDispatcher', 'search',
323 _kt('Reschedule all documents'), _kt('This function allows you to re-index your entire repository.'), 316 _kt('Reschedule all documents'), _kt('This function allows you to re-index your entire repository.'),
324 '../search2/reporting/RescheduleDocuments.php', null); 317 '../search2/reporting/RescheduleDocuments.php', null);
325 -  
326 - 318 +
  319 +
327 // Admin Pages for Previous Dashlets 320 // Admin Pages for Previous Dashlets
328 $this->registerAdminPage('indexingstatus', 'IndexingStatusDispatcher', 'search', 321 $this->registerAdminPage('indexingstatus', 'IndexingStatusDispatcher', 'search',
329 _kt('Document Indexer and External Resource Dependancy Status'), _kt('This report will show the status of external dependencies and the document indexer.'), 322 _kt('Document Indexer and External Resource Dependancy Status'), _kt('This report will show the status of external dependencies and the document indexer.'),
330 '../search2/reporting/IndexingStatus.php', null); 323 '../search2/reporting/IndexingStatus.php', null);
331 - 324 +
332 $this->registerAdminPage('lucenestatistics', 'LuceneStatisticsDispatcher', 'search', 325 $this->registerAdminPage('lucenestatistics', 'LuceneStatisticsDispatcher', 'search',
333 _kt('Document Indexer Statistics'), _kt('This report will show the Lucene Document Indexing Statistics '), 326 _kt('Document Indexer Statistics'), _kt('This report will show the Lucene Document Indexing Statistics '),
334 '../search2/reporting/LuceneStatistics.php', null); 327 '../search2/reporting/LuceneStatistics.php', null);
335 -  
336 -  
337 -  
338 - 328 +
  329 +
  330 +
  331 +
339 //config 332 //config
340 $this->registerAdminPage('emailconfigpage', 'EmailConfigPageDispatcher', 'config', 333 $this->registerAdminPage('emailconfigpage', 'EmailConfigPageDispatcher', 'config',
341 _kt('Email'), _kt('Define the sending email server address, email password, email port, and user name, and view and modify policies for emailing documents and attachments from KnowledgeTree.'), 334 _kt('Email'), _kt('Define the sending email server address, email password, email port, and user name, and view and modify policies for emailing documents and attachments from KnowledgeTree.'),
plugins/ktcore/admin/userManagement.php
@@ -6,31 +6,31 @@ @@ -6,31 +6,31 @@
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 * Portions copyright The Jam Warehouse Software (Pty) Limited 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9 - * 9 + *
10 * This program is free software; you can redistribute it and/or modify it under 10 * This program is free software; you can redistribute it and/or modify it under
11 * the terms of the GNU General Public License version 3 as published by the 11 * the terms of the GNU General Public License version 3 as published by the
12 * Free Software Foundation. 12 * Free Software Foundation.
13 - * 13 + *
14 * This program is distributed in the hope that it will be useful, but WITHOUT 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details. 17 * details.
18 - * 18 + *
19 * You should have received a copy of the GNU General Public License 19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 - *  
22 - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, 21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 * California 94120-7775, or email info@knowledgetree.com. 23 * California 94120-7775, or email info@knowledgetree.com.
24 - * 24 + *
25 * The interactive user interfaces in modified source and object code versions 25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under 26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU General Public License version 3. 27 * Section 5 of the GNU General Public License version 3.
28 - * 28 + *
29 * In accordance with Section 7(b) of the GNU General Public License version 3, 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by 30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 32 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33 - * must display the words "Powered by KnowledgeTree" and retain the original 33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 * copyright notice. 34 * copyright notice.
35 * Contributor( s): ______________________________________ 35 * Contributor( s): ______________________________________
36 * 36 *
@@ -93,7 +93,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -93,7 +93,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
93 93
94 $bCanAdd = true; 94 $bCanAdd = true;
95 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 95 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
96 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 96 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  97 + require_once($path . 'baobabkeyutil.inc.php');
97 $bCanAdd = BaobabKeyUtil::canAddUser(); 98 $bCanAdd = BaobabKeyUtil::canAddUser();
98 if (PEAR::isError($bCanAdd)) { 99 if (PEAR::isError($bCanAdd)) {
99 $bCanAdd = false; 100 $bCanAdd = false;
@@ -697,7 +698,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher { @@ -697,7 +698,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
697 $iLicenses = 0; 698 $iLicenses = 0;
698 $bRequireLicenses = false; 699 $bRequireLicenses = false;
699 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 700 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
700 - require_once(KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php'); 701 + $path = KTPluginUtil::getPluginPath('ktdms.wintools');
  702 + require_once($path . 'baobabkeyutil.inc.php');
701 $iLicenses = BaobabKeyUtil::getLicenseCount(); 703 $iLicenses = BaobabKeyUtil::getLicenseCount();
702 $bRequireLicenses = true; 704 $bRequireLicenses = true;
703 } 705 }
plugins/ktstandard/KTWebDAVDashletPlugin.php
@@ -76,8 +76,7 @@ class KTWebDAVDashlet extends KTBaseDashlet { @@ -76,8 +76,7 @@ class KTWebDAVDashlet extends KTBaseDashlet {
76 // Shortcut: Check if the the wintools plugin exists and set to true. 76 // Shortcut: Check if the the wintools plugin exists and set to true.
77 // Long way: Check that a license is installed - this is only text so having a license is not a requirement. 77 // Long way: Check that a license is installed - this is only text so having a license is not a requirement.
78 $isComm = false; 78 $isComm = false;
79 - $keyUtil = KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php';  
80 - if(file_exists($keyUtil)){ 79 + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
81 $isComm = true; 80 $isComm = true;
82 } 81 }
83 $webdavUrl = $sURL.'/ktwebdav/ktwebdav.php'; 82 $webdavUrl = $sURL.'/ktwebdav/ktwebdav.php';