Parcourir la source

[up] Piwik 7.x-2.10

opi il y a 7 ans
Parent
commit
67c8820980

+ 2 - 2
sites/all/modules/piwik/README.txt

@@ -48,8 +48,8 @@ Name: User ids
 Value: [current-user:piwik-role-ids]
 Scope: Visitor
 
-More details about custom variables can be found in the Piwik API documentation at
-http://piwik.org/docs/javascript-tracking/#toc-custom-variables.
+More details about custom variables can be found in the Piwik API documentation
+at http://piwik.org/docs/javascript-tracking/#toc-custom-variables.
 
 
 Advanced Settings

+ 3 - 3
sites/all/modules/piwik/piwik.info

@@ -5,9 +5,9 @@ package = Statistics
 configure = admin/config/system/piwik
 files[] = piwik.test
 test_dependencies[] = token
-; Information added by Drupal.org packaging script on 2016-08-09
-version = "7.x-2.9"
+; Information added by Drupal.org packaging script on 2017-11-11
+version = "7.x-2.10"
 core = "7.x"
 project = "piwik"
-datestamp = "1470779970"
+datestamp = "1510404811"
 

+ 19 - 0
sites/all/modules/piwik/piwik.module

@@ -188,6 +188,18 @@ function piwik_page_alter(&$page) {
       $set_document_title = '"404/URL = " + encodeURIComponent(document.location.pathname+document.location.search) + "/From = " + encodeURIComponent(document.referrer)';
     }
 
+    // #2693595: User has entered an invalid login and clicked on forgot
+    // password link. This link contains the username or email address and may
+    // get send to Google if we do not override it. Override only if 'name'
+    // query param exists. Last custom url condition, this need to win.
+    //
+    // URLs to protect are:
+    // - user/password?name=username
+    // - user/password?name=foo@example.com
+    if (arg(0) == 'user' && arg(1) == 'password' && array_key_exists('name', drupal_get_query_parameters())) {
+      $set_custom_url = drupal_json_encode(url('user/password'));
+    }
+
     // Add custom variables.
     $piwik_custom_vars = variable_get('piwik_custom_var', array());
     $custom_variable = '';
@@ -486,6 +498,10 @@ function _piwik_cache($location, $sync_cached_file = FALSE) {
         if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
           // Save updated tracking code file to disk.
           file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+          // Based on Drupal Core drupal_build_css_cache().
+          if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+            file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+          }
           watchdog('piwik', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
 
           // Change query-strings on css/js files to enforce reload for all users.
@@ -498,6 +514,9 @@ function _piwik_cache($location, $sync_cached_file = FALSE) {
           // There is no need to flush JS here as core refreshes JS caches
           // automatically, if new files are added.
           file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
+          if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
+            file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
+          }
           watchdog('piwik', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
 
           // Return the local JS file path.

+ 49 - 2
sites/all/modules/piwik/piwik.test

@@ -109,11 +109,11 @@ class PiwikBasicTest extends DrupalWebTestCase {
 
     // Test whether 403 forbidden tracking code is shown if user has no access.
     $this->drupalGet('admin');
-    $this->assertRaw('"403/URL = "', '[testPiwikPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
+    $this->assertRaw('403/URL = "', '[testPiwikPageVisibility]: 403 Forbidden tracking code shown if user has no access.');
 
     // Test whether 404 not found tracking code is shown on non-existent pages.
     $this->drupalGet($this->randomName(64));
-    $this->assertRaw('"404/URL = "', '[testPiwikPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
+    $this->assertRaw('404/URL = "', '[testPiwikPageVisibility]: 404 Not Found tracking code shown on non-existent page.');
   }
 
   function testPiwikTrackingCode() {
@@ -310,6 +310,53 @@ class PiwikCustomVariablesTest extends DrupalWebTestCase {
   }
 }
 
+/**
+ * Test custom url functionality of Google Analytics module.
+ */
+class PiwikCustomUrls extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Piwik custom url tests',
+      'description' => 'Test custom url functionality of Piwik module.',
+      'group' => 'Piwik',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('piwik');
+
+    $permissions = array(
+      'access administration pages',
+      'administer piwik',
+    );
+
+    // User to set up piwik.
+    $this->admin_user = $this->drupalCreateUser($permissions);
+  }
+
+  /**
+   * Tests if user password page urls are overridden.
+   */
+  public function testPiwikUserPasswordPage() {
+    $base_path = base_path();
+    $ua_code = '1';
+    variable_set('piwik_site_id', $ua_code);
+    variable_get('piwik_url_http', 'http://example.com/piwik/');
+    variable_get('piwik_url_https', 'https://example.com/piwik/');
+
+    $this->drupalGet('user/password', array('query' => array('name' => 'foo')));
+    $this->assertRaw('_paq.push(["setCustomUrl", ' . drupal_json_encode(url('user/password')) . ']);');
+
+    $this->drupalGet('user/password', array('query' => array('name' => 'foo@example.com')));
+    $this->assertRaw('_paq.push(["setCustomUrl", ' . drupal_json_encode(url('user/password')) . ']);');
+
+    $this->drupalGet('user/password');
+    $this->assertNoRaw('_paq.push(["setCustomUrl", "', '[testPiwikCustomUrls]: Custom url not set.');
+  }
+
+}
+
 class PiwikStatusMessagesTest extends DrupalWebTestCase {
 
   public static function getInfo() {