Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New setting show_update_notification_to_superusers_only makes it possible to hide update notifications for users except for super users #12224

Merged
merged 6 commits into from Nov 13, 2017
Merged
4 changes: 4 additions & 0 deletions config/global.ini.php
Expand Up @@ -456,6 +456,10 @@
; the page will automatically refresh every 5 minutes. Set to 0 to disable automatic refresh
multisites_refresh_after_seconds = 300

; by default, an update notification for a new version of Piwik is shown to every user. Set to 1 if only
; the superusers should see the notification.
show_update_notification_to_superusers_only = 0

; Set to 1 if you're using https on your Piwik server and Piwik can't detect it,
; e.g., a reverse proxy using https-to-http, or a web server that doesn't
; set the HTTPS environment variable.
Expand Down
10 changes: 10 additions & 0 deletions core/SettingsPiwik.php
Expand Up @@ -45,6 +45,16 @@ public static function isUserCredentialsSanityCheckEnabled()
return Config::getInstance()->General['disable_checks_usernames_attributes'] == 0;
}

/**
* Should Piwik show the update notification to superusers only?
*
* @return bool True if show to superusers only; false otherwise
*/
public static function isShowUpdateNotificationToSuperUsersOnlyEnabled()
{
return Config::getInstance()->General['show_update_notification_to_superusers_only'] == 1;
}

/**
* Returns every stored segment to pre-process for each site during cron archiving.
*
Expand Down
1 change: 1 addition & 0 deletions core/View.php
Expand Up @@ -241,6 +241,7 @@ public function render()
$this->userIsAnonymous = Piwik::isUserIsAnonymous();
$this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
$this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
$this->showUpdateNotificationToUser = !SettingsPiwik::isShowUpdateNotificationToSuperUsersOnlyEnabled() || Piwik::hasUserSuperUserAccess();
$this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
$this->isWidget = Common::getRequestVar('widget', 0, 'int');
$this->isMultiServerEnvironment = SettingsPiwik::isMultiServerEnvironment();
Expand Down
2 changes: 1 addition & 1 deletion plugins/CoreHome/templates/_headerMessage.twig
Expand Up @@ -10,7 +10,7 @@
</span>
{% endset %}

{% if (latest_version_available and hasSomeViewAccess and not isUserIsAnonymous) or (isSuperUser and isAdminArea is defined and isAdminArea) %}
{% if (latest_version_available and hasSomeViewAccess and not isUserIsAnonymous and showUpdateNotificationToUser) or (isSuperUser and isAdminArea is defined and isAdminArea) %}
<div piwik-expand-on-hover
id="header_message"
class="piwikSelector borderedControl {% if not latest_version_available %}header_info{% else %}{% endif %} piwikTopControl {% if latest_version_available %}update_available{% endif %}"
Expand Down