Skip to content

Commit

Permalink
Privacy plugin for privacy tools in Joomla 3.9 #59 (#60) (#62)
Browse files Browse the repository at this point in the history
* Privacy plugin for privacy tools in Joomla 3.9 #59 (#60)

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feat gdpr changes (#63)

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Feature #135356 feat: [GDPR Privacy Policy] - TJ Fields compatible with J3.9x.

* Privacy plugin for privacy tools in Joomla 3.9 #59 #60
  • Loading branch information
ankush-maherwal authored and manojLondhe committed Nov 2, 2018
1 parent e05d204 commit d97fc7c
Show file tree
Hide file tree
Showing 10 changed files with 817 additions and 18 deletions.
400 changes: 400 additions & 0 deletions build/bump.php

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions modules/mod_tjfields_search/mod_tjfields_search.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="module" client ="site" method="upgrade">
<name>mod_tjfields_search_name</name>
<author>TechJoomla</author>
<author>Techjoomla</author>
<authorEmail>extensions@techjoomla.com</authorEmail>
<authorUrl>www.techjoomla.com</authorUrl>
<copyright>Copyright(C)2012-17 TechJoomla</copyright>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2010 - 2018 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<creationDate>12th Apr 2017</creationDate>
<version>1.4</version>
<creationDate>2nd Nov 2018</creationDate>
<version>1.4.1</version>
<description>MOD_TJFIELDS_SEARCH_XML_DESCRIPTION</description>
<files>
<filename module="mod_tjfields_search">mod_tjfields_search.php</filename>
Expand Down
1 change: 1 addition & 0 deletions plugins/privacy/tjfields/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; @package TJ-Fields
; @subpackage Plg_Privacy_Tjfields
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_PRIVACY_TJFIELDS="Privacy - TJ-Fields"
PLG_PRIVACY_TJFIELDS_XML_DESCRIPTION="TJ-Fields privacy plugin"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; @package TJ-Fields
; @subpackage Plg_Privacy_Tjfields
; @copyright Copyright © 2009-2018 TechJoomla. All rights reserved.
; @license GNU General Public License version 2, or later
; Note: All ini files need to be saved as UTF-8

PLG_PRIVACY_TJFIELDS="Privacy - TJ-Fields"
PLG_PRIVACY_TJFIELDS_XML_DESCRIPTION="TJ-Fields privacy plugin"
170 changes: 170 additions & 0 deletions plugins/privacy/tjfields/tjfields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php
/**
* @package TJ-Fields
* @subpackage Plg_Privacy_TjFields
*
* @author Techjoomla <extensions@techjoomla.com>
* @copyright Copyright (C) 2009 - 2018 Techjoomla. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// No direct access.
defined('_JEXEC') or die();

JLoader::register('PrivacyPlugin', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/plugin.php');
JLoader::register('PrivacyRemovalStatus', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/removal/status.php');

use Joomla\CMS\User\User;

/**
* TjFields Privacy Plugin.
*
* @since 1.4.1
*/
class PlgPrivacyTjFields extends PrivacyPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
*
* @since 1.4.1
*/
protected $autoloadLanguage = true;

/**
* Database object
*
* @var JDatabaseDriver
* @since 1.4.1
*/
protected $db;

/**
* Processes an export request for TjFields user data
*
* This event will collect data for the following tables:
*
* - #__tjfields_fields
* - #__tjfields_groups
* - #__tjfields_fields_value
*
* @param PrivacyTableRequest $request The request record being processed
* @param JUser $user The user account associated with this request if available
*
* @return PrivacyExportDomain[]
*
* @since 1.4.1
*/
public function onPrivacyExportRequest(PrivacyTableRequest $request, JUser $user = null)
{
if (!$user)
{
return array();
}

/** @var JTableUser $user */
$userTable = User::getTable();
$userTable->load($user->id);

$domains = array();
$domains[] = $this->createTjFieldsFields($userTable);
$domains[] = $this->createTjFieldsFieldGroups($userTable);
$domains[] = $this->createTjFieldsFieldValues($userTable);

return $domains;
}

/**
* Create the domain for the TjFields fields
*
* @param JTableUser $user The JTableUser object to process
*
* @return PrivacyExportDomain
*
* @since 1.4.1
*/
private function createTjFieldsFields(JTableUser $user)
{
$domain = $this->createDomain('Fields', 'Fields created by a user');

$query = $this->db->getQuery(true)
->select($this->db->quoteName(array('id', 'label', 'name', 'type', 'created_by', 'client', 'group_id')))
->from($this->db->quoteName('#__tjfields_fields'))
->where($this->db->quoteName('created_by') . '=' . $user->id);

$fields = $this->db->setQuery($query)->loadAssocList();

if (!empty($fields))
{
foreach ($fields as $field)
{
$domain->addItem($this->createItemFromArray($field, $field['id']));
}
}

return $domain;
}

/**
* Create the domain for the TjFields groups
*
* @param JTableUser $user The JTableUser object to process
*
* @return PrivacyExportDomain
*
* @since 1.4.1
*/
private function createTjFieldsFieldGroups(JTableUser $user)
{
$domain = $this->createDomain('Groups', 'Field groups created by a user');

$query = $this->db->getQuery(true)
->select($this->db->quoteName(array('id', 'state', 'created_by', 'name', 'client')))
->from($this->db->quoteName('#__tjfields_groups'))
->where($this->db->quoteName('created_by') . '=' . $user->id);

$groups = $this->db->setQuery($query)->loadAssocList();

if (!empty($groups))
{
foreach ($groups as $group)
{
$domain->addItem($this->createItemFromArray($group, $group['id']));
}
}

return $domain;
}

/**
* Create the domain for the TjFields field values
*
* @param JTableUser $user The JTableUser object to process
*
* @return PrivacyExportDomain
*
* @since 1.4.1
*/
private function createTjFieldsFieldValues(JTableUser $user)
{
$domain = $this->createDomain('Field values', 'Field values submitted by a user');

$query = $this->db->getQuery(true)
->select($this->db->qn(array('id', 'field_id', 'content_id', 'value', 'user_id', 'email_id', 'client', 'option_id')))
->from($this->db->qn('#__tjfields_fields_value'))
->where('(' . $this->db->qn('user_id') . '=' . $user->id . ' OR ' . $this->db->qn('email_id') . '=' . $this->db->quote($user->email) . ')');

$fieldValues = $this->db->setQuery($query)->loadAssocList();

if (!empty($fieldValues))
{
foreach ($fieldValues as $fieldValue)
{
$domain->addItem($this->createItemFromArray($fieldValue, $fieldValue['id']));
}
}

return $domain;
}
}
25 changes: 25 additions & 0 deletions plugins/privacy/tjfields/tjfields.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.4" type="plugin" group="privacy" method="upgrade">
<name>plg_privacy_tjfields</name>
<version>1.4.1</version>
<creationDate>2nd Nov 2018</creationDate>
<author>Techjoomla</author>
<authorEmail>extensions@techjoomla.com</authorEmail>
<authorUrl>https://techjoomla.com</authorUrl>
<copyright>Copyright (C) 2010 - 2018 Techjoomla. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>PLG_PRIVACY_TJFIELDS_XML_DESCRIPTION</description>
<files>
<filename plugin="tjfields">tjfields.php</filename>
<filename>index.html</filename>
</files>
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_privacy_tjfields.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_privacy_tjfields.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic" />
</fields>
</config>
</extension>
Loading

0 comments on commit d97fc7c

Please sign in to comment.