diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-02-03 07:47:27 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-02-03 07:47:27 +0400 |
commit | 883ecc81b96336d3a61fb193af51ecd3fb9b6d91 (patch) | |
tree | 46b04484dbe42dc3afdb7767e1bfe3c1ab17d1ed /plugins/CoreAdminHome | |
parent | 3332750e51f995044cb25260bc3a61d454d02f26 (diff) |
refs #4563 moved custom logo from config to database
Diffstat (limited to 'plugins/CoreAdminHome')
-rw-r--r-- | plugins/CoreAdminHome/Controller.php | 18 | ||||
-rw-r--r-- | plugins/CoreAdminHome/CustomLogo.php | 22 |
2 files changed, 29 insertions, 11 deletions
diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 0993f872c6..5c54d371a9 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -16,6 +16,7 @@ use Piwik\Config; use Piwik\DataTable\Renderer\Json; use Piwik\Menu\MenuTop; use Piwik\Nonce; +use Piwik\Option; use Piwik\Piwik; use Piwik\Plugins\LanguagesManager\API as APILanguagesManager; use Piwik\Plugins\LanguagesManager\LanguagesManager; @@ -53,13 +54,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin } $view->trustedHosts = $trustedHosts; - $view->branding = Config::getInstance()->branding; - $logo = new CustomLogo(); + $view->branding = array('use_custom_logo' => $logo->isEnabled()); $view->logosWriteable = $logo->isCustomLogoWritable(); - $view->pathUserLogo = CustomLogo::getPathUserLogo(); + $view->pathUserLogo = CustomLogo::getPathUserLogo(); $view->pathUserLogoSmall = CustomLogo::getPathUserLogoSmall(); - $view->pathUserLogoSVG = CustomLogo::getPathUserSvgLogo(); + $view->pathUserLogoSVG = CustomLogo::getPathUserSvgLogo(); $view->pathUserLogoDirectory = dirname($view->pathUserLogo) . '/'; } @@ -187,10 +187,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin Url::saveTrustedHostnameInConfig($trustedHosts); } - // update branding settings - $branding = Config::getInstance()->branding; - $branding['use_custom_logo'] = Common::getRequestVar('useCustomLogo', '0'); - Config::getInstance()->branding = $branding; + $customLogo = new CustomLogo(); + if (Common::getRequestVar('useCustomLogo', '0')) { + $customLogo->enable(); + } else { + $customLogo->disable(); + } Config::getInstance()->forceSave(); diff --git a/plugins/CoreAdminHome/CustomLogo.php b/plugins/CoreAdminHome/CustomLogo.php index 8e1dfc58dd..bc1f1da055 100644 --- a/plugins/CoreAdminHome/CustomLogo.php +++ b/plugins/CoreAdminHome/CustomLogo.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\CoreAdminHome; use Piwik\Config; use Piwik\Filesystem; +use Piwik\Option; use Piwik\SettingsPiwik; class CustomLogo @@ -42,14 +43,29 @@ class CustomLogo return $svg; } + public function isEnabled() + { + return (bool) Option::get('branding_use_custom_logo'); + } + + public function enable() + { + Option::set('branding_use_custom_logo', '1', true); + } + + public function disable() + { + Option::set('branding_use_custom_logo', '0', true); + } + public function hasSVGLogo() { - if (Config::getInstance()->branding['use_custom_logo'] == 0) { + if (!$this->isEnabled()) { /* We always have our application logo */ return true; } - if (Config::getInstance()->branding['use_custom_logo'] == 1 + if ($this->isEnabled() && file_exists(Filesystem::getPathToPiwikRoot() . '/' . CustomLogo::getPathUserSvgLogo()) ) { return true; @@ -93,7 +109,7 @@ class CustomLogo if (file_exists($pathToPiwikRoot . '/' . $themeLogo)) { $logo = $themeLogo; } - if (Config::getInstance()->branding['use_custom_logo'] == 1 + if ($this->isEnabled() && file_exists($pathToPiwikRoot . '/' . $customLogo) ) { $logo = $customLogo; |