diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fe87847c..1c2cc27bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,14 @@ -# v5.0.3-alpha2 +# v5.0.3-alpha3 -- Fix library save as copy error. #1162 -- Fix the error when no components exists. #1164 -- Fix search page error due to File class. +- Fix usergrouplist compiler triggers. #1100 +- Add field type power integration [init, reset, push] # v5.0.3-alpha -- Add push option to powers area +- Add push option to powers area +- Fix library save as copy error. #1162 +- Fix the error when no components exists. #1164 +- Fix search page error due to File class. # v5.0.2 diff --git a/ComponentbuilderInstallerScript.php b/ComponentbuilderInstallerScript.php index 431754eba..a47a672b5 100644 --- a/ComponentbuilderInstallerScript.php +++ b/ComponentbuilderInstallerScript.php @@ -1514,7 +1514,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface // Fix the assets table rules column size. - $this->setDatabaseAssetsRulesFix(95200, "MEDIUMTEXT"); + $this->setDatabaseAssetsRulesFix(95680, "MEDIUMTEXT"); // Install the global extension params. $this->setExtensionsParams( '{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","subform_layouts":"default","editor":"none","manage_jcb_package_directories":"2","set_browser_storage":"1","storage_time_to_live":"global","super_powers_documentation":"0","powers_repository":"0","super_powers_repositories":"0","builder_gif_size":"480-272","compiler_plugin":["componentbuilderactionlogcompiler","componentbuilderfieldorderingcompiler","componentbuilderheaderscompiler","componentbuilderpowersautoloadercompiler","componentbuilderprivacycompiler"],"add_menu_prefix":"1","menu_prefix":"»","namespace_prefix":"JCB","minify":"0","language":"en-GB","percentagelanguageadd":"30","assets_table_fix":"2","compiler_field_builder_type":"2","field_name_builder":"1","type_name_builder":"1","import_guid_only":"1","export_language_strings":"1","cronjob_backup_type":"1","cronjob_backup_server":"0","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_company":"Vast Development Method","export_owner":"Llewellyn van der Merwe","export_email":"joomla@vdm.io","export_website":"https://dev.vdm.io/","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","add_jquery_framework":"1","uikit_load":"1","uikit_min":"","uikit_style":""}' @@ -3270,7 +3270,7 @@ class Com_ComponentbuilderInstallerScript implements InstallerScriptInterface echo '
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..902287808 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,155 @@ 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')) + { + try { + 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') . '
'; + } + } 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; + } + + /** + * 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..3ca2e60ca 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. * @@ -139,14 +140,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..57e7c53d4 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. * @@ -107,18 +108,23 @@ class PowerController extends FormController } elseif($user->authorise('power.reset', 'com_componentbuilder')) { - if (PowerFactory::_('Power.Remote.Get')->reset([$guid])) - { - // set success message - $message = ''.Text::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'
'; - $status = 'success'; - $success = true; - } - else - { + try { + if (PowerFactory::_('Power.Remote.Get')->reset([$guid])) + { + // set success message + $message = ''.Text::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'
'; + $status = 'success'; + $success = true; + } + else + { + $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '
'; + } + } catch (\Exception $e) { $message = '' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '
'; + $message .= '' . \htmlspecialchars($e->getMessage()) . '
'; } } 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 5d01006aa..2102e3ca7 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() {.
+