Skip to content
Extraits de code Groupes Projets
Valider 9c937d90 rédigé par mattab's avatar mattab
Parcourir les fichiers

Fixes #4484 Adding geolocation to system check page

parent 999ccb8a
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -26,6 +26,7 @@ use Piwik\Http;
use Piwik\Piwik;
use Piwik\Plugins\LanguagesManager\LanguagesManager;
use Piwik\Plugins\SitesManager\API as APISitesManager;
use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\Plugins\UsersManager\API as APIUsersManager;
use Piwik\ProxyHeaders;
use Piwik\Session\SessionNamespace;
......@@ -982,12 +983,36 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
* is stored in $result['load_data_infile_available']. The error message is
* stored in $result['load_data_infile_error'].
*
* - Check whether geo location is setup correctly
*
* @return array
*/
public static function performAdminPageOnlySystemCheck()
{
$result = array();
self::checkLoadDataInfile($result);
self::checkGeolocation($result);
return $result;
}
private static function checkGeolocation(&$result)
{
$currentProviderId = LocationProvider::getCurrentProviderId();
$allProviders = LocationProvider::getAllProviderInfo();
$isRecommendedProvider = in_array($currentProviderId, array( LocationProvider\GeoIp\Php::ID, $currentProviderId == LocationProvider\GeoIp\Pecl::ID));
$isProviderInstalled = ($allProviders[$currentProviderId]['status'] == LocationProvider::INSTALLED);
$result['geolocation_using_non_recommended'] = $result['geolocation_ok'] = false;
if ($isRecommendedProvider && $isProviderInstalled) {
$result['geolocation_ok'] = true;
} elseif ($isProviderInstalled) {
$result['geolocation_using_non_recommended'] = true;
}
}
private static function checkLoadDataInfile(&$result)
{
// check if LOAD DATA INFILE works
$optionTable = Common::prefixTable('option');
$testOptionNames = array('test_system_check1', 'test_system_check2');
......@@ -998,8 +1023,8 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
$optionTable,
array('option_name', 'option_value'),
array(
array($testOptionNames[0], '1'),
array($testOptionNames[1], '2'),
array($testOptionNames[0], '1'),
array($testOptionNames[1], '2'),
),
$throwException = true
);
......@@ -1009,7 +1034,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
// delete the temporary rows that were created
Db::exec("DELETE FROM `$optionTable` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')");
return $result;
}
}
......@@ -285,6 +285,25 @@
{% endif %}
</td>
</tr>
<tr>
<td class="label">{{ 'UserCountry_Geolocation'|translate }}</td>
<td>
{% if infos.extra.geolocation_ok %}
{{ ok }} {{ 'General_Ok'|translate }}
<br/>
{% elseif infos.extra.geolocation_using_non_recommended %}
{{ warning }}
<span class="warn">Geolocation works, but you are not using one of the recommended providers.
{{ 'UserCountry_GeoIpLocationProviderDesc_ServerBased2'|translate('<a href="http://piwik.org/docs/geo-locate/" target="_blank">', '', '', '</a>')|raw }}</span>
<br/>
{% else %}
{{ warning }}
<span class="warn">{{ 'UserCountry_DefaultLocationProviderDesc1'|translate }}
{{ 'UserCountry_DefaultLocationProviderDesc2'|translate('<a href="http://piwik.org/docs/geo-locate/" target="_blank">', '', '', '</a>')|raw }} </span>
</span>
{% endif %}
</td>
</tr>
{% if infos.general_infos.assume_secure_protocol is defined %}
<tr>
<td class="label">{{ 'Installation_SystemCheckSecureProtocol'|translate }}</td>
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter