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 #2224

Closed
jgerman-bot opened this issue Jan 14, 2022 · 0 comments · Fixed by #2227
Closed

[4.1] Simplify statistic plugin #2224

jgerman-bot opened this issue Jan 14, 2022 · 0 comments · Fixed by #2227

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#35983 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/language/en-GB/plg_system_stats.ini b/administrator/language/en-GB/plg_system_stats.ini
index c322fd4d7e50..60ef4610ae07 100644
--- a/administrator/language/en-GB/plg_system_stats.ini
+++ b/administrator/language/en-GB/plg_system_stats.ini
@@ -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!"
 PLG_SYSTEM_STATS_BTN_SEND_NOW="Once"
 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."
 PLG_SYSTEM_STATS_RESET_UNIQUE_ID="Reset Unique ID"
 PLG_SYSTEM_STATS_SETTING="Setting"
 PLG_SYSTEM_STATS_STATISTICS="Statistics"
diff --git a/build/media_source/plg_system_stats/js/stats-message.es6.js b/build/media_source/plg_system_stats/js/stats-message.es6.js
index 8fc75fa01aed..31a9e4c3e485 100644
--- a/build/media_source/plg_system_stats/js/stats-message.es6.js
+++ b/build/media_source/plg_system_stats/js/stats-message.es6.js
@@ -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')) {
diff --git a/plugins/system/stats/layouts/message.php b/plugins/system/stats/layouts/message.php
index 7a4d420520fd..3541af5c1603 100644
--- a/plugins/system/stats/layouts/message.php
+++ b/plugins/system/stats/layouts/message.php
@@ -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>
diff --git a/plugins/system/stats/stats.php b/plugins/system/stats/stats.php
index 8da88f512dc3..93ab0b854a08 100644
--- a/plugins/system/stats/stats.php
+++ b/plugins/system/stats/stats.php
@@ -39,15 +39,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.
 	 *
@@ -209,40 +200,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.
diff --git a/plugins/system/stats/stats.xml b/plugins/system/stats/stats.xml
index 2c096e69d617..84424110af3a 100644
--- a/plugins/system/stats/stats.xml
+++ b/plugins/system/stats/stats.xml
@@ -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>
 
tecpromotion added a commit to tecpromotion/joomla that referenced this issue Jan 15, 2022
translation changed strings
@tecpromotion tecpromotion linked a pull request Jan 15, 2022 that will close this issue
zero-24 added a commit that referenced this issue Jan 15, 2022
* change strings

* fix #2224

translation changed strings

* fix wording

* Update administrator/language/de-DE/plg_system_stats.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* Update administrator/language/de-DE/plg_system_stats.ini

Co-authored-by: Tobias Zulauf <[email protected]>

* Update administrator/language/de-DE/plg_system_stats.ini

* wording

* wording

* Update administrator/language/de-DE/plg_system_stats.ini

Co-authored-by: Tobias Zulauf <[email protected]>

Co-authored-by: Tobias Zulauf <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants