fixed mismatch on field import of JCB packages

This commit is contained in:
Llewellyn van der Merwe 2018-06-13 22:38:32 +02:00
parent 2ca5419106
commit 8402051a94
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
6 changed files with 118 additions and 21 deletions

View File

@ -125,11 +125,11 @@ 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*: 12th June, 2018
+ *Last Build*: 13th 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
+ *Line count*: **185647**
+ *Line count*: **185744**
+ *Field count*: **1054**
+ *File count*: **1236**
+ *Folder count*: **197**
@ -140,6 +140,6 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
## Donations
Come on buy VDM a coffee :)
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief)
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief) (Asseblief = Please) in Afrikaans
* Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf
* Ethereum: 0x9548144662b47327c954f3e214edb96662d51218

View File

@ -125,11 +125,11 @@ 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*: 12th June, 2018
+ *Last Build*: 13th 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
+ *Line count*: **185647**
+ *Line count*: **185744**
+ *Field count*: **1054**
+ *File count*: **1236**
+ *Folder count*: **197**
@ -140,6 +140,6 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo
## Donations
Come on buy VDM a coffee :)
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief)
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief) (Asseblief = Please) in Afrikaans
* Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf
* Ethereum: 0x9548144662b47327c954f3e214edb96662d51218

View File

@ -1020,6 +1020,7 @@ COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE
COM_COMPONENTBUILDER_BACKUP_LOCAL_DATA_FIRST="Backup Local Data First"
COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully"
COM_COMPONENTBUILDER_BACK_TO_LIBRARIES="Back to Libraries"
COM_COMPONENTBUILDER_BADMIN_FIELDS_RELATIONSB_IDS_MISMATCH_IN_BFIELDSB_AND_WAS_NOT_UPDATED_IN_THE_CUSTOM_CODE="<b>Admin fields relations</b> id:%s mismatch in <b>field:%s</b>, and was not updated in the custom code."
COM_COMPONENTBUILDER_BASIC_TUTORIAL_ON_GIT_BSB="Basic Tutorial on git: <b>%s</b>"
COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_THIS_PACKAGE_BFAILEDB_CHECKSUM_VALIDATION_THIS_COULD_BE_A_SERIOUS_SECURITY_BREACH_DO_NOT_CONTINUE="<b>Best to not continue!</b><br />This package <b>FAILED</b> checksum validation, this could be a serious security breach! DO NOT CONTINUE!!!"
COM_COMPONENTBUILDER_BBEST_TO_NOT_CONTINUEBBR_WE_COULD_NOT_LOAD_THE_CHECKSUM_FOR_THIS_PACKAGE_AND_SO_NO_VALIDATION_WAS_POSSIBLE_THIS_MAY_BE_DUE_TO_YOUR_NETWORK_OR_A_CHANGE_TO_THAT_PACKAGE_NAME="<b>Best to not continue!</b><br />We could not load the checksum for this package, and so no validation was possible. This may be due to your network, or a change to that package name."
@ -4707,7 +4708,7 @@ Project duration: **###projectWeekTime### weeks** or **###projectMonthTime### mo
## Donations<br />
<br />
If you want to support this project, please consider donating:<br />
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief)<br />
* PayPal: [paypal.me/asseblief](https://www.paypal.me/asseblief) (Asseblief = Please) in Afrikaans<br />
* Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf<br />
* Ethereum: 0x9548144662b47327c954f3e214edb96662d51218
</code></div>"

View File

@ -1007,8 +1007,8 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
**/
public function updateAfterAll()
{
// update the fields
if (ComponentbuilderHelper::checkArray($this->updateAfter['field']))
// update the fields
if (isset($this->updateAfter['field']) && ComponentbuilderHelper::checkArray($this->updateAfter['field']))
{
// update repeatable
foreach ($this->updateAfter['field'] as $field)
@ -1070,7 +1070,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
}
// do a after all run on admin views that need it
if (ComponentbuilderHelper::checkArray($this->updateAfter['adminview']))
if (isset($this->updateAfter['adminview']) && ComponentbuilderHelper::checkArray($this->updateAfter['adminview']))
{
// update the addlinked_views
foreach ($this->updateAfter['adminview'] as $adminview)
@ -1107,7 +1107,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
}
// update the joomla_component dashboard
if (ComponentbuilderHelper::checkArray($this->updateAfter['joomla_component']))
if (isset($this->updateAfter['joomla_component']) && ComponentbuilderHelper::checkArray($this->updateAfter['joomla_component']))
{
// update dashboard of the components
foreach ($this->updateAfter['joomla_component'] as $component)
@ -1155,6 +1155,87 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
}
}
// update the admin_fields_relations
if (isset($this->updateAfter['relations']) && ComponentbuilderHelper::checkArray($this->updateAfter['relations']))
{
// update repeatable
foreach ($this->updateAfter['relations'] as $relation)
{
// check if we must update this relation
$update = false;
if (isset($this->newID['admin_fields_relations'][$relation]))
{
$relation = $this->newID['admin_fields_relations'][$relation];
}
// get the set relation from db
if ($addrelations = ComponentbuilderHelper::getVar('admin_fields_relations', $relation, 'id', 'addrelations'))
{
if (ComponentbuilderHelper::checkJson($addrelations))
{
$addrelations = json_decode($addrelations, true);
if (ComponentbuilderHelper::checkArray($addrelations))
{
foreach ($addrelations as $nr => &$value)
{
// reset the buckets
$bucket = array();
// get fields
$found = ComponentbuilderHelper::getAllBetween($value['set'], '[field=', ']');
// if found
if (ComponentbuilderHelper::checkArray($found))
{
$bucket[] = $found;
}
// get fields
$found = ComponentbuilderHelper::getAllBetween($value['set'], '$item->{', '}');
// if found
if (ComponentbuilderHelper::checkArray($found))
{
$bucket[] = $found;
}
// check if we have values
if (ComponentbuilderHelper::checkArray($bucket))
{
$fields = ComponentbuilderHelper::mergeArrays($bucket);
// reset the buckets
$bucket = array();
if (ComponentbuilderHelper::checkArray($fields))
{
foreach ($fields as $field)
{
if (isset($this->newID['field'][(int) $field]))
{
$bucket['[field=' . (int) $field . ']'] = '[field=' . (int) $this->newID['field'][(int) $field] . ']';
$bucket['$item->{' . (int) $field . '}'] = '$item->{' . (int) $this->newID['field'][(int) $field] . '}';
}
else
{
$this->app->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_BADMIN_FIELDS_RELATIONSB_IDS_MISMATCH_IN_BFIELDSB_AND_WAS_NOT_UPDATED_IN_THE_CUSTOM_CODE', $relation, $field), 'warning');
}
}
// check if we have a bucket of values to update
if (ComponentbuilderHelper::checkArray($bucket))
{
$value['set'] = str_replace(array_keys($bucket), array_values($bucket), $value['set']);
$update = true;
}
}
}
}
// update only if needed
if ($update)
{
$object = new stdClass;
$object->id = $relation;
$object->addrelations = json_encode($addrelations, JSON_FORCE_OBJECT);
// update the field
$this->_db->updateObject('#__componentbuilder_admin_fields_relations', $object, 'id');
}
}
}
}
}
}
}
/**
@ -2111,7 +2192,9 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$updaterT = array(
// subformfield => field => type_value
'addrelations' => array('listfield' => 'field', 'joinfields' => 'field')
);
);
// special fix for custom code
$this->updateAfter['relations'][$item->id] = $item->id; // addrelations->set
}
// update the repeatable fields
@ -2369,12 +2452,15 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// load the created and id
$query->where($this->_db->quoteName('a.created') . ' = '. $this->_db->quote($item->created));
$query->where($this->_db->quoteName('a.id') .' = '. (int) $item->id);
// set to run query
$runQuery = true;
}
elseif (componentbuilderHelper::checkArray($get))
{
foreach ($get as $field)
{
// set to run query
$runQuery = true;
if (isset($item->{$field}))
{
// set the value
@ -2399,18 +2485,21 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
else
{
return false;
// do not run query
$runQuery = false;
}
$runQuery = true;
}
else
{
return false;
// do not run query
$runQuery = false;
}
}
}
elseif (isset($item->{$get}))
{
// set to run query
$runQuery = true;
// set the value
$value = $item->{$get};
// check if we have special value
@ -2433,9 +2522,8 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
}
else
{
return false; // really not needed but who knows for sure...
$runQuery = false; // really not needed but who knows for sure...
}
$runQuery = true;
}
// since where has been set run the query
if ($runQuery)
@ -2486,12 +2574,18 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// get by name and xml to target correct field
if ($retry == 2)
{
// get by id name..
// get by name + xml...
$getter = array('name','datatype','store','indexes','null_switch','xml');
$retryAgain = 3;
}
elseif ($retry == 3)
{
// get by name + created...
$getter = array('name','datatype','created');
}
else
{
// get by id name..
// get by name + xml or type..
$getter = array('name','datatype','store','indexes','null_switch');
// lets try to add the fieldtype
if (isset($item->fieldtype) && is_numeric($item->fieldtype) && $item->fieldtype > 0 && isset($this->newID['fieldtype'][(int) $item->fieldtype]) && $this->newID['fieldtype'][(int) $item->fieldtype] > 0)
@ -2504,6 +2598,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
else
{
$getter[] = 'xml';
$retryAgain = 3;
}
}
break;

View File

@ -1678,7 +1678,8 @@ INSERT INTO `#__componentbuilder_admin_fields_relations` (`id`, `addrelations`,
(1, '', 14, 1, '2018-05-22 01:20:34', '2018-05-23 03:37:27', 9, '', 1),
(2, '', 22, 1, '2018-05-23 03:38:52', '2018-05-26 07:37:25', 18, '', 2),
(3, '', 13, 1, '2018-05-24 17:04:40', '2018-05-24 17:12:52', 4, '', 3),
(4, '{\"addrelations0\":{\"listfield\":\"913\",\"column_name\":\"Preacher Details\",\"joinfields\":[\"691\"],\"area\":\"2\",\"join_type\":\"1\",\"set\":\"<br \\/>\"}}', 54, 1, '2018-05-28 07:00:41', '2018-05-28 09:45:25', 7, '', 4);
(4, '{\"addrelations0\":{\"listfield\":\"913\",\"column_name\":\"Preacher Details\",\"joinfields\":[\"691\"],\"area\":\"2\",\"join_type\":\"1\",\"set\":\"<br \\/>\"}}', 54, 1, '2018-05-28 07:00:41', '2018-05-28 09:45:25', 7, '', 4),
(5, '{\"addrelations0\":{\"listfield\":\"2209\",\"column_name\":\"Member\",\"joinfields\":[\"1004\",\"1207\",\"1302\",\"1005\",\"280\"],\"area\":\"2\",\"join_type\":\"2\",\"set\":\"[field=2209]\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{1005})): ?>\\r\\n<br \\/>\\r\\n[field=1005]\\r\\n<?php endif; ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{1004})): ?>\\r\\n<br \\/>\\r\\n[field=1004]\\r\\n<?php endif; ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{1302})): ?>\\r\\n<br \\/>\\r\\n[field=1302]\\r\\n<?php endif; ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{1207})): ?>\\r\\n<br \\/>\\r\\n[field=1207]\\r\\n<?php endif; ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{280})): ?>\\r\\n<br \\/>\\r\\n[field=280]\\r\\n<?php endif; ?>\"},\"addrelations1\":{\"listfield\":\"608\",\"column_name\":\"Phone\",\"joinfields\":[\"1160\"],\"area\":\"2\",\"join_type\":\"2\",\"set\":\"<?php if ([[[Component]]]Helper::checkString($item->{608})): ?>\\r\\n[field=608]\\r\\n<?php endif; ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{1160})): ?>\\r\\n<?php if ([[[Component]]]Helper::checkString($item->{608})): ?><br \\/><?php endif; ?>\\r\\n[field=1160]\\r\\n<?php endif; ?>\"}}', 177, 1, '2018-06-12 21:23:39', '0000-00-00 00:00:00', 1, '', 5);
--
-- Dumping data for table `#__componentbuilder_component_admin_views`

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name>
<creationDate>12th June, 2018</creationDate>
<creationDate>13th June, 2018</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>