first commit - v1.0.0

This commit is contained in:
Llewellyn van der Merwe 2021-10-14 16:31:00 +02:00
commit 11bd116ee8
Signed by: Llewellyn
GPG Key ID: EFC0C720A240551C
16 changed files with 868 additions and 0 deletions

View File

@ -0,0 +1,163 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Registry\Registry;
use Joomla\CMS\Form\Form;
JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php');
/**
* Content - Componentbuilder Privacy Tabs plugin.
*
* @package ComponentbuilderPrivacyTabs
* @since 1.0.0
*/
class PlgContentComponentbuilderPrivacyTabs extends CMSPlugin
{
/**
* Affects constructor behavior. If true, language files will be loaded automatically.
*
* @var boolean
* @since 1.0
*/
protected $autoloadLanguage = true;
/**
* Runs on content preparation of form.
*
* @param JForm $form The form
* @param stdClass $data The data
*
* @return boolean
*
* @since 1.0
*/
public function onContentPrepareForm(Form $form, $data)
{
$context = $form->getName();
// When this is componentbuilder admin view
if (strpos($context, 'com_componentbuilder.admin_view') === 0)
{
// Add the forms path
Form::addFormPath(__DIR__ . '/forms');
// add the admin view params for privacy integration
$form->loadFile('admin_view');
// if the global plugin is not set, allow it to be set from the admin view
if (($plugin = $this->params->get('plugin', 0)) == 0)
{
$form->loadFile('config');
// make the plugin field required (LATER when we can give more info)
//$form->setFieldAttribute('plugin', 'required', true, 'params.privacy');
//$form->setFieldAttribute('plugin', 'showon', 'activate:1', 'params.privacy');
//$form->setFieldAttribute('note_select_privacy_plugin', 'showon', 'activate:1', 'params.privacy');
}
// update all editors to use this components global editor
$global_editor = JComponentHelper::getParams('com_componentbuilder')->get('editor', 'none');
// set the field editor value (with none as fallback)
$form->setFieldAttribute('custom_link', 'editor', $global_editor . '|none', 'params.privacy');
}
return true;
}
/**
* This is an event that is called right before the content
* is saved into the database.
*
* @param string $context The context of the content passed to the plugin (added in 1.6).
* @param object $article A JTableContent object.
* @param bool $isNew If the content is just about to be created.
*
* @return void.
*
* @since 1.0
*/
public function onContentBeforeSave($context, $item, $isNew, $data = array())
{
// When this is componentbuilder admin view
if ('com_componentbuilder.admin_view' === $context)
{
// check if this is json
if (ComponentbuilderHelper::checkJson($item->params))
{
// Convert the params field to an array.
$registry = new Registry;
$registry->loadString($item->params);
$item->params = $registry->toArray();
}
// check if the plugin was set
if (isset($item->params['plugin']) && $item->params['plugin'] > 0)
{
// first set new params
$this->params->set('plugin', (int) $item->params['plugin']);
// update the global plugin settings
$extensionTable = new JtableExtension(JFactory::getDbo());
$extensionTable->load(array('element' => 'componentbuilderprivacytabs'));
// Save the change
$extensionTable->set('params', $this->params->toString());
$extensionTable->save((array) $extensionTable);
// and remove the value from the params
unset($item->params['plugin']);
// clear the plugin cache
$this->cleanCache('com_plugins', 0);
$this->cleanCache('com_plugins', 1);
}
// check if this is an array
if (ComponentbuilderHelper::checkArray($item->params))
{
// Convert the params field to a string.
$params = new JRegistry;
$params->loadArray($item->params);
$item->params = (string) $params;
}
}
}
/**
* Clean the cache
*
* @param string $group The cache group
* @param integer $client_id The ID of the client
*
* @return void
*
* @since 3.0
*/
protected function cleanCache($group = null, $client_id = 0)
{
$conf = \JFactory::getConfig();
$options = array(
'defaultgroup' => $group ?: (isset($this->option) ? $this->option : \JFactory::getApplication()->input->get('option')),
'cachebase' => $client_id ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache'),
'result' => true,
);
try
{
/** @var \JCacheControllerCallback $cache */
$cache = \JCache::getInstance('callback', $options);
$cache->clean();
}
catch (\JCacheException $exception)
{
$options['result'] = false;
}
// Trigger the onContentCleanCache event.
\JEventDispatcher::getInstance()->trigger('onContentCleanCache', $options);
}
}

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" version="3.8" group="content" method="upgrade">
<name>PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS</name>
<creationDate>20th February, 2021</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<version>1.0.0</version>
<description>PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION</description>
<!-- Scripts to run on installation -->
<scriptfile>script.php</scriptfile>
<!-- Language files -->
<languages folder="language">
<language tag="en-GB">en-GB/en-GB.plg_content_componentbuilderprivacytabs.ini</language>
<language tag="en-GB">en-GB/en-GB.plg_content_componentbuilderprivacytabs.sys.ini</language>
</languages>
<!-- Plugin files -->
<files>
<filename plugin="componentbuilderprivacytabs">componentbuilderprivacytabs.php</filename>
<filename>index.html</filename>
<folder>language</folder>
<folder>fields</folder>
<folder>forms</folder>
<folder>rules</folder>
</files>
<!-- Config parameter -->
<config>
<fields name="params">
<!-- default paths of basic fieldset points to the plugin -->
<fieldset name="basic" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_GLOBAL_PRIVACY"
addrulepath="/plugins/content/componentbuilderprivacytabs/rules"
addfieldpath="/plugins/content/componentbuilderprivacytabs/fields"
>
<!-- Note_select_privacy_plugin Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_select_privacy_plugin" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_DESCRIPTION" heading="h4" class="alert alert-info note_select_privacy_plugin" />
<!-- Plugin Field. Type: Joomlaplugins. (custom) -->
<field
type="joomlaplugins"
name="plugin"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN_LABEL"
class="list_class span12"
multiple="false"
default="0"
button="true"
/>
</fieldset>
</fields>
</config>
</extension>

1
fields/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

177
fields/joomlaplugins.php Normal file
View File

@ -0,0 +1,177 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Joomlaplugins Form Field class for the Componentbuilder component
*/
class JFormFieldJoomlaplugins extends JFormFieldList
{
/**
* The joomlaplugins field type.
*
* @var string
*/
public $type = 'joomlaplugins';
/**
* Override to add new button
*
* @return string The field input markup.
*
* @since 3.2
*/
protected function getInput()
{
// see if we should add buttons
$set_button = $this->getAttribute('button');
// get html
$html = parent::getInput();
// if true set button
if ($set_button === 'true')
{
$button = array();
$script = array();
$button_code_name = $this->getAttribute('name');
// get the input from url
$app = JFactory::getApplication();
$jinput = $app->input;
// get the view name & id
$values = $jinput->getArray(array(
'id' => 'int',
'view' => 'word'
));
// check if new item
$ref = '';
$refJ = '';
if (!is_null($values['id']) && strlen($values['view']))
{
// only load referral if not new item.
$ref = '&amp;ref=' . $values['view'] . '&amp;refid=' . $values['id'];
$refJ = '&ref=' . $values['view'] . '&refid=' . $values['id'];
// get the return value.
$_uri = (string) JUri::getInstance();
$_return = urlencode(base64_encode($_uri));
// load return value.
$ref .= '&amp;return=' . $_return;
$refJ .= '&return=' . $_return;
}
// get button label
$button_label = trim($button_code_name);
$button_label = preg_replace('/_+/', ' ', $button_label);
$button_label = preg_replace('/\s+/', ' ', $button_label);
$button_label = preg_replace("/[^A-Za-z ]/", '', $button_label);
$button_label = ucfirst(strtolower($button_label));
// get user object
$user = JFactory::getUser();
// only add if user allowed to create joomla_plugin
if ($user->authorise('joomla_plugin.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build Create button
$button[] = '<a id="'.$button_code_name.'Create" class="btn btn-small btn-success hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CREATE_NEW_S', $button_label).'" style="border-radius: 0px 4px 4px 0px; padding: 4px 4px 4px 7px;"
href="index.php?option=com_componentbuilder&amp;view=joomla_plugin&amp;layout=edit'.$ref.'" >
<span class="icon-new icon-white"></span></a>';
}
// only add if user allowed to edit joomla_plugin
if ($user->authorise('joomla_plugin.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area.
{
// build edit button
$button[] = '<a id="'.$button_code_name.'Edit" class="btn btn-small hasTooltip" title="'.JText::sprintf('PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_EDIT_S', $button_label).'" style="display: none; padding: 4px 4px 4px 7px;" href="#" >
<span class="icon-edit"></span></a>';
// build script
$script[] = "
jQuery(document).ready(function() {
jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) {
e.preventDefault();
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val();
".$button_code_name."Button(".$button_code_name."Value);
});
function ".$button_code_name."Button(value) {
if (value > 0) {
// hide the create button
jQuery('#".$button_code_name."Create').hide();
// show edit button
jQuery('#".$button_code_name."Edit').show();
var url = 'index.php?option=com_componentbuilder&view=joomla_plugins&task=joomla_plugin.edit&id='+value+'".$refJ."';
jQuery('#".$button_code_name."Edit').attr('href', url);
} else {
// show the create button
jQuery('#".$button_code_name."Create').show();
// hide edit button
jQuery('#".$button_code_name."Edit').hide();
}
}";
}
// check if button was created for joomla_plugin field.
if (is_array($button) && count($button) > 0)
{
// Load the needed script.
$document = JFactory::getDocument();
$document->addScriptDeclaration(implode(' ',$script));
// return the button attached to input field.
return '<div class="input-append">' .$html . implode('',$button).'</div>';
}
}
return $html;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// Get the user object.
$user = JFactory::getUser();
// Get the databse object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.system_name','a.name','b.name','c.name'),array('id','plugin_system_name','name','class_extends_name','joomla_plugin_group_name')));
$query->from($db->quoteName('#__componentbuilder_joomla_plugin', 'a'));
$query->join('LEFT', $db->quoteName('#__componentbuilder_class_extends', 'b') . ' ON (' . $db->quoteName('a.class_extends') . ' = ' . $db->quoteName('b.id') . ')');
$query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_plugin_group', 'c') . ' ON (' . $db->quoteName('a.joomla_plugin_group') . ' = ' . $db->quoteName('c.id') . ')');
$query->where($db->quoteName('a.published') . ' >= 1');
$query->order('a.system_name ASC');
// Implement View Level Access (if set in table)
if (!$user->authorise('core.options', 'com_componentbuilder'))
{
$columns = $db->getTableColumns('#__componentbuilder_joomla_plugin');
if(isset($columns['access']))
{
$groups = implode(',', $user->getAuthorisedViewLevels());
$query->where('a.access IN (' . $groups . ')');
}
}
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
$options[] = JHtml::_('select.option', '', 'Select a plugin');
foreach($items as $item)
{
// set a full class name
$options[] = JHtml::_('select.option', $item->id, '( ' . $item->plugin_system_name . ' ) class Plg' . ucfirst($item->joomla_plugin_group_name) . $item->name . ' extends ' . $item->class_extends_name);
}
}
return $options;
}
}

109
fields/targetfields.php Normal file
View File

@ -0,0 +1,109 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import the list field type
jimport('joomla.form.helper');
JFormHelper::loadFieldClass('list');
/**
* Targetfields Form Field class for the Componentbuilder component
*/
class JFormFieldTargetfields extends JFormFieldList
{
/**
* The targetfields field type.
*
* @var string
*/
public $type = 'targetfields';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getOptions()
{
// load the db opbject
$db = JFactory::getDBO();
// get the input from url
$jinput = JFactory::getApplication()->input;
// get the id
$ID = $jinput->getInt('id', 0);
// get the view name
$VIEW = $jinput->get('view', null, 'WORD');
// rest the fields ids
$fieldIds = array();
// if this is an actual admin view then we are done
if ('admin_view' === $VIEW && is_numeric($ID) && $ID >= 1)
{
$adminView = $ID;
}
elseif (is_numeric($ID) && $ID >= 1)
{
// get the admin view ID
$adminView = ComponentbuilderHelper::getVar('admin_fields_conditions', (int) $ID, 'id', 'admin_view');
}
elseif ('admin_view' !== $VIEW)
{
// get the admin view ID
$adminView = $jinput->getInt('refid', 0);
}
if (isset($adminView) && is_numeric($adminView) && $adminView >= 1)
{
// get all the fields linked to the admin view
if ($addFields = ComponentbuilderHelper::getVar('admin_fields', (int) $adminView, 'admin_view', 'addfields'))
{
if (ComponentbuilderHelper::checkJson($addFields))
{
$addFields = json_decode($addFields, true);
if (ComponentbuilderHelper::checkArray($addFields))
{
foreach($addFields as $addField)
{
if (isset($addField['field']))
{
$fieldIds[] = (int) $addField['field'];
}
}
}
}
}
}
$query = $db->getQuery(true);
$query->select($db->quoteName(array('a.id','a.name','t.name'),array('id','name','type')));
$query->from($db->quoteName('#__componentbuilder_field', 'a'));
$query->join('LEFT', $db->quoteName('#__componentbuilder_fieldtype', 't') . ' ON (' . $db->quoteName('a.fieldtype') . ' = ' . $db->quoteName('t.id') . ')');
$query->where($db->quoteName('a.published') . ' >= 1');
// filter by fields linked
if (ComponentbuilderHelper::checkArray($fieldIds))
{
// only load these fields
$query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')');
}
$query->order('a.name ASC');
$db->setQuery((string)$query);
$items = $db->loadObjectList();
$options = array();
if ($items)
{
foreach($items as $item)
{
$options[] = JHtml::_('select.option', $item->id, $item->name . ' [' . $item->type . ']');
}
}
return $options;
}
}

146
forms/admin_view.xml Normal file
View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- default paths of admin_view form points to componentbuilder -->
<form>
<fields name="params">
<!-- default paths of privacy fieldset points to the plugin -->
<fieldset name="privacy" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PRIVACY"
addrulepath="/plugins/content/componentbuilderprivacytabs/rules"
addfieldpath="/plugins/content/componentbuilderprivacytabs/fields"
>
<fields name="privacy">
<!-- Note_plugin_actions Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_plugin_actions" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_DESCRIPTION" heading="h3" class="alert alert-info note_plugin_actions" />
<!-- Activate Field. Type: Radio. (joomla) -->
<field
type="radio"
name="activate"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_LABEL"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
required="true">
<!-- Option Set. -->
<option value="1">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_YES</option>
<option value="0">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NO</option>
</field>
<!-- Note_plugin_permission Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_plugin_permission" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_DESCRIPTION" heading="h4" class="alert alert-info note_plugin_permission" showon="activate:1" />
<!-- Permissions Field. Type: Radio. (joomla) -->
<field
type="radio"
name="permissions"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_LABEL"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
required="true"
showon="activate:1">
<!-- Option Set. -->
<option value="1">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_YES</option>
<option value="0">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NO</option>
</field>
<!-- Note_plugin_anonymize Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_plugin_anonymize" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_DESCRIPTION" heading="h4" class="alert alert-info note_plugin_anonymize" showon="activate:1" />
<!-- Anonymize Field. Type: Radio. (joomla) -->
<field
type="radio"
name="anonymize"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_LABEL"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_DESCRIPTION"
class="btn-group btn-group-yesno"
default="0"
required="true"
showon="activate:1">
<!-- Option Set. -->
<option value="1">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_YES</option>
<option value="0">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NO</option>
</field>
<!-- Anonymize_fields Field. Type: Subform. (joomla) -->
<field
type="subform"
name="anonymize_fields"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_FIELDS_LABEL"
layout="joomla.form.field.subform.repeatable-table"
multiple="true"
buttons="add,remove,move"
icon="list"
max="50"
showon="activate:1[AND]anonymize:1">
<form hidden="true" name="list_anonymize_fields_modal" repeat="true">
<!-- Field Field. Type: Targetfields. (custom) -->
<field
type="targetfields"
name="field"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_FIELD_LABEL"
button="false"
/>
<!-- Value Field. Type: Text. (joomla) -->
<field
type="text"
name="value"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_LABEL"
size="10"
maxlength="50"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_DESCRIPTION"
class="text_area"
filter="STRING"
autocomplete="on"
/>
</form>
</field>
<!-- Note_plugin_user_link Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_plugin_user_link" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_DESCRIPTION" heading="h4" class="alert alert-info note_plugin_user_link" showon="activate:1" />
<!-- User_link Field. Type: Radio. (joomla) -->
<field
type="radio"
name="user_link"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_LABEL"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_DESCRIPTION"
class="btn-group btn-group-yesno"
default="1"
required="true"
showon="activate:1">
<!-- Option Set. -->
<option value="1">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CREATED_BY</option>
<option value="2">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD</option>
<option value="3">
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM</option>
</field>
<!-- Custom_link Field. Type: Editor. (joomla) -->
<field
type="editor"
name="custom_link"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_LABEL"
default="$query->where($db->quoteName('created_by') . ' = ' . $db->quote($user->id));"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_DESCRIPTION"
width="100%"
height="80px"
cols="15"
rows="30"
buttons="no"
syntax="php"
editor="codemirror|none"
filter="raw"
validate="code"
showon="activate:1[AND]user_link:3"
/>
<!-- Other_user_field Field. Type: Targetfields. (custom) -->
<field
type="targetfields"
name="other_user_field"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_LABEL"
description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_DESCRIPTION"
showon="activate:1[AND]user_link:2"
/>
</fields>
</fieldset>
</fields>
</form>

24
forms/config.xml Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- default paths of config form points to componentbuilder -->
<form>
<fields name="params">
<!-- default paths of plugin fieldset points to the plugin -->
<fieldset name="plugin" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN"
addrulepath="/plugins/content/componentbuilderprivacytabs/rules"
addfieldpath="/plugins/content/componentbuilderprivacytabs/fields"
>
<!-- Note_select_privacy_plugin Field. Type: Note. A None Database Field. (joomla) -->
<field type="note" name="note_select_privacy_plugin" label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_LABEL" description="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_DESCRIPTION" heading="h4" class="alert alert-info note_select_privacy_plugin" />
<!-- Plugin Field. Type: Joomlaplugins. (custom) -->
<field
type="joomlaplugins"
name="plugin"
label="PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN_LABEL"
class="list_class span12"
multiple="false"
default="0"
button="true"
/>
</fieldset>
</fields>
</form>

1
forms/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

1
index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

View File

@ -0,0 +1,39 @@
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS="Content - Componentbuilder Privacy Tabs"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_DESCRIPTION="This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="<h1>Content - Componentbuilder Privacy Tabs (v.1.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 17th August, 2019</small></p>"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_GLOBAL_PRIVACY="Global Privacy"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN="Plugin"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PRIVACY="Privacy"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_LABEL="Select your global privacy plugin here."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_DESCRIPTION="If you don't yet have a global privacy plugin, <a href='https://www.youtube.com/watch?v=r56zcvek0Ik&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=90' target='_blank'>watch this tutorial</a> to see how to setup it up."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN_LABEL="Plugins"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_LABEL="Does the values stored in this admin view have a direct relationship with any user in Joomla?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_DESCRIPTION="The Joomla Privacy Suite helps you comply with the privacy requirements of your component. So should this admin view in you component have any personal data related to any user in Joomla where your component is eventually installed by Joomla website owners/developers, then you should activate this integration with Joomla Privacy Suite."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_LABEL="Activate"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_DESCRIPTION="Turn on the integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_YES="Yes"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NO="No"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_LABEL="Should we use permissions (where available) to determine the users access to data?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_DESCRIPTION="When you add permission control to view/edit/access a field value we can add that layer of security when a privacy event is taken."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_LABEL="Permissions"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_DESCRIPTION="As an extra layer of security you add permission control."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_LABEL="When a user makes a request to remove their data from the Joomla website, should we instead allow it to be anonymized?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_DESCRIPTION="At times you may want to give website owners the option to anonymize data instead of deleting. This switch adds that option to the privacy integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_LABEL="Anonymize"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_DESCRIPTION="When deletion request is made, allow it to be anonymized instead."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_FIELDS_LABEL="Select all fields that must be anonymized?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_FIELD_LABEL="Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_FIELD="Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_LABEL="Anonymize Value"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_DESCRIPTION="RANDOM gives a random 8 digit value"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_LABEL="How is the user linked to this admin view?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_DESCRIPTION="The privacy plugin needs to be able to get all rows that belongs to the user. Most of the time it is the rows that the user created, but it could also be via another user field or some custom relationship."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_LABEL="User Link"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_DESCRIPTION="Here you can setup the way we can link a user to their data in this admin view."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CREATED_BY="Created By"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD="Other User Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM="Custom"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_LABEL="PHP Custom Code"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_DESCRIPTION="Only the lines of code to like this $user->id to a field in the table, see the code in the editor for an example."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_LABEL="Select other User Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_DESCRIPTION="Select the other field that is the user-id field you would like to use to link the data to the user."

View File

@ -0,0 +1,39 @@
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS="Content - Componentbuilder Privacy Tabs"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_DESCRIPTION="This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_XML_DESCRIPTION="<h1>Content - Componentbuilder Privacy Tabs (v.1.0.0)</h1> <div style='clear: both;'></div><p>This plugin is used to link your components to the privacy suite of Joomla by adding a new privacy tab to the JCB admin views, where you can set all the required details for the integration.</p><p>Created by <a href='http://www.joomlacomponentbuilder.com' target='_blank'>Llewellyn van der Merwe</a><br /><small>Development started 17th August, 2019</small></p>"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_GLOBAL_PRIVACY="Global Privacy"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN="Plugin"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PRIVACY="Privacy"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_LABEL="Select your global privacy plugin here."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_SELECT_PRIVACY_PLUGIN_DESCRIPTION="If you don't yet have a global privacy plugin, <a href='https://www.youtube.com/watch?v=r56zcvek0Ik&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=90' target='_blank'>watch this tutorial</a> to see how to setup it up."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PLUGIN_LABEL="Plugins"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_LABEL="Does the values stored in this admin view have a direct relationship with any user in Joomla?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ACTIONS_DESCRIPTION="The Joomla Privacy Suite helps you comply with the privacy requirements of your component. So should this admin view in you component have any personal data related to any user in Joomla where your component is eventually installed by Joomla website owners/developers, then you should activate this integration with Joomla Privacy Suite."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_LABEL="Activate"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ACTIVATE_DESCRIPTION="Turn on the integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_YES="Yes"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NO="No"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_LABEL="Should we use permissions (where available) to determine the users access to data?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_PERMISSION_DESCRIPTION="When you add permission control to view/edit/access a field value we can add that layer of security when a privacy event is taken."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_LABEL="Permissions"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_PERMISSIONS_DESCRIPTION="As an extra layer of security you add permission control."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_LABEL="When a user makes a request to remove their data from the Joomla website, should we instead allow it to be anonymized?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_ANONYMIZE_DESCRIPTION="At times you may want to give website owners the option to anonymize data instead of deleting. This switch adds that option to the privacy integration."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_LABEL="Anonymize"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_DESCRIPTION="When deletion request is made, allow it to be anonymized instead."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_ANONYMIZE_FIELDS_LABEL="Select all fields that must be anonymized?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_FIELD_LABEL="Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_FIELD="Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_LABEL="Anonymize Value"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_VALUE_DESCRIPTION="RANDOM gives a random 8 digit value"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_LABEL="How is the user linked to this admin view?"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_NOTE_PLUGIN_USER_LINK_DESCRIPTION="The privacy plugin needs to be able to get all rows that belongs to the user. Most of the time it is the rows that the user created, but it could also be via another user field or some custom relationship."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_LABEL="User Link"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_USER_LINK_DESCRIPTION="Here you can setup the way we can link a user to their data in this admin view."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CREATED_BY="Created By"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD="Other User Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM="Custom"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_LABEL="PHP Custom Code"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_CUSTOM_LINK_DESCRIPTION="Only the lines of code to like this $user->id to a field in the table, see the code in the editor for an example."
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_LABEL="Select other User Field"
PLG_CONTENT_COMPONENTBUILDERPRIVACYTABS_OTHER_USER_FIELD_DESCRIPTION="Select the other field that is the user-id field you would like to use to link the data to the user."

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

1
language/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

53
rules/code.php Normal file
View File

@ -0,0 +1,53 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormRule;
use Joomla\Registry\Registry;
/**
* Form Rule (Code) class for the Joomla Platform.
*/
class JFormRuleCode extends FormRule
{
/**
* Method to test the value.
*
* @param \SimpleXMLElement $element The SimpleXMLElement object representing the `<field>` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param Registry $input An optional Registry object with the entire data set to validate against the entire form.
* @param Form $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
{
// This removes all validation (is dangerous) but needed to submit code via JCB
return true;
/**
* My idea is to add some kind of validation to improve JCB code (per/language)
*
* So at this time this code validation is used for JavaScript,CSS,HTML and PHP.
* We can see what language is being worked on with the syntax property in the $element. (in JCB)
* What complicates things is the placeholders, of both custom code, component, and view names.
* Ideally we could strip them and then validate the code to being syntactically correct.
* But since some of the placeholders form part of the class/function names and the more, it seems like we are pressed for a much more advance solution.
* If you have any ideas to how we can go about to do this, then please open an issue on github and lets begin. (this is a nice to have, so don't break a leg...)
*/
}
}

1
rules/index.html Normal file
View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>

57
script.php Normal file
View File

@ -0,0 +1,57 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
/**
* Content - Componentbuilder Privacy Tabs script file.
*
* @package PlgContentComponentbuilderPrivacyTabs
*/
class plgContentComponentbuilderPrivacyTabsInstallerScript
{
/**
* Called before any type of action
*
* @param string $route Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $adapter The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($route, JAdapterInstance $adapter)
{
// get application
$app = JFactory::getApplication();
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
if ('install' === $route)
{
// check that componentbuilder is installed
$pathToCore = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php';
if (!JFile::exists($pathToCore))
{
$app->enqueueMessage('Joomla Component Builder must first be installed from <a href="https://www.joomlacomponentbuilder.com/ " target="_blank">Joomla Component Builder</a>.', 'error');
return false;
}
}
return true;
}
}