From fcfea05579c41f50f1d255bd2bbf454fadc29778 Mon Sep 17 00:00:00 2001 From: aB0t Date: Mon, 11 Mar 2024 18:39:21 +0200 Subject: [PATCH] Release of v2.0.0 --- componentbuilderprivacycompiler.php | 72 ++++++----- componentbuilderprivacycompiler.xml | 6 +- ...ension_componentbuilderprivacycompiler.ini | 2 +- ...on_componentbuilderprivacycompiler.sys.ini | 2 +- script.php | 116 ------------------ 5 files changed, 44 insertions(+), 154 deletions(-) diff --git a/componentbuilderprivacycompiler.php b/componentbuilderprivacycompiler.php index 8a7c810..8dae518 100644 --- a/componentbuilderprivacycompiler.php +++ b/componentbuilderprivacycompiler.php @@ -19,20 +19,16 @@ use Joomla\CMS\Plugin\CMSPlugin; use Joomla\Registry\Registry; use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - -use VDM\Joomla\Componentbuilder\Compiler\Factory as CFactory; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; -use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; - +use VDM\Joomla\Componentbuilder\Compiler\Factory as CompilerFactory; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line; +use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix; /** * Extension - Componentbuilder Privacy Compiler plugin. * * @package ComponentbuilderPrivacyCompiler - * @since 1.2.2 + * @since 2.0.0 */ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin { @@ -99,15 +95,25 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin { $view->addpermissions = array_values($view->addpermissions); // add the new permissions - $view->addpermissions[] = array('action' => 'view.privacy.delete', 'implementation' => 3, 'title' => $view->name_list . ' Privacy Delete', 'description' => ' Allows the users in this group to remove their personal data in ' . $view->name_list . ' via the Joomla privacy suite.'); - $view->addpermissions[] = array('action' => 'view.privacy.access', 'implementation' => 3, 'title' => $view->name_list . ' Privacy Access', 'description' => ' Allows the users in this group to access their personal data in ' . $view->name_list . ' via the Joomla privacy suite.'); + $view->addpermissions[] = [ + 'action' => 'view.privacy.delete', + 'implementation' => 3, + 'title' => $view->name_list . ' Privacy Delete', + 'description' => ' Allows the users in this group to remove their personal data in ' . $view->name_list . ' via the Joomla privacy suite.' + ]; + $view->addpermissions[] = [ + 'action' => 'view.privacy.access', + 'implementation' => 3, + 'title' => $view->name_list . ' Privacy Access', + 'description' => ' Allows the users in this group to access their personal data in ' . $view->name_list . ' via the Joomla privacy suite.' + ]; // convert back to json $view->addpermissions = json_encode($view->addpermissions, JSON_FORCE_OBJECT); } // add placeholders to view if not already set if (!isset($this->activeViews[$view->id]->placeholders)) { - $this->activeViews[$view->id]->placeholders = CFactory::_('Placeholder')->active; + $this->activeViews[$view->id]->placeholders = CompilerFactory::_('Placeholder')->active; } } } @@ -124,7 +130,7 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin // check if this component needs a privacy plugin loaded if ($this->loadPrivacy) { - $plugin = JPluginHelper::getPlugin('content', 'componentbuilderprivacytabs'); + $plugin = \JPluginHelper::getPlugin('content', 'componentbuilderprivacytabs'); // check if this is json if (isset($plugin->params) && JsonHelper::check($plugin->params)) { @@ -137,7 +143,7 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin if (isset($plugin->params['plugin']) && $plugin->params['plugin'] > 0) { // if linked it will only load it once - CFactory::_('Joomlaplugin.Data')->set($plugin->params['plugin']); + CompilerFactory::_('Joomlaplugin.Data')->set($plugin->params['plugin']); } else { @@ -160,8 +166,8 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin if ($this->loadPrivacy && ArrayHelper::check($this->activeViews)) { // get compiler defaults - $strictFieldExportPermissions = CFactory::_('Config')->get('permission_strict_per_field', false); - $exportTextOnly = CFactory::_('Config')->get('export_text_only', 1); + $strictFieldExportPermissions = CompilerFactory::_('Config')->get('permission_strict_per_field', false); + $exportTextOnly = CompilerFactory::_('Config')->get('export_text_only', 1); // load the getPrivacyExport functions foreach ($this->activeViews as $id => &$view) @@ -169,18 +175,18 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin // set permissions based on view if (isset($view->params['privacy']['permissions'])) { - CFactory::_('Config')->set('permission_strict_per_field', (bool) $view->params['privacy']['permissions']); + CompilerFactory::_('Config')->set('permission_strict_per_field', (bool) $view->params['privacy']['permissions']); } // allow text only export - CFactory::_('Config')->set('export_text_only', 1); + CompilerFactory::_('Config')->set('export_text_only', 1); // set view list name $viewName_list = StringHelper::safe($view->name_list); // set view single name $viewName_single = StringHelper::safe($view->name_single); // load the function - CFactory::_('Compiler.Builder.Content.Multi')->add($viewName_list . '|MODELEXPORTMETHOD', + CompilerFactory::_('Compiler.Builder.Content.Multi')->add($viewName_list . '|MODELEXPORTMETHOD', $compiler->setGetItemsModelMethod( $viewName_single, $viewName_list, @@ -192,7 +198,7 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin ) ); // get the permissions building values for later if needed - if (CFactory::_('Config')->get('permission_strict_per_field', false) && + if (CompilerFactory::_('Config')->get('permission_strict_per_field', false) && isset($compiler->permissionFields[$viewName_single]) && ArrayHelper::check($compiler->permissionFields[$viewName_single])) { @@ -201,8 +207,8 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin } // set compiler defaults - CFactory::_('Config')->set('permission_strict_per_field', $strictFieldExportPermissions); - CFactory::_('Config')->set('export_text_only', $exportTextOnly); + CompilerFactory::_('Config')->set('permission_strict_per_field', $strictFieldExportPermissions); + CompilerFactory::_('Config')->set('export_text_only', $exportTextOnly); // add helper classes $helper_strings = ['CUSTOM_HELPER_SCRIPT', 'SITE_CUSTOM_HELPER_SCRIPT', 'BOTH_CUSTOM_HELPER_SCRIPT']; @@ -214,7 +220,7 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin foreach ($helper_strings as $helper) { - if (($helper_content = CFactory::_('Compiler.Builder.Content.One')->get($helper)) !== null && + if (($helper_content = CompilerFactory::_('Compiler.Builder.Content.One')->get($helper)) !== null && StringHelper::check($helper_content)) { foreach ($privacy_events as $privacy_event => &$add) @@ -229,8 +235,8 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin } // add the events still needed - CFactory::_('Compiler.Builder.Content.One')->add('BOTH_CUSTOM_HELPER_SCRIPT', - CFactory::_('Placeholder')->update_($this->getHelperMethod($privacy_events)) + CompilerFactory::_('Compiler.Builder.Content.One')->add('BOTH_CUSTOM_HELPER_SCRIPT', + CompilerFactory::_('Placeholder')->update_($this->getHelperMethod($privacy_events)) ); } } @@ -248,7 +254,7 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin { foreach($this->languageArray as $key => $string) { - CFactory::_('Language')->set('site', $key, $string); + CompilerFactory::_('Language')->set('site', $key, $string); } } } @@ -316,9 +322,9 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin $methods .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Check if user has permission to delete " . $view->name_list; // set the if statement based on the permission builder $methods .= PHP_EOL . Indent::_(2) . "if (!\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.delete') + . CompilerFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.delete') . "', 'com_" . Placefix::_("component") . "') && !\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.privacy.delete') + . CompilerFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.privacy.delete') . "', 'com_" . Placefix::_("component") . "'))"; $methods .= PHP_EOL . Indent::_(2) . "{"; // set language key @@ -374,9 +380,9 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin $methods .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Check if user has permission to access " . $view->name_list; // set the if statement based on the permission builder $methods .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($viewName_single, 'core.access') + . CompilerFactory::_('Compiler.Creator.Permission')->getGlobal($viewName_single, 'core.access') . "', 'com_" . Placefix::_("component") . "') || \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getGlobal($viewName_single, 'core.privacy.access') + . CompilerFactory::_('Compiler.Creator.Permission')->getGlobal($viewName_single, 'core.privacy.access') . "', 'com_" . Placefix::_("component") . "'))"; $methods .= PHP_EOL . Indent::_(2) . "{"; $methods .= PHP_EOL . Indent::_(3) . "//" . Line::_(__Line__, __Class__) . " Get " . $view->name_single . " domain"; @@ -576,9 +582,9 @@ class PlgExtensionComponentbuilderPrivacyCompiler extends CMSPlugin $methods .= PHP_EOL . Indent::_(2) . "//" . Line::_(__Line__, __Class__) . " Check if user has permission to delet " . $view->name_list; // set the if statement based on the permission builder $methods .= PHP_EOL . Indent::_(2) . "if (\$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.delete') + . CompilerFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.delete') . "', 'com_" . Placefix::_("component") . "') || \$user->authorise('" - . CFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.privacy.delete') + . CompilerFactory::_('Compiler.Creator.Permission')->getAction($viewName_single, 'core.privacy.delete') . "', 'com_" . Placefix::_("component") . "'))"; $methods .= PHP_EOL . Indent::_(2) . "{"; // check if this is a plain delete, or it is a Anonymize diff --git a/componentbuilderprivacycompiler.xml b/componentbuilderprivacycompiler.xml index bdecf0d..09bcf71 100644 --- a/componentbuilderprivacycompiler.xml +++ b/componentbuilderprivacycompiler.xml @@ -1,13 +1,13 @@ - + PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER - 9th March, 2024 + 11th March, 2024 Llewellyn van der Merwe joomla@vdm.io https://dev.vdm.io Copyright (C) 2015 Vast Development Method. All rights reserved. GNU General Public License version 2 or later; see LICENSE.txt - 1.2.2 + 2.0.0 PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_XML_DESCRIPTION diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.ini b/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.ini index 2d249ec..9624d7a 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.ini @@ -1,4 +1,4 @@ PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER="Extension - Componentbuilder Privacy Compiler" PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_DESCRIPTION="This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin." -PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Privacy Compiler (v.1.2.2)

This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin.

Created by Llewellyn van der Merwe
Development started 17th August, 2019

" +PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Privacy Compiler (v.2.0.0)

This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_PRIVACY_PLUGIN_SETUP_SO_THE_INTEGRATION_WITH_JOOMLA_PRIVACY_SUITE_COULD_NOT_BE_BUILD="You do not have a global privacy plugin setup, so the integration with Joomla privacy suite could not be build." \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.sys.ini b/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.sys.ini index 2d249ec..9624d7a 100644 --- a/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.sys.ini +++ b/language/en-GB/en-GB.plg_extension_componentbuilderprivacycompiler.sys.ini @@ -1,4 +1,4 @@ PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER="Extension - Componentbuilder Privacy Compiler" PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_DESCRIPTION="This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin." -PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Privacy Compiler (v.1.2.2)

This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin.

Created by Llewellyn van der Merwe
Development started 17th August, 2019

" +PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_XML_DESCRIPTION="

Extension - Componentbuilder Privacy Compiler (v.2.0.0)

This plugin is used to build the privacy plugin for your component during compilation. To activate it you must first enable it here. Then open your JCB component global options, and under the Global tab, select this plugin in the Activate Compiler Plugins field.Also be sure to link your admin views to the privacy suite of Joomla via our other Content - Componentbuilder Privacy Tabs plugin.

Created by Llewellyn van der Merwe
Development started 10th March, 2024

" PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER_YOU_DO_NOT_HAVE_A_GLOBAL_PRIVACY_PLUGIN_SETUP_SO_THE_INTEGRATION_WITH_JOOMLA_PRIVACY_SUITE_COULD_NOT_BE_BUILD="You do not have a global privacy plugin setup, so the integration with Joomla privacy suite could not be build." \ No newline at end of file diff --git a/script.php b/script.php index a0ea86b..6eaed04 100644 --- a/script.php +++ b/script.php @@ -24,120 +24,4 @@ use Joomla\CMS\Filesystem\Folder; */ class plgExtensionComponentbuilderPrivacyCompilerInstallerScript { - - /** - * Called before any type of action - * - * @param string $route Which action is happening (install|uninstall|discover_install|update) - * @param Joomla\CMS\Installer\InstallerAdapter $adapter The object responsible for running this script - * - * @return boolean True on success - */ - public function preflight($route, $adapter) - { - // get application - $app = Factory::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) - { -// needs fix - - - // 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 Joomla Component Builder.', 'error'); - return false; - } - - // load the helper class - JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - - // block install - $blockInstall = true; - - // check the version of JCB - $manifest = ComponentbuilderHelper::manifest(); - if (isset($manifest->version) && strpos($manifest->version, '.') !== false) - { - // get the version - $jcbVersion = explode('.', $manifest->version); - // check that we have JCB 3.0.0 or higher installed - if (count($jcbVersion) == 3 && $jcbVersion[0] >= 3 && - ( - ($jcbVersion[0] == 3 && $jcbVersion[1] == 0 && $jcbVersion[2] >= 0) || - ($jcbVersion[0] == 3 && $jcbVersion[1] > 0) || - $jcbVersion[0] > 3) - ) - { - $blockInstall = false; - } - } - - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB v3.0.0 or higher before installing this plugin.', 'error'); - return false; - } - - - // 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 Joomla Component Builder.', 'error'); - return false; - } - // load the helper class - JLoader::register('ComponentbuilderHelper', JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/componentbuilder.php'); - // block install - $blockInstall = true; - // check the version of JCB - $manifest = ComponentbuilderHelper::manifest(); - if (isset($manifest->version) && strpos($manifest->version, '.') !== false) - { - // get the version - $jcbVersion = explode('.', $manifest->version); - // check that we have JCB 2.10.13 or higher installed - if (count($jcbVersion) == 3 && (($jcbVersion[0] == 2 && $jcbVersion[1] >= 10 && (($jcbVersion[1] == 10 && $jcbVersion[2] >= 13) || ($jcbVersion[1] > 10))) || $jcbVersion[0] >= 3)) - { - $blockInstall = false; - } - } - // allow install if all conditions are met - if ($blockInstall) - { - $app->enqueueMessage('Please upgrade to JCB 2.10.13 or higher before installing this plugin.', 'error'); - return false; - } - - // 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 Joomla Component Builder.', 'error'); - return false; - } - - // 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 Joomla Component Builder.', 'error'); - return false; - } - } - - return true; - } }