Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-26 10:30:54 +0400
committerBenaka Moorthi <benaka.moorthi@gmail.com>2013-09-26 10:30:54 +0400
commit30002d635b7569d11c9e14675a69d5169c514064 (patch)
treeb69e9271544944f52ccfd5e5a596de4bd5e4e692 /core
parent3433a3d353a86c4c001693dedeea102c06b4c19e (diff)
parent675d8b441aa0138d0ed557115d9d0efcc99c4bb2 (diff)
Merge branch 'master' into log
Diffstat (limited to 'core')
-rw-r--r--core/Access.php2
-rw-r--r--core/Auth.php72
-rw-r--r--core/Db.php8
-rw-r--r--core/Tracker/Cache.php3
-rw-r--r--core/Tracker/Request.php21
-rw-r--r--core/Tracker/Visit.php81
-rw-r--r--core/ViewDataTable.php7
-rw-r--r--core/ViewDataTable/Properties.php10
8 files changed, 86 insertions, 118 deletions
diff --git a/core/Access.php b/core/Access.php
index 303e5d638d..6e13db6579 100644
--- a/core/Access.php
+++ b/core/Access.php
@@ -162,7 +162,7 @@ class Access
// access = array ( idsite => accessIdSite, idsite2 => accessIdSite2)
$result = $this->auth->authenticate();
- if (!$result->isValid()) {
+ if (!$result->wasAuthenticationSuccessful()) {
return false;
}
$this->login = $result->getIdentity();
diff --git a/core/Auth.php b/core/Auth.php
index 67edbbabaf..30401d0e04 100644
--- a/core/Auth.php
+++ b/core/Auth.php
@@ -39,35 +39,57 @@ interface Auth
*
* @package Piwik
* @subpackage Piwik_Auth
- * @see Zend_AuthResult, libs/Zend/Auth/Result.php
- * @link http://framework.zend.com/manual/en/zend.auth.html
*/
-class AuthResult extends \Zend_Auth_Result
+class AuthResult
{
+ const FAILURE = 0;
+ const SUCCESS = 1;
+ const SUCCESS_SUPERUSER_AUTH_CODE = 42;
+
/**
* token_auth parameter used to authenticate in the API
*
* @var string
*/
- protected $_token_auth = null;
+ protected $tokenAuth = null;
- const SUCCESS_SUPERUSER_AUTH_CODE = 42;
+ /**
+ * The login used to authenticate.
+ *
+ * @var string
+ */
+ protected $login = null;
+
+ /**
+ * The authentication result code. Can be self::FAILURE, self::SUCCESS, or
+ * self::SUCCESS_SUPERUSER_AUTH_CODE.
+ *
+ * @var int
+ */
+ protected $code = null;
/**
* Constructor for AuthResult
*
* @param int $code
* @param string $login identity
- * @param string $token_auth
- * @param array $messages
+ * @param string $tokenAuth
+ */
+ public function __construct($code, $login, $tokenAuth)
+ {
+ $this->code = (int)$code;
+ $this->login = $login;
+ $this->tokenAuth = $tokenAuth;
+ }
+
+ /**
+ * Returns the login used to authenticate.
+ *
+ * @return string
*/
- public function __construct($code, $login, $token_auth, array $messages = array())
+ public function getIdentity()
{
- // AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, AuthResult::SUCCESS, AuthResult::FAILURE
- $this->_code = (int)$code;
- $this->_identity = $login;
- $this->_messages = $messages;
- $this->_token_auth = $token_auth;
+ return $this->login;
}
/**
@@ -77,6 +99,26 @@ class AuthResult extends \Zend_Auth_Result
*/
public function getTokenAuth()
{
- return $this->_token_auth;
+ return $this->tokenAuth;
}
-}
+
+ /**
+ * Returns the authentication result code.
+ *
+ * @return int
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Returns true if this result was successfully authentication.
+ *
+ * @return bool
+ */
+ public function wasAuthenticationSuccessful()
+ {
+ return $this->code > self::FAILURE;
+ }
+} \ No newline at end of file
diff --git a/core/Db.php b/core/Db.php
index ef2f756f9d..a8369943ba 100644
--- a/core/Db.php
+++ b/core/Db.php
@@ -156,11 +156,15 @@ class Db
* @param string $where The where clause of the query. Must include the WHERE keyword.
* @param int $maxRowsPerQuery The maximum number of rows to delete per DELETE query.
* @param array $parameters Parameters to bind in the query.
+ * @param string $primaryKey Name of primary key to sort by.
* @return int The total number of rows deleted.
*/
- static public function deleteAllRows($table, $where, $maxRowsPerQuery = 100000, $parameters = array())
+ static public function deleteAllRows($table, $where, $orderBy, $maxRowsPerQuery = 100000, $parameters = array())
{
- $sql = "DELETE FROM $table $where LIMIT " . (int)$maxRowsPerQuery;
+ $sql = "DELETE FROM $table
+ $where
+ ORDER BY $orderBy ASC
+ LIMIT " . (int)$maxRowsPerQuery;
// delete rows w/ a limit
$totalRowsDeleted = 0;
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index 7319818e41..2acf983c78 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -15,7 +15,6 @@ use Piwik\Config;
use Piwik\Piwik;
use Piwik\CacheFile;
use Piwik\Tracker;
-use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Simple cache mechanism used in Tracker to avoid requesting settings from mysql on every request
@@ -104,8 +103,8 @@ class Cache
$cacheContent = array(
'isBrowserTriggerEnabled' => Rules::isBrowserTriggerEnabled(),
'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'),
- 'currentLocationProviderId' => LocationProvider::getCurrentProviderId(),
);
+ Piwik_PostEvent('Tracker.setTrackerCacheGeneral', array(&$cacheContent));
self::setCacheGeneral($cacheContent);
return $cacheContent;
}
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index 0687090245..e81838b233 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -8,7 +8,6 @@ use Piwik\Cookie;
use Piwik\IP;
use Piwik\Tracker;
use Piwik\Tracker\Cache;
-use Piwik\Plugins\UserCountry\LocationProvider;
/**
* Piwik - Open source web analytics
@@ -483,29 +482,29 @@ class Request
return $this->forcedVisitorId;
}
- public function enrichLocation($location)
+ public function overrideLocation(&$visitorInfo)
{
if (!$this->isAuthenticated()) {
- return $location;
+ return;
}
// check for location override query parameters (ie, lat, long, country, region, city)
static $locationOverrideParams = array(
- 'country' => array('string', LocationProvider::COUNTRY_CODE_KEY),
- 'region' => array('string', LocationProvider::REGION_CODE_KEY),
- 'city' => array('string', LocationProvider::CITY_NAME_KEY),
- 'lat' => array('float', LocationProvider::LATITUDE_KEY),
- 'long' => array('float', LocationProvider::LONGITUDE_KEY),
+ 'country' => array('string', 'location_country'),
+ 'region' => array('string', 'location_region'),
+ 'city' => array('string', 'location_city'),
+ 'lat' => array('float', 'location_latitude'),
+ 'long' => array('float', 'location_longitude'),
);
foreach ($locationOverrideParams as $queryParamName => $info) {
- list($type, $locationResultKey) = $info;
+ list($type, $visitorInfoKey) = $info;
$value = Common::getRequestVar($queryParamName, false, $type, $this->params);
if (!empty($value)) {
- $location[$locationResultKey] = $value;
+ $visitorInfo[$visitorInfoKey] = $value;
}
}
- return $location;
+ return;
}
public function getPlugins()
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php
index 74ab001bae..3f3d7588ec 100644
--- a/core/Tracker/Visit.php
+++ b/core/Tracker/Visit.php
@@ -39,7 +39,6 @@ use Piwik\Tracker\Request;
use Piwik\Tracker\Referrer;
use Exception;
use Piwik\Tracker\VisitExcluded;
-use Piwik\Plugins\UserCountry\LocationProvider;
use UserAgentParser;
/**
@@ -477,10 +476,6 @@ class Visit implements Tracker\VisitInterface
'location_browser_lang' => $userInfo['location_browser_lang'],
);
- // add optional location components
- $location = $this->getVisitorLocation($userInfo['location_browser_lang']);
- $this->updateVisitInfoWithLocation($location);
-
// Add Custom variable key,value to the visitor array
$this->visitorInfo = array_merge($this->visitorInfo, $this->visitorCustomVariables);
@@ -489,6 +484,8 @@ class Visit implements Tracker\VisitInterface
);
Piwik_PostEvent('Tracker.newVisitorInformation', array(&$this->visitorInfo, $extraInfo));
+ $this->request->overrideLocation($this->visitorInfo);
+
$debugVisitInfo = $this->visitorInfo;
$debugVisitInfo['idvisitor'] = bin2hex($debugVisitInfo['idvisitor']);
$debugVisitInfo['config_id'] = bin2hex($debugVisitInfo['config_id']);
@@ -511,77 +508,6 @@ class Visit implements Tracker\VisitInterface
}
/**
- * Returns the location of the visitor, based on the visitor's IP and browser language.
- *
- * @param string $browserLang
- * @return array See LocationProvider::getLocation for more info.
- */
- private function getVisitorLocation($browserLang)
- {
- $location = array();
- $userInfo = array('lang' => $browserLang, 'ip' => IP::N2P($this->getVisitorIp()));
- Piwik_PostEvent('Tracker.getVisitorLocation', array(&$location, $userInfo));
-
- $location = $this->request->enrichLocation($location);
-
- if (empty($location['country_code'])) // sanity check
- {
- $location['country_code'] = self::UNKNOWN_CODE;
- }
-
- return $location;
- }
-
- /**
- * Sets visitor info array with location info.
- *
- * @param array $location See LocationProvider::getLocation for more info.
- */
- private function updateVisitInfoWithLocation($location)
- {
- static $logVisitToLowerLocationMapping = array(
- 'location_country' => LocationProvider::COUNTRY_CODE_KEY,
- );
-
- static $logVisitToLocationMapping = array(
- 'location_region' => LocationProvider::REGION_CODE_KEY,
- 'location_city' => LocationProvider::CITY_NAME_KEY,
- 'location_latitude' => LocationProvider::LATITUDE_KEY,
- 'location_longitude' => LocationProvider::LONGITUDE_KEY,
- );
-
- foreach ($logVisitToLowerLocationMapping as $column => $locationKey) {
- if (!empty($location[$locationKey])) {
- $this->visitorInfo[$column] = strtolower($location[$locationKey]);
- }
- }
-
- foreach ($logVisitToLocationMapping as $column => $locationKey) {
- if (!empty($location[$locationKey])) {
- $this->visitorInfo[$column] = $location[$locationKey];
- }
- }
-
- // if the location has provider/organization info, set it
- if (!empty($location[LocationProvider::ISP_KEY])) {
- $providerValue = $location[LocationProvider::ISP_KEY];
-
- // if the org is set and not the same as the isp, add it to the provider value
- if (!empty($location[LocationProvider::ORG_KEY])
- && $location[LocationProvider::ORG_KEY] != $providerValue
- ) {
- $providerValue .= ' - ' . $location[LocationProvider::ORG_KEY];
- }
- } else if (!empty($location[LocationProvider::ORG_KEY])) {
- $providerValue = $location[LocationProvider::ORG_KEY];
- }
-
- if (isset($providerValue)) {
- $this->visitorInfo['location_provider'] = $providerValue;
- }
- }
-
- /**
* Save new visitor information to log_visit table.
* Provides pre- and post- event hooks (Tracker.saveVisitorInformation and Tracker.saveVisitorInformation.end) for plugins
*/
@@ -921,7 +847,6 @@ class Visit implements Tracker\VisitInterface
$os,
$browserName,
$browserVersion,
- $resolution,
$plugin_Flash,
$plugin_Java,
$plugin_Director,
@@ -1036,7 +961,7 @@ class Visit implements Tracker\VisitInterface
* @param $browserLang
* @return string
*/
- protected function getConfigHash($os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
+ protected function getConfigHash($os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
$hash = md5($os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang, $raw_output = true);
return Common::substr($hash, 0, Tracker::LENGTH_BINARY_ID);
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index a74a6c360f..b7c37d9206 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -1276,6 +1276,13 @@ class ViewDataTable
$this->getPropertyFromQueryParam($name, $default);
}
}
+
+ // handle special 'columns' query parameter
+ $columns = Common::getRequestVar('columns', false);
+ if ($columns !== false) {
+ $this->columns_to_display = Piwik::getArrayFromApiParameter($columns);
+ array_unshift($this->columns_to_display, 'label');
+ }
}
private function getPropertyFromQueryParam($name, $defaultValue)
diff --git a/core/ViewDataTable/Properties.php b/core/ViewDataTable/Properties.php
index 310c09f3d6..bcb8286c1a 100644
--- a/core/ViewDataTable/Properties.php
+++ b/core/ViewDataTable/Properties.php
@@ -693,7 +693,7 @@ class Properties
*/
public static function getDefaultPropertyValues()
{
- $result = array(
+ return array(
'footer_icons' => false,
'show_visualization_only' => false,
'datatable_js_type' => 'DataTable',
@@ -749,14 +749,6 @@ class Properties
'columns_to_display' => array(),
'y_axis_unit' => false
);
-
- $columns = Common::getRequestVar('columns', false);
- if ($columns !== false) {
- $result['columns_to_display'] = Piwik::getArrayFromApiParameter($columns);
- array_unshift($result['columns_to_display'], 'label');
- }
-
- return $result;
}
private static function getFlippedClassConstantMap($klass)