diff options
author | Kate Butler <kate@innocraft.com> | 2019-10-11 00:05:15 +0300 |
---|---|---|
committer | Thomas Steur <tsteur@users.noreply.github.com> | 2019-10-11 00:05:15 +0300 |
commit | e0cf1401e4683fa1fa3de680442520bd9ad3e91e (patch) | |
tree | f973d38269469770f414fd090e11f4e865afd0d9 | |
parent | 2b18ed0a078cee2ec39109eeefcc5b316ea70901 (diff) |
Add config setting to disable custom logo upload (#14982)
* Add enable_custom_logo config setting to control whether user is permitted to upload logos
* Rename method, add check in setBrandingSettings
* Update Controller.php
* Update expected screenshot
-rwxr-xr-x | config/global.ini.php | 3 | ||||
-rw-r--r-- | plugins/CoreAdminHome/API.php | 11 | ||||
-rw-r--r-- | plugins/CoreAdminHome/Controller.php | 6 | ||||
-rw-r--r-- | plugins/CoreAdminHome/CustomLogo.php | 5 | ||||
-rw-r--r-- | plugins/CoreAdminHome/templates/generalSettings.twig | 3 | ||||
-rw-r--r-- | tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png | 4 |
6 files changed, 26 insertions, 6 deletions
diff --git a/config/global.ini.php b/config/global.ini.php index b161bb5822..6dfb458b5e 100755 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -653,6 +653,9 @@ overlay_following_pages_limit = 300 ; With this option, you can disable the framed mode of the Overlay plugin. Use it if your website contains a framebuster. overlay_disable_framed_mode = 0 +; Controls whether the user is able to upload a custom logo for their Matomo install +enable_custom_logo = 1 + ; By default we check whether the Custom logo is writable or not, before we display the Custom logo file uploader enable_custom_logo_check = 1 diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php index 9fd0ffaf25..ee97d75a67 100644 --- a/plugins/CoreAdminHome/API.php +++ b/plugins/CoreAdminHome/API.php @@ -109,10 +109,13 @@ class API extends \Piwik\Plugin\API Piwik::checkUserHasSuperUserAccess(); $customLogo = new CustomLogo(); - if ($useCustomLogo) { - $customLogo->enable(); - } else { - $customLogo->disable(); + + if ($customLogo->isCustomLogoFeatureEnabled()) { + if ($useCustomLogo) { + $customLogo->enable(); + } else { + $customLogo->disable(); + } } return true; diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 5e9c6b961d..51c03b89d2 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -105,6 +105,7 @@ class Controller extends ControllerAdmin $view->branding = array('use_custom_logo' => $logo->isEnabled()); $view->fileUploadEnabled = $logo->isFileUploadEnabled(); $view->logosWriteable = $logo->isCustomLogoWritable(); + $view->customLogoEnabled = $logo->isCustomLogoFeatureEnabled(); $view->hasUserLogo = CustomLogo::hasUserLogo(); $view->pathUserLogo = CustomLogo::getPathUserLogo(); $view->hasUserFavicon = CustomLogo::hasUserFavicon(); @@ -233,6 +234,11 @@ class Controller extends ControllerAdmin $this->checkTokenInUrl(); $logo = new CustomLogo(); + + if (! $logo->isCustomLogoFeatureEnabled()) { + return '0'; + } + $successLogo = $logo->copyUploadedLogoToFilesystem(); $successFavicon = $logo->copyUploadedFaviconToFilesystem(); diff --git a/plugins/CoreAdminHome/CustomLogo.php b/plugins/CoreAdminHome/CustomLogo.php index 9c2606cd20..e8dfffe3e6 100644 --- a/plugins/CoreAdminHome/CustomLogo.php +++ b/plugins/CoreAdminHome/CustomLogo.php @@ -85,6 +85,11 @@ class CustomLogo return ini_get('file_uploads') == 1; } + public function isCustomLogoFeatureEnabled() + { + return Config::getInstance()->General['enable_custom_logo'] != 0; + } + /** * @return bool */ diff --git a/plugins/CoreAdminHome/templates/generalSettings.twig b/plugins/CoreAdminHome/templates/generalSettings.twig index cc7d68c73f..84a47c88e5 100644 --- a/plugins/CoreAdminHome/templates/generalSettings.twig +++ b/plugins/CoreAdminHome/templates/generalSettings.twig @@ -141,6 +141,8 @@ </div> </div> {% endif %} + +{% if customLogoEnabled %} <div piwik-content-block content-title="{{ 'CoreAdminHome_BrandingSettings'|translate|e('html_attr') }}"> <div piwik-form ng-controller="BrandingController as brandingSettings"> @@ -215,6 +217,7 @@ <div onconfirm="brandingSettings.save()" saving="brandingSettings.isLoading" piwik-save-button></div> </div> </div> +{% endif %} {% if isDataPurgeSettingsEnabled %} <div piwik-content-block content-title="{{ 'PrivacyManager_DeleteDataSettings'|translate|e('html_attr') }}"> diff --git a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png index 6e389f2ff1..eabfffc87d 100644 --- a/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png +++ b/tests/UI/expected-screenshots/UIIntegrationTest_admin_diagnostics_configfile.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7dae96bb18a7b4e522cb5e7b30e50799150ecd373cc782d3f0dd383ed205829b -size 4394569 +oid sha256:5a9ea7f84c27cfdeaa536973e65725853df62cc0fffe31e907d05d13c21b2490 +size 4403487 |