From a169c829f2a51d0aa7a9a6dfe5d8c29b3ce30785 Mon Sep 17 00:00:00 2001
From: aB0t Upgrade to Version 4.0.3-alpha2 Was Successful! Let us know if anything is not working as expected.
Upgrade to Version 4.0.3-alpha3 Was Successful! Let us know if anything is not working as expected.
';
// Add/Update component in the action logs extensions table.
$this->setActionLogsExtensions();
diff --git a/README.md b/README.md
index 39ce7d3c9..240161e5c 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
-You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (4.0.3-alpha2) with **ALL** its features and **ALL** concepts totally open-source and free!
+You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (4.0.3-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@@ -144,14 +144,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
-+ *Last Build*: 21st August, 2024
-+ *Version*: 4.0.3-alpha2
++ *Last Build*: 23rd August, 2024
++ *Version*: 4.0.3-alpha3
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
-+ *Line count*: **828095**
++ *Line count*: **832511**
+ *Field count*: **2098**
-+ *File count*: **5740**
-+ *Folder count*: **606**
++ *File count*: **5784**
++ *Folder count*: **610**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)
diff --git a/admin/README.txt b/admin/README.txt
index 39ce7d3c9..240161e5c 100644
--- a/admin/README.txt
+++ b/admin/README.txt
@@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
-You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (4.0.3-alpha2) with **ALL** its features and **ALL** concepts totally open-source and free!
+You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (4.0.3-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
@@ -144,14 +144,14 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
+ *First Build*: 30th April, 2015
-+ *Last Build*: 21st August, 2024
-+ *Version*: 4.0.3-alpha2
++ *Last Build*: 23rd August, 2024
++ *Version*: 4.0.3-alpha3
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
-+ *Line count*: **828095**
++ *Line count*: **832511**
+ *Field count*: **2098**
-+ *File count*: **5740**
-+ *Folder count*: **606**
++ *File count*: **5784**
++ *Folder count*: **610**
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io)
diff --git a/admin/access.xml b/admin/access.xml
index b9c62d874..f02c11430 100644
--- a/admin/access.xml
+++ b/admin/access.xml
@@ -271,6 +271,9 @@
%s
Joomla Power repository at %s/%s gave the following error!
%s
Joomla Power guid:%s not found!
" COM_COMPONENTBUILDER_PJOOMLA_POWER_BGUIDSB_WAS_FOUND_BUT_MISSING_A_NAMESPACE_VALUE_FOR_JOOMLA_SP="Joomla Power guid:%s was found, but missing a namespace value for Joomla %s!
" @@ -7995,6 +8003,7 @@ COM_COMPONENTBUILDER_REPOSITORY_GUID_DESCRIPTION="Globally Unique Identifier" COM_COMPONENTBUILDER_REPOSITORY_GUID_HINT="Auto Generated" COM_COMPONENTBUILDER_REPOSITORY_GUID_LABEL="GUID" COM_COMPONENTBUILDER_REPOSITORY_ID="Id" +COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPES="Joomla Field Types" COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER="Joomla Power" COM_COMPONENTBUILDER_REPOSITORY_MODIFIED_BY_DESC="The last user that modified this Repository." COM_COMPONENTBUILDER_REPOSITORY_MODIFIED_BY_LABEL="Modified By" @@ -8902,7 +8911,6 @@ COM_COMPONENTBUILDER_SUBMENU_TEMPLATES="Templates" COM_COMPONENTBUILDER_SUBMENU_VALIDATION_RULES="Validation Rules" COM_COMPONENTBUILDER_SUCCESS="Success" COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_JOOMLA_POWERS="Successfully Initialized all Remote Joomla Powers" -COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_POWERS="Successfully Initialized all Remote Powers" COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED="Success! The snippet was saved." COM_COMPONENTBUILDER_SUCCESS_THE_SNIPPET_WAS_SAVED_BUT_THE_MODIFIED_DATE_COULD_NOT_BE_ADJUSTED_BR_BR_BTHIS_MEANS_THE_SNIPPETS_WILL_CONTINUE_TO_APPEAR_OUT_OF_DATEB="Success! The snippet was saved. But the modified date could not be adjusted.' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INITIALIZE_JOOMLA_FIELD_TYPES') . '
'; + $status = 'error'; + $success = false; + + if($user->authorise('fieldtype.init', 'com_componentbuilder')) + { + try { + if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Get')->init()) + { + // set success message + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_JOOMLA_FIELD_TYPES_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '
'; + + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_JOOMLA_FIELD_TYPES_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { + $message = '' . \htmlspecialchars($e->getMessage()) . '
'; + } + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', $success); + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + /** + * Resets the selected Joomla Field Types. + * + * This function performs several checks and operations: + * 1. It verifies the authenticity of the request to prevent request forgery. + * 2. It retrieves the IDs of the selected powers from the user input. + * 3. It sanitizes the input by converting the IDs to integers. + * 4. It checks whether any powers have been selected. + * 5. It checks whether the current user has the necessary permissions to reset the selected Joomla Field Types. + * 6. If the user is authorized and powers are selected, it attempts to reset the selected Joomla Field Types. + * 7. Depending on the result of the reset operation, it sets the appropriate success or error message. + * 8. It redirects the user to a specified URL with the result message and status. + * + * @return bool True on successful reset, false on failure. + */ + public function resetPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get IDS of the selected powers + $pks = $this->input->post->get('cid', [], 'array'); + + // Sanitize the input + ArrayHelper::toInteger($pks); + + // check if there is any selections + if ($pks === []) + { + // set error message + $message = ''.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'
'; + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', false); + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + $status = 'error'; + $success = false; + + // check if user has the right + $user = Factory::getUser(); + if($user->authorise('fieldtype.reset', 'com_componentbuilder')) + { + $guids = GetHelper::vars('fieldtype', $pks, 'id', 'guid'); + + try { + if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Get')->reset($guids)) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_FIELD_TYPES_HAVE_SUCCESSFULLY_BEEN_RESET').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_JOOMLA_FIELD_TYPES_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { + $message = '' . \htmlspecialchars($e->getMessage()) . '
'; + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', $success); + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', false); + $this->setRedirect($redirect_url); + return $success; + } + + /** + * Pushes the selected Joomla Field Types. + * + * This function performs several checks and operations: + * 1. It verifies the authenticity of the request to prevent request forgery. + * 2. It retrieves the IDs of the selected powers from the user input. + * 3. It sanitizes the input by converting the IDs to integers. + * 4. It checks whether any powers have been selected. + * 5. It checks whether the current user has the necessary permissions to push the selected Joomla Field Types. + * 6. If the user is authorized and powers are selected, it attempts to push the selected Joomla Field Types. + * 7. Depending on the result of the push operation, it sets the appropriate success or error message. + * 8. It redirects the user to a specified URL with the result message and status. + * + * @return bool True on successful push, false on failure. + */ + public function pushPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get IDS of the selected powers + $pks = $this->input->post->get('cid', [], 'array'); + + // Sanitize the input + ArrayHelper::toInteger($pks); + + // check if there is any selections + if ($pks === []) + { + // set error message + $message = ''.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'
'; + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', false); + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + + $status = 'error'; + $success = false; + + // check if user has the right + $user = Factory::getUser(); + if($user->authorise('fieldtype.push', 'com_componentbuilder')) + { + $guids = GetHelper::vars('fieldtype', $pks, 'id', 'guid'); + + try { + if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Set')->items($guids)) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THESE_JOOMLA_FIELD_TYPES_HAVE_SUCCESSFULLY_BEEN_PUSHED').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THESE_JOOMLA_FIELD_TYPES_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { + $message = '' . \htmlspecialchars($e->getMessage()) . '
'; + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', $success); + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + // set redirect + $redirect_url = Route::_('index.php?option=com_componentbuilder&view=fieldtypes', false); + $this->setRedirect($redirect_url); + return $success; + } + /** * Method override to check if you can add a new record. * diff --git a/admin/src/Controller/FieldtypesController.php b/admin/src/Controller/FieldtypesController.php index 509a721c0..0abeb85a1 100644 --- a/admin/src/Controller/FieldtypesController.php +++ b/admin/src/Controller/FieldtypesController.php @@ -17,6 +17,7 @@ use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; +use VDM\Joomla\Componentbuilder\Fieldtype\Factory as FieldtypeFactory; // No direct access to this file \defined('_JEXEC') or die; @@ -51,4 +52,150 @@ class FieldtypesController extends AdminController { return parent::getModel($name, $prefix, $config); } + + + /** + * Resets the specified Joomla Field Type. + * + * This function performs several checks and operations: + * 1. It verifies the authenticity of the request to prevent request forgery. + * 2. It retrieves the item data posted by the user. + * 3. It checks whether the current user has the necessary permissions to reset the Joomla Field Type. + * 4. It validates the presence of the necessary item identifiers (ID and GUID). + * 5. If the user is authorized and the identifiers are valid, it attempts to reset the specified Joomla Field Type. + * 6. Depending on the result of the reset operation, it sets the appropriate success or error message. + * 7. It redirects the user to a specified URL with the result message and status. + * + * @return bool True on successful reset, false on failure. + */ + public function resetPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get Item posted + $item = $this->input->post->get('jform', array(), 'array'); + + // check if user has the right + $user = Factory::getUser(); + + // set default error message + $message = '' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_RESET_THIS_JOOMLA_FIELD_TYPE') . '
'; + $status = 'error'; + $success = false; + + // load the ID + $id = $item['id'] ?? null; + $guid = $item['guid'] ?? null; + + // check if there is any selections + if ($id === null || $guid === null) + { + // set error message + $message = '' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_JOOMLA_FIELD_TYPE_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '
'; + } + elseif($user->authorise('fieldtype.reset', 'com_componentbuilder')) + { + if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Get')->reset([$guid])) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_FIELD_TYPE_HAS_SUCCESSFULLY_BEEN_RESET').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_FIELD_TYPE_HAS_FAILED') . '
'; + } + } + + // set redirect + $redirect_url = Route::_( + 'index.php?option=com_componentbuilder&view=fieldtype' + . $this->getRedirectToItemAppend($id), $success + ); + + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } + + /** + * Pushes the specified Joomla Field Type. + * + * This function performs several checks and operations: + * 1. It verifies the authenticity of the request to prevent request forgery. + * 2. It retrieves the item data posted by the user. + * 3. It checks whether the current user has the necessary permissions to push the Joomla Field Type. + * 4. It validates the presence of the necessary item identifiers (ID and GUID). + * 5. If the user is authorized and the identifiers are valid, it attempts to push the specified Joomla Field Type. + * 6. Depending on the result of the push operation, it sets the appropriate success or error message. + * 7. It redirects the user to a specified URL with the result message and status. + * + * @return bool True on successful push, false on failure. + */ + public function pushPowers() + { + // Check for request forgeries + Session::checkToken() or die(Text::_('JINVALID_TOKEN')); + + // get Item posted + $item = $this->input->post->get('jform', array(), 'array'); + + // check if user has the right + $user = Factory::getUser(); + + // set default error message + $message = '' . Text::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_PUSH_THIS_JOOMLA_FIELD_TYPE') . '
'; + $status = 'error'; + $success = false; + + // load the ID + $id = $item['id'] ?? null; + $guid = $item['guid'] ?? null; + + // check if there is any selections + if ($id === null || $guid === null) + { + // set error message + $message = '' . Text::_('COM_COMPONENTBUILDER_YOU_MUST_FIRST_SAVE_THE_JOOMLA_FIELD_TYPE_BEFORE_YOU_CAN_USE_THIS_FEATURE') . '
'; + } + elseif($user->authorise('fieldtype.push', 'com_componentbuilder')) + { + try { + if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Set')->items([$guid])) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_FIELD_TYPE_HAS_SUCCESSFULLY_BEEN_PUSHED').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_JOOMLA_FIELD_TYPE_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { + $message = '' . \htmlspecialchars($e->getMessage()) . '
'; + } + } + + // set redirect + $redirect_url = Route::_( + 'index.php?option=com_componentbuilder&view=fieldtype' + . $this->getRedirectToItemAppend($id), $success + ); + + $this->setRedirect($redirect_url, $message, $status); + + return $success; + } } \ No newline at end of file diff --git a/admin/src/Controller/Joomla_powerController.php b/admin/src/Controller/Joomla_powerController.php index 4679c1c01..4dbf758e1 100644 --- a/admin/src/Controller/Joomla_powerController.php +++ b/admin/src/Controller/Joomla_powerController.php @@ -63,15 +63,16 @@ class Joomla_powerController extends FormController */ protected $view_list = 'joomla_powers'; + /** - * Resets the specified Joomla power. + * Resets the specified Joomla Power. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the item data posted by the user. - * 3. It checks whether the current user has the necessary permissions to reset the Joomla power. + * 3. It checks whether the current user has the necessary permissions to reset the Joomla Power. * 4. It validates the presence of the necessary item identifiers (ID and GUID). - * 5. If the user is authorized and the identifiers are valid, it attempts to reset the specified power. + * 5. If the user is authorized and the identifiers are valid, it attempts to reset the specified Joomla Power. * 6. Depending on the result of the reset operation, it sets the appropriate success or error message. * 7. It redirects the user to a specified URL with the result message and status. * @@ -107,23 +108,18 @@ class Joomla_powerController extends FormController } elseif($user->authorise('joomla_power.reset', 'com_componentbuilder')) { - try { - if (JoomlaPowerFactory::_('Joomla.Power.Remote.Get')->reset([$guid])) - { - // set success message - $message = ''.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'
'; - $status = 'success'; - $success = true; - } - else - { - $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '
'; - } - } catch (\Exception $e) { + if (JoomlaPowerFactory::_('Joomla.Power.Remote.Get')->reset([$guid])) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'
'; + $status = 'success'; + $success = true; + } + else + { $message = '' . \htmlspecialchars($e->getMessage()) . '
'; + $message .= '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '
'; } } @@ -139,14 +135,14 @@ class Joomla_powerController extends FormController } /** - * Pushes the specified Joomla power. + * Pushes the specified Joomla Power. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the item data posted by the user. - * 3. It checks whether the current user has the necessary permissions to push the Joomla power. + * 3. It checks whether the current user has the necessary permissions to push the Joomla Power. * 4. It validates the presence of the necessary item identifiers (ID and GUID). - * 5. If the user is authorized and the identifiers are valid, it attempts to push the specified power. + * 5. If the user is authorized and the identifiers are valid, it attempts to push the specified Joomla Power. * 6. Depending on the result of the push operation, it sets the appropriate success or error message. * 7. It redirects the user to a specified URL with the result message and status. * diff --git a/admin/src/Controller/Joomla_powersController.php b/admin/src/Controller/Joomla_powersController.php index 8c73d07f3..f2a4503a3 100644 --- a/admin/src/Controller/Joomla_powersController.php +++ b/admin/src/Controller/Joomla_powersController.php @@ -54,13 +54,14 @@ class Joomla_powersController extends AdminController return parent::getModel($name, $prefix, $config); } + /** - * Initializes all remote Joomla powers and syncs them with the local database. + * Initializes all remote Joomla Powers and syncs them with the local database. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. - * 2. It checks whether the current user has the necessary permissions to initialize the Joomla powers. - * 3. If the user is authorized, it attempts to initialize the remote Joomla powers. + * 2. It checks whether the current user has the necessary permissions to initialize the Joomla Powers. + * 3. If the user is authorized, it attempts to initialize the remote Joomla Powers. * 4. Depending on the result of the initialization operation, it sets the appropriate success or error message. * 5. It redirects the user to a specified URL with the result message and status. * @@ -111,15 +112,15 @@ class Joomla_powersController extends AdminController } /** - * Resets the selected Joomla powers. + * Resets the selected Joomla Powers. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the IDs of the selected powers from the user input. * 3. It sanitizes the input by converting the IDs to integers. * 4. It checks whether any powers have been selected. - * 5. It checks whether the current user has the necessary permissions to reset the selected Joomla powers. - * 6. If the user is authorized and powers are selected, it attempts to reset the selected Joomla powers. + * 5. It checks whether the current user has the necessary permissions to reset the selected Joomla Powers. + * 6. If the user is authorized and powers are selected, it attempts to reset the selected Joomla Powers. * 7. Depending on the result of the reset operation, it sets the appropriate success or error message. * 8. It redirects the user to a specified URL with the result message and status. * @@ -190,15 +191,15 @@ class Joomla_powersController extends AdminController } /** - * Pushes the selected Joomla powers. + * Pushes the selected Joomla Powers. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the IDs of the selected powers from the user input. * 3. It sanitizes the input by converting the IDs to integers. * 4. It checks whether any powers have been selected. - * 5. It checks whether the current user has the necessary permissions to push the selected Joomla powers. - * 6. If the user is authorized and powers are selected, it attempts to push the selected Joomla powers. + * 5. It checks whether the current user has the necessary permissions to push the selected Joomla Powers. + * 6. If the user is authorized and powers are selected, it attempts to push the selected Joomla Powers. * 7. Depending on the result of the push operation, it sets the appropriate success or error message. * 8. It redirects the user to a specified URL with the result message and status. * diff --git a/admin/src/Controller/PowerController.php b/admin/src/Controller/PowerController.php index d9fd5173b..5fc2e42a5 100644 --- a/admin/src/Controller/PowerController.php +++ b/admin/src/Controller/PowerController.php @@ -63,6 +63,7 @@ class PowerController extends FormController */ protected $view_list = 'powers'; + /** * Resets the specified power. * diff --git a/admin/src/Controller/PowersController.php b/admin/src/Controller/PowersController.php index 37184982b..e31761f18 100644 --- a/admin/src/Controller/PowersController.php +++ b/admin/src/Controller/PowersController.php @@ -54,13 +54,14 @@ class PowersController extends AdminController return parent::getModel($name, $prefix, $config); } + /** - * Initializes all remote powers and syncs them with the local database. + * Initializes all remote Powers and syncs them with the local database. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. - * 2. It checks whether the current user has the necessary permissions to initialize the powers. - * 3. If the user is authorized, it attempts to initialize the remote powers. + * 2. It checks whether the current user has the necessary permissions to initialize the Powers. + * 3. If the user is authorized, it attempts to initialize the remote Powers. * 4. Depending on the result of the initialization operation, it sets the appropriate success or error message. * 5. It redirects the user to a specified URL with the result message and status. * @@ -82,19 +83,24 @@ class PowersController extends AdminController if($user->authorise('power.init', 'com_componentbuilder')) { - if (PowerFactory::_('Power.Remote.Get')->init()) - { - // set success message - $message = '' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '
'; + try { + if (PowerFactory::_('Power.Remote.Get')->init()) + { + // set success message + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '
'; - $status = 'success'; - $success = true; - } - else - { + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { $message = '' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED') . '
'; + $message .= '' . \htmlspecialchars($e->getMessage()) . '
'; } } @@ -106,15 +112,15 @@ class PowersController extends AdminController } /** - * Resets the selected powers. + * Resets the selected Powers. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the IDs of the selected powers from the user input. * 3. It sanitizes the input by converting the IDs to integers. * 4. It checks whether any powers have been selected. - * 5. It checks whether the current user has the necessary permissions to reset the selected powers. - * 6. If the user is authorized and powers are selected, it attempts to reset the selected powers. + * 5. It checks whether the current user has the necessary permissions to reset the selected Powers. + * 6. If the user is authorized and powers are selected, it attempts to reset the selected Powers. * 7. Depending on the result of the reset operation, it sets the appropriate success or error message. * 8. It redirects the user to a specified URL with the result message and status. * @@ -152,18 +158,23 @@ class PowersController extends AdminController { $guids = GetHelper::vars('power', $pks, 'id', 'guid'); - if (PowerFactory::_('Power.Remote.Get')->reset($guids)) - { - // set success message - $message = ''.Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'
'; - $status = 'success'; - $success = true; - } - else - { + try { + if (PowerFactory::_('Power.Remote.Get')->reset($guids)) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_POWERS_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THESE_POWERS_HAS_FAILED') . '
'; + $message .= '' . \htmlspecialchars($e->getMessage()) . '
'; } // set redirect @@ -180,15 +191,15 @@ class PowersController extends AdminController } /** - * Pushes the selected powers. + * Pushes the selected Powers. * * This function performs several checks and operations: * 1. It verifies the authenticity of the request to prevent request forgery. * 2. It retrieves the IDs of the selected powers from the user input. * 3. It sanitizes the input by converting the IDs to integers. * 4. It checks whether any powers have been selected. - * 5. It checks whether the current user has the necessary permissions to push the selected powers. - * 6. If the user is authorized and powers are selected, it attempts to push the selected powers. + * 5. It checks whether the current user has the necessary permissions to push the selected Powers. + * 6. If the user is authorized and powers are selected, it attempts to push the selected Powers. * 7. Depending on the result of the push operation, it sets the appropriate success or error message. * 8. It redirects the user to a specified URL with the result message and status. * diff --git a/admin/src/Helper/ComponentbuilderHelper.php b/admin/src/Helper/ComponentbuilderHelper.php index 1900d9517..fb7fd0b01 100644 --- a/admin/src/Helper/ComponentbuilderHelper.php +++ b/admin/src/Helper/ComponentbuilderHelper.php @@ -3514,12 +3514,12 @@ abstract class ComponentbuilderHelper 'editor', 'editors', 'email', 'file', 'file', 'filelist', 'folderlist', 'groupedlist', 'headertag', 'helpsite', 'hidden', 'imagelist', 'integer', 'language', 'list', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'moduleorder', 'moduleposition', 'moduletag', 'note', 'number', 'password', 'plugins', 'predefinedlist', 'radio', 'range', 'repeatable', 'rules', - 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + 'sessionhandler', 'spacer', 'sql', 'subform', 'tag', 'tel', 'templatestyle', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup', 'usergrouplist' ), 'plain' => array( 'cachehandler', 'calendar', 'checkbox', 'chromestyle', 'color', 'componentlayout', 'contenttype', 'editor', 'editors', 'captcha', 'email', 'file', 'headertag', 'helpsite', 'hidden', 'integer', 'language', 'media', 'menu', 'modal_menu', 'menuitem', 'meter', 'modulelayout', 'templatestyle', - 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup' + 'moduleorder', 'moduletag', 'number', 'password', 'range', 'rules', 'tag', 'tel', 'text', 'textarea', 'timezone', 'url', 'user', 'usergroup', 'usergrouplist' ), 'option' => array( 'accesslevel', 'category', 'checkboxes', 'combo', 'contentlanguage', 'databaseconnection', 'components', diff --git a/admin/src/Model/Help_documentsModel.php b/admin/src/Model/Help_documentsModel.php index 47a69c4f0..1bd26e67f 100644 --- a/admin/src/Model/Help_documentsModel.php +++ b/admin/src/Model/Help_documentsModel.php @@ -25,7 +25,6 @@ use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper; use Joomla\CMS\Helper\TagsHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; -use VDM\Joomla\Utilities\JsonHelper; use VDM\Joomla\Utilities\StringHelper; // No direct access to this file @@ -216,8 +215,17 @@ class Help_documentsModel extends ListModel continue; } - // convert groups - $item->groups = JsonHelper::string($item->groups, ', ', 'groups'); + // decode groups + $groupsArray = json_decode($item->groups, true); + if (UtilitiesArrayHelper::check($groupsArray)) + { + $groupsNames = []; + foreach ($groupsArray as $groups) + { + $groupsNames[] = ComponentbuilderHelper::getGroupName($groups); + } + $item->groups = implode(', ', $groupsNames); + } } } @@ -317,7 +325,7 @@ class Help_documentsModel extends ListModel else { $search = $db->quote('%' . $db->escape($search) . '%'); - $query->where('(a.title LIKE '.$search.' OR a.type LIKE '.$search.' OR a.location LIKE '.$search.' OR a.admin_view LIKE '.$search.' OR h. LIKE '.$search.' OR a.site_view LIKE '.$search.' OR i. LIKE '.$search.')'); + $query->where('(a.title LIKE '.$search.' OR a.type LIKE '.$search.' OR a.location LIKE '.$search.' OR a.admin_view LIKE '.$search.' OR g. LIKE '.$search.' OR a.site_view LIKE '.$search.' OR h. LIKE '.$search.')'); } } diff --git a/admin/src/Model/RepositoriesModel.php b/admin/src/Model/RepositoriesModel.php index bd30b680c..ce4096a60 100644 --- a/admin/src/Model/RepositoriesModel.php +++ b/admin/src/Model/RepositoriesModel.php @@ -249,7 +249,8 @@ class RepositoriesModel extends ListModel $targetArray = array( 0 => 'COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION', 1 => 'COM_COMPONENTBUILDER_REPOSITORY_SUPER_POWER', - 2 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER' + 2 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER', + 3 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPES' ); // Now check if value is found in this array if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value])) diff --git a/admin/src/View/Fieldtype/HtmlView.php b/admin/src/View/Fieldtype/HtmlView.php index dc6329bee..dd61c940b 100644 --- a/admin/src/View/Fieldtype/HtmlView.php +++ b/admin/src/View/Fieldtype/HtmlView.php @@ -256,6 +256,16 @@ class HtmlView extends BaseHtmlView { ToolbarHelper::custom('fieldtype.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); } + if ($this->canDo->get('fieldtype.reset')) + { + // add Reset button. + ToolbarHelper::custom('fieldtype.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); + } + if ($this->canDo->get('fieldtype.push')) + { + // add Push button. + ToolbarHelper::custom('fieldtype.pushPowers', 'joomla custom-button-pushpowers', '', 'COM_COMPONENTBUILDER_PUSH', false); + } ToolbarHelper::cancel('fieldtype.cancel', 'JTOOLBAR_CLOSE'); } } diff --git a/admin/src/View/Fieldtypes/HtmlView.php b/admin/src/View/Fieldtypes/HtmlView.php index de2e5ce27..025669bad 100644 --- a/admin/src/View/Fieldtypes/HtmlView.php +++ b/admin/src/View/Fieldtypes/HtmlView.php @@ -198,6 +198,21 @@ class HtmlView extends BaseHtmlView ToolbarHelper::trash('fieldtypes.trash'); } } + if ($this->user->authorise('fieldtype.init', 'com_componentbuilder')) + { + // add Init button. + ToolbarHelper::custom('fieldtypes.initPowers', 'health custom-button-initpowers', '', 'COM_COMPONENTBUILDER_INIT', false); + } + if ($this->user->authorise('fieldtype.reset', 'com_componentbuilder')) + { + // add Reset button. + ToolbarHelper::custom('fieldtypes.resetPowers', 'joomla custom-button-resetpowers', '', 'COM_COMPONENTBUILDER_RESET', false); + } + if ($this->user->authorise('fieldtype.push', 'com_componentbuilder')) + { + // add Push button. + ToolbarHelper::custom('fieldtypes.pushPowers', 'joomla custom-button-pushpowers', '', 'COM_COMPONENTBUILDER_PUSH', false); + } // set help url for this view if found $this->help_url = ComponentbuilderHelper::getHelpUrl('fieldtypes'); diff --git a/admin/src/View/Help_documents/HtmlView.php b/admin/src/View/Help_documents/HtmlView.php index 2cc23cb1b..3e314c634 100644 --- a/admin/src/View/Help_documents/HtmlView.php +++ b/admin/src/View/Help_documents/HtmlView.php @@ -270,8 +270,8 @@ class HtmlView extends BaseHtmlView 'a.title' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TITLE_LABEL'), 'a.type' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_TYPE_LABEL'), 'a.location' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_LOCATION_LABEL'), - 'h.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL'), - 'i.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL'), + 'g.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_ADMIN_VIEW_LABEL'), + 'h.' => Text::_('COM_COMPONENTBUILDER_HELP_DOCUMENT_SITE_VIEW_LABEL'), 'a.id' => Text::_('JGRID_HEADING_ID') ); } diff --git a/admin/tmpl/compiler/default.php b/admin/tmpl/compiler/default.php index de6c7fb17..81642e261 100644 --- a/admin/tmpl/compiler/default.php +++ b/admin/tmpl/compiler/default.php @@ -181,6 +181,7 @@ document.addEventListener('DOMContentLoaded', function() {.
+