Skip to content

Commit

Permalink
Merge pull request #2 from phproberto/rdeutz-8346
Browse files Browse the repository at this point in the history
Allow users to accept & configure stats sending
  • Loading branch information
rdeutz committed Nov 10, 2015
2 parents 25abae2 + 67fe07a commit a0f977c
Show file tree
Hide file tree
Showing 5 changed files with 497 additions and 61 deletions.
18 changes: 16 additions & 2 deletions administrator/language/en-GB/en-GB.plg_system_stats.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,23 @@
; Note : All ini files need to be saved as UTF-8

PLG_SYSTEM_STATS="System - Joomla! Statistics"
PLG_SYSTEM_STATS_BTN_NEVER_SEND="Never"
PLG_SYSTEM_STATS_BTN_SEND_ALWAYS="Always"
PLG_SYSTEM_STATS_BTN_SEND_NOW="Once"
PLG_SYSTEM_STATS_DEBUG_DESC="Enable debug for testing purposes. Stats sent every page load."
PLG_SYSTEM_STATS_DEBUG_LABEL="Debug"
PLG_SYSTEM_STATS_INTERVAL_DESC="Stats will be sent each X hours. Default is 12"
PLG_SYSTEM_STATS_INTERVAL_LABEL="Interval (hours)"
PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE="Joomla! would like your permission collect some basic statistics."
PLG_SYSTEM_STATS_MODE_DESC="Selec the way you want that statistics are sent"
PLG_SYSTEM_STATS_MODE_LABEL="Mode"
PLG_SYSTEM_STATS_MODE_OPTION_ALWAYS_SEND="Always send"
PLG_SYSTEM_STATS_MODE_OPTION_NEVER_SEND="Never send"
PLG_SYSTEM_STATS_MODE_OPTION_ON_DEMAND="On demand"
PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA="Enable Joomla Statistics?"
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."
PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT="Click here to see which information will be sent."
PLG_SYSTEM_STATS_RESET_UNIQUE_ID="Reset Unique Id"
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."
PLG_SYSTEM_STATS_UNIQUE_ID_LABEL="Unique ID"
PLG_SYSTEM_STATS_URL_DESC="The official Joomla server url"
PLG_SYSTEM_STATS_URL_LABEL="Url"
PLG_SYSTEM_STATS_XML_DESCRIPTION="System Plugin that sends environment statistics to a server controlled by the Joomla! project for statistical analysis. Statistics sent include PHP version, CMS version, Database type, Database version and Server type."
78 changes: 78 additions & 0 deletions media/plg_system_stats/js/stats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
(function ($) {
$(document).ready(function () {
var ajaxData = {
'option' : 'com_ajax',
'group' : 'system',
'plugin' : 'renderStatsMessage',
'format' : 'raw'
},
messageContainer = $('#system-message-container');

/**
* Initialise events for the message container
*
* @return void
*/
function initStatsEvents()
{
var globalContainer = messageContainer.find('.js-pstats-alert'),
detailsContainer = messageContainer.find('.js-pstats-data-details');

// Show details about the information being sent
messageContainer.on('click', '.js-pstats-btn-details', function(e){
detailsContainer.toggle(200);
e.preventDefault();
});

// Always allow
messageContainer.on('click', '.js-pstats-btn-allow-always', function(e){

// Remove message
globalContainer.hide(200);
detailsContainer.remove();
ajaxData.plugin = 'sendAlways';

$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});

// Allow once
messageContainer.on('click', '.js-pstats-btn-allow-once', function(e){

// Remove message
globalContainer.hide(200);
detailsContainer.remove();

ajaxData.plugin = 'sendOnce';

$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});

// Never allow
messageContainer.on('click', '.js-pstats-btn-allow-never', function(e){

// Remove message
globalContainer.hide(200);
detailsContainer.remove();

ajaxData.plugin = 'sendNever';

$.getJSON('index.php', ajaxData, function(response){});
e.preventDefault();
});
}

ajaxData.plugin = 'sendStats';

$.getJSON('index.php', ajaxData, function(response){
if (response && response.html) {
messageContainer
.append(response.html)
.find('.js-pstats-alert').show(200);

initStatsEvents();
}
});
});
})(jQuery);
38 changes: 38 additions & 0 deletions plugins/system/stats/layouts/message.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Layout
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('JPATH_BASE') or die;

extract($displayData);

/**
* Layout variables
* -----------------
* @var PlgSystemStats $plugin Plugin rendering this layout
* @var \Joomla\Registry\Registry $pluginParams Plugin parameters
* @var array $statsData Array containing the data that will be sent to the stats server
*/
?>
<div class="alert alert-info js-pstats-alert" style="display:none;">
<button data-dismiss="alert" class="close" type="button">×</button>
<h2><?php echo JText::_('PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE'); ?></h2>
<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>
<dl class="dl-horizontal js-pstats-data-details" style="display:none;">
<?php foreach ($statsData as $key => $value) : ?>
<dt><?php echo $key; ?></dt>
<dd><?php echo $value; ?></dd>
<?php endforeach; ?>
</dl>
<p><?php echo JText::_('PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA'); ?></p>
<p class="actions">
<a href="#" class="btn btn-default js-pstats-btn-allow-always"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_ALWAYS'); ?></a>
<a href="#" class="btn btn-default js-pstats-btn-allow-once"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_SEND_NOW'); ?></a>
<a href="#" class="btn btn-default js-pstats-btn-allow-never"><?php echo JText::_('PLG_SYSTEM_STATS_BTN_NEVER_SEND'); ?></a>
</p>
</div>
Loading

0 comments on commit a0f977c

Please sign in to comment.