/** * Checks if a datatable for a view is empty and if so, displays a message in the footer * telling users to configure GeoIP. */ protected function checkIfNoDataForGeoIpReport(ViewDataTable $view) { $view->config->filters[] = function ($dataTable) use($view) { // if there's only one row whose label is 'Unknown', display a message saying there's no data if ($dataTable->getRowsCount() == 1 && $dataTable->getFirstRow()->getColumn('label') == Piwik::translate('General_Unknown')) { $footerMessage = Piwik::translate('UserCountry_NoDataForGeoIPReport1'); $userCountry = new UserCountry(); // if GeoIP is working, don't display this part of the message if (!$userCountry->isGeoIPWorking()) { $params = array('module' => 'UserCountry', 'action' => 'adminIndex'); $footerMessage .= ' ' . Piwik::translate('UserCountry_NoDataForGeoIPReport2', array('<a target="_blank" href="' . Url::getCurrentQueryStringWithParametersModified($params) . '">', '</a>', '<a target="_blank" href="http://dev.maxmind.com/geoip/geolite?rId=piwik">', '</a>')); } else { $footerMessage .= ' ' . Piwik::translate('UserCountry_ToGeolocateOldVisits', array('<a target="_blank" href="http://piwik.org/faq/how-to/#faq_167">', '</a>')); } $view->config->show_footer_message = $footerMessage; } }; }
/** * Set the location provider * * @param string $providerId The ID of the provider to use eg 'default', 'geoip_php', ... * @throws Exception if ID is invalid */ public function setLocationProvider($providerId) { Piwik::checkUserHasSuperUserAccess(); if (!UserCountry::isGeoLocationAdminEnabled()) { throw new \Exception('Setting geo location has been disabled in config.'); } $provider = LocationProvider::setCurrentProvider($providerId); if ($provider === false) { throw new Exception("Invalid provider ID: '{$providerId}'."); } }
private function dieIfGeolocationAdminIsDisabled() { if (!UserCountry::isGeoLocationAdminEnabled()) { throw new \Exception('Geo location setting page has been disabled.'); } }
public function configureAdminMenu(MenuAdmin $menu) { if (UserCountry::isGeoLocationAdminEnabled() && Piwik::hasUserSuperUserAccess()) { $menu->addSettingsItem('UserCountry_Geolocation', $this->urlForAction('adminIndex'), $order = 9); } }
public function configureAdminMenu(MenuAdmin $menu) { if (UserCountry::isGeoLocationAdminEnabled()) { $menu->add('General_Settings', 'UserCountry_Geolocation', array('module' => 'UserCountry', 'action' => 'adminIndex'), Piwik::hasUserSuperUserAccess(), $order = 8); } }