From 04ed58afe81eab060cb1d71738e5a531bf2e0ccd Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 15 Aug 2019 16:26:46 +0200 Subject: [PATCH] Fixed gh-458 so that the && is not added if we have no extra values to validate. Added linked to details to Joomla Plugin area. --- README.md | 4 +-- admin/README.txt | 4 +-- admin/controllers/ajax.json.php | 34 ++++++++++----------- admin/helpers/compiler/a_Get.php | 4 +-- admin/helpers/compiler/e_Interpretation.php | 22 ++++--------- admin/models/ajax.php | 8 +++-- admin/models/joomla_components.php | 2 +- componentbuilder.xml | 2 +- 8 files changed, 37 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index b2a1ea926..cc093056d 100644 --- a/README.md +++ b/README.md @@ -146,11 +146,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*: 14th August, 2019 ++ *Last Build*: 15th August, 2019 + *Version*: 2.10.0 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **246448** ++ *Line count*: **246452** + *Field count*: **1319** + *File count*: **1595** + *Folder count*: **244** diff --git a/admin/README.txt b/admin/README.txt index b2a1ea926..cc093056d 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -146,11 +146,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*: 14th August, 2019 ++ *Last Build*: 15th August, 2019 + *Version*: 2.10.0 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **246448** ++ *Line count*: **246452** + *Field count*: **1319** + *File count*: **1595** + *Folder count*: **244** diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php index 69a27a482..38bcd82dd 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/controllers/ajax.json.php @@ -271,7 +271,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $identifierValue = $jinput->get('identifier', NULL, 'CMD'); $keyValue = $jinput->get('key', NULL, 'ALNUM'); - if($identifierValue && $keyValue && $user->id != 0) + if($identifierValue && $user->id != 0 && $keyValue) { $result = $this->getModel('ajax')->getCrowdinDetails($identifierValue, $keyValue); } @@ -310,7 +310,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $idValue = $jinput->get('id', NULL, 'INT'); $typeValue = $jinput->get('type', NULL, 'WORD'); - if($idValue && $typeValue && $user->id != 0) + if($idValue && $user->id != 0 && $typeValue) { $result = $this->getModel('ajax')->getClassCode($idValue, $typeValue); } @@ -349,7 +349,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $idValue = $jinput->get('id', NULL, 'INT'); $typeValue = $jinput->get('type', NULL, 'WORD'); - if($idValue && $typeValue && $user->id != 0) + if($idValue && $user->id != 0 && $typeValue) { $result = $this->getModel('ajax')->getClassCodeIds($idValue, $typeValue); } @@ -388,7 +388,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $idValue = $jinput->get('id', NULL, 'INT'); $typeValue = $jinput->get('type', NULL, 'WORD'); - if($idValue && $typeValue && $user->id != 0) + if($idValue && $user->id != 0 && $typeValue) { $result = $this->getModel('ajax')->getClassHeaderCode($idValue, $typeValue); } @@ -541,7 +541,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $typeValue = $jinput->get('type', NULL, 'WORD'); $sizeValue = $jinput->get('size', NULL, 'INT'); - if($typeValue && $sizeValue && $user->id != 0) + if($typeValue && $user->id != 0 && $sizeValue) { $result = $this->getModel('ajax')->getButton($typeValue, $sizeValue); } @@ -580,7 +580,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $typeValue = $jinput->get('type', NULL, 'WORD'); $sizeValue = $jinput->get('size', NULL, 'INT'); - if($typeValue && $sizeValue && $user->id != 0) + if($typeValue && $user->id != 0 && $sizeValue) { $result = $this->getModel('ajax')->getButtonID($typeValue, $sizeValue); } @@ -810,7 +810,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $nameValue = $jinput->get('name', NULL, 'WORD'); $asValue = $jinput->get('as', NULL, 'WORD'); $typeValue = $jinput->get('type', NULL, 'INT'); - if($nameValue && $asValue && $typeValue && $user->id != 0) + if($nameValue && $user->id != 0 && $asValue && $typeValue) { $result = $this->getModel('ajax')->getDbTableColumns($nameValue, $asValue, $typeValue); } @@ -850,7 +850,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $idValue = $jinput->get('id', NULL, 'INT'); $asValue = $jinput->get('as', NULL, 'WORD'); $typeValue = $jinput->get('type', NULL, 'INT'); - if($idValue && $asValue && $typeValue && $user->id != 0) + if($idValue && $user->id != 0 && $asValue && $typeValue) { $result = $this->getModel('ajax')->getViewTableColumns($idValue, $asValue, $typeValue); } @@ -889,7 +889,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $idValue = $jinput->get('id', NULL, 'INT'); $viewValue = $jinput->get('view', NULL, 'WORD'); - if($idValue && $viewValue && $user->id != 0) + if($idValue && $user->id != 0 && $viewValue) { $result = $this->getModel('ajax')->getDynamicValues($idValue, $viewValue); } @@ -928,7 +928,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $functioNameValue = $jinput->get('functioName', NULL, 'STRING'); $idValue = $jinput->get('id', NULL, 'INT'); - if($functioNameValue && $idValue && $user->id != 0) + if($functioNameValue && $user->id != 0 && $idValue) { $result = $this->getModel('ajax')->checkFunctionName($functioNameValue, $idValue); } @@ -968,7 +968,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $functioNameValue = $jinput->get('functioName', NULL, 'WORD'); $idValue = $jinput->get('id', NULL, 'INT'); $targetValue = $jinput->get('target', NULL, 'WORD'); - if($functioNameValue && $idValue && $targetValue && $user->id != 0) + if($functioNameValue && $user->id != 0 && $idValue && $targetValue) { $result = $this->getModel('ajax')->usedin($functioNameValue, $idValue, $targetValue); } @@ -1046,7 +1046,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $placeholderValue = $jinput->get('placeholder', NULL, 'WORD'); $idValue = $jinput->get('id', NULL, 'INT'); $targetValue = $jinput->get('target', NULL, 'WORD'); - if($placeholderValue && $idValue && $targetValue && $user->id != 0) + if($placeholderValue && $user->id != 0 && $idValue && $targetValue) { $result = $this->getModel('ajax')->placedin($placeholderValue, $idValue, $targetValue); } @@ -1085,7 +1085,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $idValue = $jinput->get('id', NULL, 'INT'); $placeholderNameValue = $jinput->get('placeholderName', NULL, 'STRING'); - if($idValue && $placeholderNameValue && $user->id != 0) + if($idValue && $user->id != 0 && $placeholderNameValue) { $result = $this->getModel('ajax')->checkPlaceholderName($idValue, $placeholderNameValue); } @@ -1200,7 +1200,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $nameValue = $jinput->get('name', NULL, 'STRING'); $idValue = $jinput->get('id', NULL, 'INT'); - if($nameValue && $idValue && $user->id != 0) + if($nameValue && $user->id != 0 && $idValue) { $result = $this->getModel('ajax')->checkRuleName($nameValue, $idValue); } @@ -1277,7 +1277,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $propertyValue = $jinput->get('property', NULL, 'WORD'); $fieldtypeValue = $jinput->get('fieldtype', NULL, 'ALNUM'); - if($propertyValue && $fieldtypeValue && $user->id != 0) + if($propertyValue && $user->id != 0 && $fieldtypeValue) { $result = $this->getModel('ajax')->getFieldPropertyDesc($propertyValue, $fieldtypeValue); } @@ -1318,7 +1318,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $joinfieldsValue = $jinput->get('joinfields', NULL, 'STRING'); $typeValue = $jinput->get('type', NULL, 'INT'); $areaValue = $jinput->get('area', NULL, 'INT'); - if($listfieldValue && $joinfieldsValue && $typeValue && $areaValue && $user->id != 0) + if($listfieldValue && $user->id != 0 && $joinfieldsValue && $typeValue && $areaValue) { $result = $this->getModel('ajax')->getCodeGlueOptions($listfieldValue, $joinfieldsValue, $typeValue, $areaValue); } @@ -1395,7 +1395,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $pathValue = $jinput->get('path', NULL, 'STRING'); $statusValue = $jinput->get('status', NULL, 'WORD'); - if($pathValue && $statusValue && $user->id != 0) + if($pathValue && $user->id != 0 && $statusValue) { $result = $this->getModel('ajax')->setSnippetGithub($pathValue, $statusValue); } diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index fd043bcc5..d92f53c69 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -108,7 +108,7 @@ class Get */ public $componentData; - /* * ********************************************************************************************* + /** * The custom script placeholders - we use the (xxx) to avoid detection it should be (***) * ##################################---> PHP/JS <---#################################### * @@ -140,7 +140,7 @@ class Get * ////////23 is the ID of the code in the system don't change it!!!!!!!!!!!!!!!!!!!!!!!!!! * * @var array - * ********************************************************************************************* */ + */ protected $customCodePlaceholders = array( 1 => 'REPLACE<>$$$$]', 2 => 'INSERT<>$$$$]', diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index 8fc70e878..ac27493e5 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -10684,15 +10684,13 @@ class Interpretation extends Fields $ifArray[$task['task_name']][] = "\$" . $task['value_name'] . "Value"; } // see user check is needed - if (isset($task['user_check']) && 1 == $task['user_check']) + if (!isset($userCheck[$task['task_name']]) && isset($task['user_check']) && 1 == $task['user_check']) { // add it since this means it was not set, and in the old method we assumed it was inplace // or it is set and 1 means we still want it inplace - $userCheck[$task['task_name']] = ' && $user->id != 0'; - } - else - { - $userCheck[$task['task_name']] = ''; + $ifArray[$task['task_name']][] = '$user->id != 0'; + // add it only once + $userCheck[$task['task_name']] = true; } } } @@ -10715,17 +10713,9 @@ class Interpretation extends Fields // check if we have some values to check if (isset($ifArray[$task]) && ComponentbuilderHelper::checkArray($ifArray[$task])) { + // set if string $ifvalues = implode(' && ', $ifArray[$task]); - } - else - { - $ifvalues = ''; - } - // build the if string - $ifvalues = $ifvalues . $userCheck[$task]; - // check if we have a if string - if (ComponentbuilderHelper::checkString($ifvalues)) - { + // add to case $cases .= PHP_EOL . $this->_t(6) . "if(" . $ifvalues . ")"; $cases .= PHP_EOL . $this->_t(6) . "{"; $cases .= PHP_EOL . $this->_t(7) . $getMethod; diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 00e8ac331..c036b4672 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -1323,7 +1323,8 @@ class ComponentbuilderModelAjax extends JModelList 'field' => array( array('table' => 'component_config', 'tables' => 'components_config', 'fields' => array('addconfig' => 'field', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name'), array('table' => 'admin_fields', 'tables' => 'admins_fields', 'fields' => array('addfields' => 'field', 'admin_view' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_ADMIN_VIEW', 'linked_name' => 'system_name'), - array('table' => 'field', 'tables' => 'fields', 'fields' => array('xml' => 'fields', 'name' => 'NAME', 'fieldtype' => 'TYPE'), 'linked' => 'COM_COMPONENTBUILDER_FIELD', 'type_name' => 'name') + array('table' => 'field', 'tables' => 'fields', 'fields' => array('xml' => 'fields', 'name' => 'NAME', 'fieldtype' => 'TYPE'), 'linked' => 'COM_COMPONENTBUILDER_FIELD', 'type_name' => 'name'), + array('table' => 'joomla_plugin', 'tables' => 'joomla_plugins', 'fields' => array('fields' => 'field', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_PLUGIN') ), 'admin_view' => array( array('table' => 'component_admin_views', 'tables' => 'components_admin_views', 'fields' => array('addadmin_views' => 'adminview', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') @@ -1343,6 +1344,9 @@ class ComponentbuilderModelAjax extends JModelList 'dynamic_get' => array( array('table' => 'site_view', 'tables' => 'site_views', 'fields' => array('custom_get' => 'ARRAY', 'main_get' => 'INT', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_SITE_VIEW'), array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'fields' => array('custom_get' => 'ARRAY', 'main_get' => 'INT', 'system_name' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW') + ), + 'joomla_plugin' => array( + array('table' => 'component_plugins', 'tables' => 'components_plugins', 'fields' => array('addjoomla_plugins' => 'plugin', 'joomla_component' => 'NAME'), 'linked' => 'COM_COMPONENTBUILDER_JOOMLA_COMPONENT', 'linked_name' => 'system_name') ) ); @@ -2419,7 +2423,7 @@ class ComponentbuilderModelAjax extends JModelList ), // #__componentbuilder_joomla_plugin (q) 'joomla_plugin' => array( - 'search' => array('id', 'system_name', 'name', 'main_class_code', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'search' => array('id', 'system_name', 'name', 'main_class_code', 'head', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall'), 'views' => 'joomla_plugins', 'not_base64' => array('description' => 'string'), diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index b47b82d63..dbe8330ee 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -1887,7 +1887,7 @@ class ComponentbuilderModelJoomla_components extends JModelList ), // #__componentbuilder_joomla_plugin (q) 'joomla_plugin' => array( - 'search' => array('id', 'system_name', 'name', 'main_class_code', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', + 'search' => array('id', 'system_name', 'name', 'main_class_code', 'head', 'description', 'php_script_construct', 'php_preflight_install', 'php_preflight_update', 'php_preflight_uninstall', 'php_postflight_install', 'php_postflight_update', 'php_method_uninstall'), 'views' => 'joomla_plugins', 'not_base64' => array('description' => 'string'), diff --git a/componentbuilder.xml b/componentbuilder.xml index afb03b075..0495082c1 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 14th August, 2019 + 15th August, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com