summaryrefslogtreecommitdiff
path: root/plugins/piwik_analytics
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-04 14:17:22 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-04 14:17:22 (GMT)
commitc5fd4cd4a398a44b2c7de0332f12eb2d4114a70d (patch)
treeaed8c04559d22624ba96257b1576059dd2ac5a1a /plugins/piwik_analytics
parentd3d3a6e3232eb7acbebc9d879d695f3110ef5fc3 (diff)
downloadroundcubemail-plugins-kolab-c5fd4cd4a398a44b2c7de0332f12eb2d4114a70d.tar.gz
Add an improved version of piwik_analytics.
Diffstat (limited to 'plugins/piwik_analytics')
-rw-r--r--plugins/piwik_analytics/config.inc.php.dist44
-rw-r--r--plugins/piwik_analytics/piwik_analytics.php83
2 files changed, 127 insertions, 0 deletions
diff --git a/plugins/piwik_analytics/config.inc.php.dist b/plugins/piwik_analytics/config.inc.php.dist
new file mode 100644
index 0000000..7397e8f
--- /dev/null
+++ b/plugins/piwik_analytics/config.inc.php.dist
@@ -0,0 +1,44 @@
+<?php
+ /* piwik site id */
+ $rcmail_config['piwik_analytics_id'] = 4;
+
+ /* domain of your piwik installation */
+ $rcmail_config['piwik_analytics_url'] = 'noc.kolabsys.com/piwik/';
+
+ /* exclude private pages - analytics will works only for non-logged users */
+ $rcmail_config['piwik_analytics_privacy'] = false;
+
+ /* exclude the following templates */
+ $rcmail_config['piwik_analytics_exclude'] = Array(
+ );
+
+ // Possible templates:
+
+// "message",
+// "messagepreview",
+// "compose",
+// "editidentity",
+// "editcontact",
+// "showcontact"
+
+ // "message",
+ // "messagepart",
+ // "messagepreview",
+ // "messageerror",
+ // "showcontact",
+ // "addcontact",
+ // "editcontact",
+ // "importcontacts",
+ // "addressbook",
+ // "compose",
+ // "editidentity",
+ // "error",
+ // "identities",
+ // "login",
+ // "mail",
+ // "managefolders",
+ // "plugin",
+ // "settingsedit",
+ // "settings"
+
+?> \ No newline at end of file
diff --git a/plugins/piwik_analytics/piwik_analytics.php b/plugins/piwik_analytics/piwik_analytics.php
new file mode 100644
index 0000000..27a2603
--- /dev/null
+++ b/plugins/piwik_analytics/piwik_analytics.php
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ *
+ * piwik_analytics
+ *
+ * Bind piwik analytics script - based on: http://github.com/igloonet/roundcube_google_analytics
+ *
+ * @version 1.0 - 28. 11. 2010
+ * @author Florian Beer
+ * @modified_by Florian Beer
+ * @website http://blog.no-panic.at
+ * @licence GNU GPL
+ *
+ * Updated by Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>
+ *
+ **/
+
+class piwik_analytics extends rcube_plugin
+{
+ function init()
+ {
+ if (file_exists(dirname(__FILE__) . "/config.inc.php")) {
+ $this->load_config('config.inc.php');
+ } elseif (file_exists(dirname(__FILE__) . "/config.inc.php.dist")) {
+ $this->load_config('config.inc.php.dist');
+ } elseif (file_exists(dirname(__FILE__) . "/config/config.inc.php")) {
+ $this->load_config('config/config.inc.php');
+ } elseif (file_exists(dirname(__FILE__) . "/config/config.inc.php.dist")) {
+ $this->load_config('config/config.inc.php.dist');
+ /* } else {
+ error_log("Cannot find / load configuration for plugin piwik_analytics"); */
+ }
+
+ $this->add_hook('render_page', array($this, 'add_script'));
+ }
+
+ function add_script($args) {
+ $rcmail = rcmail::get_instance();
+
+ $exclude = $rcmail->config->get('piwik_analytics_exclude');
+
+ if (empty($exclude) || !is_array($exclude)) {
+ $exclude = Array();
+ }
+
+ if (isset($exclude[$args['template']])) {
+ return $args;
+ }
+
+ if ($rcmail->config->get('piwik_analytics_privacy', true)) {
+ if (!empty($_SESSION['user_id'])) {
+ return $args;
+ }
+ }
+
+ if (!$rcmail->config->get('piwik_analytics_url', false)) {
+ return $args;
+ }
+
+ $script = '
+<!-- Piwik -->
+<script type="text/javascript">
+ var pkBaseURL = (("https:" == document.location.protocol) ? "https://' . $rcmail->config->get('piwik_analytics_url') . '" : "http://' . $rcmail->config->get('piwik_analytics_url') . '");
+ document.write(unescape("%3Cscript src=\'" + pkBaseURL + "piwik.js\' type=\'text/javascript\'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+ try {
+ var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", ' . $rcmail->config->get('piwik_analytics_id') . ');
+ piwikTracker.trackPageView();
+ piwikTracker.enableLinkTracking();
+ } catch( err ) {}
+</script><noscript><p><img src="http://' . $rcmail->config->get('piwik_analytics_url') . '/piwik.php?idsite=' . $rcmail->config->get('piwik_analytics_id') . '" style="border:0" alt="" /></p></noscript>
+<!-- End Piwik Tag -->';
+
+ // add script to end of page
+ $rcmail->output->add_footer($script);
+
+ return $args;
+ }
+}
+
+?>