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

Proposed fixes for the new privacyconsent plugin #73

Merged
merged 4 commits into from
Apr 16, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ INSERT INTO `#__extensions` (`extension_id`, `package_id`, `name`, `type`, `elem
(481, 0, 'plg_user_privacyconsent', 'plugin', 'privacyconsent', 'user', 0, 0, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);
INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`)
VALUES
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem
(481, 0, 'plg_user_privacyconsent', 'plugin', 'privacyconsent', 'user', 0, 0, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0);
INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled")
VALUES
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ INSERT INTO "#__extensions" ("extension_id", "package_id", "name", "type", "elem
(481, 0, 'plg_user_privacyconsent', 'plugin', 'privacyconsent', 'user', 0, 0, 1, 0, '', '', '', '', 0, '1990-01-01 00:00:00', 0, 0);
INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description_key", "action_key", "language_extension", "language_client_id", "type", "action_file", "action", "condition_file", "condition_method", "version_introduced", "enabled")
VALUES
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
44 changes: 22 additions & 22 deletions administrator/language/en-GB/en-GB.plg_user_privacyconsent.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
; Brian Teeman
; Copyright (C) 2018 - Brian Teeman. All rights reserved.
; License GNU General Public License version 3
; Joomla! Project
; Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8


PLG_USER_PRIVACY_BODY="<p>The user consented to storing their user information using the IP address <strong>%s</strong></p><p>The user agent string of the user's browser was:<br/>%s</p><p>This information was automatically recorded when the user submitted their details on the web site and checked the confirm box</p>"
PLG_USER_PRIVACY_FIELD_ARTICLE_DESC="Select the desired Privacy article from the list."
PLG_USER_PRIVACY_FIELD_ARTICLE_LABEL="Privacy Article"
PLG_USER_PRIVACY_FIELD_DESC="Read the full privacy policy"
PLG_USER_PRIVACY_FIELD_ERROR="Agreement to the site's Privacy Policy is required."
PLG_USER_PRIVACY_FIELD_LABEL="Privacy Policy"
PLG_USER_PRIVACY_LABEL="Web Site Privacy"
PLG_USER_PRIVACY_NOTE_FIELD_DEFAULT="By signing up to this web site and agree to the Privacy Policy you agree to this web site storing your information."
PLG_USER_PRIVACY_NOTE_FIELD_DESC="Write a summary of the site's privacy policy."
PLG_USER_PRIVACY_NOTE_FIELD_LABEL="Short Privacy Policy"
PLG_USER_PRIVACY_OPTION_AGREE="I agree"
PLG_USER_PRIVACY_REDIRECT_MESSAGE_DEFAULT="Please confirm that you consent to this web site storing your information by agreeing to the privacy policy."
PLG_USER_PRIVACY_REDIRECT_MESSAGE_DESC="Custom message to be displayed on redirect. If left blank then the default message will be used."
PLG_USER_PRIVACY_REDIRECT_MESSAGE_LABEL="Redirect Message"
PLG_USER_PRIVACY_SUBJECT="Privacy Policy"
PLG_USER_PRIVACY_XML_DESCRIPTION="Basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
PLG_USER_PRIVACYCONSENT_TITLE="Privacy Policy (GDPR) Plugin"
PLG_USER_PRIVACYCONSENT_BODY="This is a basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
PLG_USER_PRIVACYCONSENT_BODY="<p>The user consented to storing their user information using the IP address <strong>%s</strong></p><p>The user agent string of the user's browser was:<br/>%s</p><p>This information was automatically recorded when the user submitted their details on the web site and checked the confirm box</p>"
PLG_USER_PRIVACYCONSENT_FIELD_ARTICLE_DESC="Select the desired Privacy article from the list."
PLG_USER_PRIVACYCONSENT_FIELD_ARTICLE_LABEL="Privacy Article"
PLG_USER_PRIVACYCONSENT_FIELD_DESC="Read the full privacy policy"
PLG_USER_PRIVACYCONSENT_FIELD_ERROR="Agreement to the site's Privacy Policy is required."
PLG_USER_PRIVACYCONSENT_FIELD_LABEL="Privacy Policy"
PLG_USER_PRIVACYCONSENT_LABEL="Web Site Privacy"
PLG_USER_PRIVACYCONSENT_NOTE_FIELD_DEFAULT="By signing up to this web site and agreeing to the Privacy Policy you agree to this web site storing your information."
PLG_USER_PRIVACYCONSENT_NOTE_FIELD_DESC="Write a summary of the site's privacy policy."
PLG_USER_PRIVACYCONSENT_NOTE_FIELD_LABEL="Short Privacy Policy"
PLG_USER_PRIVACYCONSENT_OPTION_AGREE="I agree"
PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE="Privacy Policy (GDPR) Plugin"
PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY="This is a basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
PLG_USER_PRIVACYCONSENT_REDIRECT_MESSAGE_DEFAULT="Please confirm that you consent to this web site storing your information by agreeing to the privacy policy."
PLG_USER_PRIVACYCONSENT_REDIRECT_MESSAGE_DESC="Custom message to be displayed on redirect. If left blank then the default message will be used."
PLG_USER_PRIVACYCONSENT_REDIRECT_MESSAGE_LABEL="Redirect Message"
PLG_USER_PRIVACYCONSENT_SUBJECT="Privacy Policy"
PLG_USER_PRIVACYCONSENT_XML_DESCRIPTION="Basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
; Brian Teeman
; Copyright (C) 2018 - Brian Teeman. All rights reserved.
; License GNU General Public License version 3
; Joomla! Project
; Copyright (C) 2005 - 2018 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8



PLG_USER_PRIVACY_XML_DESCRIPTION="Basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
PLG_USER_PRIVACYCONSENT="User - Privacy Consent"
PLG_USER_PRIVACYCONSENT="User - Privacy Consent"
PLG_USER_PRIVACYCONSENT_XML_DESCRIPTION="Basic plugin to request user's consent to the site's privacy policy. Existing users who have not consented yet will be redirected on login to update their profile."
2 changes: 1 addition & 1 deletion installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description
(700, 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_TITLE', 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_BODY', '', 'com_cpanel', 1, 'message', '', '', 'admin://components/com_admin/postinstall/joomla40checks.php', 'admin_postinstall_joomla40checks_condition', '3.7.0', 1),
(700, 'TPL_HATHOR_MESSAGE_POSTINSTALL_TITLE', 'TPL_HATHOR_MESSAGE_POSTINSTALL_BODY', 'TPL_HATHOR_MESSAGE_POSTINSTALL_ACTION', 'tpl_hathor', 1, 'action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_condition', '3.7.0', 1),
(700, 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_TITLE', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_BODY', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_ACTION', 'plg_captcha_recaptcha', 1, 'action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_condition', '3.8.6', 1);
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);

-- --------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description
(700, 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_TITLE', 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_BODY', '', 'com_cpanel', 1, 'message', '', '', 'admin://components/com_admin/postinstall/joomla40checks.php', 'admin_postinstall_joomla40checks_condition', '3.7.0', 1),
(700, 'TPL_HATHOR_MESSAGE_POSTINSTALL_TITLE', 'TPL_HATHOR_MESSAGE_POSTINSTALL_BODY', 'TPL_HATHOR_MESSAGE_POSTINSTALL_ACTION', 'tpl_hathor', 1, 'action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_condition', '3.7.0', 1),
(700, 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_TITLE', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_BODY', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_ACTION', 'plg_captcha_recaptcha', 1, 'action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_condition', '3.8.6', 1);
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);

--
-- Table structure for table `#__redirect_links`
Expand Down
2 changes: 1 addition & 1 deletion installation/sql/sqlazure/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ INSERT INTO "#__postinstall_messages" ("extension_id", "title_key", "description
(700, 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_TITLE', 'COM_CPANEL_MSG_JOOMLA40_PRE_CHECKS_BODY', '', 'com_cpanel', 1, 'message', '', '', 'admin://components/com_admin/postinstall/joomla40checks.php', 'admin_postinstall_joomla40checks_condition', '3.7.0', 1),
(700, 'TPL_HATHOR_MESSAGE_POSTINSTALL_TITLE', 'TPL_HATHOR_MESSAGE_POSTINSTALL_BODY', 'TPL_HATHOR_MESSAGE_POSTINSTALL_ACTION', 'tpl_hathor', 1, 'action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_action', 'admin://templates/hathor/postinstall/hathormessage.php', 'hathormessage_postinstall_condition', '3.7.0', 1),
(700, 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_TITLE', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_BODY', 'PLG_PLG_RECAPTCHA_VERSION_1_POSTINSTALL_ACTION', 'plg_captcha_recaptcha', 1, 'action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_action', 'site://plugins/captcha/recaptcha/postinstall/actions.php', 'recaptcha_postinstall_condition', '3.8.6', 1);
(700, 'PLG_USER_PRIVACYCONSENT_TITLE', 'PLG_USER_PRIVACYCONSENT_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);
(700, 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_TITLE', 'PLG_USER_PRIVACYCONSENT_POSTINSTALL_BODY', '', 'plg_user_privacyconsent', 1, 'message', '', '', '', '', '3.9.0', 1);

--
-- Table structure for table `#__redirect_links`
Expand Down
21 changes: 11 additions & 10 deletions plugins/user/privacyconsent/field/privacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;

JFormHelper::loadFieldClass('radio');

/**
Expand All @@ -35,7 +38,7 @@ class JFormFieldprivacy extends JFormFieldRadio
*/
protected function getInput()
{
$privacynote = !empty($this->element['note']) ? $this->element['note'] : JText::_('PLG_USER_PRIVACY_NOTE_FIELD_DEFAULT');
$privacynote = !empty($this->element['note']) ? $this->element['note'] : Text::_('PLG_USER_PRIVACYCONSENT_NOTE_FIELD_DEFAULT');

echo '<div class="alert alert-info">' . $privacynote . '</div>';

Expand All @@ -52,16 +55,14 @@ protected function getInput()
*/
protected function getLabel()
{
$label = '';

if ($this->hidden)
{
return $label;
return '';
}

// Get the label text from the XML element, defaulting to the element name.
$text = $this->element['label'] ? (string) $this->element['label'] : (string) $this->element['name'];
$text = $this->translateLabel ? JText::_($text) : $text;
$text = $this->translateLabel ? Text::_($text) : $text;

// Set required to true as this field is not displayed at all if not required.
$this->required = true;
Expand All @@ -74,29 +75,29 @@ protected function getLabel()
$class = !empty($this->labelClass) ? $class . ' ' . $this->labelClass : $class;

// Add the opening label tag and main attributes.
$label .= '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="' . $class . '"';
$label = '<label id="' . $this->id . '-lbl" for="' . $this->id . '" class="' . $class . '"';

// If a description is specified, use it to build a tooltip.
if (!empty($this->description))
{
$label .= ' title="'
. htmlspecialchars(
trim($text, ':') . '<br />' . ($this->translateDescription ? JText::_($this->description) : $this->description),
trim($text, ':') . '<br />' . ($this->translateDescription ? Text::_($this->description) : $this->description),
ENT_COMPAT, 'UTF-8'
) . '"';
}

$privacyarticle = $this->element['article'] > 0 ? (int) $this->element['article'] : 0;

if ($privacyarticle && JFactory::getApplication()->isClient('site'))
if ($privacyarticle && Factory::getApplication()->isClient('site'))
{
JLoader::register('ContentHelperRoute', JPATH_BASE . '/components/com_content/helpers/route.php');

$attribs = array();
$attribs['class'] = 'modal';
$attribs['rel'] = '{handler: \'iframe\', size: {x:800, y:500}}';

$db = JFactory::getDbo();
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('id', 'alias', 'catid', 'language')))
->from($db->quoteName('#__content'))
Expand All @@ -109,7 +110,7 @@ protected function getLabel()
$privacyassociated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $privacyarticle);
}

$current_lang = JFactory::getLanguage()->getTag();
$current_lang = Factory::getLanguage()->getTag();

if (isset($privacyassociated) && $current_lang !== $article->language && array_key_exists($current_lang, $privacyassociated))
{
Expand Down
Loading