From e6b3c2391d4bc487f10f8f033d6200a6df438acc Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Tue, 22 Aug 2017 23:44:53 +0100 Subject: [PATCH] fixed function button bug that loaded it to all views, instead of only the owner view --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/e_Interpretation.php | 20 ++++++++++++-------- admin/helpers/compiler/f_Infusion.php | 2 +- admin/views/admin_views/view.html.php | 7 +------ admin/views/custom_admin_views/view.html.php | 7 +------ admin/views/custom_codes/view.html.php | 7 +------ admin/views/dynamic_gets/view.html.php | 7 +------ admin/views/fields/view.html.php | 7 +------ admin/views/fieldtypes/view.html.php | 7 +------ admin/views/layouts/view.html.php | 7 +------ admin/views/site_views/view.html.php | 7 +------ admin/views/snippets/view.html.php | 7 +------ admin/views/templates/view.html.php | 7 +------ 14 files changed, 25 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index fb859603c..7b1ee528f 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.5.0 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **111712** ++ *Line count*: **111662** + *File count*: **663** + *Folder count*: **117** diff --git a/admin/README.txt b/admin/README.txt index fb859603c..7b1ee528f 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -112,7 +112,7 @@ Component Builder is mapped as a component in itself on my local development env + *Version*: 2.5.0 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **111712** ++ *Line count*: **111662** + *File count*: **663** + *Folder count*: **117** diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d14980255..8b0131f96 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -3113,11 +3113,15 @@ class Interpretation extends Fields // add cpanel button TODO does not work well on site with permissions if (isset($custom_button['type']) && $custom_button['type'] == 2) { - $this->onlyFunctionButton[] = "\t".$tab."if (\$this->user->authorise('".$viewName.".".$keyCode."'))"; - $this->onlyFunctionButton[] = "\t".$tab."{"; - $this->onlyFunctionButton[] = "\t".$tab."\t//".$this->setLine(__LINE__)." add ".$custom_button['name']." button."; - $this->onlyFunctionButton[] = "\t".$tab."\tJToolBarHelper::custom('".$viewsName.".".$custom_button['method']."', '".$custom_button['icomoon']."', '', '".$keyLang."', false);"; - $this->onlyFunctionButton[] = "\t".$tab."}"; + if (!isset($this->onlyFunctionButton[$viewsName])) + { + $this->onlyFunctionButton[$viewsName] = array(); + } + $this->onlyFunctionButton[$viewsName][] = "\t".$tab."if (\$this->user->authorise('".$viewName.".".$keyCode."'))"; + $this->onlyFunctionButton[$viewsName][] = "\t".$tab."{"; + $this->onlyFunctionButton[$viewsName][] = "\t".$tab."\t//".$this->setLine(__LINE__)." add ".$custom_button['name']." button."; + $this->onlyFunctionButton[$viewsName][] = "\t".$tab."\tJToolBarHelper::custom('".$viewsName.".".$custom_button['method']."', '".$custom_button['icomoon']."', '', '".$keyLang."', false);"; + $this->onlyFunctionButton[$viewsName][] = "\t".$tab."}"; } else { @@ -3182,12 +3186,12 @@ class Interpretation extends Fields return ''; } - public function setFunctionOnlyButtons() + public function setFunctionOnlyButtons($viewName_list) { // return buttons if they were build - if (isset($this->onlyFunctionButton) && ComponentbuilderHelper::checkArray($this->onlyFunctionButton)) + if (isset($this->onlyFunctionButton[$viewName_list]) && ComponentbuilderHelper::checkArray($this->onlyFunctionButton[$viewName_list])) { - return PHP_EOL.implode(PHP_EOL,$this->onlyFunctionButton); + return PHP_EOL.implode(PHP_EOL,$this->onlyFunctionButton[$viewName_list]); } return ''; } diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 7bed309f5..749bb4e92 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -443,7 +443,7 @@ class Infusion extends Interpretation $this->fileContentDynamic[$viewName_list]['###ADMIN_CUSTOM_BUTTONS_LIST###'] = $this->setCustomButtons($view, 3, "\t"); $this->fileContentDynamic[$viewName_list]['###ADMIN_CUSTOM_FUNCTION_ONLY_BUTTONS_LIST###'] - = $this->setFunctionOnlyButtons(); + = $this->setFunctionOnlyButtons($viewName_list); // ###GET_ITEMS_METHOD_STRING_FIX### <<>> $this->fileContentDynamic[$viewName_list]['###GET_ITEMS_METHOD_STRING_FIX###'] diff --git a/admin/views/admin_views/view.html.php b/admin/views/admin_views/view.html.php index 70998559d..cf8c2a0c2 100644 --- a/admin/views/admin_views/view.html.php +++ b/admin/views/admin_views/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewAdmin_views extends JViewLegacy { JToolBarHelper::custom('admin_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('admin_view.import')) { diff --git a/admin/views/custom_admin_views/view.html.php b/admin/views/custom_admin_views/view.html.php index 62b0eb508..928ea77b6 100644 --- a/admin/views/custom_admin_views/view.html.php +++ b/admin/views/custom_admin_views/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewCustom_admin_views extends JViewLegacy { JToolBarHelper::custom('custom_admin_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('custom_admin_view.import')) { diff --git a/admin/views/custom_codes/view.html.php b/admin/views/custom_codes/view.html.php index 4b16cc357..fa029fe46 100644 --- a/admin/views/custom_codes/view.html.php +++ b/admin/views/custom_codes/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewCustom_codes extends JViewLegacy { JToolBarHelper::custom('custom_codes.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('custom_code.import')) { diff --git a/admin/views/dynamic_gets/view.html.php b/admin/views/dynamic_gets/view.html.php index 5b9d4afba..239f98ec5 100644 --- a/admin/views/dynamic_gets/view.html.php +++ b/admin/views/dynamic_gets/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewDynamic_gets extends JViewLegacy { JToolBarHelper::custom('dynamic_gets.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('dynamic_get.import')) { diff --git a/admin/views/fields/view.html.php b/admin/views/fields/view.html.php index d0f465c97..cb2fd8a2d 100644 --- a/admin/views/fields/view.html.php +++ b/admin/views/fields/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewFields extends JViewLegacy { JToolBarHelper::custom('fields.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('field.import')) { diff --git a/admin/views/fieldtypes/view.html.php b/admin/views/fieldtypes/view.html.php index 6dab16e56..ff2476e89 100644 --- a/admin/views/fieldtypes/view.html.php +++ b/admin/views/fieldtypes/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewFieldtypes extends JViewLegacy { JToolBarHelper::custom('fieldtypes.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('fieldtype.import')) { diff --git a/admin/views/layouts/view.html.php b/admin/views/layouts/view.html.php index beb0208c0..bdebb27ed 100644 --- a/admin/views/layouts/view.html.php +++ b/admin/views/layouts/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewLayouts extends JViewLegacy { JToolBarHelper::custom('layouts.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('layout.import')) { diff --git a/admin/views/site_views/view.html.php b/admin/views/site_views/view.html.php index b0eb45559..1cf01c715 100644 --- a/admin/views/site_views/view.html.php +++ b/admin/views/site_views/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewSite_views extends JViewLegacy { JToolBarHelper::custom('site_views.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('site_view.import')) { diff --git a/admin/views/snippets/view.html.php b/admin/views/snippets/view.html.php index 64275961e..02833344e 100644 --- a/admin/views/snippets/view.html.php +++ b/admin/views/snippets/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewSnippets extends JViewLegacy { JToolBarHelper::custom('snippets.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('snippet.import')) { diff --git a/admin/views/templates/view.html.php b/admin/views/templates/view.html.php index b8101dd89..cf9b3b24e 100644 --- a/admin/views/templates/view.html.php +++ b/admin/views/templates/view.html.php @@ -149,12 +149,7 @@ class ComponentbuilderViewTemplates extends JViewLegacy { JToolBarHelper::custom('templates.exportData', 'download', '', 'COM_COMPONENTBUILDER_EXPORT_DATA', true); } - } - if ($this->user->authorise('joomla_component.import_components')) - { - // add Import Components button. - JToolBarHelper::custom('joomla_components.smartImport', 'upload', '', 'COM_COMPONENTBUILDER_IMPORT_COMPONENTS', false); - } + } if ($this->canDo->get('core.import') && $this->canDo->get('template.import')) {