1<?php 2/** 3 * DokuWiki plugin for piwik2 4 * 5 * Generates the inserted js/html code that is inserted into dom (HTML-HEAD) 6 * 7 * @license GPLv3 (http://www.gnu.org/licenses/gpl.html) 8 * @author Marcel Lange <info@ask-sheldon.con> 9 */ 10require_once(DOKU_INC . 'inc/auth.php'); 11 12 13/** 14 * Injects the necessary trackingcodes for piwik tracking (v2.x) into DOM 15 * like specified in the plugin manager fields 16 */ 17function piwik_code() 18{ 19 global $conf; 20 21 if (isset($conf['plugin']['piwik2']['js_tracking_code']) 22 || (isset($conf['plugin']['piwik2']['img_tracking_code'])) 23 ) { 24 // Config does not contain keys if they are default; 25 // so check whether they are set & to non-default value 26 27 // default 0, so check if it's not set or 0 28 if (!isset($conf['plugin']['piwik2']['track_admin_user']) 29 || $conf['plugin']['piwik2']['track_admin_user'] == 0 30 ) { 31 if (isset($_SERVER['REMOTE_USER']) && auth_isadmin()) { 32 return; 33 } 34 } 35 36 // default 1, so check if it's set and 0 37 if (isset($conf['plugin']['piwik2']['track_user']) 38 && $conf['plugin']['piwik2']['track_user'] == 0 39 ) { 40 if (isset($_SERVER['REMOTE_USER'])) { 41 return; 42 } 43 } 44 45 //changes made by Marcel Lange (info@bravehartk2.de) 46 $trackingCode = (isset($conf['plugin']['piwik2']['js_tracking_code'])) 47 ? $conf['plugin']['piwik2']['js_tracking_code'] : ''; 48 if (isset($conf['plugin']['piwik2']['use_img_tracking']) 49 && $conf['plugin']['piwik2']['use_img_tracking'] == 1 50 && isset($conf['plugin']['piwik2']['img_tracking_code']) 51 ) { 52 $trackingCode = $conf['plugin']['piwik2']['img_tracking_code']; 53 } 54 ptln($trackingCode); 55 } else { 56 // Show configuration tip for admin 57 if (isset($_SERVER['REMOTE_USER']) && auth_isadmin()) { 58 msg('Please configure the piwik2 plugin'); 59 } 60 } 61} 62