Skip to content

Commit 3399721

Browse files
committed
[imp] allow users to accept & configure stats sending
1 parent 25abae2 commit 3399721

File tree

5 files changed

+468
-54
lines changed

5 files changed

+468
-54
lines changed

administrator/language/en-GB/en-GB.plg_system_stats.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44
; Note : All ini files need to be saved as UTF-8
55

66
PLG_SYSTEM_STATS="System - Joomla! Statistics"
7+
PLG_SYSTEM_STATS_BTN_NEVER_SEND="Never"
8+
PLG_SYSTEM_STATS_BTN_SEND_ALWAYS="Always"
9+
PLG_SYSTEM_STATS_BTN_SEND_NOW="Once"
10+
PLG_SYSTEM_STATS_DEBUG_DESC="Enable debug (stats sent every single time)"
11+
PLG_SYSTEM_STATS_DEBUG_LABEL="Debug"
12+
PLG_SYSTEM_STATS_INTERVAL_DESC="Stats will be sent each X hours. Default is 12"
13+
PLG_SYSTEM_STATS_INTERVAL_LABEL="Interval (hours)"
14+
PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE="Joomla! would like your permission collect some basic statistics."
15+
PLG_SYSTEM_STATS_MODE_DESC="Selec the way you want that statistics are sent"
16+
PLG_SYSTEM_STATS_MODE_LABEL="Mode"
17+
PLG_SYSTEM_STATS_MODE_OPTION_ALWAYS_SEND="Always send"
18+
PLG_SYSTEM_STATS_MODE_OPTION_NEVER_SEND="Never send"
19+
PLG_SYSTEM_STATS_MODE_OPTION_ON_DEMAND="On demand"
20+
PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA="Enable Joomla Statistics?"
21+
PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA="In order to better understand our install base and end user environments, this plugin has been created to send those stats back to a Joomla controlled central server. No identifying data is captured at any point. You can change this settings later from Plugins > System Joomla! Statistics."
22+
PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT="Click here to see which information will be sent."
723
PLG_SYSTEM_STATS_RESET_UNIQUE_ID="Reset Unique Id"
824
PLG_SYSTEM_STATS_UNIQUE_ID_DESC="An identifier that allows the Joomla! project to count unique installs of the plugin. This is sent with the statistics back to the server."
925
PLG_SYSTEM_STATS_UNIQUE_ID_LABEL="Unique ID"

media/plg_system_stats/js/stats.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
(function ($) {
2+
$(document).ready(function () {
3+
var ajaxData = {
4+
'option' : 'com_ajax',
5+
'group' : 'system',
6+
'plugin' : 'renderStatsMessage',
7+
'format' : 'json'
8+
},
9+
messageContainer = $('#system-message-container');
10+
11+
/**
12+
* Initialise events for the message container
13+
*
14+
* @return void
15+
*/
16+
function initStatsEvents()
17+
{
18+
var globalContainer = messageContainer.find('.js-pstats-alert'),
19+
detailsContainer = messageContainer.find('.js-pstats-data-details');
20+
21+
// Show details about the information being sent
22+
messageContainer.on('click', '.js-pstats-btn-details', function(e){
23+
detailsContainer.toggle(200);
24+
e.preventDefault();
25+
});
26+
27+
// Always allow
28+
messageContainer.on('click', '.js-pstats-btn-allow-always', function(e){
29+
30+
// Remove message
31+
globalContainer.hide(200);
32+
detailsContainer.remove();
33+
ajaxData.plugin = 'sendAlways';
34+
35+
$.getJSON('index.php', ajaxData, function(response){
36+
37+
});
38+
e.preventDefault();
39+
});
40+
41+
// Allow once
42+
messageContainer.on('click', '.js-pstats-btn-allow-once', function(e){
43+
44+
// Remove message
45+
globalContainer.hide(200);
46+
detailsContainer.remove();
47+
48+
ajaxData.plugin = 'sendOnce';
49+
50+
$.getJSON('index.php', ajaxData, function(response){
51+
52+
});
53+
e.preventDefault();
54+
});
55+
56+
// Never allow
57+
messageContainer.on('click', '.js-pstats-btn-allow-never', function(e){
58+
59+
// Remove message
60+
globalContainer.hide(200);
61+
detailsContainer.remove();
62+
63+
ajaxData.plugin = 'sendNever';
64+
65+
$.getJSON('index.php', ajaxData, function(response){
66+
});
67+
e.preventDefault();
68+
});
69+
}
70+
71+
ajaxData.plugin = 'renderStatsMessage';
72+
73+
$.getJSON('index.php', ajaxData, function(response){
74+
messageContainer
75+
.append(response.data[0].html)
76+
.find('.js-pstats-alert').show(200);
77+
78+
initStatsEvents();
79+
});
80+
});
81+
})(jQuery);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* @package Joomla.Plugin
4+
* @subpackage Layout
5+
*
6+
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
7+
* @license GNU General Public License version 2 or later; see LICENSE.txt
8+
*/
9+
10+
defined('JPATH_BASE') or die;
11+
12+
extract($displayData);
13+
14+
/**
15+
* Layout variables
16+
* -----------------
17+
* @var PlgSystemStats $plugin Plugin rendering this layout
18+
* @var \Joomla\Registry\Registry $pluginParams Plugin parameters
19+
* @var array $statsData Array containing the data that will be sent to the stats server
20+
*/
21+
?>
22+
<div class="alert alert-info js-pstats-alert" style="display:none;">
23+
<button data-dismiss="alert" class="close" type="button">×</button>
24+
<h2><?php echo JText::_('PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE'); ?></h2>
25+
<p><?php echo JText::_('PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA'); ?> <a href="#" class="js-pstats-btn-details"><?php echo JText::_('PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT'); ?></a></p>
26+
<dl class="dl-horizontal js-pstats-data-details" style="display:none;">
27+
<?php foreach ($statsData as $key => $value) : ?>
28+
<dt><?php echo $key; ?></dt>
29+
<dd><?php echo $value; ?></dd>
30+
<?php endforeach; ?>
31+
</dl>
32+
<p><?php echo JText::_('PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA'); ?></p>
33+
<p class="actions">
34+
<a href="#" class="btn btn-default js-pstats-btn-allow-always"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_ALWAYS'); ?></a>
35+
<a href="#" class="btn btn-default js-pstats-btn-allow-once"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_NOW'); ?></a>
36+
<a href="#" class="btn btn-default js-pstats-btn-allow-never"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_NEVER_SEND'); ?></a>
37+
</p>
38+
</div>

0 commit comments

Comments
 (0)