Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] Simplify statistic plugin #35983

Merged
merged 8 commits into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions administrator/language/en-GB/plg_system_stats.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
; 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_NEVER_SEND="No"
PLG_SYSTEM_STATS_BTN_SEND_ALWAYS="Yes, I'll help Joomla!"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PLG_SYSTEM_STATS_BTN_SEND_ALWAYS="Yes, I'll help Joomla!"
PLG_SYSTEM_STATS_BTN_SEND_ALWAYS="Yes, I'll send statistics"

PLG_SYSTEM_STATS_BTN_SEND_NOW="Once"
bembelimen marked this conversation as resolved.
Show resolved Hide resolved
PLG_SYSTEM_STATS_INTERVAL_LABEL="Interval (hours)"
PLG_SYSTEM_STATS_LABEL_CMS_VERSION="CMS Version"
PLG_SYSTEM_STATS_LABEL_DB_TYPE="DB Type"
PLG_SYSTEM_STATS_LABEL_DB_VERSION="DB Version"
PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE="Joomla! would like your permission to collect some basic statistics."
PLG_SYSTEM_STATS_LABEL_MESSAGE_TITLE="Help us make Joomla! better!"
PLG_SYSTEM_STATS_LABEL_PHP_VERSION="PHP Version"
PLG_SYSTEM_STATS_LABEL_SERVER_OS="Server OS"
PLG_SYSTEM_STATS_LABEL_UNIQUE_ID="Unique ID"
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_MODE_OPTION_ON_DEMAND="Ask again"
PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA="Enable Joomla Statistics?"
PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA="To better understand our install base and end user environments it is helpful if you send some site information back to a Joomla! controlled central server. No identifying data is captured at any point. You can change these settings later from Plugins → System - Joomla! Statistics."
PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT="Select here to see the information that will be sent."
PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA="We want to increase the compatibility of our Joomla! software with our user's server settings. Therefore we need anonymous data from your site to better understand the install base and end user environments. All data is anonymised and only sent to a Joomla! controlled central server. You can change these settings later from Plugins → System - Joomla! Statistics."
PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT="No identifying data is captured at any point. Select here to review."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You know that atleast in germany the IP is interpreted as identifying data so just tell them that technically we collect the IP but do not use that.

PLG_SYSTEM_STATS_RESET_UNIQUE_ID="Reset Unique ID"
PLG_SYSTEM_STATS_SETTING="Setting"
PLG_SYSTEM_STATS_STATISTICS="Statistics"
Expand Down
12 changes: 0 additions & 12 deletions build/media_source/plg_system_stats/js/stats-message.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@ Joomla = window.Joomla || {};
}
});

// Allow once
document.addEventListener('click', (event) => {
if (event.target.classList.contains('js-pstats-btn-allow-once')) {
event.preventDefault();

// Remove message
joomlaAlert.close();

callback({ plugin: 'sendOnce' });
}
});

// Never allow
document.addEventListener('click', (event) => {
if (event.target.classList.contains('js-pstats-btn-allow-never')) {
Expand Down
7 changes: 4 additions & 3 deletions plugins/system/stats/layouts/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
<div class="alert-message">
<p>
<?php echo Text::_('PLG_SYSTEM_STATS_MSG_JOOMLA_WANTS_TO_SEND_DATA'); ?>
</p>
<p>
<a href="#" class="js-pstats-btn-details alert-link"><?php echo Text::_('PLG_SYSTEM_STATS_MSG_WHAT_DATA_WILL_BE_SENT'); ?></a>
</p>
<?php
echo $plugin->render('stats', compact('statsData'));
?>
<p><?php echo Text::_('PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA'); ?></p>
<p class="fw-bold"><?php echo Text::_('PLG_SYSTEM_STATS_MSG_ALLOW_SENDING_DATA'); ?></p>
<p class="actions">
<button type="button" class="btn btn-primary js-pstats-btn-allow-always"><?php echo Text::_('PLG_SYSTEM_STATS_BTN_SEND_ALWAYS'); ?></button>
<button type="button" class="btn btn-primary js-pstats-btn-allow-once"><?php echo Text::_('PLG_SYSTEM_STATS_BTN_SEND_NOW'); ?></button>
<button type="button" class="btn btn-primary js-pstats-btn-allow-never"><?php echo Text::_('PLG_SYSTEM_STATS_BTN_NEVER_SEND'); ?></button>
<button type="button" class="btn btn-primary js-pstats-btn-allow-always"><?php echo Text::_('PLG_SYSTEM_STATS_BTN_SEND_ALWAYS'); ?></button>
</p>
</div>
</div>
Expand Down
42 changes: 0 additions & 42 deletions plugins/system/stats/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ class PlgSystemStats extends CMSPlugin
*/
const MODE_ALLOW_ALWAYS = 1;

/**
* Indicates sending statistics is only allowed one time.
*
* @var integer
* @since 3.5
*/
const MODE_ALLOW_ONCE = 2;

/**
* Indicates sending statistics is never allowed.
*
Expand Down Expand Up @@ -206,40 +198,6 @@ public function onAjaxSendNever()
echo json_encode(['sent' => 0]);
}

/**
* User selected to send data once.
*
* @return void
*
* @since 3.5
*
* @throws Exception If user is not allowed.
* @throws RuntimeException If there is an error saving the params, disabling the plugin or sending the data.
*/
public function onAjaxSendOnce()
{
if (!$this->isAllowedUser() || !$this->isAjaxRequest())
{
throw new Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'), 403);
}

$this->params->set('mode', static::MODE_ALLOW_ONCE);

if (!$this->saveParams())
{
throw new RuntimeException('Unable to save plugin settings', 500);
}

$this->sendStats();

if (!$this->disablePlugin())
{
throw new RuntimeException('Unable to disable the statistics plugin', 500);
}

echo json_encode(['sent' => 1]);
}

/**
* Send the stats to the server.
* On first load | on demand mode it will show a message asking users to select mode.
Expand Down
2 changes: 1 addition & 1 deletion plugins/system/stats/stats.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
default="1"
validate="options"
>
<option value="1">PLG_SYSTEM_STATS_MODE_OPTION_ALWAYS_SEND</option>
<option value="2">PLG_SYSTEM_STATS_MODE_OPTION_ON_DEMAND</option>
<option value="1">PLG_SYSTEM_STATS_MODE_OPTION_ALWAYS_SEND</option>
<option value="3">PLG_SYSTEM_STATS_MODE_OPTION_NEVER_SEND</option>
</field>

Expand Down