From 0b97a84227a4f05bc6d6f98986e3bd68f1bb8651 Mon Sep 17 00:00:00 2001
From: mattab <matthieu.aubry@gmail.com>
Date: Fri, 9 Aug 2013 16:59:31 +0200
Subject: [PATCH] Making "Theme Enable" work for PleineLune

---
 core/PluginsManager.php              | 18 ++++++++++--------
 plugins/PleineLune/plugin.piwik.json |  2 +-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index bbfec52d9a..e61b7195fc 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -282,13 +282,21 @@ class PluginsManager
             return;
         }
 
+        // Only one theme enabled at a time
+        $themeAlreadyEnabled = $this->getThemeEnabled();
+        if($themeAlreadyEnabled) {
+            $plugin = $this->loadPlugin($pluginName);
+            if($plugin->isTheme()) {
+                $plugins = $this->deactivatePlugin( $themeAlreadyEnabled, $plugins );
+            }
+        }
+
+        // Load plugin
         $plugin = $this->loadPlugin($pluginName);
         if ($plugin === null) {
             return;
         }
-
         $this->installPluginIfNecessary($plugin);
-
         $plugin->activate();
 
         // we add the plugin to the list of activated plugins
@@ -297,12 +305,6 @@ class PluginsManager
         }
         $plugins = array_unique($plugins);
 
-        // Only one theme enabled at a time
-        $themeAlreadyEnabled = $this->getThemeEnabled();
-        if($plugin->isTheme()
-            && $themeAlreadyEnabled) {
-            $plugins = $this->deactivatePlugin( $themeAlreadyEnabled, $plugins );
-        }
 
         // the config file will automatically be saved with the new plugin
         $this->updatePluginsConfig($plugins);
diff --git a/plugins/PleineLune/plugin.piwik.json b/plugins/PleineLune/plugin.piwik.json
index a05e6aad75..d0718e1737 100644
--- a/plugins/PleineLune/plugin.piwik.json
+++ b/plugins/PleineLune/plugin.piwik.json
@@ -1,5 +1,5 @@
 {
     "name": "PleineLune",
-    "description": "A dark theme for Piwik, ideal to view your analytics reports before sunrise!",
+    "description": "A dark theme for Piwik, ideal to view your analytics reports before sunrise.",
     "theme": true
 }
\ No newline at end of file
-- 
GitLab