Commit 2108bdc13622bf71eddb10c9f906ecc8ca7daac1
1 parent
335e41a2
Add an admin page to manage plugins - currently can view and
disable/enable plugins. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4572 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
81 additions
and
0 deletions
plugins/ktcore/admin/plugins.php
0 → 100755
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . '/dispatcher.inc.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/validation/dispatchervalidation.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/templating/templating.inc.php'); | |
| 6 | + | |
| 7 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | |
| 8 | +require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | |
| 9 | +require_once(KT_LIB_DIR . '/plugins/pluginentity.inc.php'); | |
| 10 | + | |
| 11 | +require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); | |
| 12 | + | |
| 13 | +class KTPluginDispatcher extends KTAdminDispatcher { | |
| 14 | + var $bAutomaticTransaction = true; | |
| 15 | + | |
| 16 | + function check() { | |
| 17 | + $this->aBreadcrumbs[] = array( | |
| 18 | + 'url' => $_SERVER['PHP_SELF'], | |
| 19 | + 'name' => _('Plugins'), | |
| 20 | + ); | |
| 21 | + return parent::check(); | |
| 22 | + } | |
| 23 | + | |
| 24 | + function do_main() { | |
| 25 | + $aPlugins = KTPluginEntity::getList(); | |
| 26 | + $aEnabledPluginIds = KTPluginEntity::getEnabledPlugins(); | |
| 27 | + | |
| 28 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 29 | + $oTemplate =& $oTemplating->loadTemplate('ktcore/plugins/list'); | |
| 30 | + $oTemplate->setData(array( | |
| 31 | + 'context' => $this, | |
| 32 | + 'plugins' => $aPlugins, | |
| 33 | + 'enabled_plugins' => $aEnabledPluginIds, | |
| 34 | + )); | |
| 35 | + return $oTemplate; | |
| 36 | + } | |
| 37 | + | |
| 38 | + function do_update() { | |
| 39 | + $sTable = KTUtil::getTableName('plugins'); | |
| 40 | + $aIds = KTUtil::arrayGet($_REQUEST, 'pluginids'); | |
| 41 | + $sIds = DBUtil::paramArray($aIds); | |
| 42 | + $sQuery = sprintf('UPDATE %s SET disabled = true WHERE id NOT IN (%s)', $sTable, $sIds); | |
| 43 | + DBUtil::runQuery(array($sQuery, $aIds)); | |
| 44 | + $sQuery = sprintf('UPDATE %s SET disabled = false WHERE id IN (%s)', $sTable, $sIds); | |
| 45 | + DBUtil::runQuery(array($sQuery, $aIds)); | |
| 46 | + $this->successRedirectToMain('Plugins updated'); | |
| 47 | + } | |
| 48 | + | |
| 49 | + function do_reread() { | |
| 50 | + KTPluginUtil::registerPlugins(); | |
| 51 | + $this->successRedirectToMain('Plugins read from the filesystem'); | |
| 52 | + } | |
| 53 | +} | |
| 54 | + | |
| 55 | +?> | ... | ... |
templates/ktcore/plugins/list.smarty
0 → 100644
| 1 | +<h2>Plugins</h2> | |
| 2 | + | |
| 3 | +{if $plugins} | |
| 4 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 5 | +<input type="hidden" name="action" value="update" /> | |
| 6 | +{entity_checkboxes entities=$plugins selected=$enabled_plugins | |
| 7 | +method=getNamespace assign=boxes name="pluginids"} | |
| 8 | +{foreach from=$boxes item=box} | |
| 9 | +{$box} <br /> | |
| 10 | +{/foreach} | |
| 11 | + | |
| 12 | +<input type="submit" name="submit" value="Update" /> | |
| 13 | +</form> | |
| 14 | +{/if} | |
| 15 | + | |
| 16 | +<h3>Read plugins from filesystem</h3> | |
| 17 | + | |
| 18 | +<p class="descriptiveText">If you have moved your document management | |
| 19 | +system on the filesystem, or installed or removed plugins, the plugins | |
| 20 | +must be re-read from the filesystem</p> | |
| 21 | + | |
| 22 | +<form action="{$smarty.server.PHP_SELF}" method="POST"> | |
| 23 | +<input type="hidden" name="action" value="reread" /> | |
| 24 | +<input type="submit" name="submit" value="Reread plugins" /> | |
| 25 | +</form> | |
| 26 | + | ... | ... |