From 25afc31e7f2d2ba73ec5e90525663676f0116671 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 11 Jul 2020 02:51:45 +0200 Subject: [PATCH] fixed greateUser logic to use the admin and site creation modes in correct way. Fixed language import issue that cause header mismatching. Added the option to add header values to the custom-custom fields. --- README.md | 4 +-- admin/README.txt | 4 +-- admin/helpers/compiler/e_Interpretation.php | 30 +++++++++---------- admin/helpers/componentbuilder.php | 12 ++++++-- admin/models/import.php | 10 ++++++- admin/models/import_language_translations.php | 16 ++++++++-- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 12 ++++++-- 8 files changed, 63 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index f80f39c77..a6ac9c86c 100644 --- a/README.md +++ b/README.md @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 7th July, 2020 ++ *Last Build*: 11th July, 2020 + *Version*: 2.11.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **282473** ++ *Line count*: **282509** + *Field count*: **1522** + *File count*: **1785** + *Folder count*: **295** diff --git a/admin/README.txt b/admin/README.txt index f80f39c77..a6ac9c86c 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -144,11 +144,11 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 7th July, 2020 ++ *Last Build*: 11th July, 2020 + *Version*: 2.11.2 + *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **282473** ++ *Line count*: **282509** + *Field count*: **1522** + *File count*: **1785** + *Folder count*: **295** diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index f477e7df1..caf861940 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1876,20 +1876,22 @@ class Interpretation extends Fields . "\$lang->load(\$extension, \$base_dir, \$language_tag, \$reload);"; $method[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Load the correct user model."; - $method[] = $this->_t(2) . "if (\$mode == 1)"; - $method[] = $this->_t(2) . "{"; - $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) - . " Load the backend-user model"; - $method[] = $this->_t(3) - . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');"; - $method[] = $this->_t(2) . "}"; - $method[] = $this->_t(2) . "else"; + $method[] = $this->_t(2) . "if (\$mode == 1) //" . $this->setLine(__LINE__) + . " 1 = Site Registrations"; $method[] = $this->_t(2) . "{"; $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Load the user site-registration model"; $method[] = $this->_t(3) . "\$model = self::getModel('registration', JPATH_ROOT. '/components/com_users', 'Users');"; $method[] = $this->_t(2) . "}"; + $method[] = $this->_t(2) . "else //" . $this->setLine(__LINE__) + . " 0 = Admin Registration"; + $method[] = $this->_t(2) . "{"; + $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) + . " Load the backend-user model"; + $method[] = $this->_t(3) + . "\$model = self::getModel('user', JPATH_ADMINISTRATOR . '/components/com_users', 'Users');"; + $method[] = $this->_t(2) . "}"; $method[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Check if we have params/config"; $method[] = $this->_t(2) . "if (self::checkArray(\$params))"; @@ -1921,16 +1923,14 @@ class Interpretation extends Fields $method[] = $this->_t(3) . "'block' => 0 );"; $method[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Added details based on mode"; - $method[] = $this->_t(2) . "if (\$mode == 1)"; + $method[] = $this->_t(2) . "if (\$mode == 1) //". $this->setLine(__LINE__) + . " 1 = Site-registration mode"; $method[] = $this->_t(2) . "{"; - $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) - . " Site-registration mode"; $method[] = $this->_t(3) . "\$data['email1'] = \$credentials['email'];"; $method[] = $this->_t(2) . "}"; - $method[] = $this->_t(2) . "else"; + $method[] = $this->_t(2) . "else //" . $this->setLine(__LINE__) + . " 0 = Admin-registration mode"; $method[] = $this->_t(2) . "{"; - $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) - . " Admin-registration mode"; $method[] = $this->_t(3) . "\$data['email'] = \$credentials['email'];"; $method[] = $this->_t(3) . "\$data['registerDate'] = JFactory::getDate()->toSql();"; $method[] = $this->_t(2) . "}"; @@ -1943,7 +1943,7 @@ class Interpretation extends Fields $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set random password when empty password was submitted,"; $method[] = $this->_t(3) . "//" . $this->setLine(__LINE__) - . " and we are using the site-registration mode"; + . " when using the 1 = site-registration mode"; $method[] = $this->_t(3) . "\$credentials['password'] = self::randomkey(8);"; $method[] = $this->_t(3) . "\$credentials['password2'] = \$credentials['password'];"; $method[] = $this->_t(2) . "}"; diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 0454e54b1..171b27dbd 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -57,7 +57,7 @@ abstract class ComponentbuilderHelper /** * Array of php fields Allowed (16) **/ - public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x'); + public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER'); /** * The global params @@ -2965,7 +2965,15 @@ abstract class ComponentbuilderHelper $script['setdata'][] = self::_t(3) . "\$jinput = JFactory::getApplication()->input;"; $script['setdata'][] = self::_t(3) . "foreach(\$target_headers as \$header)"; $script['setdata'][] = self::_t(3) . "{"; - $script['setdata'][] = self::_t(4) . "\$data['target_headers'][\$header] = \$jinput->getString(\$header, null);"; + $script['setdata'][] = self::_t(4) . "if ((\$column = \$jinput->getString(\$header, false)) !== false ||"; + $script['setdata'][] = self::_t(5) . "(\$column = \$jinput->getString(strtolower(\$header), false)) !== false)"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = \$column;"; + $script['setdata'][] = self::_t(4) . "}"; + $script['setdata'][] = self::_t(4) . "else"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = null;"; + $script['setdata'][] = self::_t(4) . "}"; $script['setdata'][] = self::_t(3) . "}"; $script['setdata'][] = self::_t(3) . "// set the data"; $script['setdata'][] = self::_t(3) . "if(isset(\$package['dir']))"; diff --git a/admin/models/import.php b/admin/models/import.php index 71b78bc15..fb6e19c80 100644 --- a/admin/models/import.php +++ b/admin/models/import.php @@ -426,7 +426,15 @@ class ComponentbuilderModelImport extends JModelLegacy $jinput = JFactory::getApplication()->input; foreach($target_headers as $header) { - $data['target_headers'][$header] = $jinput->getString($header, null); + if (($column = $jinput->getString($header, false)) !== false || + ($column = $jinput->getString(strtolower($header), false)) !== false) + { + $data['target_headers'][$header] = $column; + } + else + { + $data['target_headers'][$header] = null; + } } // set the data if(isset($package['dir'])) diff --git a/admin/models/import_language_translations.php b/admin/models/import_language_translations.php index 9f36e3076..90dfb4e63 100644 --- a/admin/models/import_language_translations.php +++ b/admin/models/import_language_translations.php @@ -424,7 +424,15 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy $jinput = JFactory::getApplication()->input; foreach($target_headers as $header) { - $data['target_headers'][$header] = $jinput->getString(strtolower($header), null); + if (($column = $jinput->getString($header, false)) !== false || + ($column = $jinput->getString(strtolower($header), false)) !== false) + { + $data['target_headers'][$header] = $column; + } + else + { + $data['target_headers'][$header] = null; + } } // set the data if(isset($package['dir'])) @@ -463,10 +471,14 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy { $source_key = $data['target_headers']['Source']; } - else + elseif (isset($data['target_headers']['English'])) { $source_key = $data['target_headers']['English']; } + else + { + $source_key = null; + } // get the first array set $firstSet = reset($data['array']); // check if first array is a header array and remove if true diff --git a/componentbuilder.xml b/componentbuilder.xml index 39bd367af..bd08cb429 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 7th July, 2020 + 11th July, 2020 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 81594fcb7..30406c90c 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -54,7 +54,7 @@ abstract class ComponentbuilderHelper /** * Array of php fields Allowed (16) **/ - public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x'); + public static $phpFieldArray = array('', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'x', 'HEADER'); /** * The global params @@ -2962,7 +2962,15 @@ abstract class ComponentbuilderHelper $script['setdata'][] = self::_t(3) . "\$jinput = JFactory::getApplication()->input;"; $script['setdata'][] = self::_t(3) . "foreach(\$target_headers as \$header)"; $script['setdata'][] = self::_t(3) . "{"; - $script['setdata'][] = self::_t(4) . "\$data['target_headers'][\$header] = \$jinput->getString(\$header, null);"; + $script['setdata'][] = self::_t(4) . "if ((\$column = \$jinput->getString(\$header, false)) !== false ||"; + $script['setdata'][] = self::_t(5) . "(\$column = \$jinput->getString(strtolower(\$header), false)) !== false)"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = \$column;"; + $script['setdata'][] = self::_t(4) . "}"; + $script['setdata'][] = self::_t(4) . "else"; + $script['setdata'][] = self::_t(4) . "{"; + $script['setdata'][] = self::_t(5) . "\$data['target_headers'][\$header] = null;"; + $script['setdata'][] = self::_t(4) . "}"; $script['setdata'][] = self::_t(3) . "}"; $script['setdata'][] = self::_t(3) . "// set the data"; $script['setdata'][] = self::_t(3) . "if(isset(\$package['dir']))";