From 0c7d7265dd1cebd1aa9089f979e0acd2269673e7 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Fri, 15 Jun 2018 15:31:23 +0200 Subject: [PATCH] Improved the table detection in the mapping of the extrusion class when building table/fields from mysql dump --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/e_Interpretation.php | 5 +++ admin/helpers/extrusion/a_mapping.php | 36 +++++++++++++-------- componentbuilder.xml | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7c6908575..74409efb7 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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*: 13th June, 2018 ++ *Last Build*: 15th June, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/README.txt b/admin/README.txt index 7c6908575..74409efb7 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,7 +125,7 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *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*: 13th June, 2018 ++ *Last Build*: 15th June, 2018 + *Version*: 2.8.0 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d406960a1..253a15e7d 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1417,6 +1417,11 @@ class Interpretation extends Fields $method[] = $this->_t(3) . "'password1' => \$password, // First password field"; $method[] = $this->_t(3) . "'password2' => \$password2, // Confirm password field"; $method[] = $this->_t(3) . "'block' => 0 );"; + $method[] = $this->_t(2) . "// set groups if found"; + $method[] = $this->_t(2) . "if (isset(\$new['groups']) && self::checkArray(\$new['groups']))"; + $method[] = $this->_t(2) . "{"; + $method[] = $this->_t(3) . "\$data['groups'] = \$new['groups'];"; + $method[] = $this->_t(2) . "}"; $method[] = $this->_t(2) . "// register the new user"; $method[] = $this->_t(2) . "\$done = \$model->save(\$data);"; $method[] = $this->_t(2) . "// if user is updated"; diff --git a/admin/helpers/extrusion/a_mapping.php b/admin/helpers/extrusion/a_mapping.php index 2dd0e3608..4305d1bb4 100644 --- a/admin/helpers/extrusion/a_mapping.php +++ b/admin/helpers/extrusion/a_mapping.php @@ -101,7 +101,7 @@ class Mapping { // set the app to insure messages can be set $this->app = JFactory::getApplication(); - + if (ComponentbuilderHelper::checkArray($data)) { if (isset($data['buildcomp']) && 1 == $data['buildcomp'] && isset($data['buildcompsql'])) @@ -155,7 +155,7 @@ class Mapping ); return false; } - + /** * The mapping function * To Map the views and fields that are needed @@ -169,7 +169,8 @@ class Mapping foreach ($queries as $query) { // only use create table queries - if (strpos($query, 'CREATE TABLE IF NOT EXISTS `') !== false) + if (strpos($query, 'CREATE TABLE IF NOT EXISTS') !== false || + strpos($query, 'CREATE TABLE') !== false) { if ($tableName = $this->getTableName($query)) { @@ -205,15 +206,24 @@ class Mapping } return false; } - + /** * Get the table name */ protected function getTableName(&$query) { - $tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`"); + if (strpos($query, '`#__') !== false) + { + // get table name + $tableName = ComponentbuilderHelper::getBetween($query, '`#__', "`"); + } + elseif (strpos($query, "'#__") !== false) + { + // get table name + $tableName = ComponentbuilderHelper::getBetween($query, "'#__", "'"); + } // if it still was not found - if (!ComponentbuilderHelper::checkString($tableName)) + if (!isset($tableName) || !ComponentbuilderHelper::checkString($tableName)) { // skip this query return false; @@ -231,13 +241,13 @@ class Mapping // skip this query return false; } - + /** * Get the field details */ protected function getFields(&$query) { - $rows = array_map('trim', explode("\n", $query)); + $rows = array_map('trim', explode(PHP_EOL, $query)); $fields = array(); foreach ($rows as $row) { @@ -306,7 +316,7 @@ class Mapping } return false; } - + /** * Get the field types */ @@ -325,7 +335,7 @@ class Mapping } return false; } - + /** * Get the field size */ @@ -337,7 +347,7 @@ class Mapping } return ''; } - + /** * Get the field default */ @@ -355,7 +365,7 @@ class Mapping } return ''; } - + /** * Get the field Null Value */ @@ -373,7 +383,7 @@ class Mapping } return 'NULL'; } - + /** * Get the field key status */ diff --git a/componentbuilder.xml b/componentbuilder.xml index 0dcb0371d..fdb8bcb3d 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 13th June, 2018 + 15th June, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com