diff --git a/application/controllers/admin/PluginManagerController.php b/application/controllers/admin/PluginManagerController.php
index 83d0332a6f2..d756422cb3d 100644
--- a/application/controllers/admin/PluginManagerController.php
+++ b/application/controllers/admin/PluginManagerController.php
@@ -16,7 +16,10 @@ public function index()
{
$oPluginManager = App()->getPluginManager();
+ $oPluginManager->scanPlugins();
+
// Scan the plugins folder.
+ /*
$aDiscoveredPlugins = $oPluginManager->scanPlugins();
$aInstalledPlugins = $oPluginManager->getInstalledPlugins();
$aInstalledNames = array_map(
@@ -27,7 +30,6 @@ function ($installedPlugin) {
);
// Install newly discovered plugins.
- /*
foreach ($aDiscoveredPlugins as $discoveredPlugin) {
if (!in_array($discoveredPlugin['pluginClass'], $aInstalledNames)) {
$oPlugin = new Plugin();
@@ -45,22 +47,14 @@ function ($installedPlugin) {
$aoPlugins = Plugin::model()->findAll(array('order' => 'name'));
$data = array();
foreach ($aoPlugins as $oPlugin) {
- /* @var $plugin Plugin */
- $plugin = App()->getPluginManager()->loadPlugin($oPlugin->name, $oPlugin->id);
- if ($plugin) {
- $aPluginSettings = $plugin->getPluginSettings(false);
- $data[] = array(
- 'id' => $oPlugin->id,
- 'name' => $aDiscoveredPlugins[$oPlugin->name]['pluginName'],
- 'description' => $aDiscoveredPlugins[$oPlugin->name]['description'],
- 'active' => $oPlugin->active,
- 'settings' => $aPluginSettings,
- 'new' => !in_array($oPlugin->name, $aInstalledNames)
- );
- } else {
- tracevar($oPlugin->name);
- // What?
- }
+ $data[] = [
+ 'id' => $oPlugin->id,
+ 'name' => $oPlugin->name,
+ 'load_error' => $oPlugin->load_error,
+ 'description' => '',
+ 'active' => $oPlugin->active,
+ 'settings' => []
+ ];
}
if (Yii::app()->request->getParam('pageSize')) {
@@ -70,11 +64,13 @@ function ($installedPlugin) {
$aData['fullpagebar']['returnbutton']['url'] = 'index';
$aData['fullpagebar']['returnbutton']['text'] = gT('Return to admin home');
$aData['data'] = $data;
- $this->_renderWrappedTemplate('pluginmanager', 'index', $aData);
+
if (!Permission::model()->hasGlobalPermission('settings', 'read')) {
Yii::app()->setFlashMessage(gT("No permission"), 'error');
$this->getController()->redirect(array('/admin'));
}
+
+ $this->_renderWrappedTemplate('pluginmanager', 'index', $aData);
}
/**
diff --git a/application/libraries/PluginManager/PluginManager.php b/application/libraries/PluginManager/PluginManager.php
index 84dbcd2021a..9276cec20c3 100644
--- a/application/libraries/PluginManager/PluginManager.php
+++ b/application/libraries/PluginManager/PluginManager.php
@@ -49,7 +49,7 @@ class PluginManager extends \CApplicationComponent
/**
* @var PluginManagerShutdownFunction
*/
- protected $shutdownObject;
+ public $shutdownObject;
/**
* Creates the plugin manager.
@@ -385,7 +385,9 @@ public function loadPlugins()
$records = $pluginModel->findAllByAttributes(array('active'=>1));
foreach ($records as $record) {
- $this->loadPlugin($record->name, $record->id);
+ if ($record->load_error == 0) {
+ $this->loadPlugin($record->name, $record->id);
+ }
}
} else {
// Log it ? tracevar ?
@@ -401,7 +403,9 @@ public function loadAllPlugins()
{
$records = Plugin::model()->findAll();
foreach ($records as $record) {
- $this->loadPlugin($record->name, $record->id);
+ if ($record->load_error == 0) {
+ $this->loadPlugin($record->name, $record->id);
+ }
}
}
diff --git a/application/libraries/PluginManager/PluginManagerShutdownFunction.php b/application/libraries/PluginManager/PluginManagerShutdownFunction.php
index 20c29ea48ff..aa8fc4bd223 100644
--- a/application/libraries/PluginManager/PluginManagerShutdownFunction.php
+++ b/application/libraries/PluginManager/PluginManagerShutdownFunction.php
@@ -43,6 +43,14 @@ public function disable()
$this->enabled = false;
}
+ /**
+ * @return boolean
+ */
+ public function isEnabled()
+ {
+ return $this->enabled;
+ }
+
/**
*
*/
diff --git a/application/models/behaviors/PluginEventBehavior.php b/application/models/behaviors/PluginEventBehavior.php
index 94973622316..55c0a48822e 100644
--- a/application/models/behaviors/PluginEventBehavior.php
+++ b/application/models/behaviors/PluginEventBehavior.php
@@ -25,8 +25,12 @@ public function afterDelete(CEvent $event)
public function afterSave(CEvent $event)
{
- $this->dispatchPluginModelEvent('after'.get_class($this->owner).'Save');
- $this->dispatchPluginModelEvent('afterModelSave');
+ $pluginManager = App()->getPluginManager();
+ // Don't propagate event if we're in a shutdown, since it will lead to an infinite loop.
+ if (!$pluginManager->shutdownObject->isEnabled()) {
+ $this->dispatchPluginModelEvent('after'.get_class($this->owner).'Save');
+ $this->dispatchPluginModelEvent('afterModelSave');
+ }
}
public function beforeDelete(CModelEvent $event)
@@ -37,8 +41,12 @@ public function beforeDelete(CModelEvent $event)
public function beforeSave(CModelEvent $event)
{
- $this->dispatchPluginModelEvent('before'.get_class($this->owner).'Save');
- $this->dispatchPluginModelEvent('beforeModelSave');
+ $pluginManager = App()->getPluginManager();
+ // Don't propagate event if we're in a shutdown, since it will lead to an infinite loop.
+ if (!$pluginManager->shutdownObject->isEnabled()) {
+ $this->dispatchPluginModelEvent('before'.get_class($this->owner).'Save');
+ $this->dispatchPluginModelEvent('beforeModelSave');
+ }
}
/**
diff --git a/application/views/admin/pluginmanager/index.php b/application/views/admin/pluginmanager/index.php
index 25937d9af3c..2137fca2161 100644
--- a/application/views/admin/pluginmanager/index.php
+++ b/application/views/admin/pluginmanager/index.php
@@ -61,12 +61,14 @@
//'value' => function($data) { return ($data['active'] == 1 ? CHtml::image(App()->getConfig('adminimageurl') . 'active.png', gT('Active'), array('width' => 32, 'height' => 32)) : CHtml::image(App()->getConfig('adminimageurl') . 'inactive.png', gT('Inactive'), array('width' => 32, 'height' => 32))); }
'value' => function($data)
{
- if ($data['active'] == 1)
- {
+ if ($data['load_error'] == 1) {
+ return sprintf(
+ "",
+ gT('Plugin load error')
+ );
+ } elseif ($data['active'] == 1) {
return "";
- }
- else
- {
+ } else {
return "";
}
}
@@ -91,7 +93,9 @@
$output='';
if(Permission::model()->hasGlobalPermission('settings','update'))
{
- if ($data['active'] == 0)
+ if ($data['load_error'] == 1) {
+ $output = '';
+ } elseif ($data['active'] == 0)
{
$output = ""
. " "