Commit 2be186b03a66648b12cb4fbe65e8832da71d8dec

Authored by Megan Watson
1 parent cad6b36d

KTS-2847

"Disabled plugins still load"
Fixed. Used a debug trace to find which plugin is adding a location and get the plugin namespace, so that the location can be linked to the plugin and not loaded when its been disabled.

Committed by: Megan Watson
Reviewed by: Conrad Vermeulen



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7958 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/plugins/pluginutil.inc.php
... ... @@ -214,9 +214,14 @@ class KTPluginUtil {
214 214  
215 215 KTPluginUtil::load($aPluginList);
216 216  
217   - // Load the template locations
218   - $query = "SELECT * FROM plugin_helper h WHERE h.classtype='locations'";
  217 + // Load the template locations - ignore disabled plugins
  218 + // Allow for templates that don't correctly link to the plugin
  219 + $query = "SELECT * FROM plugin_helper h
  220 + LEFT JOIN plugins p ON (p.namespace = h.plugin)
  221 + WHERE h.classtype='locations' AND (disabled = 0 OR disabled IS NULL)";
  222 +
219 223 $aLocations = DBUtil::getResultArray($query);
  224 +
220 225 if(!empty($aLocations)){
221 226 $oTemplating =& KTTemplating::getSingleton();
222 227 foreach ($aLocations as $location){
... ...
lib/templating/templating.inc.php
... ... @@ -127,12 +127,64 @@ class KTTemplating {
127 127 * @param unknown_type $descr
128 128 * @param unknown_type $loc
129 129 */
130   - function addLocation ($descr, $loc) {
  130 + function addLocation ($descr, $loc, $sPluginNamespace = NULL) {
131 131 $this->aLocationRegistry[$descr] = $loc;
132   - KTPlugin::registerPluginHelper($descr, $descr, $loc, $descr.'|'.$loc, 'general', 'locations');
  132 +
  133 + if(!empty($sPluginNamespace)){
  134 + $sPlugin = $sPluginNamespace;
  135 + }else{
  136 + $sPlugin = $this->getPluginName();
  137 + $sPlugin = (!empty($sPlugin)) ? $sPlugin : $descr;
  138 + }
  139 +
  140 + KTPlugin::registerPluginHelper($sPlugin, $sPlugin, $loc, $descr.'|'.$loc, 'general', 'locations');
133 141 }
134 142 // }}}
135 143  
  144 + function getPluginName(){
  145 + $class = 'kttemplating';
  146 + $function = 'addlocation';
  147 + $function2 = 'setup';
  148 + $bIsPlugin = false;
  149 + $file = false;
  150 + $plugin = false;
  151 +
  152 + $trace = debug_backtrace();
  153 +
  154 + if(empty($trace)){
  155 + return '';
  156 + }
  157 +
  158 + foreach($trace as $call){
  159 + if(strtolower($call['class']) == $class && strtolower($call['function']) == $function){
  160 + $file = $call['file'];
  161 + }
  162 + if($file && strtolower($call['function']) == $function2){
  163 + $plugin = $call['class'];
  164 + }
  165 + if(strtolower($call['class']) == 'ktplugin' && strtolower($call['function']) == 'register'){
  166 + $bIsPlugin = true;
  167 + break;
  168 + }
  169 + if(strtolower($call['class']) == 'ktplugindispatcher' && strtolower($call['function']) == 'do_update'){
  170 + $bIsPlugin = true;
  171 + break;
  172 + }
  173 + }
  174 +
  175 + if($bIsPlugin && $file !== false && $plugin !== false){
  176 + include_once($file);
  177 + $oPlugin = new $plugin;
  178 + $sPluginName = $oPlugin->sNamespace;
  179 +
  180 + if(!empty($sPluginName)){
  181 + return $sPluginName;
  182 + }
  183 + }
  184 +
  185 + return '';
  186 + }
  187 +
136 188 /**
137 189 * Add the template location to the location registry
138 190 *
... ...