BUG 5978 Fix some problems when installing a plugin with PluginRegistry
This commit is contained in:
@@ -199,6 +199,7 @@ class PMPluginRegistry {
|
||||
if ( $sFilename == baseName ( $row->sFilename ) )
|
||||
return $row;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,8 +217,10 @@ class PMPluginRegistry {
|
||||
if (method_exists($oPlugin, 'enable')) {
|
||||
$oPlugin->enable();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
throw new Exception("Unable to enable plugin '$sNamespace' (plugin not found)");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,6 +230,7 @@ class PMPluginRegistry {
|
||||
*/
|
||||
function disablePlugin($sNamespace )
|
||||
{
|
||||
$found = false;
|
||||
foreach ( $this->_aPluginDetails as $namespace=>$detail ) {
|
||||
if ( $sNamespace == $namespace ) {
|
||||
unset ($this->_aPluginDetails[$sNamespace]);
|
||||
@@ -235,9 +239,13 @@ class PMPluginRegistry {
|
||||
if (method_exists($oPlugin, 'disable')) {
|
||||
$oPlugin->disable();
|
||||
}
|
||||
$found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found)
|
||||
throw new Exception("Unable to disable plugin '$sNamespace' (plugin not found)");
|
||||
|
||||
foreach ( $this->_aMenus as $key=>$detail ) {
|
||||
if ( $detail->sNamespace == $sNamespace )
|
||||
unset ( $this->_aMenus[ $key ] );
|
||||
@@ -308,15 +316,21 @@ class PMPluginRegistry {
|
||||
function getStatusPlugin($sNamespace ) {
|
||||
foreach ( $this->_aPluginDetails as $namespace=>$detail ) {
|
||||
if ( $sNamespace == $namespace )
|
||||
if ( $this->_aPluginDetails[$sNamespace]->enabled )
|
||||
return 'enabled';
|
||||
else
|
||||
return 'disabled';
|
||||
if ( $this->_aPluginDetails[$sNamespace]->enabled )
|
||||
return 'enabled';
|
||||
else
|
||||
return 'disabled';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function installPluginArchive($filename, $pluginInstall = NULL) {
|
||||
/**
|
||||
* Install a plugin archive. If pluginName is specified, the archive will
|
||||
* only be installed if it contains this plugin.
|
||||
*
|
||||
* @return bool true if enabled, false otherwise
|
||||
*/
|
||||
function installPluginArchive($filename, $pluginName = NULL) {
|
||||
G::LoadThirdParty( 'pear/Archive','Tar');
|
||||
$tar = new Archive_Tar ($filename);
|
||||
|
||||
@@ -332,8 +346,8 @@ class PMPluginRegistry {
|
||||
if (count($plugins) > 1)
|
||||
throw new Exception("Multiple plugins in one archive are not supported currently");
|
||||
|
||||
if (!in_array($pluginInstall, $plugins))
|
||||
throw new Exception("Plugin $pluginInstall not found in archive");
|
||||
if (isset($pluginName) && !in_array($pluginName, $plugins))
|
||||
throw new Exception("Plugin '$pluginName' not found in archive");
|
||||
|
||||
$pluginName = $plugins[0];
|
||||
$pluginFile = "$pluginName.php";
|
||||
@@ -373,11 +387,14 @@ class PMPluginRegistry {
|
||||
throw ( new Exception( "File '$pluginFile' doesn't exist ") );
|
||||
|
||||
require_once ( PATH_PLUGINS . $pluginFile );
|
||||
$details = $oPluginRegistry->getPluginDetails( $pluginFile );
|
||||
$details = $this->getPluginDetails( $pluginFile );
|
||||
|
||||
$oPluginRegistry->installPlugin( $details->sNamespace);
|
||||
$oPluginRegistry->setupPlugins(); //get and setup enabled plugins
|
||||
$size = file_put_contents ( PATH_DATA_SITE . 'plugin.singleton', $oPluginRegistry->serializeInstance() );
|
||||
$this->installPlugin($details->sNamespace);
|
||||
$this->setupPlugins();
|
||||
|
||||
$this->enablePlugin($details->sNamespace);
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
function uninstallPlugin($sNamespace) {
|
||||
|
||||
Reference in New Issue
Block a user