diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-07-10 22:44:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-10 22:44:52 +0300 |
commit | 4b88aa24c9c85c45340ca854c812c21014d86dc2 (patch) | |
tree | e1f279d3d4faa5d3ac00a523dff360e9abec3fe0 /plugins/UserCountry | |
parent | a4c01fe919de7c5696e3c06d2c066085e08ec255 (diff) |
Disables some more feature if internet features are disabled (#13076)
* Disable GeoIP update tasks if no internet connection available
* Show GeoLocation Auto Updater UI only with enabled internet connection
* Throw exception if Marketplace is used without enabled internet features
* Hide Marketplace menu entry if internet is disabled
* Implements new plugin class method requiresInternetConnection, to automatically unloaded plugins if required
* Improve how plugins not working without internet connection are shown in plugin list
* Adds UI test
* typo 'whether'
Diffstat (limited to 'plugins/UserCountry')
-rw-r--r-- | plugins/UserCountry/Controller.php | 3 | ||||
-rw-r--r-- | plugins/UserCountry/GeoIPAutoUpdater.php | 6 | ||||
-rw-r--r-- | plugins/UserCountry/templates/adminIndex.twig | 86 |
3 files changed, 53 insertions, 42 deletions
diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php index 6097a5e0bf..bbb67d4020 100644 --- a/plugins/UserCountry/Controller.php +++ b/plugins/UserCountry/Controller.php @@ -19,6 +19,7 @@ use Piwik\Plugins\GeoIp2\GeoIP2AutoUpdater; use Piwik\Plugins\UserCountry\LocationProvider\GeoIp; use Piwik\Plugins\GeoIp2\LocationProvider\GeoIp2; use Piwik\Plugins\UserCountry\LocationProvider\DefaultProvider; +use Piwik\SettingsPiwik; use Piwik\View; /** @@ -79,6 +80,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin $view->showGeoIPUpdateSection = false; } + $view->isInternetEnabled = SettingsPiwik::isInternetEnabled(); + $this->setUpdaterManageVars($view); $this->setBasicVariablesView($view); $this->setBasicVariablesAdminView($view); diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php index 53b299a5c6..4f62fc7ec1 100644 --- a/plugins/UserCountry/GeoIPAutoUpdater.php +++ b/plugins/UserCountry/GeoIPAutoUpdater.php @@ -26,6 +26,7 @@ use Piwik\Scheduler\Task; use Piwik\Scheduler\Timetable; use Piwik\Scheduler\Schedule\Monthly; use Piwik\Scheduler\Schedule\Weekly; +use Piwik\SettingsPiwik; use Piwik\Unzip; /** @@ -63,6 +64,11 @@ class GeoIPAutoUpdater extends Task */ public function __construct() { + if (!SettingsPiwik::isInternetEnabled()) { + // no automatic updates possible if no internet available + return; + } + $schedulePeriodStr = self::getSchedulePeriod(); // created the scheduledtime instance, also, since GeoIP updates are done on tuesdays, diff --git a/plugins/UserCountry/templates/adminIndex.twig b/plugins/UserCountry/templates/adminIndex.twig index e8f155342c..ea26230f5f 100644 --- a/plugins/UserCountry/templates/adminIndex.twig +++ b/plugins/UserCountry/templates/adminIndex.twig @@ -98,7 +98,7 @@ </div> </div> -{% if geoIPLegacyLocUrl is defined and geoIPLegacyLocUrl %} +{% if geoIPLegacyLocUrl is defined and geoIPLegacyLocUrl and isInternetEnabled %} {# The text in this part is not translatable on purpose, as it will be removed again soon #} <div piwik-content-block content-title="Automatic Updates for GeoIP Legacy"> @@ -127,54 +127,56 @@ </div> {% endif %} -<div piwik-content-block - content-title="{% if not geoIPDatabasesInstalled %}{{ 'UserCountry_GeoIPDatabases'|translate|e('html_attr') }}{% else %}{{ 'UserCountry_SetupAutomaticUpdatesOfGeoIP'|translate|e('html_attr') }}{% endif %}" - id="geoip-db-mangement"> - - <div piwik-location-provider-updater - geoip-database-installed="{% if geoIPDatabasesInstalled %}1{% else %}0{% endif %}"> - - {% if showGeoIPUpdateSection %} - {% if not geoIPDatabasesInstalled %} - <div ng-show="!locationUpdater.geoipDatabaseInstalled"> - <div ng-show="locationUpdater.showPiwikNotManagingInfo"> - <h3>{{ 'UserCountry_PiwikNotManagingGeoIPDBs'|translate|e('html_attr') }}</h3> - <div id="manage-geoip-dbs"> - <div class="row" id="geoipdb-screen1"> - <div class="geoipdb-column-1 col s6"> - <p>{{ 'UserCountry_IWantToDownloadFreeGeoIP'|translate|raw }}</p> - </div> - <div class="geoipdb-column-2 col s6"> - <p>{{ 'UserCountry_IPurchasedGeoIPDBs'|translate('<a href="http://www.maxmind.com/en/geolocation_landing?rId=piwik">','</a>')|raw }}</p> - </div> - <div class="geoipdb-column-1 col s6"> - <input type="button" class="btn" - ng-click="locationUpdater.startDownloadFreeGeoIp()" - value="{{ 'General_GetStarted'|translate }}..."/> - </div> - <div class="geoipdb-column-2 col s6"> - <input type="button" class="btn" - ng-click="locationUpdater.startAutomaticUpdateGeoIp()" - value="{{ 'General_GetStarted'|translate }}..." id="start-automatic-update-geoip"/> +{% if isInternetEnabled %} + <div piwik-content-block + content-title="{% if not geoIPDatabasesInstalled %}{{ 'UserCountry_GeoIPDatabases'|translate|e('html_attr') }}{% else %}{{ 'UserCountry_SetupAutomaticUpdatesOfGeoIP'|translate|e('html_attr') }}{% endif %}" + id="geoip-db-mangement"> + + <div piwik-location-provider-updater + geoip-database-installed="{% if geoIPDatabasesInstalled %}1{% else %}0{% endif %}"> + + {% if showGeoIPUpdateSection %} + {% if not geoIPDatabasesInstalled %} + <div ng-show="!locationUpdater.geoipDatabaseInstalled"> + <div ng-show="locationUpdater.showPiwikNotManagingInfo"> + <h3>{{ 'UserCountry_PiwikNotManagingGeoIPDBs'|translate|e('html_attr') }}</h3> + <div id="manage-geoip-dbs"> + <div class="row" id="geoipdb-screen1"> + <div class="geoipdb-column-1 col s6"> + <p>{{ 'UserCountry_IWantToDownloadFreeGeoIP'|translate|raw }}</p> + </div> + <div class="geoipdb-column-2 col s6"> + <p>{{ 'UserCountry_IPurchasedGeoIPDBs'|translate('<a href="http://www.maxmind.com/en/geolocation_landing?rId=piwik">','</a>')|raw }}</p> + </div> + <div class="geoipdb-column-1 col s6"> + <input type="button" class="btn" + ng-click="locationUpdater.startDownloadFreeGeoIp()" + value="{{ 'General_GetStarted'|translate }}..."/> + </div> + <div class="geoipdb-column-2 col s6"> + <input type="button" class="btn" + ng-click="locationUpdater.startAutomaticUpdateGeoIp()" + value="{{ 'General_GetStarted'|translate }}..." id="start-automatic-update-geoip"/> + </div> </div> </div> </div> - </div> - <div id="geoipdb-screen2-download" ng-show="locationUpdater.showFreeDownload"> - <div piwik-progressbar - label="{{ ('UserCountry_DownloadingDb'|translate('<a href="'~geoLiteUrl~'">'~geoLiteFilename~'</a>') ~ '...')|json_encode }}" - progress="locationUpdater.progressFreeDownload"> + <div id="geoipdb-screen2-download" ng-show="locationUpdater.showFreeDownload"> + <div piwik-progressbar + label="{{ ('UserCountry_DownloadingDb'|translate('<a href="'~geoLiteUrl~'">'~geoLiteFilename~'</a>') ~ '...')|json_encode }}" + progress="locationUpdater.progressFreeDownload"> + </div> </div> </div> - </div> - {% endif %} + {% endif %} - {% include "@UserCountry/_updaterManage.twig" %} - {% else %} - <p class="form-description">{{ 'UserCountry_CannotSetupGeoIPAutoUpdating'|translate }}</p> - {% endif %} + {% include "@UserCountry/_updaterManage.twig" %} + {% else %} + <p class="form-description">{{ 'UserCountry_CannotSetupGeoIPAutoUpdating'|translate }}</p> + {% endif %} + </div> </div> -</div> +{% endif %} {% endblock %} |