Release of v3.2.4-alpha4
Fix database default fields to allow NULL. #1169. Fix the power list field to allow search. #1167. Remove Demo component from JCB v3 and added Hello Word component as demo in JCB v3.
This commit is contained in:
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,13 +1,17 @@
|
||||
# v3.2.4-alpha3
|
||||
# v3.2.4-alpha4
|
||||
|
||||
- Fix usergrouplist compiler triggers. #1100
|
||||
- Fix database default fields to allow NULL. #1169
|
||||
- Fix the power list field to allow search. #1167
|
||||
- Remove Demo component from JCB v3 and added Hello Word component as demo in JCB v3.
|
||||
|
||||
# v3.2.4-alpha
|
||||
|
||||
- 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.
|
||||
- Fix search page error due to File class.
|
||||
- Fix usergrouplist compiler triggers. #1100
|
||||
- Add field type power integration [init, reset, push]
|
||||
|
||||
# v3.2.3
|
||||
|
||||
|
12
README.md
12
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 (3.2.4-alpha3) 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 (3.2.4-alpha4) 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*: 23rd August, 2024
|
||||
+ *Version*: 3.2.4-alpha3
|
||||
+ *Last Build*: 18th September, 2024
|
||||
+ *Version*: 3.2.4-alpha4
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **840006**
|
||||
+ *Line count*: **848150**
|
||||
+ *Field count*: **2098**
|
||||
+ *File count*: **5722**
|
||||
+ *Folder count*: **500**
|
||||
+ *File count*: **5778**
|
||||
+ *Folder count*: **505**
|
||||
|
||||
> 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)
|
||||
|
@ -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 (3.2.4-alpha3) 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 (3.2.4-alpha4) 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*: 23rd August, 2024
|
||||
+ *Version*: 3.2.4-alpha3
|
||||
+ *Last Build*: 18th September, 2024
|
||||
+ *Version*: 3.2.4-alpha4
|
||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||
+ *Line count*: **840006**
|
||||
+ *Line count*: **848150**
|
||||
+ *Field count*: **2098**
|
||||
+ *File count*: **5722**
|
||||
+ *Folder count*: **500**
|
||||
+ *File count*: **5778**
|
||||
+ *Folder count*: **505**
|
||||
|
||||
> 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)
|
||||
|
@ -52,7 +52,23 @@ class ###View###Controller extends FormController
|
||||
* @var string
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $view_list = '###views###';###ADMIN_CUSTOM_BUTTONS_CONTROLLER###
|
||||
protected $view_list = '###views###';
|
||||
|
||||
/**
|
||||
* Referral value
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0
|
||||
*/
|
||||
protected string $ref;
|
||||
|
||||
/**
|
||||
* Referral ID value
|
||||
*
|
||||
* @var int
|
||||
* @since 5.0
|
||||
*/
|
||||
protected int $refid;###ADMIN_CUSTOM_BUTTONS_CONTROLLER###
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
|
@ -94,18 +94,23 @@ class ComponentbuilderControllerFieldtype extends FormController
|
||||
}
|
||||
elseif($user->authorise('fieldtype.reset', 'com_componentbuilder'))
|
||||
{
|
||||
if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_FIELD_TYPE_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
if (FieldtypeFactory::_('Joomla.Fieldtype.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_FIELD_TYPE_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_FIELD_TYPE_HAS_FAILED') . '</p>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_FIELD_TYPE_HAS_FAILED') . '</p>';
|
||||
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,18 +94,23 @@ class ComponentbuilderControllerJoomla_power extends FormController
|
||||
}
|
||||
elseif($user->authorise('joomla_power.reset', 'com_componentbuilder'))
|
||||
{
|
||||
if (JoomlaPowerFactory::_('Joomla.Power.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
if (JoomlaPowerFactory::_('Joomla.Power.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_JOOMLA_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_JOOMLA_POWER_HAS_FAILED') . '</p>';
|
||||
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,18 +94,23 @@ class ComponentbuilderControllerPower extends FormController
|
||||
}
|
||||
elseif($user->authorise('power.reset', 'com_componentbuilder'))
|
||||
{
|
||||
if (PowerFactory::_('Power.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try {
|
||||
if (PowerFactory::_('Power.Remote.Get')->reset([$guid]))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THE_POWER_HAS_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '</p>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_RESET_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_RESET_OF_THIS_POWER_HAS_FAILED') . '</p>';
|
||||
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
|
16
admin/custom/dynamicDownloadController.php
Normal file
16
admin/custom/dynamicDownloadController.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @version 2.0.0 - September 03, 2014
|
||||
* @package Component Builder
|
||||
* @author Llewellyn van de Merwe <http://www.vdm.io>
|
||||
* @copyright Copyright (C) 2014. All Rights Reserved
|
||||
* @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
**/
|
||||
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
?>
|
||||
###BOM###
|
||||
[CUSTOMCODE=dynamicDownloadController]
|
@ -5416,7 +5416,6 @@ abstract class ComponentbuilderHelper
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The subform layouts
|
||||
|
@ -1360,6 +1360,7 @@ COM_COMPONENTBUILDER_BULK_UPDATE_ALL_DIVERGED_SNIPPETS="Bulk Update All Diverged
|
||||
COM_COMPONENTBUILDER_BULK_UPDATE_ALL_OUT_DATED_SNIPPETS="Bulk Update All Out Dated Snippets"
|
||||
COM_COMPONENTBUILDER_BUTTON_TO_CREATE_S_WILL_SHOW_ONCE_S_IS_SAVED_FOR_THE_FIRST_TIME="Button to create %s will show once %s is saved for the first time."
|
||||
COM_COMPONENTBUILDER_CANCEL="Cancel"
|
||||
COM_COMPONENTBUILDER_CAN_NOT_SAVE_USER_WITHOUT_EMAIL_VALUE="Can not save user without email value."
|
||||
COM_COMPONENTBUILDER_CHAIN="Chain"
|
||||
COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there."
|
||||
COM_COMPONENTBUILDER_CLASS_EXTENDINGS="Class Extendings"
|
||||
@ -5866,7 +5867,7 @@ COM_COMPONENTBUILDER_JOOMLA_COMPONENT_PUBLISHING="Publishing"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README="Readme"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_README_LABEL="README.md"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_DESCRIPTION="Should we remove all line breaks ("\r", "\n") from all language strings in this component."
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL="Remove line breaks<br /><small>from language strings</small>"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL="Remove line breaks<br /><small>from language strings<br>This switch will be removed since it must always be true for J4+.</small>"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SALES_SERVER_DESCRIPTION="Select your sales server for this component"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SALES_SERVER_LABEL="Sales Server"
|
||||
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Joomla Component to customise the alias."
|
||||
@ -7487,7 +7488,7 @@ COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_DESCRIPTION="There is no be
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_THREE_LABEL="No Behaviour"
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_TWO_DESCRIPTION="There is no behaviour set for this library. This means JCB will not add any files unless you custom code it in somewhere."
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_NO_BEHAVIOUR_TWO_LABEL="No Behaviour"
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_LIBRARY_DESCRIPTION="We are working on this feature it is not yet ready, but soon enough you will be able to build real Joomla library integration here."
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_LIBRARY_DESCRIPTION="To effectively integrate a PHP library into your component, leverage the [Powers] Area within JCB. This feature empowers you to seamlessly incorporate Composer packages as well as standard PHP class structures into your component, ensuring a robust and maintainable solution."
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_LIBRARY_LABEL="Set Behaviour"
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_ONE_DESCRIPTION="All the library files linked to this library will always be added to a view if linked to the view."
|
||||
COM_COMPONENTBUILDER_LIBRARY_NOTE_YES_BEHAVIOUR_ONE_LABEL="Set Behaviour"
|
||||
@ -7999,7 +8000,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_TYPE="Joomla Field Type"
|
||||
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"
|
||||
@ -9246,9 +9247,12 @@ COM_COMPONENTBUILDER_UPDATE_ALL="Update All"
|
||||
COM_COMPONENTBUILDER_UPDATE_ALL_DIVERGED_SNIPPETS="Update All Diverged Snippets"
|
||||
COM_COMPONENTBUILDER_UPDATE_ALL_ITEMS_FOUND_WITH_THIS_DATABASE_SEARCH_WITH_THE_REPLACE_VALUE="Update all items found with this database search, with the replace value."
|
||||
COM_COMPONENTBUILDER_UPDATE_ALL_OUT_DATED_SNIPPETS="Update All Out Dated Snippets"
|
||||
COM_COMPONENTBUILDER_UPDATE_OF_USER_S_S_FAILEDS="Update of user %s (%s) failed!%s"
|
||||
COM_COMPONENTBUILDER_UP_TO_DATE="Up to date"
|
||||
COM_COMPONENTBUILDER_USAGE="Usage"
|
||||
COM_COMPONENTBUILDER_USED_IN="Used in"
|
||||
COM_COMPONENTBUILDER_USER_CREATION_FAILED="User creation failed!"
|
||||
COM_COMPONENTBUILDER_USER_S_S_CREATION_FAILEDS="User %s (%s) creation failed!%s"
|
||||
COM_COMPONENTBUILDER_USE_BATCH="Use Batch"
|
||||
COM_COMPONENTBUILDER_USE_BATCH_DESC="Allows users in this group to use batch copy/update method."
|
||||
COM_COMPONENTBUILDER_USE_KEY="Use Key"
|
||||
|
@ -18,12 +18,28 @@ use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
use Joomla\CMS\Layout\LayoutHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
$table_id = (isset($displayData['id'])) ? $displayData['id'] : StringHelper::random(7);
|
||||
$name = (isset($displayData['name'])) ? $displayData['name'] : false;
|
||||
$table_class = (isset($displayData['table_class'])) ? $displayData['table_class'] : 'uk-table';
|
||||
$table_container_class = (isset($displayData['table_container_class'])) ? $displayData['table_container_class'] : 'uk-overflow-auto';
|
||||
$headers = (isset($displayData['headers'])) ? $displayData['headers'] : [Text::_('COM_COMPONENTBUILDER_NO'), Text::_('COM_COMPONENTBUILDER_HEADERS'), Text::_('COM_COMPONENTBUILDER_FOUND')];
|
||||
$items = (isset($displayData['items'])) ? $displayData['items'] : 6;
|
||||
// Extract all keys from $displayData as individual variables.
|
||||
extract($displayData);
|
||||
|
||||
// Assign default values for variables that might not be present in $displayData.
|
||||
|
||||
// The 'table_id' parameter, defaulting to a randomly generated value if not set or is null.
|
||||
$table_id = $id ?? StringHelper::random(7);
|
||||
|
||||
// The 'name' parameter, defaulting to false if not set or is null.
|
||||
$name ??= false;
|
||||
|
||||
// The 'table_class' parameter, defaulting to 'uk-table' if not set or is null.
|
||||
$table_class ??= 'uk-table';
|
||||
|
||||
// The 'table_container_class' parameter, defaulting to 'uk-overflow-auto' if not set or is null.
|
||||
$table_container_class ??= 'uk-overflow-auto';
|
||||
|
||||
// The 'headers' parameter, defaulting to an array of default header values if not set or is null.
|
||||
$headers ??= [Text::_('COM_COMPONENTBUILDER_NO'), Text::_('COM_COMPONENTBUILDER_HEADERS'), Text::_('COM_COMPONENTBUILDER_FOUND')];
|
||||
|
||||
// The 'items' parameter, defaulting to 6 if not set or is null.
|
||||
$items ??= 6;
|
||||
|
||||
?>
|
||||
<div class="<?php echo $$table_container_class; ?>">
|
||||
|
@ -40,9 +40,9 @@ class JFormFieldNamespaces extends JFormFieldList
|
||||
protected function getOptions()
|
||||
{
|
||||
// Get the user object.
|
||||
$user = JFactory::getUser();
|
||||
$user = Factory::getUser();
|
||||
// Get the databse object.
|
||||
$db = JFactory::getDBO();
|
||||
$db = Factory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('a.guid','a.name','a.namespace','a.type','a.power_version'),array('guid','use_name','namespace','type','version')));
|
||||
$query->from($db->quoteName('#__componentbuilder_power', 'a'));
|
||||
@ -60,7 +60,7 @@ class JFormFieldNamespaces extends JFormFieldList
|
||||
}
|
||||
}
|
||||
// get the input
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
$jinput = Factory::getApplication()->input;
|
||||
// get the id
|
||||
$power_id = $jinput->getInt('id', 0);
|
||||
// if we have an id we remove all classes of the same namespace and name
|
||||
@ -74,17 +74,17 @@ class JFormFieldNamespaces extends JFormFieldList
|
||||
// if none was found, we add this to set an alternative to set custom
|
||||
if (!$items)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', JText::_('COM_COMPONENTBUILDER_NONE_FOUND'));
|
||||
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_NONE_FOUND'));
|
||||
}
|
||||
if ($items)
|
||||
{
|
||||
if ($this->multiple === false)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', '', JText::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION'));
|
||||
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_AN_OPTION'));
|
||||
}
|
||||
foreach($items as $item)
|
||||
{
|
||||
$options[] = JHtml::_('select.option', $item->guid, str_replace('.','\\', $item->namespace) . ' [' . $item->use_name . '] (v' . $item->version . ' - ' . $item->type . ')');
|
||||
$options[] = Html::_('select.option', $item->guid, str_replace('.','\\', $item->namespace) . ' [' . $item->use_name . '] (v' . $item->version . ' - ' . $item->type . ')');
|
||||
}
|
||||
}
|
||||
return $options;
|
||||
|
@ -141,6 +141,7 @@
|
||||
label="COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_LABEL"
|
||||
description="COM_COMPONENTBUILDER_CUSTOM_CODE_TYPE_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="0"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
|
@ -284,7 +284,7 @@
|
||||
label="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_LABEL"
|
||||
description="COM_COMPONENTBUILDER_JOOMLA_COMPONENT_REMOVE_LINE_BREAKS_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="0"
|
||||
default="1"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
|
@ -235,10 +235,10 @@
|
||||
label="COM_COMPONENTBUILDER_POWER_NAMESPACE_LABEL"
|
||||
layout="joomla.form.field.subform.repeatable-table"
|
||||
multiple="true"
|
||||
buttons="add,remove,move"
|
||||
buttons="add,remove"
|
||||
icon="list"
|
||||
max="30"
|
||||
min="1"
|
||||
min="0"
|
||||
nested_depth="1">
|
||||
<form hidden="true" name="list_namespace_modal" repeat="true">
|
||||
<!-- Use Field. Type: Text. (joomla) -->
|
||||
@ -493,7 +493,8 @@
|
||||
type="namespaces"
|
||||
name="use"
|
||||
label="COM_COMPONENTBUILDER_POWER_USE_LABEL"
|
||||
class="list_class span12"
|
||||
class="span12"
|
||||
layout="joomla.form.field.list-fancy-select"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="false"
|
||||
|
@ -156,7 +156,7 @@
|
||||
<option value="2">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER</option>
|
||||
<option value="3">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPE</option>
|
||||
COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPES</option>
|
||||
</field>
|
||||
<!-- Type Field. Type: List. (joomla) -->
|
||||
<field
|
||||
@ -261,9 +261,9 @@
|
||||
label="COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_LABEL"
|
||||
description="COM_COMPONENTBUILDER_REPOSITORY_ACCESS_REPO_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="">
|
||||
default="0">
|
||||
<!-- Option Set. -->
|
||||
<option value="">
|
||||
<option value="0">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_GLOBAL</option>
|
||||
<option value="1">
|
||||
COM_COMPONENTBUILDER_REPOSITORY_OVERRIDE</option>
|
||||
|
@ -200,7 +200,7 @@ class ComponentbuilderModelRepositories extends ListModel
|
||||
0 => 'COM_COMPONENTBUILDER_REPOSITORY_SELECT_AN_OPTION',
|
||||
1 => 'COM_COMPONENTBUILDER_REPOSITORY_SUPER_POWER',
|
||||
2 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_POWER',
|
||||
3 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPE'
|
||||
3 => 'COM_COMPONENTBUILDER_REPOSITORY_JOOMLA_FIELD_TYPES'
|
||||
);
|
||||
// Now check if value is found in this array
|
||||
if (isset($targetArray[$value]) && StringHelper::check($targetArray[$value]))
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,15 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.10" method="upgrade">
|
||||
<name>COM_COMPONENTBUILDER</name>
|
||||
<creationDate>23rd August, 2024</creationDate>
|
||||
<creationDate>18th September, 2024</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
<authorEmail>joomla@vdm.io</authorEmail>
|
||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<version>3.2.4-alpha3</version>
|
||||
<version>3.2.4-alpha4</version>
|
||||
<description>< is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
|
||||
|
||||
|
@ -187,7 +187,7 @@
|
||||
<version>3.2.4-alpha</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.4-alpha3.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.4-alpha4.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>alpha</tag>
|
||||
@ -202,10 +202,10 @@
|
||||
<element>pkg_component_builder</element>
|
||||
<type>package</type>
|
||||
<client>site</client>
|
||||
<version>3.2.4-alpha3</version>
|
||||
<version>3.2.4-alpha4</version>
|
||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.4-alpha3.zip</downloadurl>
|
||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.4-alpha4.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>alpha</tag>
|
||||
|
@ -24,7 +24,7 @@ use VDM\Joomla\FOF\Encrypt\Randvalinterface;
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Randval implements Randvalinterface
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'comment' => 'FK to the #__assets table.'
|
||||
]
|
||||
],
|
||||
@ -80,7 +80,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(11)',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'published' => [
|
||||
@ -94,7 +94,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'TINYINT(3)',
|
||||
'default' => '1',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'state'
|
||||
]
|
||||
@ -110,7 +110,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'modifiedby'
|
||||
]
|
||||
@ -126,7 +126,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'created_by' => [
|
||||
@ -140,7 +140,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'createdby'
|
||||
]
|
||||
@ -156,7 +156,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'checked_out' => [
|
||||
@ -170,7 +170,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'checkout'
|
||||
]
|
||||
@ -186,7 +186,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'hits' => [
|
||||
@ -200,7 +200,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'version' => [
|
||||
@ -214,7 +214,7 @@ abstract class BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '1',
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
],
|
||||
'params' => [
|
||||
|
@ -118,7 +118,7 @@ abstract class Model implements ModelInterface
|
||||
* @return array|null
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function values(?array $items = null, string $field, ?string $table = null): ?array
|
||||
public function values(?array $items, string $field, ?string $table = null): ?array
|
||||
{
|
||||
// check if this is a valid table
|
||||
if (ArrayHelper::check($items))
|
||||
|
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\ComHelperClass;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Helper Class Create User Class for Joomla 5
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class CreateUser implements CreateUserInterface
|
||||
{
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*/
|
||||
public function get($add): string
|
||||
{
|
||||
if ($add)
|
||||
{
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Save user details by either creating a new user or updating an existing user.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$credentials ['name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string]";
|
||||
$method[] = Indent::_(1) . " * @param int \$autologin";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$params ['useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int]";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int User ID on success";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \InvalidArgumentException If required credentials are missing.";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If the user update or creation fails.";
|
||||
$method[] = Indent::_(1) . " * @throws Super__"."_1c10a5f1_204d_4f17_ad9f_0e0684f2030d___Power If the user is not found.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function createUser(\$credentials, \$autologin = 0,";
|
||||
$method[] = Indent::_(2) . "\$params = [";
|
||||
$method[] = Indent::_(3)
|
||||
. "'useractivation' => 0, 'sendpassword' => 1";
|
||||
$method[] = Indent::_(2) . "], \$mode = 1";
|
||||
$method[] = Indent::_(1) . ")";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Create a user with the UserHelper class (Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update the given component params.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param string|null \$option The optional extension element name.";
|
||||
$method[] = Indent::_(1) . " * @param string \$target The parameter name to be updated.";
|
||||
$method[] = Indent::_(1) . " * @param mixed \$value The value to set for the parameter.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = PHP_EOL . Indent::_(1)
|
||||
. "public static function setParams(\$option, \$target, \$value)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Sets a parameter value for the given target in the specified option's params";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " (Super---640b5352_fb09_425f_a26e_cd44eda03f15---Power)";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update user details";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param array \$userDetails Array containing user details to be updated";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int Updated user ID on success.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If user update fails.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function updateUser(\$userDetails): int";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2)
|
||||
. "//" . Line::_(__Line__, __Class__)
|
||||
. " Update user details with the UserHelper class (Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power)";
|
||||
$method[] = Indent::_(2) . "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
// return the help method
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -155,7 +155,7 @@ final class Extension implements ExtensionInterface
|
||||
$counter = 0;
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
if ($method['access'] === 'public' && !$method['static'] && !$method['abstract'])
|
||||
if ($this->validEventName($method))
|
||||
{
|
||||
$events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'";
|
||||
|
||||
@ -191,6 +191,37 @@ final class Extension implements ExtensionInterface
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a method name is a valid event name for a Joomla plugin.
|
||||
*
|
||||
* The method must meet the following criteria:
|
||||
* - It must be public, not static, and not abstract.
|
||||
* - It must not be a magic method (i.e., should not start with '__').
|
||||
*
|
||||
* @param array $method The method details, including 'name', 'access', 'static', and 'abstract'.
|
||||
*
|
||||
* @return bool Returns true if the method is a valid event name, otherwise false.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function validEventName(array $method): bool
|
||||
{
|
||||
// Check if the method is public, static, and not abstract
|
||||
if ($method['access'] !== 'public' || $method['static'] || $method['abstract'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the method is a magic method (starts with '__')
|
||||
if (substr($method['name'], 0, 2) === '__')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If all checks pass, the method is a valid event name
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the getSubscribedEvents is set
|
||||
*
|
||||
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\ComHelperClass;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Helper Class Create User Class for Joomla 4
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class CreateUser implements CreateUserInterface
|
||||
{
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*/
|
||||
public function get($add): string
|
||||
{
|
||||
if ($add)
|
||||
{
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Save user details by either creating a new user or updating an existing user.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$credentials ['name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string]";
|
||||
$method[] = Indent::_(1) . " * @param int \$autologin";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$params ['useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int]";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int User ID on success";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \InvalidArgumentException If required credentials are missing.";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If the user update or creation fails.";
|
||||
$method[] = Indent::_(1) . " * @throws Super__"."_1c10a5f1_204d_4f17_ad9f_0e0684f2030d___Power If the user is not found.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function createUser(\$credentials, \$autologin = 0,";
|
||||
$method[] = Indent::_(2) . "\$params = [";
|
||||
$method[] = Indent::_(3)
|
||||
. "'useractivation' => 0, 'sendpassword' => 1";
|
||||
$method[] = Indent::_(2) . "], \$mode = 1";
|
||||
$method[] = Indent::_(1) . ")";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Create a user with the UserHelper class";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::create(\$credentials, \$autologin, \$params, \$mode);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update the given component params.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param string|null \$option The optional extension element name.";
|
||||
$method[] = Indent::_(1) . " * @param string \$target The parameter name to be updated.";
|
||||
$method[] = Indent::_(1) . " * @param mixed \$value The value to set for the parameter.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = PHP_EOL . Indent::_(1)
|
||||
. "public static function setParams(\$option, \$target, \$value)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Sets a parameter value for the given target in the specified option's params";
|
||||
$method[] = Indent::_(2)
|
||||
. "return Super__"."_640b5352_fb09_425f_a26e_cd44eda03f15___Power::setParams(\$target, \$value, \$option);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update user details";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @param array \$userDetails Array containing user details to be updated";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @return int Updated user ID on success.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @throws \RuntimeException If user update fails.";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1) . " * @since 3.0.0";
|
||||
$method[] = Indent::_(1) . " * @deprecated 4.3 Use Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function updateUser(\$userDetails): int";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2)
|
||||
. "//" . Line::_(__Line__, __Class__)
|
||||
. " Update user details with the UserHelper class";
|
||||
$method[] = Indent::_(2) . "return Super__"."_7832a726_87b6_4e95_887e_7b725d3fab8f___Power::update(\$userDetails);";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
// return the help method
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -155,7 +155,7 @@ final class Extension implements ExtensionInterface
|
||||
$counter = 0;
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
if ($method['access'] === 'public' && !$method['static'] && !$method['abstract'])
|
||||
if ($this->validEventName($method))
|
||||
{
|
||||
$events[$method['name']] = Indent::_(3) . "'{$method['name']}' => '{$method['name']}'";
|
||||
|
||||
@ -191,6 +191,37 @@ final class Extension implements ExtensionInterface
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates if a method name is a valid event name for a Joomla plugin.
|
||||
*
|
||||
* The method must meet the following criteria:
|
||||
* - It must be public, not static, and not abstract.
|
||||
* - It must not be a magic method (i.e., should not start with '__').
|
||||
*
|
||||
* @param array $method The method details, including 'name', 'access', 'static', and 'abstract'.
|
||||
*
|
||||
* @return bool Returns true if the method is a valid event name, otherwise false.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function validEventName(array $method): bool
|
||||
{
|
||||
// Check if the method is public, static, and not abstract
|
||||
if ($method['access'] !== 'public' || $method['static'] || $method['abstract'])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the method is a magic method (starts with '__')
|
||||
if (substr($method['name'], 0, 2) === '__')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// If all checks pass, the method is a valid event name
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the getSubscribedEvents is set
|
||||
*
|
||||
|
@ -0,0 +1,366 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\ComHelperClass;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Helper Class Create User Class for Joomla 3
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class CreateUser implements CreateUserInterface
|
||||
{
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*/
|
||||
public function get($add): string
|
||||
{
|
||||
if ($add)
|
||||
{
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Greate user and update given table";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)";
|
||||
$method[] = Indent::_(1) . " * @param int \$autologin";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @return int|Error User ID on success, or an error.";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function createUser(\$credentials, \$autologin = 0,";
|
||||
$method[] = Indent::_(2) . "\$params = array(";
|
||||
$method[] = Indent::_(3)
|
||||
. "'useractivation' => 0, 'sendpassword' => 1";
|
||||
$method[] = Indent::_(2) . "), \$mode = 1";
|
||||
$method[] = Indent::_(1) . ")";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Override mode";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 2 && method_exists(__CLASS__, 'registerUser'))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Update params";
|
||||
$method[] = Indent::_(3) . "\$params['autologin'] = \$autologin;";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Now Register User";
|
||||
$method[] = Indent::_(3)
|
||||
. "return self::registerUser(\$credentials, \$params);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "elseif (\$mode == 2)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Fallback to Site Registrations";
|
||||
$method[] = Indent::_(3) . "\$mode = 1;";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " load the user component language files if there is an error.";
|
||||
$method[] = Indent::_(2) . "\$lang = Factory::getLanguage();";
|
||||
$method[] = Indent::_(2) . "\$extension = 'com_users';";
|
||||
$method[] = Indent::_(2) . "\$base_dir = JPATH_SITE;";
|
||||
$method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
. "';";
|
||||
$method[] = Indent::_(2) . "\$reload = true;";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the correct user model.";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site Registrations";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the user site-registration model";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$model = self::getModel('registration', \$base_dir . '/components/' . \$extension, 'Users');";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin Registration";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the backend-user model";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/' . \$extension, 'Users');";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if we have params/config";
|
||||
$method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Make changes to user config";
|
||||
$method[] = Indent::_(3)
|
||||
. "foreach (\$params as \$param => \$set)";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If you know of a better path, let me know";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$params[\$param] = self::setParams(\$extension, \$param, \$set);";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Set username to email if not set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (!isset(\$credentials['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['username']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['username'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Lineup new user data array";
|
||||
$method[] = Indent::_(2) . "\$data = array(";
|
||||
$method[] = Indent::_(3)
|
||||
. "'username' => \$credentials['username'],";
|
||||
$method[] = Indent::_(3) . "'name' => \$credentials['name'],";
|
||||
$method[] = Indent::_(3) . "'block' => 0 );";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Added details based on mode";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['email1'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['email'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['registerDate'] = Factory::getDate()->toSql();";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if password was set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2'])))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Set random password when empty password was submitted,";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " when using the 1 = site-registration mode";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['password'] = self::randomkey(8);";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['password2'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Now Add password if set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$data['password1'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$data['password'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['password2'] = \$credentials['password2'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the group/s value if set, only for Admin Registration (\$mode == 0)";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 0 && isset(\$credentials['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$credentials['groups']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['groups'] = \$credentials['groups'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Create the new user";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$userId = \$model->register(\$data);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$model->save(\$data);";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$userId = \$model->getState('user.id', 0);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if we have params";
|
||||
$method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Change user params/config back";
|
||||
$method[] = Indent::_(3)
|
||||
. "foreach (\$params as \$param => \$set)";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If you know of a better path, let me know";
|
||||
$method[] = Indent::_(4)
|
||||
. "self::setParams(\$extension, \$param, \$set);";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " if user is created";
|
||||
$method[] = Indent::_(2) . "if (\$userId > 0)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Auto Login if Needed";
|
||||
$method[] = Indent::_(3)
|
||||
. "if (\$autologin && isset(\$credentials['password']))";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Try to login";
|
||||
$method[] = Indent::_(4) . "try{";
|
||||
$method[] = Indent::_(5)
|
||||
. "Factory::getApplication()->login(\$credentials);";
|
||||
$method[] = Indent::_(4) . "} catch (\Exception \$exception){";
|
||||
$method[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Do noting for now, may want to set redirect.";
|
||||
$method[] = Indent::_(4) . "}";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Return ID";
|
||||
$method[] = Indent::_(3) . "return \$userId;";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$model->getError();";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1)
|
||||
. "public static function setParams(\$component,\$target,\$value)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get the params and set the new values";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$params = ComponentHelper::getParams(\$component);";
|
||||
$method[] = Indent::_(2) . "\$was = \$params->get(\$target, null);";
|
||||
$method[] = Indent::_(2) . "if (\$was != \$value)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$params->set(\$target, \$value);";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get a new database query instance";
|
||||
$method[] = Indent::_(3) . "\$db = Factory::getDBO();";
|
||||
$method[] = Indent::_(3) . "\$query = \$db->getQuery(true);";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Build the query";
|
||||
$method[] = Indent::_(3) . "\$query->update('#__extensions AS a');";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$query->set('a.params = ' . \$db->quote((string)\$params));";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$query->where('a.element = ' . \$db->quote((string)\$component));";
|
||||
$method[] = Indent::_(3);
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Execute the query";
|
||||
$method[] = Indent::_(3) . "\$db->setQuery(\$query);";
|
||||
$method[] = Indent::_(3) . "\$db->execute();";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$was;";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update user values";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function updateUser(\$new)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2)
|
||||
. "// load the user component language files if there is an error.";
|
||||
$method[] = Indent::_(2) . "\$lang = Factory::getLanguage();";
|
||||
$method[] = Indent::_(2) . "\$extension = 'com_users';";
|
||||
$method[] = Indent::_(2) . "\$base_dir = JPATH_ADMINISTRATOR;";
|
||||
$method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
. "';";
|
||||
$method[] = Indent::_(2) . "\$reload = true;";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
|
||||
$method[] = Indent::_(2) . "// load the user model";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');";
|
||||
$method[] = Indent::_(2) . "// Check if password was set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$new['password']) && isset(\$new['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password2']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "// Use the users passwords";
|
||||
$method[] = Indent::_(3) . "\$password = \$new['password'];";
|
||||
$method[] = Indent::_(3) . "\$password2 = \$new['password2'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// set username";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (!isset(\$new['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['username']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$new['username'] = \$new['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// lineup update user data";
|
||||
$method[] = Indent::_(2) . "\$data = array(";
|
||||
$method[] = Indent::_(3) . "'id' => \$new['id'],";
|
||||
$method[] = Indent::_(3) . "'username' => \$new['username'],";
|
||||
$method[] = Indent::_(3) . "'name' => \$new['name'],";
|
||||
$method[] = Indent::_(3) . "'email' => \$new['email'],";
|
||||
$method[] = Indent::_(3)
|
||||
. "'password' => \$password, // First password field";
|
||||
$method[] = Indent::_(3)
|
||||
. "'password2' => \$password2, // Confirm password field";
|
||||
$method[] = Indent::_(3) . "'block' => 0 );";
|
||||
$method[] = Indent::_(2) . "// set groups if found";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$new['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$new['groups']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$data['groups'] = \$new['groups'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// register the new user";
|
||||
$method[] = Indent::_(2) . "\$done = \$model->save(\$data);";
|
||||
$method[] = Indent::_(2) . "// if user is updated";
|
||||
$method[] = Indent::_(2) . "if (\$done)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "return \$new['id'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$model->getError();";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
// return the help method
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -543,14 +543,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getRemovelinebreaks(): bool
|
||||
{
|
||||
// get posted value
|
||||
$value = $this->input->post->get('remove_line_breaks', 2, 'INT');
|
||||
// get global
|
||||
if ($value > 1)
|
||||
{
|
||||
return (bool) GetHelper::var('joomla_component', $this->component_id, 'id', 'remove_line_breaks');
|
||||
}
|
||||
return (bool) $value;
|
||||
return (bool) true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -889,7 +882,26 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getApprovedjoomlapaths(): array
|
||||
{
|
||||
return array_values($this->joomla_powers_init_repos);
|
||||
// some defaults repos we need by JCB
|
||||
$approved = $this->joomla_powers_init_repos;
|
||||
|
||||
$paths = RepoHelper::get(2); // Joomla Power = 2
|
||||
|
||||
if ($paths !== null)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->organisation ?? null;
|
||||
$repo = $path->repository ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$approved = ["{$owner}.{$repo}" => $path] + $approved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($approved);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -992,7 +992,8 @@ final class Builders
|
||||
'code' => $name,
|
||||
'name' => $listLangName,
|
||||
'extension' => $_extension,
|
||||
'filter' => $field['filter']
|
||||
'filter' => $field['filter'],
|
||||
'add_icon' => StringHelper::check($view['settings']->icon_category)
|
||||
]);
|
||||
// also set code name for title alias fix
|
||||
$this->categorycode->set($nameSingleCode, [
|
||||
|
@ -12,13 +12,12 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Hash;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\LockBase;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\DispenserInterface;
|
||||
|
||||
|
||||
@ -33,7 +32,7 @@ class Dispenser implements DispenserInterface
|
||||
* Customcode Dispenser Hub
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public array $hub;
|
||||
|
||||
@ -41,7 +40,7 @@ class Dispenser implements DispenserInterface
|
||||
* Compiler Placeholder
|
||||
*
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
@ -49,7 +48,7 @@ class Dispenser implements DispenserInterface
|
||||
* Compiler Customcode
|
||||
*
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Customcode $customcode;
|
||||
|
||||
@ -57,7 +56,7 @@ class Dispenser implements DispenserInterface
|
||||
* Compiler Customcode in Gui
|
||||
*
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Gui $gui;
|
||||
|
||||
@ -65,7 +64,7 @@ class Dispenser implements DispenserInterface
|
||||
* Compiler Customcode to Hash
|
||||
*
|
||||
* @var Hash
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Hash $hash;
|
||||
|
||||
@ -73,29 +72,29 @@ class Dispenser implements DispenserInterface
|
||||
* Compiler Customcode to LockBase
|
||||
*
|
||||
* @var LockBase
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected LockBase $base64;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param Gui|null $gui The compiler customcode gui object.
|
||||
* @param Hash|null $hash The compiler customcode hash object.
|
||||
* @param LockBase|null $base64 The compiler customcode lock base64 object.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Customcode $customcode The Customcode Class.
|
||||
* @param Gui $gui The Gui Class.
|
||||
* @param Hash $hash The Hash Class.
|
||||
* @param LockBase $lockbase The LockBase Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Placeholder $placeholder = null, ?Customcode $customcode = null,
|
||||
?Gui $gui = null, ?Hash $hash = null, ?LockBase $base64 = null)
|
||||
public function __construct(Placeholder $placeholder, Customcode $customcode, Gui $gui,
|
||||
Hash $hash, LockBase $lockbase)
|
||||
{
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->hash = $hash ?: Compiler::_('Customcode.Hash');
|
||||
$this->base64 = $base64 ?: Compiler::_('Customcode.LockBase');
|
||||
$this->placeholder = $placeholder;
|
||||
$this->customcode = $customcode;
|
||||
$this->gui = $gui;
|
||||
$this->hash = $hash;
|
||||
$this->base64 = $lockbase;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +113,7 @@ class Dispenser implements DispenserInterface
|
||||
* default: false
|
||||
*
|
||||
* @return bool true on success
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(&$script, string $first, ?string $second = null, ?string $third = null,
|
||||
array $config = [], bool $base64 = true, bool $dynamic = true, bool $add = false): bool
|
||||
@ -177,7 +176,7 @@ class Dispenser implements DispenserInterface
|
||||
* @param string $suffix The suffix to add after the script if found
|
||||
*
|
||||
* @return mixed The string/script if found or the default value if not found
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $first, string $second, string $prefix = '', ?string $note = null,
|
||||
bool $unset = false, $default = null, string $suffix = '')
|
||||
@ -224,7 +223,7 @@ class Dispenser implements DispenserInterface
|
||||
* default: false
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function initHub(string $first, ?string $second = null, ?string $third = null, bool $add = false)
|
||||
{
|
||||
@ -255,7 +254,7 @@ class Dispenser implements DispenserInterface
|
||||
* default: false
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function setHub(string $script, string $first, ?string $second = null, ?string $third = null, bool $add = false)
|
||||
{
|
||||
|
@ -787,7 +787,7 @@ class Extractor implements ExtractorInterface
|
||||
$query->columns($this->db->quoteName($columns));
|
||||
foreach ($this->new as $values)
|
||||
{
|
||||
if (count((array) $values) == 15)
|
||||
if (count((array) $values) == 16)
|
||||
{
|
||||
$query->values(implode(',', $values));
|
||||
$continue = true;
|
||||
|
@ -42,6 +42,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Service\Utilities;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderAJ;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\BuilderLZ;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Creator;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureComHelperClass;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureController;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitectureModel;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\ArchitecturePlugin;
|
||||
@ -142,6 +143,7 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
->registerServiceProvider(new BuilderAJ())
|
||||
->registerServiceProvider(new BuilderLZ())
|
||||
->registerServiceProvider(new Creator())
|
||||
->registerServiceProvider(new ArchitectureComHelperClass())
|
||||
->registerServiceProvider(new ArchitectureController())
|
||||
->registerServiceProvider(new ArchitectureModel())
|
||||
->registerServiceProvider(new ArchitecturePlugin())
|
||||
|
@ -173,7 +173,7 @@ class Get
|
||||
* @var bool
|
||||
* @deprecated 3.3 Use CFactory::_('Config')->remove_line_breaks;
|
||||
*/
|
||||
public $removeLineBreaks = false;
|
||||
public $removeLineBreaks = true;
|
||||
|
||||
/**
|
||||
* The placeholders for custom code keys
|
||||
|
@ -337,9 +337,10 @@ class Infusion extends Interpretation
|
||||
|
||||
// HELPER_CREATEUSER
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('HELPER_CREATEUSER',
|
||||
$this->setCreateUserHelperMethod(
|
||||
CFactory::_('Component')->get('creatuserhelper')
|
||||
));
|
||||
CFactory::_('Architecture.ComHelperClass.CreateUser')->get(
|
||||
CFactory::_('Component')->get('creatuserhelper', 0)
|
||||
)
|
||||
);
|
||||
|
||||
// HELP
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('HELP', $this->noHelp());
|
||||
|
@ -1827,340 +1827,24 @@ class Interpretation extends Fields
|
||||
return '';
|
||||
}
|
||||
|
||||
public function setCreateUserHelperMethod($add)
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param int $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*
|
||||
* @since 3.0
|
||||
* @deprecated 5.0.3 Use CFactory::_('Architecture.ComHelperClass.CreateUser')->get($add);
|
||||
*/
|
||||
public function setCreateUserHelperMethod($add): string
|
||||
{
|
||||
if ($add)
|
||||
{
|
||||
$method = [];
|
||||
$method[] = PHP_EOL . PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Greate user and update given table";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$credentials Array('name' => string, 'username' => string, 'email' => string, 'password' => string, 'password2' => string)";
|
||||
$method[] = Indent::_(1) . " * @param int \$autologin";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$params Array('useractivation' => int, 'sendpassword' => int, 'allowUserRegistration' => int)";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @param array \$mode 1 = Site Registrations; 0 = Admin Registration; 2 = Custom Helper Method Called registerUser";
|
||||
$method[] = Indent::_(1) . " *";
|
||||
$method[] = Indent::_(1)
|
||||
. " * @return int|Error User ID on success, or an error.";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function createUser(\$credentials, \$autologin = 0,";
|
||||
$method[] = Indent::_(2) . "\$params = array(";
|
||||
$method[] = Indent::_(3)
|
||||
. "'useractivation' => 0, 'sendpassword' => 1";
|
||||
$method[] = Indent::_(2) . "), \$mode = 1";
|
||||
$method[] = Indent::_(1) . ")";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Override mode";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 2 && method_exists(__CLASS__, 'registerUser'))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Update params";
|
||||
$method[] = Indent::_(3) . "\$params['autologin'] = \$autologin;";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Now Register User";
|
||||
$method[] = Indent::_(3)
|
||||
. "return self::registerUser(\$credentials, \$params);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "elseif (\$mode == 2)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Fallback to Site Registrations";
|
||||
$method[] = Indent::_(3) . "\$mode = 1;";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " load the user component language files if there is an error.";
|
||||
$method[] = Indent::_(2) . "\$lang = Factory::getLanguage();";
|
||||
$method[] = Indent::_(2) . "\$extension = 'com_users';";
|
||||
$method[] = Indent::_(2) . "\$base_dir = JPATH_SITE;";
|
||||
$method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
. "';";
|
||||
$method[] = Indent::_(2) . "\$reload = true;";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the correct user model.";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site Registrations";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the user site-registration model";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$model = self::getModel('registration', \$base_dir . '/components/' . \$extension, 'Users');";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin Registration";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the backend-user model";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/' . \$extension, 'Users');";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if we have params/config";
|
||||
$method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Make changes to user config";
|
||||
$method[] = Indent::_(3)
|
||||
. "foreach (\$params as \$param => \$set)";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If you know of a better path, let me know";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$params[\$param] = self::setParams(\$extension, \$param, \$set);";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Set username to email if not set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (!isset(\$credentials['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['username']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['username'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Lineup new user data array";
|
||||
$method[] = Indent::_(2) . "\$data = array(";
|
||||
$method[] = Indent::_(3)
|
||||
. "'username' => \$credentials['username'],";
|
||||
$method[] = Indent::_(3) . "'name' => \$credentials['name'],";
|
||||
$method[] = Indent::_(3) . "'block' => 0 );";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Added details based on mode";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['email1'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['email'] = \$credentials['email'];";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['registerDate'] = Factory::getDate()->toSql();";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if password was set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 1 && (!isset(\$credentials['password']) || !isset(\$credentials['password2']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2'])))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Set random password when empty password was submitted,";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " when using the 1 = site-registration mode";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['password'] = self::randomkey(8);";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$credentials['password2'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Now Add password if set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$credentials['password']) && isset(\$credentials['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$credentials['password2']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$data['password1'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4)
|
||||
. "\$data['password'] = \$credentials['password'];";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['password2'] = \$credentials['password2'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Load the group/s value if set, only for Admin Registration (\$mode == 0)";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (\$mode == 0 && isset(\$credentials['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$credentials['groups']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$data['groups'] = \$credentials['groups'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Create the new user";
|
||||
$method[] = Indent::_(2) . "if (\$mode == 1) //" . Line::_(
|
||||
__LINE__,__CLASS__
|
||||
)
|
||||
. " 1 = Site-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$userId = \$model->register(\$data);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "else //" . Line::_(__Line__, __Class__)
|
||||
. " 0 = Admin-registration mode";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$model->save(\$data);";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$userId = \$model->getState('user.id', 0);";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Check if we have params";
|
||||
$method[] = Indent::_(2) . "if (Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$params))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Change user params/config back";
|
||||
$method[] = Indent::_(3)
|
||||
. "foreach (\$params as \$param => \$set)";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " If you know of a better path, let me know";
|
||||
$method[] = Indent::_(4)
|
||||
. "self::setParams(\$extension, \$param, \$set);";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " if user is created";
|
||||
$method[] = Indent::_(2) . "if (\$userId > 0)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Auto Login if Needed";
|
||||
$method[] = Indent::_(3)
|
||||
. "if (\$autologin && isset(\$credentials['password']))";
|
||||
$method[] = Indent::_(3) . "{";
|
||||
$method[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Try to login";
|
||||
$method[] = Indent::_(4) . "try{";
|
||||
$method[] = Indent::_(5)
|
||||
. "Factory::getApplication()->login(\$credentials);";
|
||||
$method[] = Indent::_(4) . "} catch (\Exception \$exception){";
|
||||
$method[] = Indent::_(5) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Do noting for now, may want to set redirect.";
|
||||
$method[] = Indent::_(4) . "}";
|
||||
$method[] = Indent::_(3) . "}";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Return ID";
|
||||
$method[] = Indent::_(3) . "return \$userId;";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$model->getError();";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1)
|
||||
. "public static function setParams(\$component,\$target,\$value)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get the params and set the new values";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$params = ComponentHelper::getParams(\$component);";
|
||||
$method[] = Indent::_(2) . "\$was = \$params->get(\$target, null);";
|
||||
$method[] = Indent::_(2) . "if (\$was != \$value)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$params->set(\$target, \$value);";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Get a new database query instance";
|
||||
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$method[] = Indent::_(3) . "\$db = Factory::getDBO();";
|
||||
}
|
||||
else
|
||||
{
|
||||
$method[] = Indent::_(3) . "\$db = Factory::getContainer()->get(DatabaseInterface::class);";
|
||||
}
|
||||
|
||||
$method[] = Indent::_(3) . "\$query = \$db->getQuery(true);";
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Build the query";
|
||||
$method[] = Indent::_(3) . "\$query->update('#__extensions AS a');";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$query->set('a.params = ' . \$db->quote((string)\$params));";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$query->where('a.element = ' . \$db->quote((string)\$component));";
|
||||
$method[] = Indent::_(3);
|
||||
$method[] = Indent::_(3) . "//" . Line::_(__Line__, __Class__)
|
||||
. " Execute the query";
|
||||
$method[] = Indent::_(3) . "\$db->setQuery(\$query);";
|
||||
$method[] = Indent::_(3) . "\$db->execute();";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$was;";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
$method[] = PHP_EOL . Indent::_(1) . "/**";
|
||||
$method[] = Indent::_(1) . " * Update user values";
|
||||
$method[] = Indent::_(1) . " */";
|
||||
$method[] = Indent::_(1)
|
||||
. "public static function updateUser(\$new)";
|
||||
$method[] = Indent::_(1) . "{";
|
||||
$method[] = Indent::_(2)
|
||||
. "// load the user component language files if there is an error.";
|
||||
$method[] = Indent::_(2) . "\$lang = Factory::getLanguage();";
|
||||
$method[] = Indent::_(2) . "\$extension = 'com_users';";
|
||||
$method[] = Indent::_(2) . "\$base_dir = JPATH_ADMINISTRATOR;";
|
||||
$method[] = Indent::_(2) . "\$language_tag = '" . CFactory::_('Config')->get('lang_tag', 'en-GB')
|
||||
. "';";
|
||||
$method[] = Indent::_(2) . "\$reload = true;";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);";
|
||||
$method[] = Indent::_(2) . "// load the user model";
|
||||
$method[] = Indent::_(2)
|
||||
. "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');";
|
||||
$method[] = Indent::_(2) . "// Check if password was set";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$new['password']) && isset(\$new['password2']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password']) && Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['password2']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "// Use the users passwords";
|
||||
$method[] = Indent::_(3) . "\$password = \$new['password'];";
|
||||
$method[] = Indent::_(3) . "\$password2 = \$new['password2'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// set username";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (!isset(\$new['username']) || !Super_" . "__1f28cb53_60d9_4db1_b517_3c7dc6b429ef___Power::check(\$new['username']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3)
|
||||
. "\$new['username'] = \$new['email'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// lineup update user data";
|
||||
$method[] = Indent::_(2) . "\$data = array(";
|
||||
$method[] = Indent::_(3) . "'id' => \$new['id'],";
|
||||
$method[] = Indent::_(3) . "'username' => \$new['username'],";
|
||||
$method[] = Indent::_(3) . "'name' => \$new['name'],";
|
||||
$method[] = Indent::_(3) . "'email' => \$new['email'],";
|
||||
$method[] = Indent::_(3)
|
||||
. "'password' => \$password, // First password field";
|
||||
$method[] = Indent::_(3)
|
||||
. "'password2' => \$password2, // Confirm password field";
|
||||
$method[] = Indent::_(3) . "'block' => 0 );";
|
||||
$method[] = Indent::_(2) . "// set groups if found";
|
||||
$method[] = Indent::_(2)
|
||||
. "if (isset(\$new['groups']) && Super_" . "__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a___Power::check(\$new['groups']))";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "\$data['groups'] = \$new['groups'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "// register the new user";
|
||||
$method[] = Indent::_(2) . "\$done = \$model->save(\$data);";
|
||||
$method[] = Indent::_(2) . "// if user is updated";
|
||||
$method[] = Indent::_(2) . "if (\$done)";
|
||||
$method[] = Indent::_(2) . "{";
|
||||
$method[] = Indent::_(3) . "return \$new['id'];";
|
||||
$method[] = Indent::_(2) . "}";
|
||||
$method[] = Indent::_(2) . "return \$model->getError();";
|
||||
$method[] = Indent::_(1) . "}";
|
||||
|
||||
// return the help method
|
||||
return implode(PHP_EOL, $method);
|
||||
}
|
||||
|
||||
return '';
|
||||
return CFactory::_('Architecture.ComHelperClass.CreateUser')->get($add);
|
||||
}
|
||||
|
||||
public function setAdminViewMenu(&$nameSingleCode, &$view)
|
||||
@ -10251,7 +9935,7 @@ class Interpretation extends Fields
|
||||
. "`id` INT(11) NOT NULL AUTO_INCREMENT,";
|
||||
}
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',";
|
||||
. "`asset_id` INT(10) unsigned NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',";
|
||||
ksort($fields);
|
||||
$last_name = 'asset_id';
|
||||
foreach ($fields as $field => $data)
|
||||
@ -10350,19 +10034,19 @@ class Interpretation extends Fields
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.published'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`published` TINYINT(3) NOT NULL DEFAULT 1,";
|
||||
. "`published` TINYINT(3) NULL DEFAULT 1,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created_by'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`created_by` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
. "`created_by` INT(10) unsigned NULL DEFAULT 0,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.modified_by'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
. "`modified_by` INT(10) unsigned NULL DEFAULT 0,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.created'))
|
||||
@ -10370,7 +10054,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
. "`created` DATETIME NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10384,7 +10068,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
. "`modified` DATETIME NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10396,7 +10080,7 @@ class Interpretation extends Fields
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`checked_out` int(11) unsigned NOT NULL DEFAULT 0,";
|
||||
. "`checked_out` int(11) unsigned NULL DEFAULT 0,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.checked_out_time'))
|
||||
@ -10404,7 +10088,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
. "`checked_out_time` DATETIME NULL DEFAULT '0000-00-00 00:00:00',";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10416,20 +10100,20 @@ class Interpretation extends Fields
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.version'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`version` INT(10) unsigned NOT NULL DEFAULT 1,";
|
||||
. "`version` INT(10) unsigned NULL DEFAULT 1,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.hits'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`hits` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
. "`hits` INT(10) unsigned NULL DEFAULT 0,";
|
||||
}
|
||||
// check if view has access
|
||||
if (CFactory::_('Compiler.Builder.Access.Switch')->exists($view)
|
||||
&& !CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.access'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`access` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
. "`access` INT(10) unsigned NULL DEFAULT 0,";
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.access',
|
||||
[
|
||||
@ -10443,7 +10127,7 @@ class Interpretation extends Fields
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL'
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
]
|
||||
);
|
||||
@ -10452,7 +10136,7 @@ class Interpretation extends Fields
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.ordering'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`ordering` INT(11) NOT NULL DEFAULT 0,";
|
||||
. "`ordering` INT(11) NULL DEFAULT 0,";
|
||||
}
|
||||
// check if metadata is added to this view
|
||||
if (CFactory::_('Compiler.Builder.Meta.Data')->isString($view))
|
||||
@ -10463,7 +10147,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metakey` TEXT NOT NULL,";
|
||||
. "`metakey` TEXT NULL,";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10477,7 +10161,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadesc` TEXT NOT NULL,";
|
||||
. "`metadesc` TEXT NULL,";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10491,7 +10175,7 @@ class Interpretation extends Fields
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT NOT NULL,";
|
||||
. "`metadata` TEXT NULL,";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -10663,22 +10347,25 @@ class Interpretation extends Fields
|
||||
// add to main DB string
|
||||
$db .= $db_ . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
// add custom sql dump to the file
|
||||
if (isset(CFactory::_('Customcode.Dispenser')->hub['sql'])
|
||||
&& ArrayHelper::check(
|
||||
CFactory::_('Customcode.Dispenser')->hub['sql']
|
||||
))
|
||||
{
|
||||
foreach (
|
||||
CFactory::_('Customcode.Dispenser')->hub['sql'] as $for => $customSql
|
||||
)
|
||||
foreach (CFactory::_('Customcode.Dispenser')->hub['sql'] as $for => $customSql)
|
||||
{
|
||||
$placeholders = array(Placefix::_('component') => $component,
|
||||
Placefix::_('view') => $for);
|
||||
$db .= CFactory::_('Placeholder')->update(
|
||||
$customSql, $placeholders
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
$placeholders = [
|
||||
Placefix::_('component') => $component,
|
||||
Placefix::_('view') => $for
|
||||
]; // dont change this just use ###view### or componentbuilder (took you a while to get here right :)
|
||||
|
||||
$db .= CFactory::_('Placeholder')->update(
|
||||
$customSql, $placeholders
|
||||
) . PHP_EOL . PHP_EOL;
|
||||
}
|
||||
|
||||
unset(CFactory::_('Customcode.Dispenser')->hub['sql']);
|
||||
}
|
||||
|
||||
@ -13762,6 +13449,14 @@ class Interpretation extends Fields
|
||||
$headerscript .= PHP_EOL . '}';
|
||||
if ($addNewButon > 0)
|
||||
{
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$add_key = 'edit';
|
||||
}
|
||||
else
|
||||
{
|
||||
$add_key = 'add';
|
||||
}
|
||||
// add the link for new
|
||||
if ($addNewButon == 1 || $addNewButon == 2)
|
||||
{
|
||||
@ -13770,7 +13465,7 @@ class Interpretation extends Fields
|
||||
$headerscript .= PHP_EOL . '$new = "index.php?option=com_'
|
||||
. CFactory::_('Config')->component_code_name . '&view=' . $name_list_code
|
||||
. '&task='
|
||||
. $name_single_code . '.edit" . $ref;';
|
||||
. $name_single_code . '.' . $add_key . '" . $ref;';
|
||||
}
|
||||
// and the link for close and new
|
||||
if ($addNewButon == 2 || $addNewButon == 3)
|
||||
@ -13781,7 +13476,7 @@ class Interpretation extends Fields
|
||||
. '$close_new = "index.php?option=com_'
|
||||
. CFactory::_('Config')->component_code_name . '&view=' . $name_list_code
|
||||
. '&task='
|
||||
. $name_single_code . '.edit";';
|
||||
. $name_single_code . '.' . $add_key . '";';
|
||||
}
|
||||
$headerscript .= PHP_EOL . '//' . Line::_(__Line__, __Class__)
|
||||
. ' load the action object';
|
||||
@ -21553,7 +21248,8 @@ class Interpretation extends Fields
|
||||
$counter++;
|
||||
}
|
||||
// dashboard link to category on dashboard is build here
|
||||
if (CFactory::_('Compiler.Builder.Category')->exists("{$name_list}.code"))
|
||||
if (CFactory::_('Compiler.Builder.Category')->exists("{$name_list}.code") &&
|
||||
CFactory::_('Compiler.Builder.Category')->get("{$name_list}.add_icon"))
|
||||
{
|
||||
$catCode = CFactory::_('Compiler.Builder.Category')->get("{$name_list}.code");
|
||||
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass;
|
||||
|
||||
|
||||
/**
|
||||
* Component Helper Class Create User Interface
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
interface CreateUserInterface
|
||||
{
|
||||
/**
|
||||
* Generates the method definition for creating or updating a user based on the provided parameters.
|
||||
*
|
||||
* This method returns a string representation of a PHP function that includes various
|
||||
* steps for handling user creation and updates, depending on the mode (site registration or admin registration).
|
||||
*
|
||||
* @param $add Determines whether to generate the user creation method or not.
|
||||
* If true, the method will be generated and returned as a string.
|
||||
*
|
||||
* @return string The generated method code as a string if $add is true.
|
||||
* Returns an empty string if $add is false.
|
||||
*/
|
||||
public function get($add): string;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -12,7 +12,6 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Model\Sqldump;
|
||||
|
||||
@ -43,15 +42,15 @@ class Sql
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Dispenser|null $dispenser The compiler customcode dispenser.
|
||||
* @param Sqldump|null $dump The compiler SQL dump.
|
||||
* @param Dispenser $dispenser The compiler customcode dispenser.
|
||||
* @param Sqldump $dump The compiler SQL dump.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Dispenser $dispenser = null, ?Sqldump $dump = null)
|
||||
public function __construct(Dispenser $dispenser, Sqldump $dump)
|
||||
{
|
||||
$this->dispenser = $dispenser ?: Compiler::_('Customcode.Dispenser');
|
||||
$this->dump = $dump ?: Compiler::_('Model.Sqldump');
|
||||
$this->dispenser = $dispenser;
|
||||
$this->dump = $dump;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,7 +90,6 @@ class Sql
|
||||
|
||||
unset($item->tables);
|
||||
unset($item->sql);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,6 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Model;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
@ -45,14 +44,13 @@ class Sqldump
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param \JDatabaseDriver|null $db The database object.
|
||||
* @param Registry $registry The compiler registry object.
|
||||
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null)
|
||||
public function __construct(Registry $registry)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->registry = $registry;
|
||||
$this->db = Factory::getDbo();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
@ -37,13 +36,13 @@ class Sqltweaking
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Registry $registry The compiler registry object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null)
|
||||
public function __construct(Registry $registry)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Registry;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
@ -45,13 +44,13 @@ class Updatesql
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Registry|null $registry The compiler registry object.
|
||||
* @param Registry $registry The compiler registry object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Registry $registry = null)
|
||||
public function __construct(Registry $registry)
|
||||
{
|
||||
$this->registry = $registry ?: Compiler::_('Registry');
|
||||
$this->registry = $registry;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\ComHelperClass\CreateUserInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\ComHelperClass\CreateUser as J5CreateUser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\ComHelperClass\CreateUser as J4CreateUser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\ComHelperClass\CreateUser as J3CreateUser;
|
||||
|
||||
|
||||
/**
|
||||
* Architecture Component Helper Class Service Provider
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
class ArchitectureComHelperClass implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Current Joomla Version Being Build
|
||||
*
|
||||
* @var int
|
||||
* @since 5.0.2
|
||||
**/
|
||||
protected $targetVersion;
|
||||
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(CreateUserInterface::class, 'Architecture.ComHelperClass.CreateUser')
|
||||
->share('Architecture.ComHelperClass.CreateUser', [$this, 'getCreateUser'], true);
|
||||
|
||||
$container->alias(J5CreateUser::class, 'Architecture.ComHelperClass.J5.CreateUser')
|
||||
->share('Architecture.ComHelperClass.J5.CreateUser', [$this, 'getJ5CreateUser'], true);
|
||||
|
||||
$container->alias(J4CreateUser::class, 'Architecture.ComHelperClass.J4.CreateUser')
|
||||
->share('Architecture.ComHelperClass.J4.CreateUser', [$this, 'getJ4CreateUser'], true);
|
||||
|
||||
$container->alias(J3CreateUser::class, 'Architecture.ComHelperClass.J3.CreateUser')
|
||||
->share('Architecture.ComHelperClass.J3.CreateUser', [$this, 'getJ3CreateUser'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUserInterface Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return CreateUserInterface
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getCreateUser(Container $container): CreateUserInterface
|
||||
{
|
||||
if (empty($this->targetVersion))
|
||||
{
|
||||
$this->targetVersion = $container->get('Config')->joomla_version;
|
||||
}
|
||||
|
||||
return $container->get('Architecture.ComHelperClass.J' . $this->targetVersion . '.CreateUser');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J5CreateUser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ5CreateUser(Container $container): J5CreateUser
|
||||
{
|
||||
return new J5CreateUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J4CreateUser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ4CreateUser(Container $container): J4CreateUser
|
||||
{
|
||||
return new J4CreateUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The CreateUser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J3CreateUser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ3CreateUser(Container $container): J3CreateUser
|
||||
{
|
||||
return new J3CreateUser();
|
||||
}
|
||||
}
|
||||
|
@ -107,9 +107,9 @@ class Config extends BaseConfig
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
{
|
||||
$repos[$this->gitea_username . '.joomla-fieldtype'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-fieldtype', 'read_branch' => 'master'];
|
||||
$repos[$this->gitea_username . '.joomla-fieldtypes'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-fieldtypes', 'read_branch' => 'master'];
|
||||
}
|
||||
$repos[$this->joomla_fieldtype_core_organisation . '.joomla-fieldtype'] = (object) ['organisation' => $this->joomla_fieldtype_core_organisation, 'repository' => 'joomla-fieldtype', 'read_branch' => 'master'];
|
||||
$repos[$this->joomla_fieldtype_core_organisation . '.joomla-fieldtypes'] = (object) ['organisation' => $this->joomla_fieldtype_core_organisation, 'repository' => 'joomla-fieldtypes', 'read_branch' => 'master'];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ final class Main implements MainInterface
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
|
||||
███████╗██╗███████╗██╗ ██████╗ ████████╗██╗ ██╗██████╗ ███████╗███████╗
|
||||
██╔════╝██║██╔════╝██║ ██╔══██╗ ╚══██╔══╝╚██╗ ██╔╝██╔══██╗██╔════╝██╔════╝
|
||||
█████╗ ██║█████╗ ██║ ██║ ██║ ██║ ╚████╔╝ ██████╔╝█████╗ ███████╗
|
||||
@ -52,7 +52,7 @@ final class Main implements MainInterface
|
||||
// default description of super powers
|
||||
$readme[] = "\n### What is JCB Joomla Field Types?\nThe Joomla field types provide a powerful way to map Joomla-related field types, enabling seamless integration with Joomla Component Builder (JCB). This repository serves as a centralized system for maintaining, updating, and distributing these field types throughout the JCB ecosystem.\n
|
||||
\n
|
||||
When you need to update any field type in JCB, simply select the desired field type and click the "reset" button. This action will automatically sync the selected field type with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
When you need to update any field type in JCB, simply select the desired field type and click the \"reset\" button. This action will automatically sync the selected field type with its corresponding version hosted in our core repository, ensuring you always have the latest updates.\n
|
||||
\n
|
||||
Moreover, if you wish to tailor the field types to your specific needs, you can fork the repository and point your JCB instance to your fork. This allows you to maintain and update field types independently from the main JCB community, offering the flexibility that is at the heart of open-source philosophy.\n
|
||||
\n
|
||||
|
@ -217,7 +217,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'tab_name' => 'Details',
|
||||
'db' => [
|
||||
'type' => 'TINYINT(1)',
|
||||
'default' => '0',
|
||||
'default' => '1',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'unique_key' => false,
|
||||
'key' => true,
|
||||
@ -1546,7 +1546,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
'metakey' => [
|
||||
@ -2267,7 +2267,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -2907,7 +2907,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -2987,7 +2987,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -3403,7 +3403,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -4891,7 +4891,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -5483,7 +5483,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -6075,7 +6075,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -6235,7 +6235,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -6395,7 +6395,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -6955,7 +6955,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7019,7 +7019,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'TINYINT(1)',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'unique_key' => false,
|
||||
'key' => true,
|
||||
],
|
||||
@ -7179,7 +7179,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7307,7 +7307,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7451,7 +7451,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7499,7 +7499,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7659,7 +7659,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7883,7 +7883,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -7963,7 +7963,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -8379,7 +8379,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -8635,7 +8635,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -8731,7 +8731,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -8779,7 +8779,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -8987,7 +8987,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9115,7 +9115,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => 'EMPTY',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'unique_key' => false,
|
||||
'key' => false,
|
||||
],
|
||||
@ -9131,7 +9131,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'TINYINT(1)',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'unique_key' => false,
|
||||
'key' => true,
|
||||
],
|
||||
@ -9211,7 +9211,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9437,7 +9437,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9485,7 +9485,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9533,7 +9533,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9581,7 +9581,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9629,7 +9629,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9677,7 +9677,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9725,7 +9725,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9773,7 +9773,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9821,7 +9821,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -9869,7 +9869,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10013,7 +10013,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10061,7 +10061,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10125,7 +10125,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10221,7 +10221,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10253,7 +10253,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => 'EMPTY',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
'unique_key' => false,
|
||||
'key' => false,
|
||||
],
|
||||
@ -10269,7 +10269,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10317,7 +10317,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10365,7 +10365,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10413,7 +10413,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10461,7 +10461,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10573,7 +10573,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10653,7 +10653,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10701,7 +10701,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10813,7 +10813,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10861,7 +10861,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -10909,7 +10909,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
@ -11021,7 +11021,7 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL',
|
||||
'null_switch' => 'NULL',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Utilities\Exception;
|
||||
|
||||
|
||||
/**
|
||||
* No User Id Found Exception
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
class NoUserIdFoundException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -0,0 +1,480 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Form\Form;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\User\User;
|
||||
use Joomla\CMS\User\UserHelper as JoomlaUserHelper;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
use VDM\Joomla\Utilities\Component\Helper as Component;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException;
|
||||
|
||||
|
||||
/**
|
||||
* Create & Update User [Save]
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
abstract class UserHelper
|
||||
{
|
||||
/**
|
||||
* Save user details by either creating a new user or updating an existing user.
|
||||
*
|
||||
* @param array $credentials User credentials including 'name', 'username', 'email', 'password', and 'password2'.
|
||||
* @param int $autologin Flag to determine whether to auto-login the user after registration.
|
||||
* @param array $params Parameters for user activation, password sending, and user registration allowance.
|
||||
* @param int $mode Mode of registration: 1 = Site Registration, 0 = Admin Registration, 2 = Custom Helper Method.
|
||||
*
|
||||
* @return int User ID on success.
|
||||
*
|
||||
* @throws \InvalidArgumentException If required credentials are missing.
|
||||
* @throws \RuntimeException If the user update or creation fails.
|
||||
* @throws NoUserIdFoundException If the user is not found.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function save(array $credentials, int $autologin = 0,
|
||||
array $params = ['useractivation' => 0, 'sendpassword' => 1], int $mode = 1): int
|
||||
{
|
||||
// can not continue without an email
|
||||
if (empty($credentials['email']))
|
||||
{
|
||||
throw new \InvalidArgumentException(Text::_('COM_COMPONENTBUILDER_CAN_NOT_SAVE_USER_WITHOUT_EMAIL_VALUE'));
|
||||
}
|
||||
|
||||
// Ensure the 'username' key exists in the credentials array, set to an empty string if not provided.
|
||||
$username = $credentials['username'] ?? $credentials['email'];
|
||||
|
||||
// If the user's ID is set and valid, handle the update logic.
|
||||
if (!empty($credentials['id']) && $credentials['id'] > 0)
|
||||
{
|
||||
$userId = $credentials['id'];
|
||||
$email = $credentials['email'];
|
||||
|
||||
// Fetch existing user by email and username.
|
||||
$existingEmailUserId = static::getUserIdByEmail($email);
|
||||
$existingUsernameId = static::getUserIdByUsername($username);
|
||||
|
||||
// Validate that we aren't attempting to update other users or reuse another user's email/username.
|
||||
if (
|
||||
($existingEmailUserId && $existingEmailUserId != $userId) ||
|
||||
($existingUsernameId && $existingUsernameId != $userId) ||
|
||||
($existingEmailUserId && $existingUsernameId && $existingEmailUserId != $existingUsernameId)
|
||||
) {
|
||||
throw new NoUserIdFoundException(
|
||||
Text::sprintf(
|
||||
'User ID mismatch detected when trying to save %s (%s) credentials.',
|
||||
$username,
|
||||
$email
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Update the existing user.
|
||||
return static::update($credentials);
|
||||
}
|
||||
|
||||
// Create a new user if no existing user is found.
|
||||
return static::create($credentials, $autologin, $params, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user and update the given table.
|
||||
*
|
||||
* @param array $credentials User credentials including 'name', 'username', 'email', 'password', and 'password2'.
|
||||
* @param int $autologin Flag to determine whether to auto-login the user after registration.
|
||||
* @param array $params Parameters for user activation, password sending, and user registration allowance.
|
||||
* @param int $mode Mode of registration: 1 = Site Registration, 0 = Admin Registration, 2 = Custom Helper Method.
|
||||
*
|
||||
* @return int User ID on success.
|
||||
*
|
||||
* @throws \RuntimeException If user creation fails.
|
||||
* @throws NoUserIdFoundException If the user is not found.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function create(array $credentials, int $autologin = 0,
|
||||
array $params = ['useractivation' => 0, 'sendpassword' => 1], int $mode = 1): int
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
$lang->load('com_users', JPATH_SITE, 'en-GB', true);
|
||||
|
||||
// Handle custom registration mode
|
||||
if ($mode === 2 && method_exists(ComponentbuilderHelper::class, 'registerUser'))
|
||||
{
|
||||
$params['autologin'] = $autologin;
|
||||
$userId = ComponentbuilderHelper::registerUser($credentials, $params);
|
||||
|
||||
if (is_numeric($userId))
|
||||
{
|
||||
return $userId;
|
||||
}
|
||||
|
||||
throw new NoUserIdFoundException(Text::_('COM_COMPONENTBUILDER_USER_CREATION_FAILED'));
|
||||
}
|
||||
|
||||
// Check if we have params/config
|
||||
if (ArrayHelper::check($params))
|
||||
{
|
||||
// Make changes to user config
|
||||
foreach ($params as $param => $set)
|
||||
{
|
||||
// If you know of a better path, let me know
|
||||
$params[$param] = Component::setParams($param, $set, 'com_users');
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to Site Registrations if mode is set to 2 but the method doesn't exist
|
||||
$mode = $mode === 2 ? 1 : $mode;
|
||||
|
||||
// Load the appropriate user model
|
||||
$model = static::getModelByMode($mode);
|
||||
|
||||
// Set default values for missing credentials
|
||||
$credentials['username'] = $credentials['username'] ?? $credentials['email'];
|
||||
|
||||
// Prepare user data
|
||||
$data = static::prepareUserData($credentials, $mode);
|
||||
|
||||
// Set form path (bug fix for Joomla)
|
||||
static::setFormPathForUserClass($mode);
|
||||
|
||||
// Handle user creation
|
||||
$userId = $mode === 1 ? $model->register($data) : static::adminRegister($model, $data);
|
||||
|
||||
// Check if we have params
|
||||
if (ArrayHelper::check($params))
|
||||
{
|
||||
// Change user params/config back
|
||||
foreach ($params as $param => $set)
|
||||
{
|
||||
// If you know of a better path, let me know
|
||||
Component::setParams($param, $set, 'com_users');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$userId)
|
||||
{
|
||||
$current_user = Factory::getApplication()->getIdentity();
|
||||
|
||||
// only allow those with access to Users to ignore errors
|
||||
if ($current_user->authorise('core.manage', 'com_users'))
|
||||
{
|
||||
$userId = static::getUserIdByUsername($credentials['username']);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_numeric($userId) && $userId > 0)
|
||||
{
|
||||
// Handle post-registration processes
|
||||
return static::handlePostRegistration($userId, $autologin, $credentials);
|
||||
}
|
||||
|
||||
$error_messages = '';
|
||||
if (method_exists($model, 'getError'))
|
||||
{
|
||||
$errors = $model->getError();
|
||||
if (!empty($errors))
|
||||
{
|
||||
if (is_array($errors))
|
||||
{
|
||||
$error_messages = '<br>' . implode('<br>', $errors);
|
||||
}
|
||||
elseif (is_string($errors))
|
||||
{
|
||||
$error_messages = '<br>' . $errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new NoUserIdFoundException(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_USER_S_S_CREATION_FAILEDS',
|
||||
(string) $credentials['username'],
|
||||
(string) $credentials['email'],
|
||||
$error_messages
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user details.
|
||||
*
|
||||
* @param array $userDetails Array containing user details to be updated.
|
||||
*
|
||||
* @return int Updated user ID on success.
|
||||
*
|
||||
* @throws \RuntimeException If user update fails.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function update(array $userDetails): int
|
||||
{
|
||||
$lang = Factory::getLanguage();
|
||||
$lang->load('com_users', JPATH_ADMINISTRATOR, 'en-GB', true);
|
||||
|
||||
$model = Component::getModel('User', 'Administrator', 'com_users');
|
||||
|
||||
// Set default values for missing credentials
|
||||
$userDetails['username'] = $userDetails['username'] ?? $userDetails['email'];
|
||||
|
||||
// Prepare user data for update
|
||||
$data = [
|
||||
'id' => $userDetails['id'],
|
||||
'username' => $userDetails['username'],
|
||||
'name' => $userDetails['name'],
|
||||
'email' => $userDetails['email'],
|
||||
'password' => $userDetails['password'] ?? null,
|
||||
'password2' => $userDetails['password2'] ?? null,
|
||||
'block' => 0
|
||||
];
|
||||
|
||||
// set groups if found
|
||||
if (isset($userDetails['groups']) && ArrayHelper::check($userDetails['groups']))
|
||||
{
|
||||
$data['groups'] = $userDetails['groups'];
|
||||
}
|
||||
|
||||
// Update the user
|
||||
if ($model->save($data))
|
||||
{
|
||||
return $userDetails['id'];
|
||||
}
|
||||
|
||||
$error_messages = '';
|
||||
if (method_exists($model, 'getError'))
|
||||
{
|
||||
$errors = $model->getError();
|
||||
if (!empty($errors))
|
||||
{
|
||||
if (is_array($errors))
|
||||
{
|
||||
$error_messages = '<br>' . implode('<br>', $errors);
|
||||
}
|
||||
elseif (is_string($errors))
|
||||
{
|
||||
$error_messages = '<br>' . $errors;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new \RuntimeException(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_UPDATE_OF_USER_S_S_FAILEDS',
|
||||
(string) $userDetails['username'],
|
||||
(string) $userDetails['email'],
|
||||
(string) $error_messages
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an instance of a user for the given id.
|
||||
*
|
||||
* @param int $id The id
|
||||
*
|
||||
* @return User
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function getUserById(int $id): User
|
||||
{
|
||||
return new User($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the user ID by username.
|
||||
*
|
||||
* @param string $username The username to check.
|
||||
*
|
||||
* @return int|null The user ID if the user exists, null otherwise.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function getUserIdByUsername(string $username): ?int
|
||||
{
|
||||
$userId = JoomlaUserHelper::getUserId($username);
|
||||
return $userId ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the user ID by email.
|
||||
*
|
||||
* @param string $email The email address to check.
|
||||
*
|
||||
* @return int|null The user ID if the user exists, null otherwise.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function getUserIdByEmail(string $email): ?int
|
||||
{
|
||||
// Initialise some variables
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('id'))
|
||||
->from($db->quoteName('#__users'))
|
||||
->where($db->quoteName('email') . ' = :email')
|
||||
->bind(':email', $email)
|
||||
->setLimit(1);
|
||||
$db->setQuery($query);
|
||||
|
||||
$userId = $db->loadResult();
|
||||
return $userId ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the correct user model based on the registration mode.
|
||||
*
|
||||
* @param int $mode The registration mode.
|
||||
*
|
||||
* @return BaseDatabaseModel The appropriate user model.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected static function getModelByMode(int $mode): BaseDatabaseModel
|
||||
{
|
||||
if ($mode === 1)
|
||||
{
|
||||
return Component::getModel('Registration', 'Site', 'com_users');
|
||||
}
|
||||
|
||||
return Component::getModel('User', 'Administrator', 'com_users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare user data array for registration or update.
|
||||
*
|
||||
* @param array $credentials User credentials.
|
||||
* @param int $mode The registration mode.
|
||||
*
|
||||
* @return array The prepared user data array.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
protected static function prepareUserData(array $credentials, int $mode)
|
||||
{
|
||||
$data = [
|
||||
'username' => $credentials['username'],
|
||||
'name' => $credentials['name'],
|
||||
'block' => 0
|
||||
];
|
||||
|
||||
if ($mode === 1)
|
||||
{
|
||||
$data['email1'] = $credentials['email'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data['email'] = $credentials['email'];
|
||||
$data['registerDate'] = Factory::getDate()->toSql();
|
||||
}
|
||||
|
||||
if ($mode === 1 && empty($credentials['password']))
|
||||
{
|
||||
$credentials['password'] = StringHelper::random(10);
|
||||
$credentials['password2'] = $credentials['password'];
|
||||
}
|
||||
|
||||
if (!empty($credentials['password']) && !empty($credentials['password2']))
|
||||
{
|
||||
$data['password1'] = $credentials['password'];
|
||||
$data['password2'] = $credentials['password2'];
|
||||
}
|
||||
|
||||
if ($mode === 0 && isset($credentials['groups']) && ArrayHelper::check($credentials['groups']))
|
||||
{
|
||||
$data['groups'] = $credentials['groups'];
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the registration process for admin mode.
|
||||
*
|
||||
* @param BaseDatabaseModel $model The user model.
|
||||
* @param array $data The user data.
|
||||
*
|
||||
* @return int The ID of the created user.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private static function adminRegister(BaseDatabaseModel $model, array $data): int
|
||||
{
|
||||
$model->save($data);
|
||||
|
||||
return $model->getState('user.id', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle post-registration processes like auto-login.
|
||||
*
|
||||
* @param int $userId The ID of the created user.
|
||||
* @param int $autologin Flag to determine whether to auto-login the user.
|
||||
* @param array $credentials The user credentials.
|
||||
*
|
||||
* @return int The user ID on success.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private static function handlePostRegistration(int $userId, int $autologin, array $credentials): int
|
||||
{
|
||||
// make sure user is it the correct groups
|
||||
if ($userId > 0 && !empty($credentials['groups']))
|
||||
{
|
||||
try
|
||||
{
|
||||
JoomlaUserHelper::setUserGroups($userId, $credentials['groups']);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// we might need say something
|
||||
}
|
||||
}
|
||||
|
||||
if ($autologin && !empty($credentials['password']))
|
||||
{
|
||||
try
|
||||
{
|
||||
Factory::getApplication()->login($credentials);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// we might need to redirect here?
|
||||
}
|
||||
}
|
||||
|
||||
return $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Address bug on \Joomla\CMS\MVC\Model\FormBehaviorTrait Line 76
|
||||
* The use of JPATH_COMPONENT cause it to load the
|
||||
* active component forms and fields, which breaks the registration model.
|
||||
*
|
||||
* @param int $mode
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private static function setFormPathForUserClass(int $mode): void
|
||||
{
|
||||
if ($mode == 1) // 1 = use of the Registration Model
|
||||
{
|
||||
// Get the form.
|
||||
Form::addFormPath(JPATH_ROOT . '/components/com_users/forms');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
110
libraries/vendor_jcb/VDM.Joomla/src/Data/Guid.php
Normal file
110
libraries/vendor_jcb/VDM.Joomla/src/Data/Guid.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Data;
|
||||
|
||||
|
||||
/**
|
||||
* Globally Unique Identifier
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
trait Guid
|
||||
{
|
||||
/**
|
||||
* Returns a GUIDv4 string.
|
||||
*
|
||||
* This function uses the best cryptographically secure method
|
||||
* available on the platform with a fallback to an older, less secure version.
|
||||
*
|
||||
* @param string $key The key to check and modify values.
|
||||
*
|
||||
* @return string A GUIDv4 string.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getGuid(string $key): string
|
||||
{
|
||||
// Windows: Use com_create_guid if available
|
||||
if (function_exists('com_create_guid'))
|
||||
{
|
||||
$guid = trim(\com_create_guid(), '{}');
|
||||
return $this->checkGuid($guid, $key);
|
||||
}
|
||||
|
||||
// Unix-based systems: Use openssl_random_pseudo_bytes if available
|
||||
if (function_exists('random_bytes'))
|
||||
{
|
||||
try {
|
||||
$data = random_bytes(16);
|
||||
} catch (Exception $e) {
|
||||
// Handle the error appropriately (logging, throwing, etc.)
|
||||
return $this->fallbackGuid($key);
|
||||
}
|
||||
|
||||
// Set the version to 0100 and the bits 6-7 to 10 as per RFC 4122
|
||||
$data[6] = chr(ord($data[6]) & 0x0f | 0x40);
|
||||
$data[8] = chr(ord($data[8]) & 0x3f | 0x80);
|
||||
|
||||
$guid = vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
return $this->checkGuid($guid, $key);
|
||||
}
|
||||
|
||||
// Fallback to older methods if secure methods are not available
|
||||
return $this->fallbackGuid($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a fallback GUIDv4 using less secure methods.
|
||||
*
|
||||
* @param string $key The key to check and modify values.
|
||||
*
|
||||
* @return string A GUIDv4 string.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function fallbackGuid(string $key): string
|
||||
{
|
||||
$charid = strtolower(md5(uniqid(random_int(0, PHP_INT_MAX), true)));
|
||||
$guidv4 = sprintf(
|
||||
'%s-%s-%s-%s-%s',
|
||||
substr($charid, 0, 8),
|
||||
substr($charid, 8, 4),
|
||||
substr($charid, 12, 4),
|
||||
substr($charid, 16, 4),
|
||||
substr($charid, 20, 12)
|
||||
);
|
||||
|
||||
return $this->checkGuid($guidv4, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the GUID value is unique and does not already exist.
|
||||
*
|
||||
* @param string $guid The GUID value to check.
|
||||
* @param string $key The key to check and modify values.
|
||||
*
|
||||
* @return string The unique GUID value.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function checkGuid(string $guid, string $key): string
|
||||
{
|
||||
// Check that the GUID does not already exist
|
||||
if ($this->items->table($this->getTable())->values([$guid], $key))
|
||||
{
|
||||
return $this->getGuid($key);
|
||||
}
|
||||
|
||||
return $guid;
|
||||
}
|
||||
}
|
||||
|
@ -445,7 +445,10 @@ final class MultiSubform implements MultiSubformInterface
|
||||
{
|
||||
if ($this->validSetMap($map))
|
||||
{
|
||||
return $this->setSubformData($subform[$key], $map, [$table => $subform]);
|
||||
// will delete all existing linked items [IF EMPTY] :( not ideal, but real
|
||||
$data = (empty($subform[$key]) || !is_array($subform[$key])) ? [] : $subform[$key];
|
||||
|
||||
return $this->setSubformData($data, $map, [$table => $subform]);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -13,6 +13,8 @@ namespace VDM\Joomla\Data;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
|
||||
use VDM\Joomla\Data\Guid;
|
||||
use VDM\Joomla\Interfaces\Data\GuidInterface;
|
||||
use VDM\Joomla\Interfaces\Data\SubformInterface;
|
||||
|
||||
|
||||
@ -21,10 +23,17 @@ use VDM\Joomla\Interfaces\Data\SubformInterface;
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
final class Subform implements SubformInterface
|
||||
final class Subform implements GuidInterface, SubformInterface
|
||||
{
|
||||
/**
|
||||
* The ItemsInterface Class.
|
||||
* The Globally Unique Identifier.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
use Guid;
|
||||
|
||||
/**
|
||||
* The Items Class.
|
||||
*
|
||||
* @var Items
|
||||
* @since 3.2.2
|
||||
@ -42,7 +51,7 @@ final class Subform implements SubformInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Items $items The ItemsInterface Class.
|
||||
* @param Items $items The Items Class.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.2
|
||||
@ -77,16 +86,17 @@ final class Subform implements SubformInterface
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $field The parent field name of the subform in the parent view.
|
||||
* @param array $get The array get:set of the keys of each row in the subform.
|
||||
* @param array $get The array SET of the keys of each row in the subform.
|
||||
* @param bool $multi The switch to return a multiple set.
|
||||
*
|
||||
* @return array|null The subform
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(string $linkValue, string $linkKey, string $field, array $get): ?array
|
||||
public function get(string $linkValue, string $linkKey, string $field, array $get, bool $multi = true): ?array
|
||||
{
|
||||
if (($items = $this->items->table($this->getTable())->get([$linkValue], $linkKey)) !== null)
|
||||
{
|
||||
return $this->converter($items, $get, $field);
|
||||
return $this->converter($items, $get, $field, $multi);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -179,11 +189,12 @@ final class Subform implements SubformInterface
|
||||
* @param array $items Array of objects or arrays to be filtered.
|
||||
* @param array $keySet Array of keys to retain in each item.
|
||||
* @param string $field The field prefix for the resulting associative array.
|
||||
* @param bool $multi The switch to return a multiple set.
|
||||
*
|
||||
* @return array Array of filtered arrays set by association.
|
||||
* @since 3.2.2
|
||||
*/
|
||||
private function converter(array $items, array $keySet, string $field): array
|
||||
private function converter(array $items, array $keySet, string $field, bool $multi): array
|
||||
{
|
||||
/**
|
||||
* Filters keys for a single item and converts it to an array.
|
||||
@ -209,6 +220,10 @@ final class Subform implements SubformInterface
|
||||
$result = [];
|
||||
foreach ($items as $index => $item)
|
||||
{
|
||||
if (!$multi)
|
||||
{
|
||||
return $filterKeys($item, $keySet);
|
||||
}
|
||||
$filteredArray = $filterKeys($item, $keySet);
|
||||
$result[$field . $index] = $filteredArray;
|
||||
}
|
||||
@ -230,6 +245,11 @@ final class Subform implements SubformInterface
|
||||
private function process($items, string $indexKey, string $linkKey, string $linkValue): array
|
||||
{
|
||||
$items = is_array($items) ? $items : [];
|
||||
if ($items !== [] && !$this->isMultipleSets($items))
|
||||
{
|
||||
$items = [$items];
|
||||
}
|
||||
|
||||
foreach ($items as &$item)
|
||||
{
|
||||
$value = $item[$indexKey] ?? '';
|
||||
@ -238,7 +258,7 @@ final class Subform implements SubformInterface
|
||||
if (empty($value))
|
||||
{
|
||||
// set INDEX
|
||||
$item[$indexKey] = $this->setGuid($indexKey);
|
||||
$item[$indexKey] = $this->getGuid($indexKey);
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
@ -259,67 +279,26 @@ final class Subform implements SubformInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a GUIDv4 string
|
||||
* Function to determine if the array consists of multiple data sets (arrays of arrays).
|
||||
*
|
||||
* Thanks to Dave Pearson (and other)
|
||||
* https://www.php.net/manual/en/function.com-create-guid.php#119168
|
||||
*
|
||||
* Uses the best cryptographically secure method
|
||||
* for all supported platforms with fallback to an older,
|
||||
* less secure version.
|
||||
*
|
||||
* @param string $key The key to check and modify values.
|
||||
* @param bool $trim
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @since 3.0.9
|
||||
* @param array $array The input array to be checked.
|
||||
*
|
||||
* @return bool True if the array contains only arrays (multiple data sets), false otherwise.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function setGuid(string $key, bool $trim = true): string
|
||||
private function isMultipleSets(array $array): bool
|
||||
{
|
||||
// Windows
|
||||
if (function_exists('com_create_guid'))
|
||||
foreach ($array as $element)
|
||||
{
|
||||
if ($trim)
|
||||
// As soon as we find a non-array element, return false
|
||||
if (!is_array($element))
|
||||
{
|
||||
return trim(\com_create_guid(), '{}');
|
||||
return false;
|
||||
}
|
||||
return \com_create_guid();
|
||||
}
|
||||
|
||||
// set the braces if needed
|
||||
$lbrace = $trim ? "" : chr(123); // "{"
|
||||
$rbrace = $trim ? "" : chr(125); // "}"
|
||||
|
||||
// OSX/Linux
|
||||
if (function_exists('openssl_random_pseudo_bytes'))
|
||||
{
|
||||
$data = \openssl_random_pseudo_bytes(16);
|
||||
$data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100
|
||||
$data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
|
||||
return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . $lbrace;
|
||||
}
|
||||
|
||||
// Fallback (PHP 4.2+)
|
||||
mt_srand((double) microtime() * 10000);
|
||||
$charid = strtolower( md5( uniqid( rand(), true)));
|
||||
$hyphen = chr(45); // "-"
|
||||
$guidv4 = $lbrace.
|
||||
substr($charid, 0, 8). $hyphen.
|
||||
substr($charid, 8, 4). $hyphen.
|
||||
substr($charid, 12, 4). $hyphen.
|
||||
substr($charid, 16, 4). $hyphen.
|
||||
substr($charid, 20, 12).
|
||||
$rbrace;
|
||||
|
||||
// check that it does not already exist (one in a billion chance ;)
|
||||
// but we do it any way...
|
||||
if ($this->items->table($this->getTable())->values([$guidv4], $key))
|
||||
{
|
||||
return $this->setGuid($key);
|
||||
}
|
||||
|
||||
return $guidv4;
|
||||
// If all elements are arrays, return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
614
libraries/vendor_jcb/VDM.Joomla/src/Data/UsersSubform.php
Normal file
614
libraries/vendor_jcb/VDM.Joomla/src/Data/UsersSubform.php
Normal file
@ -0,0 +1,614 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 3rd September, 2020
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Data;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\User\User;
|
||||
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
|
||||
use VDM\Joomla\Data\Guid;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\UserHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Exception\NoUserIdFoundException;
|
||||
use VDM\Joomla\Utilities\Component\Helper as Component;
|
||||
use VDM\Joomla\Interfaces\Data\GuidInterface;
|
||||
use VDM\Joomla\Interfaces\Data\SubformInterface;
|
||||
|
||||
|
||||
/**
|
||||
* CRUD the user data of any sub-form to another view (table)
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class UsersSubform implements GuidInterface, SubformInterface
|
||||
{
|
||||
/**
|
||||
* The Globally Unique Identifier.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
use Guid;
|
||||
|
||||
/**
|
||||
* The Items Class.
|
||||
*
|
||||
* @var Items
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected Items $items;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* The user properties
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected array $user;
|
||||
|
||||
/**
|
||||
* The current active user
|
||||
*
|
||||
* @var User
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected User $identity;
|
||||
|
||||
/**
|
||||
* The active users
|
||||
*
|
||||
* @var array
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected array $activeUsers = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Items $items The items Class.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function __construct(Items $items, ?string $table = null)
|
||||
{
|
||||
$this->items = $items;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
$this->identity = Factory::getApplication()->getIdentity();
|
||||
|
||||
// Retrieve the user properties
|
||||
$this->initializeUserProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(string $table): self
|
||||
{
|
||||
$this->table = $table;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a subform items
|
||||
*
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $field The parent field name of the subform in the parent view.
|
||||
* @param array $get The array get:set of the keys of each row in the subform.
|
||||
* @param bool $multi The switch to return a multiple set.
|
||||
*
|
||||
* @return array|null The subform
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(string $linkValue, string $linkKey, string $field, array $get, bool $multi = true): ?array
|
||||
{
|
||||
if (($items = $this->items->table($this->getTable())->get([$linkValue], $linkKey)) !== null)
|
||||
{
|
||||
return $this->converter(
|
||||
$this->getUsersDetails($items),
|
||||
$get,
|
||||
$field,
|
||||
$multi
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a subform items
|
||||
*
|
||||
* @param mixed $items The list of items from the subform to set
|
||||
* @param string $indexKey The index key on which the items should be observed as it relates to insert/update/delete.
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function set(mixed $items, string $indexKey, string $linkKey, string $linkValue): bool
|
||||
{
|
||||
$items = $this->process($items, $indexKey, $linkKey, $linkValue);
|
||||
|
||||
$this->purge($items, $indexKey, $linkKey, $linkValue);
|
||||
|
||||
if (empty($items))
|
||||
{
|
||||
return true; // nothing to set (already purged)
|
||||
}
|
||||
|
||||
return $this->items->table($this->getTable())->set(
|
||||
$items, $indexKey
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the user properties.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function initializeUserProperties(): void
|
||||
{
|
||||
$user = UserHelper::getUserById(0);
|
||||
|
||||
// Populate user properties array excluding the 'id'
|
||||
foreach (get_object_vars($user) as $property => $value)
|
||||
{
|
||||
if ($property !== 'id')
|
||||
{
|
||||
$this->user[$property] = $property;
|
||||
}
|
||||
}
|
||||
$this->user['password2'] = 'password2';
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge all items no longer in subform
|
||||
*
|
||||
* @param array $items The list of items to set.
|
||||
* @param string $indexKey The index key on which the items should be observed as it relates to insert/update/delete
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
private function purge(array $items, string $indexKey, string $linkKey, string $linkValue): void
|
||||
{
|
||||
// Get the current index values from the database
|
||||
$currentIndexValues = $this->items->table($this->getTable())->values([$linkValue], $linkKey, $indexKey);
|
||||
|
||||
if ($currentIndexValues !== null)
|
||||
{
|
||||
// Check if the items array is empty
|
||||
if (empty($items))
|
||||
{
|
||||
// Set activeIndexValues to an empty array if items is empty
|
||||
$activeIndexValues = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Extract the index values from the items array
|
||||
$activeIndexValues = array_values(array_map(function($item) use ($indexKey) {
|
||||
return $item[$indexKey] ?? null;
|
||||
}, $items));
|
||||
}
|
||||
|
||||
// Find the index values that are no longer in the items array
|
||||
$inactiveIndexValues = array_diff($currentIndexValues, $activeIndexValues);
|
||||
|
||||
// Delete the inactive index values
|
||||
if (!empty($inactiveIndexValues))
|
||||
{
|
||||
$this->items->table($this->getTable())->delete($inactiveIndexValues, $indexKey);
|
||||
|
||||
// $this->deleteUsers($inactiveIndexValues); (soon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the users details found in the user table.
|
||||
*
|
||||
* @param array $items Array of objects or arrays to be filtered.
|
||||
*
|
||||
* @return array
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getUsersDetails(array $items): array
|
||||
{
|
||||
foreach ($items as $index => &$item)
|
||||
{
|
||||
$item = (array) $item;
|
||||
$this->getUserDetails($item);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user details found in the user table.
|
||||
*
|
||||
* @param array $item The user map array
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getUserDetails(array &$item): void
|
||||
{
|
||||
// Validate the user_id and ensure it is numeric and greater than 0
|
||||
if (empty($item['user_id']) || !is_numeric($item['user_id']) || $item['user_id'] <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve the user by ID
|
||||
$user = UserHelper::getUserById((int)$item['user_id']);
|
||||
|
||||
// Verify if the user exists and the ID matches
|
||||
if ($user && $user->id === (int) $item['user_id'])
|
||||
{
|
||||
// Iterate over public properties of the user object
|
||||
foreach (get_object_vars($user) as $property => $value)
|
||||
{
|
||||
// Avoid overwriting the id in the item
|
||||
if ($property !== 'id')
|
||||
{
|
||||
$item[$property] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the specified keys from an array of objects or arrays, converts them to arrays,
|
||||
* and sets them by association with a specified key and an incrementing integer.
|
||||
*
|
||||
* @param array $items Array of objects or arrays to be filtered.
|
||||
* @param array $keySet Array of keys to retain in each item.
|
||||
* @param string $field The field prefix for the resulting associative array.
|
||||
* @param bool $multi The switch to return a multiple set.
|
||||
*
|
||||
* @return array Array of filtered arrays set by association.
|
||||
* @since 3.2.2
|
||||
*/
|
||||
private function converter(array $items, array $keySet, string $field, bool $multi): array
|
||||
{
|
||||
/**
|
||||
* Filters keys for a single item and converts it to an array.
|
||||
*
|
||||
* @param object|array $item The item to filter.
|
||||
* @param array $keySet The keys to retain.
|
||||
*
|
||||
* @return array The filtered array.
|
||||
* @since 3.2.2
|
||||
*/
|
||||
$filterKeys = function ($item, array $keySet) {
|
||||
$filteredArray = [];
|
||||
foreach ($keySet as $key) {
|
||||
if (is_object($item) && property_exists($item, $key)) {
|
||||
$filteredArray[$key] = $item->{$key};
|
||||
} elseif (is_array($item) && array_key_exists($key, $item)) {
|
||||
$filteredArray[$key] = $item[$key];
|
||||
}
|
||||
}
|
||||
return $filteredArray;
|
||||
};
|
||||
|
||||
$result = [];
|
||||
foreach ($items as $index => $item)
|
||||
{
|
||||
if (!$multi)
|
||||
{
|
||||
return $filterKeys($item, $keySet);
|
||||
}
|
||||
$filteredArray = $filterKeys($item, $keySet);
|
||||
$result[$field . $index] = $filteredArray;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an array of arrays based on the specified key.
|
||||
*
|
||||
* @param mixed $items Array of arrays to be processed.
|
||||
* @param string $indexKey The index key on which the items should be observed as it relates to insert/update/delete
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
*
|
||||
* @return array The processed array of arrays.
|
||||
* @since 3.2.2
|
||||
*/
|
||||
private function process($items, string $indexKey, string $linkKey, string $linkValue): array
|
||||
{
|
||||
$items = is_array($items) ? $items : [];
|
||||
if ($items !== [] && !$this->isMultipleSets($items))
|
||||
{
|
||||
$items = [$items];
|
||||
}
|
||||
|
||||
foreach ($items as $n => &$item)
|
||||
{
|
||||
$value = $item[$indexKey] ?? '';
|
||||
switch ($indexKey) {
|
||||
case 'guid':
|
||||
if (empty($value))
|
||||
{
|
||||
// set INDEX
|
||||
$item[$indexKey] = $this->getGuid($indexKey);
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
if (empty($value))
|
||||
{
|
||||
$item[$indexKey] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// No action for other keys if empty
|
||||
break;
|
||||
}
|
||||
|
||||
// set LINK
|
||||
$item[$linkKey] = $linkValue;
|
||||
|
||||
// create/update user
|
||||
$item['user_id'] = $this->setUserDetails(
|
||||
$item,
|
||||
$this->getActiveUsers(
|
||||
$linkKey,
|
||||
$linkValue
|
||||
)
|
||||
);
|
||||
|
||||
// remove empty row (means no user linked)
|
||||
if ($item['user_id'] == 0)
|
||||
{
|
||||
unset($items[$n]);
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current active Users Linked to this entity
|
||||
*
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $linkValue The value of the link key in child table.
|
||||
*
|
||||
* @return array The IDs of all active users.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function getActiveUsers(string $linkKey, string $linkValue): array
|
||||
{
|
||||
if (isset($this->activeUsers[$linkKey . $linkValue]))
|
||||
{
|
||||
return $this->activeUsers[$linkKey . $linkValue];
|
||||
}
|
||||
|
||||
if (($users = $this->items->table($this->getTable())->values([$linkValue], $linkKey, 'user_id')) !== null)
|
||||
{
|
||||
$this->activeUsers[$linkKey . $linkValue] = $users;
|
||||
return $users;
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles setting user details and saving them.
|
||||
*
|
||||
* This function retrieves the user by ID, sets the user details,
|
||||
* and adds appropriate user groups before saving the user.
|
||||
*
|
||||
* @param array $item The user details passed by reference.
|
||||
* @param array $activeUsers The current active user linked to this entity.
|
||||
*
|
||||
* @return int The ID of the saved user, or 0 on failure.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function setUserDetails(array &$item, array $activeUsers): int
|
||||
{
|
||||
$user = $this->loadUser($item, $activeUsers);
|
||||
$details = $this->extractUserDetails($item, $user);
|
||||
|
||||
if ($this->identity->id != $user->id)
|
||||
{
|
||||
$this->assignUserGroups($details, $user, $item);
|
||||
}
|
||||
|
||||
return $this->saveUserDetails($details, $details['id'] ?? 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the user based on the user ID from the item array.
|
||||
*
|
||||
* @param array $item The array containing user details.
|
||||
* @param array $activeUsers The current active user linked to this entity.
|
||||
*
|
||||
* @return User|null The user object if found, null otherwise.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function loadUser(array $item, array $activeUsers): ?User
|
||||
{
|
||||
if (!isset($item['user_id']) || !is_numeric($item['user_id']) || $item['user_id'] <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// only allow update to linked users
|
||||
if (!in_array($item['user_id'], $activeUsers))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = UserHelper::getUserById((int) $item['user_id']);
|
||||
|
||||
if ($user && $user->id == $item['user_id'])
|
||||
{
|
||||
return $user;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract user details from the item array and prepare them for saving.
|
||||
*
|
||||
* @param array $item The array containing user details.
|
||||
* @param User|null $user The user object if found, null otherwise.
|
||||
*
|
||||
* @return array The prepared user details array.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function extractUserDetails(array &$item, ?User $user): array
|
||||
{
|
||||
$details = [];
|
||||
|
||||
if ($user !== null)
|
||||
{
|
||||
$details['id'] = (int) $item['user_id'];
|
||||
}
|
||||
|
||||
foreach ($this->user as $property)
|
||||
{
|
||||
if (isset($item[$property]))
|
||||
{
|
||||
$details[$property] = $item[$property];
|
||||
unset($item[$property]);
|
||||
}
|
||||
}
|
||||
|
||||
return $details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns user groups based on existing groups and entity type.
|
||||
*
|
||||
* @param array &$details The array to store user details including groups.
|
||||
* @param User|null $user The user object if found, null otherwise.
|
||||
* @param array $item The array containing additional user details.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function assignUserGroups(array &$details, ?User $user, array $item): void
|
||||
{
|
||||
$groups = $user !== null ? (array) $user->groups : [];
|
||||
|
||||
if (!empty($item['entity_type']))
|
||||
{
|
||||
$global_entity_groups = Component::getParams()->get($item['entity_type'] . '_groups', []);
|
||||
foreach ($global_entity_groups as $group)
|
||||
{
|
||||
if (!in_array($group, $groups))
|
||||
{
|
||||
$groups[] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure $details['groups'] is an array if it exists, else default to an empty array
|
||||
$detailsGroups = isset($details['groups']) ? (array) $details['groups'] : [];
|
||||
|
||||
// Merge the arrays and remove duplicates
|
||||
$mergedGroups = array_unique(array_merge($detailsGroups, $groups));
|
||||
|
||||
// Only set $details['groups'] if the merged array is not empty
|
||||
if (!empty($mergedGroups))
|
||||
{
|
||||
$details['groups'] = $mergedGroups;
|
||||
}
|
||||
else
|
||||
{
|
||||
unset($details['groups']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the user details using UserHelper and handle exceptions.
|
||||
*
|
||||
* @param array $details The prepared user details array.
|
||||
* @param int $userId The ID of the user being processed.
|
||||
*
|
||||
* @return int The ID of the saved user, or 0 on failure.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function saveUserDetails(array $details, int $userId): int
|
||||
{
|
||||
try {
|
||||
return UserHelper::save($details, 0, ['useractivation' => 0, 'sendpassword' => 1, 'allowUserRegistration' => 1]);
|
||||
} catch (NoUserIdFoundException $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
|
||||
} catch (\Exception $e) {
|
||||
Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
|
||||
return $userId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to determine if the array consists of multiple data sets (arrays of arrays).
|
||||
*
|
||||
* @param array $array The input array to be checked.
|
||||
*
|
||||
* @return bool True if the array contains only arrays (multiple data sets), false otherwise.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
private function isMultipleSets(array $array): bool
|
||||
{
|
||||
foreach ($array as $element)
|
||||
{
|
||||
// As soon as we find a non-array element, return false
|
||||
if (!is_array($element))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If all elements are arrays, return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Interfaces\Data;
|
||||
|
||||
|
||||
/**
|
||||
* Globally Unique Identifier Interface
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
interface GuidInterface
|
||||
{
|
||||
/**
|
||||
* Returns a GUIDv4 string.
|
||||
*
|
||||
* This function uses the best cryptographically secure method
|
||||
* available on the platform with a fallback to an older, less secure version.
|
||||
*
|
||||
* @param string $key The key to check and modify values.
|
||||
*
|
||||
* @return string A GUIDv4 string.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getGuid(string $key): string;
|
||||
}
|
||||
|
@ -36,11 +36,12 @@ interface SubformInterface
|
||||
* @param string $linkKey The link key on which the items where linked in the child table.
|
||||
* @param string $field The parent field name of the subform in the parent view.
|
||||
* @param array $get The array SET of the keys of each row in the subform.
|
||||
* @param bool $multi The switch to return a multiple set.
|
||||
*
|
||||
* @return array|null The subform
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(string $linkValue, string $linkKey, string $field, array $get): ?array;
|
||||
public function get(string $linkValue, string $linkKey, string $field, array $get, bool $multi = true): ?array;
|
||||
|
||||
/**
|
||||
* Set a subform items
|
||||
|
@ -53,7 +53,7 @@ interface ModelInterface
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function values(?array $items = null, string $field, ?string $table = null): ?array;
|
||||
public function values(?array $items, string $field, ?string $table = null): ?array;
|
||||
|
||||
/**
|
||||
* Model the values of an item
|
||||
|
@ -21,6 +21,7 @@ use VDM\Joomla\Data\Action\Delete;
|
||||
use VDM\Joomla\Data\Item;
|
||||
use VDM\Joomla\Data\Items;
|
||||
use VDM\Joomla\Data\Subform;
|
||||
use VDM\Joomla\Data\UsersSubform;
|
||||
use VDM\Joomla\Data\MultiSubform;
|
||||
|
||||
|
||||
@ -62,6 +63,9 @@ class Data implements ServiceProviderInterface
|
||||
$container->alias(Subform::class, 'Data.Subform')
|
||||
->share('Data.Subform', [$this, 'getSubform'], true);
|
||||
|
||||
$container->alias(UsersSubform::class, 'Data.UsersSubform')
|
||||
->share('Data.UsersSubform', [$this, 'getUsersSubform'], true);
|
||||
|
||||
$container->alias(MultiSubform::class, 'Data.MultiSubform')
|
||||
->share('Data.MultiSubform', [$this, 'getMultiSubform'], true);
|
||||
}
|
||||
@ -182,6 +186,21 @@ class Data implements ServiceProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Users Subform Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UsersSubform
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getUsersSubform(Container $container): UsersSubform
|
||||
{
|
||||
return new UsersSubform(
|
||||
$container->get('Data.Items')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The MultiSubform Class.
|
||||
*
|
||||
|
@ -14,9 +14,11 @@ namespace VDM\Joomla\Utilities\Component;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
use Joomla\Input\Input;
|
||||
use Joomla\Registry\Registry;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
|
||||
/**
|
||||
@ -50,6 +52,57 @@ abstract class Helper
|
||||
*/
|
||||
protected static array $params = [];
|
||||
|
||||
/**
|
||||
* Sets a parameter value for the given target in the specified option's params.
|
||||
* If no option is provided, it falls back to the default option.
|
||||
*
|
||||
* This method updates the parameters for a given extension in the database,
|
||||
* only if the new value differs from the existing one.
|
||||
*
|
||||
* @param string $target The parameter name to be updated.
|
||||
* @param mixed $value The value to set for the parameter.
|
||||
* @param string|null $option The optional extension element name. Defaults to null, which will use the default option.
|
||||
*
|
||||
* @return mixed The previous value of the parameter before it was updated.
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function setParams(string $target, $value, ?string $option = null)
|
||||
{
|
||||
// Ensure that an option is specified, defaulting to the system's option if not provided.
|
||||
if (empty($option))
|
||||
{
|
||||
$option = static::getOption();
|
||||
}
|
||||
|
||||
// Retrieve current parameters for the specified option.
|
||||
$params = static::getParams($option);
|
||||
|
||||
// Get the current value of the target parameter.
|
||||
$was = $params->get($target, null);
|
||||
|
||||
// Only proceed if the new value differs from the current value.
|
||||
if ($was !== $value)
|
||||
{
|
||||
// Update the parameter value.
|
||||
$params->set($target, $value);
|
||||
|
||||
// Obtain a database connection instance.
|
||||
$db = Factory::getDBO();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Build and execute the query to update the parameters in the database.
|
||||
$query->update('#__extensions AS a')
|
||||
->set('a.params = ' . $db->quote((string) $params))
|
||||
->where('a.element = ' . $db->quote((string) $option));
|
||||
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
// Return the previous value of the parameter.
|
||||
return $was;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parameter object for the component
|
||||
*
|
||||
@ -64,16 +117,16 @@ abstract class Helper
|
||||
// check that we have an option
|
||||
if (empty($option))
|
||||
{
|
||||
$option = self::getOption();
|
||||
$option = static::getOption();
|
||||
}
|
||||
|
||||
// get global value
|
||||
if (!isset(self::$params[$option]) || !self::$params[$option] instanceof Registry)
|
||||
if (!isset(static::$params[$option]) || !static::$params[$option] instanceof Registry)
|
||||
{
|
||||
self::$params[$option] = ComponentHelper::getParams($option);
|
||||
static::$params[$option] = ComponentHelper::getParams($option);
|
||||
}
|
||||
|
||||
return self::$params[$option];
|
||||
return static::$params[$option];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,7 +139,7 @@ abstract class Helper
|
||||
*/
|
||||
public static function setOption(?string $option): void
|
||||
{
|
||||
self::$option = $option;
|
||||
static::$option = $option;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,13 +152,13 @@ abstract class Helper
|
||||
*/
|
||||
public static function getOption(?string $default = 'empty'): ?string
|
||||
{
|
||||
if (empty(self::$option))
|
||||
if (empty(static::$option))
|
||||
{
|
||||
// get the option from the url input
|
||||
self::$option = (new Input)->getString('option', null);
|
||||
static::$option = (new Input)->getString('option', null);
|
||||
}
|
||||
|
||||
if (empty(self::$option))
|
||||
if (empty(static::$option))
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
|
||||
@ -113,16 +166,16 @@ abstract class Helper
|
||||
if (method_exists($app, 'getInput'))
|
||||
{
|
||||
// get the option from the application
|
||||
self::$option = $app->getInput()->getCmd('option', $default);
|
||||
static::$option = $app->getInput()->getCmd('option', $default);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use the default value if getInput method does not exist
|
||||
self::$option = $default;
|
||||
static::$option = $default;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$option;
|
||||
return static::$option;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -139,7 +192,7 @@ abstract class Helper
|
||||
// check that we have an option
|
||||
if (empty($option))
|
||||
{
|
||||
$option = self::getOption();
|
||||
$option = static::getOption();
|
||||
}
|
||||
// option with com_
|
||||
if (is_string($option) && strpos($option, 'com_') === 0)
|
||||
@ -164,7 +217,7 @@ abstract class Helper
|
||||
{
|
||||
// check that we have an option
|
||||
// and get the code name from it
|
||||
if (($code_name = self::getCode($option, null)) !== null)
|
||||
if (($code_name = static::getCode($option, null)) !== null)
|
||||
{
|
||||
// we build the helper class name
|
||||
$helper_name = '\\' . \ucfirst($code_name) . 'Helper';
|
||||
@ -176,7 +229,7 @@ abstract class Helper
|
||||
}
|
||||
|
||||
// try loading namespace
|
||||
if (($namespace = self::getNamespace($option)) !== null)
|
||||
if (($namespace = static::getNamespace($option)) !== null)
|
||||
{
|
||||
$name = \ucfirst($code_name) . 'Helper';
|
||||
$namespace_helper = '\\' . $namespace . '\Administrator\Helper\\' . NamespaceHelper::safeSegment($name); // TODO target site or admin locations not just admin...
|
||||
@ -202,7 +255,7 @@ abstract class Helper
|
||||
*/
|
||||
public static function getNamespace(?string $option = null): ?string
|
||||
{
|
||||
$manifest = self::getManifest($option);
|
||||
$manifest = static::getManifest($option);
|
||||
|
||||
return $manifest->namespace ?? null;
|
||||
}
|
||||
@ -220,13 +273,13 @@ abstract class Helper
|
||||
public static function getManifest(?string $option = null): ?object
|
||||
{
|
||||
if ($option === null
|
||||
&& ($option = self::getOption($option)) === null)
|
||||
&& ($option = static::getOption($option)) === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// get global manifest_cache values
|
||||
if (!isset(self::$manifest[$option]))
|
||||
if (!isset(static::$manifest[$option]))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
@ -240,14 +293,14 @@ abstract class Helper
|
||||
|
||||
try {
|
||||
$manifest = $db->loadResult();
|
||||
self::$manifest[$option] = json_decode($manifest);
|
||||
static::$manifest[$option] = json_decode($manifest);
|
||||
} catch (\Exception $e) {
|
||||
// Handle the database error appropriately.
|
||||
self::$manifest[$option] = null;
|
||||
static::$manifest[$option] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return self::$manifest[$option];
|
||||
return static::$manifest[$option];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,7 +316,7 @@ abstract class Helper
|
||||
public static function methodExists(string $method, ?string $option = null): bool
|
||||
{
|
||||
// get the helper class
|
||||
return ($helper = self::get($option, null)) !== null &&
|
||||
return ($helper = static::get($option, null)) !== null &&
|
||||
method_exists($helper, $method);
|
||||
}
|
||||
|
||||
@ -280,7 +333,7 @@ abstract class Helper
|
||||
public static function _(string $method, array $arguments = [], ?string $option = null)
|
||||
{
|
||||
// get the helper class
|
||||
if (($helper = self::get($option, null)) !== null &&
|
||||
if (($helper = static::get($option, null)) !== null &&
|
||||
method_exists($helper, $method))
|
||||
{
|
||||
// we know this is not ideal...
|
||||
@ -291,6 +344,77 @@ abstract class Helper
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a Model object based on the specified type, prefix, and configuration.
|
||||
*
|
||||
* @param string $type The model type to instantiate. Must not be empty.
|
||||
* @param string $prefix Prefix for the model class name. Optional, defaults to 'Administrator'.
|
||||
* @param string|null $option The component option. Optional, defaults to the component's option.
|
||||
* @param array $config Configuration array for the model. Optional, defaults to an empty array.
|
||||
*
|
||||
* @return BaseDatabaseModel The instantiated model object.
|
||||
*
|
||||
* @throws \InvalidArgumentException If the $type parameter is empty.
|
||||
* @throws \Exception For other errors that may occur during model creation.
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
public static function getModel(string $type, string $prefix = 'Administrator',
|
||||
?string $option = null, array $config = []): BaseDatabaseModel
|
||||
{
|
||||
// Ensure the $type parameter is not empty
|
||||
if (empty($type))
|
||||
{
|
||||
throw new \InvalidArgumentException('The $type parameter cannot be empty when calling Component Helper getModel method.');
|
||||
}
|
||||
|
||||
// Ensure the $option parameter is set, defaulting to the component's option if not provided
|
||||
if (empty($option))
|
||||
{
|
||||
$option = static::getOption();
|
||||
}
|
||||
|
||||
// Normalize the model type name if the first character is not uppercase
|
||||
if (!ctype_upper($type[0]))
|
||||
{
|
||||
$type = StringHelper::safe($type, 'F');
|
||||
}
|
||||
|
||||
// Normalize the prefix if it's not 'Site' or 'Administrator'
|
||||
if ($prefix !== 'Site' && $prefix !== 'Administrator')
|
||||
{
|
||||
$prefix = static::getPrefixFromModelPath($prefix);
|
||||
}
|
||||
|
||||
// Instantiate and return the model using the MVCFactory
|
||||
return Factory::getApplication()
|
||||
->bootComponent($option)
|
||||
->getMVCFactory()
|
||||
->createModel($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the prefix from the model path
|
||||
*
|
||||
* @param string $path The model path
|
||||
*
|
||||
* @return string The prefix value
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private static function getPrefixFromModelPath(string $path): string
|
||||
{
|
||||
// Check if $path starts with JPATH_ADMINISTRATOR path
|
||||
if (str_starts_with($path, JPATH_ADMINISTRATOR . '/components/'))
|
||||
{
|
||||
return 'Administrator';
|
||||
}
|
||||
// Check if $path starts with JPATH_SITE path
|
||||
elseif (str_starts_with($path, JPATH_SITE . '/components/'))
|
||||
{
|
||||
return 'Site';
|
||||
}
|
||||
return 'Administrator';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10001,7 +10001,7 @@ class Com_ComponentbuilderInstallerScript
|
||||
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
|
||||
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
|
||||
</a>
|
||||
<h3>Upgrade to Version 3.2.4-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
||||
<h3>Upgrade to Version 3.2.4-alpha4 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
||||
|
||||
// Set db if not set already.
|
||||
if (!isset($db))
|
||||
|
@ -5413,7 +5413,6 @@ abstract class ComponentbuilderHelper
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The subform layouts
|
||||
|
@ -10,6 +10,7 @@ COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully"
|
||||
COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE="Be cautious! Do not continue unless you trust the origin of this package!"
|
||||
COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_SSA="<b>Get the key from</b> <a %s>%s</a>"
|
||||
COM_COMPONENTBUILDER_BGET_THE_KEY_FROM_SB_FOR_A_SSA="<b>Get the key from %s</b> for <a %s>%s</a>"
|
||||
COM_COMPONENTBUILDER_CAN_NOT_SAVE_USER_WITHOUT_EMAIL_VALUE="Can not save user without email value."
|
||||
COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there."
|
||||
COM_COMPONENTBUILDER_CODESTRINGS="code/strings"
|
||||
COM_COMPONENTBUILDER_COMPANY_S="Company: %s"
|
||||
@ -157,6 +158,9 @@ COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key."
|
||||
COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the <b>JCB Global Options</b>, go to the <b>Company</b> tab and add the correct company details there."
|
||||
COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there."
|
||||
COM_COMPONENTBUILDER_TRANSLATOR_MODULE_NOT_READYBR_THIS_AREA_IS_STILL_UNDER_PRODUCTION_HOPEFULLY_WITH_NEXT_UPDATE="Translator Module not ready!<br />This area is still under production, hopefully with next update."
|
||||
COM_COMPONENTBUILDER_UPDATE_OF_USER_S_S_FAILEDS="Update of user %s (%s) failed!%s"
|
||||
COM_COMPONENTBUILDER_USER_CREATION_FAILED="User creation failed!"
|
||||
COM_COMPONENTBUILDER_USER_S_S_CREATION_FAILEDS="User %s (%s) creation failed!%s"
|
||||
COM_COMPONENTBUILDER_VJRZDESSMHBTRWFIFTYTWVZEROAESFLVVXJTMTHREEJTWOIXM="VjRzdE%ssMHBtRW50TWV0aE%sFlvVXJTM3J2IXM="
|
||||
COM_COMPONENTBUILDER_WEBSITE_S="Website: %s"
|
||||
COM_COMPONENTBUILDER_WE_FOUND_DYNAMIC_CODE_BALL_IN_ONE_LINEB_AND_IGNORED_IT_PLEASE_REVIEW_S_FOR_MORE_DETAILS="We found dynamic code <b>all in one line</b>, and ignored it! Please review (%s) for more details!"
|
||||
|
Reference in New Issue
Block a user