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 636  
637 637 if ($checkup !== true) {
638 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 641 $name = BaobabKeyUtil::getName();
641 642 if ($name) {
642 643 $default->versionName = sprintf('%s %s', $default->versionName, $name);
... ...
lib/plugins/pluginutil.inc.php
... ... @@ -525,7 +525,7 @@ class KTPluginUtil {
525 525 }
526 526 return false;
527 527 }
528   -
  528 +
529 529 /* Get the priority of the plugin */
530 530 function getPluginPriority($sFile) {
531 531 $defaultPriority = 10;
... ... @@ -560,7 +560,7 @@ class KTPluginUtil {
560 560  
561 561 $files = array();
562 562 $plugins = array();
563   -
  563 +
564 564 KTPluginUtil::_walk(KT_DIR . '/plugins', $files);
565 565 foreach ($files as $sFile) {
566 566 $plugin_ending = "Plugin.php";
... ... @@ -569,17 +569,17 @@ class KTPluginUtil {
569 569 $plugins[$sFile] = KTPluginUtil::getPluginPriority($sFile);
570 570 }
571 571 }
572   -
  572 +
573 573 /* Sort the plugins by priority */
574 574 asort($plugins);
575   -
  575 +
576 576 foreach($plugins as $sFile => $priority) {
577 577 require_once($sFile);
578 578 }
579   -
580   -
581   -
582   -
  579 +
  580 +
  581 +
  582 +
583 583  
584 584 $oRegistry =& KTPluginRegistry::getSingleton();
585 585 $aRegistryList = $oRegistry->getPlugins();
... ... @@ -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 719 if (is_null($plugin) || PEAR::isError($plugin)) { return false; } // no such plugin
701 720 else { // check if its active
... ... @@ -709,4 +728,4 @@ class KTPluginUtil {
709 728 }
710 729 }
711 730  
712 731 -?>
  732 +?>
713 733 \ No newline at end of file
... ...
lib/session/Session.inc
... ... @@ -56,7 +56,8 @@ class Session {
56 56 // Don't need to lock a user out the web interface if KT Tools exists and has no license.
57 57 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
58 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 61 $res = BaobabKeyUtil::isValidUser($oUser);
61 62 if (PEAR::isError($res)) {
62 63 return $res;
... ... @@ -236,7 +237,7 @@ class Session {
236 237 }
237 238  
238 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 242 $numrows = count($aRows);
242 243  
... ...
lib/users/User.inc
... ... @@ -465,7 +465,8 @@ class User extends KTEntity {
465 465 $this->setDisabled(1);
466 466 $this->update();
467 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 470 BaobabKeyUtil::deallocateUser($this);
470 471 }
471 472 return;
... ... @@ -475,7 +476,8 @@ class User extends KTEntity {
475 476 $this->setDisabled(0);
476 477 $this->update();
477 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 481 BaobabKeyUtil::allocateUser($this);
480 482 }
481 483 return;
... ... @@ -483,7 +485,8 @@ class User extends KTEntity {
483 485  
484 486 function create() {
485 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 490 $res = BaobabKeyUtil::canAddUser();
488 491 if (PEAR::isError($res)) {
489 492 return $res;
... ... @@ -516,7 +519,8 @@ class User extends KTEntity {
516 519  
517 520 $this->update();
518 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 524 BaobabKeyUtil::deallocateUser($this);
521 525 }
522 526 return;
... ...
plugins/ktcore/KTCorePlugin.php
... ... @@ -108,14 +108,14 @@ class KTCorePlugin extends KTPlugin {
108 108 $this->registerDashlet('KTCheckoutDashlet', 'ktcore.dashlet.checkout', 'KTDashlets.php');
109 109 $this->registerDashlet('KTMailServerDashlet', 'ktcore.dashlet.mail_server', 'KTDashlets.php');
110 110 $this->registerDashlet('LuceneMigrationDashlet', 'ktcore.dashlet.lucene_migration', KT_DIR . '/plugins/search2/MigrationDashlet.php');
111   -
112   -
  111 +
  112 +
113 113 // THESE THREE DASHLETS HAVE BEEN MOVED TO ADMIN PAGES
114   -
  114 +
115 115 //$this->registerDashlet('ExternalResourceStatusDashlet', 'ktcore.dashlet.resource_status', KT_DIR . '/plugins/search2/ExternalDashlet.php');
116 116 //$this->registerDashlet('IndexingStatusDashlet', 'ktcore.dashlet.indexing_status', KT_DIR . '/plugins/search2/IndexingStatusDashlet.php');
117 117 //$this->registerDashlet('LuceneStatisticsDashlet', 'ktcore.dashlet.indexing_statss', KT_DIR . '/plugins/search2/LuceneStatisticsDashlet.php');
118   -
  118 +
119 119 $this->registerDashlet('schedulerDashlet', 'ktcore.schedulerdashlet.plugin', 'scheduler/schedulerDashlet.php');
120 120  
121 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 279 _kt('Document Fieldsets'),
280 280 _kt('Manage the different types of information that can be associated with classes of documents.'),
281 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 282 $this->registerAdminPage('workflows_2', 'KTWorkflowAdminV2', 'documents',
290 283 _kt('Workflows'), _kt('Configure automated Workflows that map to document life-cycles.'),
291 284 'admin/workflowsv2.php', null);
... ... @@ -322,20 +315,20 @@ class KTCorePlugin extends KTPlugin {
322 315 $this->registerAdminPage('reschedulealldocuments', 'RescheduleDocumentsDispatcher', 'search',
323 316 _kt('Reschedule all documents'), _kt('This function allows you to re-index your entire repository.'),
324 317 '../search2/reporting/RescheduleDocuments.php', null);
325   -
326   -
  318 +
  319 +
327 320 // Admin Pages for Previous Dashlets
328 321 $this->registerAdminPage('indexingstatus', 'IndexingStatusDispatcher', 'search',
329 322 _kt('Document Indexer and External Resource Dependancy Status'), _kt('This report will show the status of external dependencies and the document indexer.'),
330 323 '../search2/reporting/IndexingStatus.php', null);
331   -
  324 +
332 325 $this->registerAdminPage('lucenestatistics', 'LuceneStatisticsDispatcher', 'search',
333 326 _kt('Document Indexer Statistics'), _kt('This report will show the Lucene Document Indexing Statistics '),
334 327 '../search2/reporting/LuceneStatistics.php', null);
335   -
336   -
337   -
338   -
  328 +
  329 +
  330 +
  331 +
339 332 //config
340 333 $this->registerAdminPage('emailconfigpage', 'EmailConfigPageDispatcher', 'config',
341 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 6 * Document Management Made Simple
7 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 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 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 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 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 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -93,7 +93,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
93 93  
94 94 $bCanAdd = true;
95 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 98 $bCanAdd = BaobabKeyUtil::canAddUser();
98 99 if (PEAR::isError($bCanAdd)) {
99 100 $bCanAdd = false;
... ... @@ -697,7 +698,8 @@ class KTUserAdminDispatcher extends KTAdminDispatcher {
697 698 $iLicenses = 0;
698 699 $bRequireLicenses = false;
699 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 703 $iLicenses = BaobabKeyUtil::getLicenseCount();
702 704 $bRequireLicenses = true;
703 705 }
... ...
plugins/ktstandard/KTWebDAVDashletPlugin.php
... ... @@ -76,8 +76,7 @@ class KTWebDAVDashlet extends KTBaseDashlet {
76 76 // Shortcut: Check if the the wintools plugin exists and set to true.
77 77 // Long way: Check that a license is installed - this is only text so having a license is not a requirement.
78 78 $isComm = false;
79   - $keyUtil = KT_DIR . '/plugins/wintools/baobabkeyutil.inc.php';
80   - if(file_exists($keyUtil)){
  79 + if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
81 80 $isComm = true;
82 81 }
83 82 $webdavUrl = $sURL.'/ktwebdav/ktwebdav.php';
... ...