From e3f22d631c74ed260bb0ce63f66e26597e63b757 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Thu, 5 Sep 2019 23:12:56 +0200 Subject: [PATCH] Fixed count (php 7.2) issue across JCB. Improved the setModelExportMethod method in the compiler to now work as a setGetItemsModelMethod instead. Added more strict permissional implementation per/field across the export methods of JCB. --- README.md | 4 +- admin/README.txt | 4 +- admin/compiler/joomla_3/Helper.php | 2 +- admin/compiler/joomla_3/Helper_site.php | 2 +- admin/helpers/compiler.php | 6 +- admin/helpers/compiler/a_Get.php | 24 +- admin/helpers/compiler/b_Structure.php | 4 +- admin/helpers/compiler/c_Fields.php | 8 +- admin/helpers/compiler/e_Interpretation.php | 237 +++++++++++------- admin/helpers/compiler/f_Infusion.php | 2 +- admin/helpers/componentbuilder.php | 4 +- admin/models/admin_views.php | 18 +- admin/models/admins_custom_tabs.php | 8 +- admin/models/admins_fields.php | 8 +- admin/models/admins_fields_conditions.php | 8 +- admin/models/admins_fields_relations.php | 8 +- admin/models/class_extendings.php | 8 +- admin/models/class_methods.php | 18 +- admin/models/class_properties.php | 18 +- admin/models/components_admin_views.php | 8 +- admin/models/components_config.php | 8 +- .../models/components_custom_admin_menus.php | 8 +- .../models/components_custom_admin_views.php | 8 +- admin/models/components_dashboard.php | 8 +- admin/models/components_files_folders.php | 8 +- admin/models/components_mysql_tweaks.php | 8 +- admin/models/components_placeholders.php | 8 +- admin/models/components_plugins.php | 8 +- admin/models/components_site_views.php | 8 +- admin/models/components_updates.php | 8 +- admin/models/custom_admin_views.php | 18 +- admin/models/custom_codes.php | 18 +- admin/models/dynamic_gets.php | 18 +- admin/models/fields.php | 18 +- admin/models/fieldtype.php | 8 +- admin/models/fieldtypes.php | 18 +- admin/models/help_documents.php | 33 +-- admin/models/joomla_components.php | 18 +- admin/models/joomla_plugins.php | 8 +- .../joomla_plugins_files_folders_urls.php | 8 +- admin/models/joomla_plugins_updates.php | 8 +- admin/models/language_translations.php | 18 +- admin/models/languages.php | 18 +- admin/models/layouts.php | 18 +- admin/models/libraries.php | 12 +- admin/models/libraries_config.php | 8 +- admin/models/libraries_files_folders_urls.php | 8 +- admin/models/placeholders.php | 18 +- admin/models/server.php | 8 +- admin/models/servers.php | 18 +- admin/models/site_views.php | 18 +- admin/models/snippet_types.php | 8 +- admin/models/snippets.php | 18 +- admin/models/templates.php | 18 +- admin/models/validation_rules.php | 18 +- admin/views/compiler/view.html.php | 2 +- admin/views/get_snippets/view.html.php | 2 +- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 4 +- site/views/api/view.html.php | 2 +- 60 files changed, 623 insertions(+), 247 deletions(-) diff --git a/README.md b/README.md index eba7c76c5..463651c9d 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*: 4th September, 2019 ++ *Last Build*: 5th September, 2019 + *Version*: 2.10.1 + *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*: **251119** ++ *Line count*: **251450** + *Field count*: **1343** + *File count*: **1608** + *Folder count*: **253** diff --git a/admin/README.txt b/admin/README.txt index eba7c76c5..463651c9d 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*: 4th September, 2019 ++ *Last Build*: 5th September, 2019 + *Version*: 2.10.1 + *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*: **251119** ++ *Line count*: **251450** + *Field count*: **1343** + *File count*: **1608** + *Folder count*: **253** diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index 843e76d0c..b8132d932 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -654,7 +654,7 @@ abstract class ###Component###Helper } } // check if there are any view values remaining - if (count($_result)) + if (count((array) $_result)) { $_result = json_encode($_result); $_result = array($_result); diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index 6ea715db8..cf98c8d43 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -292,7 +292,7 @@ abstract class ###Component###Helper } } // check if there are any view values remaining - if (count($_result)) + if (count((array) $_result)) { $_result = json_encode($_result); $_result = array($_result); diff --git a/admin/helpers/compiler.php b/admin/helpers/compiler.php index ff61d8ea4..a5d4d97aa 100644 --- a/admin/helpers/compiler.php +++ b/admin/helpers/compiler.php @@ -174,7 +174,7 @@ class Compiler extends Infusion if (isset($mismatch) && ComponentbuilderHelper::checkArray($mismatch)) { $this->app->enqueueMessage(JText::_('

Language Warning

'), 'Warning'); - if (count($mismatch) > 1) + if (count((array) $mismatch) > 1) { $this->app->enqueueMessage(JText::_('

Please check the following mismatching Joomla.JText language constants.

'), 'Warning'); } @@ -742,7 +742,7 @@ class Compiler extends Infusion // we musk keep last three lines to dynamic find target entry $fingerPrint[$lineNumber] = trim($lineContent); // check lines each time if it fits our target - if (count($fingerPrint) === $sizeEnd && !$foundEnd) + if (count((array) $fingerPrint) === $sizeEnd && !$foundEnd) { $fingerTest = md5(implode('', $fingerPrint)); if ($fingerTest === $hashEnd) @@ -766,7 +766,7 @@ class Compiler extends Infusion // we musk keep last three lines to dynamic find target entry $fingerPrint[$lineNumber] = trim($lineContent); // check lines each time if it fits our target - if (count($fingerPrint) === $size && !$found) + if (count((array) $fingerPrint) === $size && !$found) { $fingerTest = md5(implode('', $fingerPrint)); if ($fingerTest === $hash) diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index a4851006e..9f77d8ea2 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -922,7 +922,7 @@ class Get $results = $dispatcher->trigger($event, $data); // Check for errors encountered while trigger the event - if (count($results) && in_array(false, $results, true)) + if (count((array) $results) && in_array(false, $results, true)) { // Get the last error. $error = $dispatcher->getError(); @@ -3862,7 +3862,7 @@ class Get $id_range = (array) array_map('trim', explode('=>', $id)); unset($id_array[$key]); // build range - if (count($id_range) == 2) + if (count((array) $id_range) == 2) { $range = range($id_range[0], $id_range[1]); $id_array_new = array_merge($id_array_new, $range); @@ -5890,7 +5890,7 @@ class Get */ protected function setNewLangStrings($when = 1) { - if (count($this->newLangStrings) >= $when) + if (count((array) $this->newLangStrings) >= $when) { // Create a new query object. $query = $this->db->getQuery(true); @@ -5902,7 +5902,7 @@ class Get $query->columns($this->db->quoteName($columns)); foreach ($this->newLangStrings as $values) { - if (count($values) == 7) + if (count((array) $values) == 7) { $query->values(implode(',', $values)); $continue = true; @@ -5934,7 +5934,7 @@ class Get */ protected function setExistingLangStrings($when = 1) { - if (count($this->existingLangStrings) >= $when) + if (count((array) $this->existingLangStrings) >= $when) { foreach ($this->existingLangStrings as $values) { @@ -6663,7 +6663,7 @@ class Get */ protected function setNewCustomCode($when = 1) { - if (count($this->newCustomCode) >= $when) + if (count((array) $this->newCustomCode) >= $when) { // Create a new query object. $query = $this->db->getQuery(true); @@ -6675,7 +6675,7 @@ class Get $query->columns($this->db->quoteName($columns)); foreach ($this->newCustomCode as $values) { - if (count($values) == 15) + if (count((array) $values) == 15) { $query->values(implode(',', $values)); $continue = true; @@ -6707,7 +6707,7 @@ class Get */ protected function setExistingCustomCode($when = 1) { - if (count($this->existingCustomCode) >= $when) + if (count((array) $this->existingCustomCode) >= $when) { foreach ($this->existingCustomCode as $code) { @@ -6903,7 +6903,7 @@ class Get } } // check if the endfingerprint is ready to save - if (count($endFingerPrint) === 3) + if (count((array) $endFingerPrint) === 3) { $hashendtarget = '3__' . md5(implode('', $endFingerPrint)); // all new records we can do a bulk insert @@ -7045,15 +7045,15 @@ class Get } } // make sure only a few lines is kept at a time - if (count($fingerPrint) > 10) + if (count((array) $fingerPrint) > 10) { $fingerPrint = array_slice($fingerPrint, -6, 6, true); } } // if the code is at the end of the page and there were not three more lines - if (count($endFingerPrint) > 0 || $loadEndFingerPrint) + if (count((array) $endFingerPrint) > 0 || $loadEndFingerPrint) { - if (count($endFingerPrint) > 0) + if (count((array) $endFingerPrint) > 0) { $leng = count($endFingerPrint); $hashendtarget = $leng . '__' . md5(implode('', $endFingerPrint)); diff --git a/admin/helpers/compiler/b_Structure.php b/admin/helpers/compiler/b_Structure.php index 79d7cbe1c..9c770522b 100644 --- a/admin/helpers/compiler/b_Structure.php +++ b/admin/helpers/compiler/b_Structure.php @@ -843,7 +843,7 @@ class Structure extends Get { // set the default view $getter = explode('_', $this->componentData->dashboard); - if (count($getter) == 2 && is_numeric($getter[1])) + if (count((array) $getter) == 2 && is_numeric($getter[1])) { // the pointers $t = ComponentbuilderHelper::safeString($getter[0], 'U'); @@ -1212,7 +1212,7 @@ class Structure extends Get $this->app->enqueueMessage(JText::sprintf('A method (setDynamicF0ld3rs) was added to the install script.php of this package to insure that the folder/s are copied into the correct place when this componet is installed!'), 'Notice'); } } - elseif (count($checker) == 2 && ComponentbuilderHelper::checkString($checker[0])) + elseif (count((array) $checker) == 2 && ComponentbuilderHelper::checkString($checker[0])) { $add_to_extra = false; // set the target diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 21c502cc8..5da41c36f 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -947,7 +947,7 @@ class Fields extends Structure $this->fieldCount++; } // load the dynamic fields now - if (count($dynamicFieldsXML)) + if (count((array) $dynamicFieldsXML)) { ComponentbuilderHelper::xmlComment($fieldSetXML, $this->setLine(__LINE__) . " Dynamic Fields."); foreach ($dynamicFieldsXML as $dynamicfield) @@ -2331,7 +2331,7 @@ class Fields extends Structure * @param string $langLabel The language string for field label * @param string $langView The language string of the view * @param string $view_name_list The list view name - * @param string $view_name_single The singel view name + * @param string $view_name_single The single view name * @param array $placeholders The place holder and replace values * @param boolean $repeatable The repeatable field switch * @@ -2657,7 +2657,7 @@ class Fields extends Structure * * @param string $langLabel The language string for field label * @param string $langView The language string of the view - * @param string $view_name_single The singel view name + * @param string $view_name_single The single view name * @param string $view_name_list The list view name * @param string $name The field name * @param array $view The view data @@ -3073,7 +3073,7 @@ class Fields extends Structure // so we have name spacing in custom field type name $dotTypeArray = explode('.', $data['type']); // set the J prefix - if (count($dotTypeArray) > 1) + if (count((array) $dotTypeArray) > 1) { $jprefix = strtoupper(array_shift($dotTypeArray)); } diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index b49bd184b..ebe3e5aeb 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -3341,7 +3341,7 @@ class Interpretation extends Fields $method .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Check for errors."; $method .= PHP_EOL . $this->_t(2) . "if (count(\$errors = \$this->get('Errors')))"; $method .= PHP_EOL . $this->_t(2) . "{"; - $method .= PHP_EOL . $this->_t(3) . "throw new Exception(implode(" . '"\n", $errors), 500);'; + $method .= PHP_EOL . $this->_t(3) . "throw new Exception(implode(PHP_EOL, \$errors), 500);"; $method .= PHP_EOL . $this->_t(2) . "}"; // add events if needed if ($view['settings']->main_get->gettype == 1 && ComponentbuilderHelper::checkArray($view['settings']->main_get->plugin_events)) @@ -6005,11 +6005,11 @@ class Interpretation extends Fields } $fixUniqe[] = PHP_EOL . $this->_t(3) . "if (" . implode(' || ', $ifStatment) . ")"; $fixUniqe[] = $this->_t(3) . "{"; - if ($setCategory && count($titles) == 1) + if ($setCategory && count((array) $titles) == 1) { $fixUniqe[] = $this->_t(4) . "list(" . implode('', $titleVars) . ", \$" . $alias . ") = \$this->generateNewTitle(\$data['" . $category . "'], \$data['" . $alias . "'], " . implode('', $titleData) . ");"; } - elseif (count($titles) == 1) + elseif (count((array) $titles) == 1) { $fixUniqe[] = $this->_t(4) . "list(" . implode(', ', $titleVars) . ", \$" . $alias . ") = \$this->_generateNewTitle(\$data['" . $alias . "'], " . implode('', $titleData) . ");"; } @@ -9125,29 +9125,38 @@ class Interpretation extends Fields } /** - * @param $viewName_single - * @param $viewName_list + * A function that builds get Items Method for model + * + * @param string $viewName_single The single view name + * @param string $viewName_list The list view name + * @param array $config The config details to adapt the method being build + * * @return string */ - public function setModelExportMethod($viewName_single, $viewName_list) + public function setGetItemsModelMethod($viewName_single, $viewName_list, $config = array('functionName' => 'getExportData', 'docDesc' => 'Method to get list export data.', 'type' => 'export')) { $query = ''; - if ($this->eximportView[$viewName_list]) + if ($this->eximportView[$viewName_list] || 'export' !== $config['type']) { + $isExport = ('export' === $config['type']); + $query = PHP_EOL . PHP_EOL . $this->_t(1) . "/**"; - $query .= PHP_EOL . $this->_t(1) . " * Method to get list export data."; + $query .= PHP_EOL . $this->_t(1) . " * " . $config['docDesc']; + $query .= PHP_EOL . $this->_t(1) . " *"; + $query .= PHP_EOL . $this->_t(1) . " * @param array \$pks The ids of the items to get"; + $query .= PHP_EOL . $this->_t(1) . " * @param JUser \$user The user making the request"; $query .= PHP_EOL . $this->_t(1) . " *"; $query .= PHP_EOL . $this->_t(1) . " * @return mixed An array of data items on success, false on failure."; $query .= PHP_EOL . $this->_t(1) . " */"; - $query .= PHP_EOL . $this->_t(1) . "public function getExportData(\$pks, \$user = null)"; + $query .= PHP_EOL . $this->_t(1) . "public function " . $config['functionName'] . "(\$pks, \$user = null)"; $query .= PHP_EOL . $this->_t(1) . "{"; $query .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " setup the query"; $query .= PHP_EOL . $this->_t(2) . "if (" . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . "Helper::checkArray(\$pks))"; $query .= PHP_EOL . $this->_t(2) . "{"; - $query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME)"; - $query .= PHP_EOL . $this->_t(3) . "\$_export = true;"; + $query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set a value to know this is " . $config['type'] . " method. (USE IN CUSTOM CODE TO ALTER OUTCOME)"; + $query .= PHP_EOL . $this->_t(3) . "\$_" . $config['type'] . " = true;"; $query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Get the user object if not set."; - $query .= PHP_EOL . $this->_t(3) . "if (" . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . "Helper::checkObject(\$user))"; + $query .= PHP_EOL . $this->_t(3) . "if (!isset(\$user) || !" . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . "Helper::checkObject(\$user))"; $query .= PHP_EOL . $this->_t(3) . "{"; $query .= PHP_EOL . $this->_t(4) . "\$user = JFactory::getUser();"; $query .= PHP_EOL . $this->_t(3) . "}"; @@ -9161,7 +9170,7 @@ class Interpretation extends Fields $query .= PHP_EOL . $this->_t(3) . "\$query->where('a.id IN (' . implode(',',\$pks) . ')');"; // add custom filtering php $query .= $this->getCustomScriptBuilder('php_getlistquery', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(1)); - + // add access levels if the view has access set if (isset($this->accessBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName_single])) { $query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Implement View Level Access"; @@ -9179,22 +9188,29 @@ class Interpretation extends Fields $query .= PHP_EOL . $this->_t(3) . "if (\$db->getNumRows())"; $query .= PHP_EOL . $this->_t(3) . "{"; $query .= PHP_EOL . $this->_t(4) . "\$items = \$db->loadObjectList();"; - $query .= $this->setGetItemsMethodStringFix($viewName_single, $viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2), true); - // add custom php to getitems method after all + $query .= $this->setGetItemsMethodStringFix($viewName_single, $viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2), $isExport); + // add translations + if (!$isExport) + { + $query .= $this->setSelectionTranslationFix($viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2)); + } + // add custom php to getItems method after all $query .= $this->getCustomScriptBuilder('php_getitems_after_all', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(2)); $query .= PHP_EOL . $this->_t(4) . "return \$items;"; $query .= PHP_EOL . $this->_t(3) . "}"; $query .= PHP_EOL . $this->_t(2) . "}"; $query .= PHP_EOL . $this->_t(2) . "return false;"; $query .= PHP_EOL . $this->_t(1) . "}"; - // get the header script - $header = ComponentbuilderHelper::getDynamicScripts('headers'); + if ($isExport) + { + $header = ComponentbuilderHelper::getDynamicScripts('headers'); - // add getExImPortHeaders - $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, - // set a default script for those with no custom script - PHP_EOL . PHP_EOL . $this->setPlaceholders($header, $this->placeholders)); + // add getExImPortHeaders + $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, + // set a default script for those with no custom script + PHP_EOL . PHP_EOL . $this->setPlaceholders($header, $this->placeholders)); + } } return $query; } @@ -12149,9 +12165,9 @@ class Interpretation extends Fields { // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $fields .= ",".PHP_EOL.$this->_t(4) . "'".$filter['custom']['db'].".".$filter['custom']['text']."','".$filter['code']."_".$filter['custom']['text']."'"; - } */ + { + $fields .= ",".PHP_EOL.$this->_t(4) . "'".$filter['custom']['db'].".".$filter['custom']['text']."','".$filter['code']."_".$filter['custom']['text']."'"; + } */ $fields .= "," . PHP_EOL . $this->_t(4) . "'a." . $filter['code'] . "','" . $filter['code'] . "'"; } $donelist[] = $filter['code']; @@ -12178,9 +12194,9 @@ class Interpretation extends Fields { // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $fields .= ",".PHP_EOL.$this->_t(4) . "'".$filter['custom']['db'].".".$filter['custom']['text']."','".$filter['code']."_".$filter['custom']['text']."'"; - } */ + { + $fields .= ",".PHP_EOL.$this->_t(4) . "'".$filter['custom']['db'].".".$filter['custom']['text']."','".$filter['code']."_".$filter['custom']['text']."'"; + } */ $fields .= "," . PHP_EOL . $this->_t(4) . "'a." . $filter['code'] . "','" . $filter['code'] . "'"; } $donelist[] = $filter['code']; @@ -12226,9 +12242,9 @@ class Interpretation extends Fields { // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $stored .= PHP_EOL.$this->_t(2) . "\$id .= ':' . \$this->getState('filter.".$filter['code']."_".$filter['custom']['text']."');"; - } */ + { + $stored .= PHP_EOL.$this->_t(2) . "\$id .= ':' . \$this->getState('filter.".$filter['code']."_".$filter['custom']['text']."');"; + } */ $stored .= PHP_EOL . $this->_t(2) . "\$id .= ':' . \$this->getState('filter." . $filter['code'] . "');"; } $donelist[] = $filter['code']; @@ -12255,9 +12271,9 @@ class Interpretation extends Fields { // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $stored .= PHP_EOL.$this->_t(2) . "\$id .= ':' . \$this->getState('filter.".$filter['code']."_".$filter['custom']['text']."');"; - } */ + { + $stored .= PHP_EOL . $this->_t(2) . "\$id .= ':' . \$this->getState('filter.".$filter['code']."_".$filter['custom']['text']."');"; + } */ $stored .= PHP_EOL . $this->_t(2) . "\$id .= ':' . \$this->getState('filter." . $filter['code'] . "');"; } $donelist[] = $filter['code']; @@ -12486,11 +12502,11 @@ class Interpretation extends Fields } // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $state .= $spacer."\$".$filter['code']."_".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['code']."_".$filter['custom']['text']."', 'filter_".$filter['code']."_".$filter['custom']['text']."');"; - $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['code']."_".$filter['custom']['text']."', \$".$filter['code']."_".$filter['custom']['text'].");"; - $spacer = PHP_EOL.PHP_EOL.$this->_t(2); - } */ + { + $state .= $spacer."\$".$filter['code']."_".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['code']."_".$filter['custom']['text']."', 'filter_".$filter['code']."_".$filter['custom']['text']."');"; + $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['code']."_".$filter['custom']['text']."', \$".$filter['code']."_".$filter['custom']['text'].");"; + $spacer = PHP_EOL.PHP_EOL.$this->_t(2); + } */ $state .= $spacer . "\$" . $filter['code'] . " = \$this->getUserStateFromRequest(\$this->context . '.filter." . $filter['code'] . "', 'filter_" . $filter['code'] . "');"; $state .= PHP_EOL . $this->_t(2) . "\$this->setState('filter." . $filter['code'] . "', \$" . $filter['code'] . ");"; } @@ -12537,13 +12553,13 @@ class Interpretation extends Fields } // check if custom field is set /* if (ComponentbuilderHelper::checkArray($filter['custom'])) - { - $state .= $spacer."\$".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['custom']['text']."', 'filter_".$filter['custom']['text']."');"; - $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['custom']['text']."', \$".$filter['custom']['text'].");"; - $state .= PHP_EOL.$this->_t(2) . "\$".$filter['code']."_".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['code']."_".$filter['custom']['text']."', 'filter_".$filter['code']."_".$filter['custom']['text']."');"; - $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['code']."_".$filter['custom']['text']."', \$".$filter['code']."_".$filter['custom']['text'].");"; - $spacer = PHP_EOL.PHP_EOL.$this->_t(2); - } */ + { + $state .= $spacer."\$".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['custom']['text']."', 'filter_".$filter['custom']['text']."');"; + $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['custom']['text']."', \$".$filter['custom']['text'].");"; + $state .= PHP_EOL.$this->_t(2) . "\$".$filter['code']."_".$filter['custom']['text']." = \$this->getUserStateFromRequest(\$this->context . '.filter.".$filter['code']."_".$filter['custom']['text']."', 'filter_".$filter['code']."_".$filter['custom']['text']."');"; + $state .= PHP_EOL.$this->_t(2) . "\$this->setState('filter.".$filter['code']."_".$filter['custom']['text']."', \$".$filter['code']."_".$filter['custom']['text'].");"; + $spacer = PHP_EOL.PHP_EOL.$this->_t(2); + } */ $state .= $spacer . "\$" . $filter['code'] . " = \$this->getUserStateFromRequest(\$this->context . '.filter." . $filter['code'] . "', 'filter_" . $filter['code'] . "');"; $state .= PHP_EOL . $this->_t(2) . "\$this->setState('filter." . $filter['code'] . "', \$" . $filter['code'] . ");"; } @@ -12649,7 +12665,7 @@ class Interpretation extends Fields return $checkin; } - public function setGetItemsMethodStringFix($view, $viewName_list, $Component, $tab = '', $export = false) + public function setGetItemsMethodStringFix($viewName_single, $viewName_list, $Component, $tab = '', $export = false) { // add the fix if this view has the need for it $fix = ''; @@ -12661,16 +12677,17 @@ class Interpretation extends Fields } // setup correct core target $coreLoad = false; - if (isset($this->permissionCore[$view])) + if (isset($this->permissionCore[$viewName_single])) { - $core = $this->permissionCore[$view]; + $core = $this->permissionCore[$viewName_single]; $coreLoad = true; } $component = ComponentbuilderHelper::safeString($Component); // check if the item has permissions. - if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder[$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.access']]) && in_array($view, $this->permissionBuilder[$core['core.access']])) + if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder[$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.access']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.access']])) { - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$access = (JFactory::getUser()->authorise('" . $core['core.access'] . "', 'com_" . $component . "." . $view . ".' . (int) \$item->id) && JFactory::getUser()->authorise('" . $core['core.access'] . "', 'com_" . $component . "'));"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Remove items the user can't access."; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$access = (\$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$item->id) && \$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "'));"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (!\$access)"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "unset(\$items[\$nr]);"; @@ -12700,9 +12717,9 @@ class Interpretation extends Fields } } // open the values - if (isset($this->{$methodName}[$view]) && ComponentbuilderHelper::checkArray($this->{$methodName}[$view])) + if (isset($this->{$methodName}[$viewName_single]) && ComponentbuilderHelper::checkArray($this->{$methodName}[$viewName_single])) { - foreach ($this->{$methodName}[$view] as $item) + foreach ($this->{$methodName}[$viewName_single] as $item) { switch ($item['method']) { @@ -12749,53 +12766,35 @@ class Interpretation extends Fields $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (" . $Component . "Helper::checkArray(\$" . $item['name'] . "Array))"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$" . $item['name'] . "Names = '';"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$counter = 0;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$" . $item['name'] . "Names = array();"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "foreach (\$" . $item['name'] . "Array as \$" . $item['name'] . ")"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "if (\$counter == 0)"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(6) . "\$" . $item['name'] . "Names .= " . $Component . "Helper::getGroupName(\$" . $item['name'] . ");"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "else"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(6) . "\$" . $item['name'] . "Names .= ', '." . $Component . "Helper::getGroupName(\$" . $item['name'] . ");"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "\$counter++;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "\$" . $item['name'] . "Names[] = " . $Component . "Helper::getGroupName(\$" . $item['name'] . ");"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$item->" . $item['name'] . " = \$" . $item['name'] . "Names;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$item->" . $item['name'] . " = implode(', ', \$" . $item['name'] . "Names);"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}"; } /* elseif ($item['type'] === 'usergroup' && $export) - { - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "//".$this->setLine(__LINE__)." decode ".$item['name']; - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "\$".$item['name']."Array = ".$decode."(\$item->".$item['name'].$suffix_decode.");"; - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "if (".$Component."Helper::checkArray(\$".$item['name']."Array))"; - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "{"; - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);"; - $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "}"; - } */ + { + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "//".$this->setLine(__LINE__)." decode ".$item['name']; + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "\$".$item['name']."Array = ".$decode."(\$item->".$item['name'].$suffix_decode.");"; + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "if (".$Component."Helper::checkArray(\$".$item['name']."Array))"; + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "{"; + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);"; + $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "}"; + } */ elseif ($item['translation'] && !$export) { - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " convert " . $item['name']; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name']; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (" . $Component . "Helper::checkArray(\$" . $item['name'] . "Array))"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$" . $item['name'] . "Names = '';"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$counter = 0;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$" . $item['name'] . "Names = array();"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "foreach (\$" . $item['name'] . "Array as \$" . $item['name'] . ")"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "if (\$counter == 0)"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(6) . "\$" . $item['name'] . "Names .= JText:" . ":_(\$this->selectionTranslation(\$" . $item['name'] . ", '" . $item['name'] . "'));"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "else"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "{"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(6) . "\$" . $item['name'] . "Names .= ', '.JText:" . ":_(\$this->selectionTranslation(\$" . $item['name'] . ", '" . $item['name'] . "'));"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "\$counter++;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "\$" . $item['name'] . "Names[] = JText:" . ":_(\$this->selectionTranslation(\$" . $item['name'] . ", '" . $item['name'] . "'));"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "}"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$item->" . $item['name'] . " = \$" . $item['name'] . "Names;"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "\$item->" . $item['name'] . " = implode(', ', \$" . $item['name'] . "Names);"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}"; } else @@ -12899,15 +12898,15 @@ class Interpretation extends Fields } } } - // set translation (TODO) would be nice to cut down on double loops.. -// if (!$export && isset($this->selectionTranslationFixBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->selectionTranslationFixBuilder[$viewName_list])) -// { -// foreach ($this->selectionTranslationFixBuilder[$viewName_list] as $name => $values) -// { -// $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " convert " . $name; -// $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$item->" . $name . " = \$this->selectionTranslation(\$item->" . $name . ", '" . $name . "');"; -// } -// } + /* // set translation (TODO) would be nice to cut down on double loops.. + if (!$export && isset($this->selectionTranslationFixBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->selectionTranslationFixBuilder[$viewName_list])) + { + foreach ($this->selectionTranslationFixBuilder[$viewName_list] as $name => $values) + { + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " convert " . $name; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$item->" . $name . " = \$this->selectionTranslation(\$item->" . $name . ", '" . $name . "');"; + } + } */ // load the relations after modeling if (isset($this->fieldRelations[$viewName_list]) && ComponentbuilderHelper::checkArray($this->fieldRelations[$viewName_list])) { @@ -12929,8 +12928,53 @@ class Interpretation extends Fields $forEachStart = PHP_EOL . PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " set values to display correctly."; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "if (" . $Component . "Helper::checkArray(\$items))"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "{"; + // do not add to export since it is already done + if (!$export) + { + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Get the user object if not set."; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "if (!isset(\$user) || !" . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . "Helper::checkObject(\$user))"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "{"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$user = JFactory::getUser();"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "}"; + } + // add the permissional removal of values the user has not right to view or access + if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single])) + { + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " -- get global permissional control activation. (default is inactive) ---"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " to use this feature add a global option radio button to your"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " component with a value of 1 as on/activate and 0 as inactive/off"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " make sure it has the name: strict_permission_per_field"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "\$strict_permission_per_field = JComponentHelper::getParams('com_" . $component . "')->get('strict_permission_per_field', 0);" . PHP_EOL; + } $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "foreach (\$items as \$nr => &\$item)"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "{"; + // add the permissional removal of values the user has not right to view or access + if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single])) + { + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " use permissional control if globaly set."; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$strict_permission_per_field)"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; + foreach ($this->permissionFields[$viewName_single] as $fieldName => $permission_options) + { + foreach($permission_options as $permission_option => $fieldType) + { + switch ($permission_option) + { + case 'access': + case 'view': + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "//" . $this->setLine(__LINE__) . " set " . $permission_option . " permissional control for " . $fieldName . " value."; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "if (isset(\$item->" . $fieldName . ") && (!\$user->authorise('" . $viewName_single . "." . $permission_option . "." . $fieldName . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$item->id)"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "|| !\$user->authorise('" . $viewName_single . "." . $permission_option . "." . $fieldName . "', 'com_" . $component . "')))"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "{"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "//" . $this->setLine(__LINE__) . " We JUST empty the value (do you have a better idea)"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(5) . "\$item->" . $fieldName . " = '';"; + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "}"; + break; + } + } + } + $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}"; + } // remove these values if export if ($export) { @@ -12939,6 +12983,7 @@ class Interpretation extends Fields $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "unset(\$item->checked_out);"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "unset(\$item->checked_out_time);"; } + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "}"; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "}"; if ($export) @@ -12953,7 +12998,7 @@ class Interpretation extends Fields } // add custom php to getitems method - $fix .= $this->getCustomScriptBuilder('php_getitems', $view, PHP_EOL . PHP_EOL . $tab); + $fix .= $this->getCustomScriptBuilder('php_getitems', $viewName_single, PHP_EOL . PHP_EOL . $tab); // load the encryption object if needed $script = ''; @@ -13260,7 +13305,7 @@ class Interpretation extends Fields foreach ($this->iconBuilder as $icon => $path) { $array_buket = explode('.', $icon); - if (count($array_buket) == 3) + if (count((array) $array_buket) == 3) { list($type, $name, $action) = $array_buket; } diff --git a/admin/helpers/compiler/f_Infusion.php b/admin/helpers/compiler/f_Infusion.php index 1447d0851..8ec7bad42 100644 --- a/admin/helpers/compiler/f_Infusion.php +++ b/admin/helpers/compiler/f_Infusion.php @@ -475,7 +475,7 @@ class Infusion extends Interpretation $this->fileContentDynamic[$viewName_list][$this->hhh . 'LISTQUERY' . $this->hhh] = $this->setListQuery($viewName_single, $viewName_list); // MODELEXPORTMETHOD <<>> - $this->fileContentDynamic[$viewName_list][$this->hhh . 'MODELEXPORTMETHOD' . $this->hhh] = $this->setModelExportMethod($viewName_single, $viewName_list); + $this->fileContentDynamic[$viewName_list][$this->hhh . 'MODELEXPORTMETHOD' . $this->hhh] = $this->setGetItemsModelMethod($viewName_single, $viewName_list); // MODELEXIMPORTMETHOD <<>> $this->fileContentDynamic[$viewName_list][$this->hhh . 'CONTROLLEREXIMPORTMETHOD' . $this->hhh] = $this->setControllerEximportMethod($viewName_single, $viewName_list); diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 67025475f..f3e76868e 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -1826,7 +1826,7 @@ abstract class ComponentbuilderHelper $field = $db->loadObject(); // load the values form params $field->xml = json_decode($field->xml); - $field->type_name = self::safeString($field->type_name); + $field->type_name = self::safeTypeName($field->type_name); $load = true; // if category then name must be catid (only one per view) if ($field->type_name == 'category') @@ -6331,7 +6331,7 @@ abstract class ComponentbuilderHelper } } // check if there are any view values remaining - if (count($_result)) + if (count((array) $_result)) { $_result = json_encode($_result); $_result = array($_result); diff --git a/admin/models/admin_views.php b/admin/models/admin_views.php index 9d28f3bc6..3350860e5 100644 --- a/admin/models/admin_views.php +++ b/admin/models/admin_views.php @@ -117,9 +117,15 @@ class ComponentbuilderModelAdmin_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && JFactory::getUser()->authorise('admin_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && $user->authorise('admin_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -326,6 +332,9 @@ class ComponentbuilderModelAdmin_views extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -333,10 +342,10 @@ class ComponentbuilderModelAdmin_views extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -372,7 +381,8 @@ class ComponentbuilderModelAdmin_views extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && JFactory::getUser()->authorise('admin_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_view.access', 'com_componentbuilder.admin_view.' . (int) $item->id) && $user->authorise('admin_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/admins_custom_tabs.php b/admin/models/admins_custom_tabs.php index cd20baf6e..ac8d144bd 100644 --- a/admin/models/admins_custom_tabs.php +++ b/admin/models/admins_custom_tabs.php @@ -87,9 +87,15 @@ class ComponentbuilderModelAdmins_custom_tabs extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_custom_tabs.access', 'com_componentbuilder.admin_custom_tabs.' . (int) $item->id) && JFactory::getUser()->authorise('admin_custom_tabs.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_custom_tabs.access', 'com_componentbuilder.admin_custom_tabs.' . (int) $item->id) && $user->authorise('admin_custom_tabs.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/admins_fields.php b/admin/models/admins_fields.php index 5555c1d36..61352a12a 100644 --- a/admin/models/admins_fields.php +++ b/admin/models/admins_fields.php @@ -87,9 +87,15 @@ class ComponentbuilderModelAdmins_fields extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_fields.access', 'com_componentbuilder.admin_fields.' . (int) $item->id) && JFactory::getUser()->authorise('admin_fields.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_fields.access', 'com_componentbuilder.admin_fields.' . (int) $item->id) && $user->authorise('admin_fields.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/admins_fields_conditions.php b/admin/models/admins_fields_conditions.php index 7997768a9..9da1a1aeb 100644 --- a/admin/models/admins_fields_conditions.php +++ b/admin/models/admins_fields_conditions.php @@ -87,9 +87,15 @@ class ComponentbuilderModelAdmins_fields_conditions extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_fields_conditions.access', 'com_componentbuilder.admin_fields_conditions.' . (int) $item->id) && JFactory::getUser()->authorise('admin_fields_conditions.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_fields_conditions.access', 'com_componentbuilder.admin_fields_conditions.' . (int) $item->id) && $user->authorise('admin_fields_conditions.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/admins_fields_relations.php b/admin/models/admins_fields_relations.php index c95fa14e4..82835f409 100644 --- a/admin/models/admins_fields_relations.php +++ b/admin/models/admins_fields_relations.php @@ -87,9 +87,15 @@ class ComponentbuilderModelAdmins_fields_relations extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('admin_fields_relations.access', 'com_componentbuilder.admin_fields_relations.' . (int) $item->id) && JFactory::getUser()->authorise('admin_fields_relations.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('admin_fields_relations.access', 'com_componentbuilder.admin_fields_relations.' . (int) $item->id) && $user->authorise('admin_fields_relations.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/class_extendings.php b/admin/models/class_extendings.php index 37a3781f0..7122b54db 100644 --- a/admin/models/class_extendings.php +++ b/admin/models/class_extendings.php @@ -93,9 +93,15 @@ class ComponentbuilderModelClass_extendings extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('class_extends.access', 'com_componentbuilder.class_extends.' . (int) $item->id) && JFactory::getUser()->authorise('class_extends.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('class_extends.access', 'com_componentbuilder.class_extends.' . (int) $item->id) && $user->authorise('class_extends.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/class_methods.php b/admin/models/class_methods.php index 88964fd0b..d2a0af058 100644 --- a/admin/models/class_methods.php +++ b/admin/models/class_methods.php @@ -97,9 +97,15 @@ class ComponentbuilderModelClass_methods extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && JFactory::getUser()->authorise('class_method.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && $user->authorise('class_method.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -253,6 +259,9 @@ class ComponentbuilderModelClass_methods extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -260,10 +269,10 @@ class ComponentbuilderModelClass_methods extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -299,7 +308,8 @@ class ComponentbuilderModelClass_methods extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && JFactory::getUser()->authorise('class_method.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('class_method.access', 'com_componentbuilder.class_method.' . (int) $item->id) && $user->authorise('class_method.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/class_properties.php b/admin/models/class_properties.php index 3ee8b17ad..0237b58fe 100644 --- a/admin/models/class_properties.php +++ b/admin/models/class_properties.php @@ -97,9 +97,15 @@ class ComponentbuilderModelClass_properties extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && JFactory::getUser()->authorise('class_property.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && $user->authorise('class_property.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -253,6 +259,9 @@ class ComponentbuilderModelClass_properties extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -260,10 +269,10 @@ class ComponentbuilderModelClass_properties extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -299,7 +308,8 @@ class ComponentbuilderModelClass_properties extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && JFactory::getUser()->authorise('class_property.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('class_property.access', 'com_componentbuilder.class_property.' . (int) $item->id) && $user->authorise('class_property.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_admin_views.php b/admin/models/components_admin_views.php index 2976d7fa4..10f3bf33a 100644 --- a/admin/models/components_admin_views.php +++ b/admin/models/components_admin_views.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_admin_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_admin_views.access', 'com_componentbuilder.component_admin_views.' . (int) $item->id) && JFactory::getUser()->authorise('component_admin_views.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_admin_views.access', 'com_componentbuilder.component_admin_views.' . (int) $item->id) && $user->authorise('component_admin_views.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_config.php b/admin/models/components_config.php index 3b60bd76b..3e1dc7c6b 100644 --- a/admin/models/components_config.php +++ b/admin/models/components_config.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_config extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_config.access', 'com_componentbuilder.component_config.' . (int) $item->id) && JFactory::getUser()->authorise('component_config.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_config.access', 'com_componentbuilder.component_config.' . (int) $item->id) && $user->authorise('component_config.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_custom_admin_menus.php b/admin/models/components_custom_admin_menus.php index 6acc69b14..5437e46de 100644 --- a/admin/models/components_custom_admin_menus.php +++ b/admin/models/components_custom_admin_menus.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_custom_admin_menus extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_custom_admin_menus.access', 'com_componentbuilder.component_custom_admin_menus.' . (int) $item->id) && JFactory::getUser()->authorise('component_custom_admin_menus.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_custom_admin_menus.access', 'com_componentbuilder.component_custom_admin_menus.' . (int) $item->id) && $user->authorise('component_custom_admin_menus.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_custom_admin_views.php b/admin/models/components_custom_admin_views.php index 1a52b4847..6e4721b6b 100644 --- a/admin/models/components_custom_admin_views.php +++ b/admin/models/components_custom_admin_views.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_custom_admin_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_custom_admin_views.access', 'com_componentbuilder.component_custom_admin_views.' . (int) $item->id) && JFactory::getUser()->authorise('component_custom_admin_views.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_custom_admin_views.access', 'com_componentbuilder.component_custom_admin_views.' . (int) $item->id) && $user->authorise('component_custom_admin_views.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_dashboard.php b/admin/models/components_dashboard.php index f9785b344..247cd7ee6 100644 --- a/admin/models/components_dashboard.php +++ b/admin/models/components_dashboard.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_dashboard extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_dashboard.access', 'com_componentbuilder.component_dashboard.' . (int) $item->id) && JFactory::getUser()->authorise('component_dashboard.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_dashboard.access', 'com_componentbuilder.component_dashboard.' . (int) $item->id) && $user->authorise('component_dashboard.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_files_folders.php b/admin/models/components_files_folders.php index 7288797b2..a8b47edad 100644 --- a/admin/models/components_files_folders.php +++ b/admin/models/components_files_folders.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_files_folders extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_files_folders.access', 'com_componentbuilder.component_files_folders.' . (int) $item->id) && JFactory::getUser()->authorise('component_files_folders.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_files_folders.access', 'com_componentbuilder.component_files_folders.' . (int) $item->id) && $user->authorise('component_files_folders.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_mysql_tweaks.php b/admin/models/components_mysql_tweaks.php index cba16c7ed..4dd13eaf4 100644 --- a/admin/models/components_mysql_tweaks.php +++ b/admin/models/components_mysql_tweaks.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_mysql_tweaks extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_mysql_tweaks.access', 'com_componentbuilder.component_mysql_tweaks.' . (int) $item->id) && JFactory::getUser()->authorise('component_mysql_tweaks.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_mysql_tweaks.access', 'com_componentbuilder.component_mysql_tweaks.' . (int) $item->id) && $user->authorise('component_mysql_tweaks.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_placeholders.php b/admin/models/components_placeholders.php index 6dd0fdbce..f1968bb25 100644 --- a/admin/models/components_placeholders.php +++ b/admin/models/components_placeholders.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_placeholders extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_placeholders.access', 'com_componentbuilder.component_placeholders.' . (int) $item->id) && JFactory::getUser()->authorise('component_placeholders.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_placeholders.access', 'com_componentbuilder.component_placeholders.' . (int) $item->id) && $user->authorise('component_placeholders.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_plugins.php b/admin/models/components_plugins.php index 60ab04568..e7bbc86f7 100644 --- a/admin/models/components_plugins.php +++ b/admin/models/components_plugins.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_plugins extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_plugins.access', 'com_componentbuilder.component_plugins.' . (int) $item->id) && JFactory::getUser()->authorise('component_plugins.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_plugins.access', 'com_componentbuilder.component_plugins.' . (int) $item->id) && $user->authorise('component_plugins.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_site_views.php b/admin/models/components_site_views.php index 518e8dea8..7e46bebb3 100644 --- a/admin/models/components_site_views.php +++ b/admin/models/components_site_views.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_site_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_site_views.access', 'com_componentbuilder.component_site_views.' . (int) $item->id) && JFactory::getUser()->authorise('component_site_views.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_site_views.access', 'com_componentbuilder.component_site_views.' . (int) $item->id) && $user->authorise('component_site_views.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/components_updates.php b/admin/models/components_updates.php index 3e97a94ad..51c9019cb 100644 --- a/admin/models/components_updates.php +++ b/admin/models/components_updates.php @@ -87,9 +87,15 @@ class ComponentbuilderModelComponents_updates extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('component_updates.access', 'com_componentbuilder.component_updates.' . (int) $item->id) && JFactory::getUser()->authorise('component_updates.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('component_updates.access', 'com_componentbuilder.component_updates.' . (int) $item->id) && $user->authorise('component_updates.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/custom_admin_views.php b/admin/models/custom_admin_views.php index 2e928d801..c2d4dfccc 100644 --- a/admin/models/custom_admin_views.php +++ b/admin/models/custom_admin_views.php @@ -109,9 +109,15 @@ class ComponentbuilderModelCustom_admin_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && JFactory::getUser()->authorise('custom_admin_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && $user->authorise('custom_admin_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -267,6 +273,9 @@ class ComponentbuilderModelCustom_admin_views extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -274,10 +283,10 @@ class ComponentbuilderModelCustom_admin_views extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -313,7 +322,8 @@ class ComponentbuilderModelCustom_admin_views extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && JFactory::getUser()->authorise('custom_admin_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('custom_admin_view.access', 'com_componentbuilder.custom_admin_view.' . (int) $item->id) && $user->authorise('custom_admin_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/custom_codes.php b/admin/models/custom_codes.php index d2be51bb2..ff318b1e5 100644 --- a/admin/models/custom_codes.php +++ b/admin/models/custom_codes.php @@ -105,9 +105,15 @@ class ComponentbuilderModelCustom_codes extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && JFactory::getUser()->authorise('custom_code.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && $user->authorise('custom_code.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -300,6 +306,9 @@ class ComponentbuilderModelCustom_codes extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -307,10 +316,10 @@ class ComponentbuilderModelCustom_codes extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -346,7 +355,8 @@ class ComponentbuilderModelCustom_codes extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && JFactory::getUser()->authorise('custom_code.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('custom_code.access', 'com_componentbuilder.custom_code.' . (int) $item->id) && $user->authorise('custom_code.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/dynamic_gets.php b/admin/models/dynamic_gets.php index fade3ed2f..18cc8be8c 100644 --- a/admin/models/dynamic_gets.php +++ b/admin/models/dynamic_gets.php @@ -97,9 +97,15 @@ class ComponentbuilderModelDynamic_gets extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && JFactory::getUser()->authorise('dynamic_get.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && $user->authorise('dynamic_get.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -250,6 +256,9 @@ class ComponentbuilderModelDynamic_gets extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -257,10 +266,10 @@ class ComponentbuilderModelDynamic_gets extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -296,7 +305,8 @@ class ComponentbuilderModelDynamic_gets extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && JFactory::getUser()->authorise('dynamic_get.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('dynamic_get.access', 'com_componentbuilder.dynamic_get.' . (int) $item->id) && $user->authorise('dynamic_get.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/fields.php b/admin/models/fields.php index 8083bb364..19f1f8165 100644 --- a/admin/models/fields.php +++ b/admin/models/fields.php @@ -121,9 +121,15 @@ class ComponentbuilderModelFields extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && JFactory::getUser()->authorise('field.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -365,6 +371,9 @@ class ComponentbuilderModelFields extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -372,10 +381,10 @@ class ComponentbuilderModelFields extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -411,7 +420,8 @@ class ComponentbuilderModelFields extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && JFactory::getUser()->authorise('field.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index 07f155050..ad7e135ae 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -267,9 +267,15 @@ class ComponentbuilderModelFieldtype extends JModelAdmin // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && JFactory::getUser()->authorise('field.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('field.access', 'com_componentbuilder.field.' . (int) $item->id) && $user->authorise('field.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/fieldtypes.php b/admin/models/fieldtypes.php index e810a9be6..31938f718 100644 --- a/admin/models/fieldtypes.php +++ b/admin/models/fieldtypes.php @@ -105,9 +105,15 @@ class ComponentbuilderModelFieldtypes extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && JFactory::getUser()->authorise('fieldtype.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && $user->authorise('fieldtype.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -219,6 +225,9 @@ class ComponentbuilderModelFieldtypes extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -226,10 +235,10 @@ class ComponentbuilderModelFieldtypes extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -265,7 +274,8 @@ class ComponentbuilderModelFieldtypes extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && JFactory::getUser()->authorise('fieldtype.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('fieldtype.access', 'com_componentbuilder.fieldtype.' . (int) $item->id) && $user->authorise('fieldtype.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/help_documents.php b/admin/models/help_documents.php index 2f3095dab..55cc41f0b 100644 --- a/admin/models/help_documents.php +++ b/admin/models/help_documents.php @@ -105,9 +105,15 @@ class ComponentbuilderModelHelp_documents extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && JFactory::getUser()->authorise('help_document.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -118,21 +124,12 @@ class ComponentbuilderModelHelp_documents extends JModelList $groupsArray = json_decode($item->groups, true); if (ComponentbuilderHelper::checkArray($groupsArray)) { - $groupsNames = ''; - $counter = 0; + $groupsNames = array(); foreach ($groupsArray as $groups) { - if ($counter == 0) - { - $groupsNames .= ComponentbuilderHelper::getGroupName($groups); - } - else - { - $groupsNames .= ', '.ComponentbuilderHelper::getGroupName($groups); - } - $counter++; + $groupsNames[] = ComponentbuilderHelper::getGroupName($groups); } - $item->groups = $groupsNames; + $item->groups = implode(', ', $groupsNames); } } } @@ -271,6 +268,9 @@ class ComponentbuilderModelHelp_documents extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -278,10 +278,10 @@ class ComponentbuilderModelHelp_documents extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -311,7 +311,8 @@ class ComponentbuilderModelHelp_documents extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && JFactory::getUser()->authorise('help_document.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('help_document.access', 'com_componentbuilder.help_document.' . (int) $item->id) && $user->authorise('help_document.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/joomla_components.php b/admin/models/joomla_components.php index b750ba375..ae86e3a73 100644 --- a/admin/models/joomla_components.php +++ b/admin/models/joomla_components.php @@ -2035,9 +2035,15 @@ class ComponentbuilderModelJoomla_components extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -2135,6 +2141,9 @@ class ComponentbuilderModelJoomla_components extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -2142,10 +2151,10 @@ class ComponentbuilderModelJoomla_components extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -2186,7 +2195,8 @@ class ComponentbuilderModelJoomla_components extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/joomla_plugins.php b/admin/models/joomla_plugins.php index 86d9d6107..8f43e81e8 100644 --- a/admin/models/joomla_plugins.php +++ b/admin/models/joomla_plugins.php @@ -276,9 +276,15 @@ class ComponentbuilderModelJoomla_plugins extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_plugin.access', 'com_componentbuilder.joomla_plugin.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_plugin.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin.access', 'com_componentbuilder.joomla_plugin.' . (int) $item->id) && $user->authorise('joomla_plugin.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/joomla_plugins_files_folders_urls.php b/admin/models/joomla_plugins_files_folders_urls.php index 629c7fe83..6ae90bb80 100644 --- a/admin/models/joomla_plugins_files_folders_urls.php +++ b/admin/models/joomla_plugins_files_folders_urls.php @@ -87,9 +87,15 @@ class ComponentbuilderModelJoomla_plugins_files_folders_urls extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder.joomla_plugin_files_folders_urls.' . (int) $item->id) && $user->authorise('joomla_plugin_files_folders_urls.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/joomla_plugins_updates.php b/admin/models/joomla_plugins_updates.php index 2e595bd74..e9dd08b62 100644 --- a/admin/models/joomla_plugins_updates.php +++ b/admin/models/joomla_plugins_updates.php @@ -87,9 +87,15 @@ class ComponentbuilderModelJoomla_plugins_updates extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_plugin_updates.access', 'com_componentbuilder.joomla_plugin_updates.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_plugin_updates.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_plugin_updates.access', 'com_componentbuilder.joomla_plugin_updates.' . (int) $item->id) && $user->authorise('joomla_plugin_updates.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/language_translations.php b/admin/models/language_translations.php index 42c6afea2..3cc6f7f38 100644 --- a/admin/models/language_translations.php +++ b/admin/models/language_translations.php @@ -89,9 +89,15 @@ class ComponentbuilderModelLanguage_translations extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && JFactory::getUser()->authorise('language_translation.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && $user->authorise('language_translation.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -268,6 +274,9 @@ class ComponentbuilderModelLanguage_translations extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -275,10 +284,10 @@ class ComponentbuilderModelLanguage_translations extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -314,7 +323,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && JFactory::getUser()->authorise('language_translation.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('language_translation.access', 'com_componentbuilder.language_translation.' . (int) $item->id) && $user->authorise('language_translation.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/languages.php b/admin/models/languages.php index 799112a9f..59636a80c 100644 --- a/admin/models/languages.php +++ b/admin/models/languages.php @@ -216,9 +216,15 @@ class ComponentbuilderModelLanguages extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && JFactory::getUser()->authorise('language.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && $user->authorise('language.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -306,6 +312,9 @@ class ComponentbuilderModelLanguages extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -313,10 +322,10 @@ class ComponentbuilderModelLanguages extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -352,7 +361,8 @@ class ComponentbuilderModelLanguages extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && JFactory::getUser()->authorise('language.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('language.access', 'com_componentbuilder.language.' . (int) $item->id) && $user->authorise('language.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/layouts.php b/admin/models/layouts.php index c6144becf..d27f7b1cf 100644 --- a/admin/models/layouts.php +++ b/admin/models/layouts.php @@ -101,9 +101,15 @@ class ComponentbuilderModelLayouts extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && JFactory::getUser()->authorise('layout.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && $user->authorise('layout.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -239,6 +245,9 @@ class ComponentbuilderModelLayouts extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -246,10 +255,10 @@ class ComponentbuilderModelLayouts extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -285,7 +294,8 @@ class ComponentbuilderModelLayouts extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && JFactory::getUser()->authorise('layout.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('layout.access', 'com_componentbuilder.layout.' . (int) $item->id) && $user->authorise('layout.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/libraries.php b/admin/models/libraries.php index 6c08fd585..e9b5a8215 100644 --- a/admin/models/libraries.php +++ b/admin/models/libraries.php @@ -101,17 +101,23 @@ class ComponentbuilderModelLibraries extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('library.access', 'com_componentbuilder.library.' . (int) $item->id) && JFactory::getUser()->authorise('library.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('library.access', 'com_componentbuilder.library.' . (int) $item->id) && $user->authorise('library.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); continue; } - // convert how - $item->how = $this->selectionTranslation($item->how, 'how'); + // convert how + $item->how = $this->selectionTranslation($item->how, 'how'); } diff --git a/admin/models/libraries_config.php b/admin/models/libraries_config.php index e7730e88d..a3a66eb24 100644 --- a/admin/models/libraries_config.php +++ b/admin/models/libraries_config.php @@ -87,9 +87,15 @@ class ComponentbuilderModelLibraries_config extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $item->id) && JFactory::getUser()->authorise('library_config.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $item->id) && $user->authorise('library_config.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/libraries_files_folders_urls.php b/admin/models/libraries_files_folders_urls.php index dc87d306e..d75effd77 100644 --- a/admin/models/libraries_files_folders_urls.php +++ b/admin/models/libraries_files_folders_urls.php @@ -87,9 +87,15 @@ class ComponentbuilderModelLibraries_files_folders_urls extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $item->id) && JFactory::getUser()->authorise('library_files_folders_urls.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $item->id) && $user->authorise('library_files_folders_urls.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/placeholders.php b/admin/models/placeholders.php index de2ccf7dd..7f80e7cf0 100644 --- a/admin/models/placeholders.php +++ b/admin/models/placeholders.php @@ -93,9 +93,15 @@ class ComponentbuilderModelPlaceholders extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && JFactory::getUser()->authorise('placeholder.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && $user->authorise('placeholder.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -185,6 +191,9 @@ class ComponentbuilderModelPlaceholders extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -192,10 +201,10 @@ class ComponentbuilderModelPlaceholders extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -231,7 +240,8 @@ class ComponentbuilderModelPlaceholders extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && JFactory::getUser()->authorise('placeholder.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('placeholder.access', 'com_componentbuilder.placeholder.' . (int) $item->id) && $user->authorise('placeholder.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/server.php b/admin/models/server.php index c54490f3b..b0b8b76c9 100644 --- a/admin/models/server.php +++ b/admin/models/server.php @@ -247,9 +247,15 @@ class ComponentbuilderModelServer extends JModelAdmin // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && JFactory::getUser()->authorise('joomla_component.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('joomla_component.access', 'com_componentbuilder.joomla_component.' . (int) $item->id) && $user->authorise('joomla_component.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/servers.php b/admin/models/servers.php index 5b3bfc6bb..4b7a9ae41 100644 --- a/admin/models/servers.php +++ b/admin/models/servers.php @@ -93,9 +93,15 @@ class ComponentbuilderModelServers extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && JFactory::getUser()->authorise('server.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && $user->authorise('server.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -228,6 +234,9 @@ class ComponentbuilderModelServers extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -235,10 +244,10 @@ class ComponentbuilderModelServers extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -279,7 +288,8 @@ class ComponentbuilderModelServers extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && JFactory::getUser()->authorise('server.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('server.access', 'com_componentbuilder.server.' . (int) $item->id) && $user->authorise('server.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/site_views.php b/admin/models/site_views.php index 7e23497a6..bb52770e8 100644 --- a/admin/models/site_views.php +++ b/admin/models/site_views.php @@ -113,9 +113,15 @@ class ComponentbuilderModelSite_views extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && JFactory::getUser()->authorise('site_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && $user->authorise('site_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -271,6 +277,9 @@ class ComponentbuilderModelSite_views extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -278,10 +287,10 @@ class ComponentbuilderModelSite_views extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -317,7 +326,8 @@ class ComponentbuilderModelSite_views extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && JFactory::getUser()->authorise('site_view.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('site_view.access', 'com_componentbuilder.site_view.' . (int) $item->id) && $user->authorise('site_view.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/snippet_types.php b/admin/models/snippet_types.php index 4764f5896..6de53c1d6 100644 --- a/admin/models/snippet_types.php +++ b/admin/models/snippet_types.php @@ -93,9 +93,15 @@ class ComponentbuilderModelSnippet_types extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('snippet_type.access', 'com_componentbuilder.snippet_type.' . (int) $item->id) && JFactory::getUser()->authorise('snippet_type.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('snippet_type.access', 'com_componentbuilder.snippet_type.' . (int) $item->id) && $user->authorise('snippet_type.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/snippets.php b/admin/models/snippets.php index cae5329f7..8fb1c5c65 100644 --- a/admin/models/snippets.php +++ b/admin/models/snippets.php @@ -219,9 +219,15 @@ class ComponentbuilderModelSnippets extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && JFactory::getUser()->authorise('snippet.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && $user->authorise('snippet.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -327,6 +333,9 @@ class ComponentbuilderModelSnippets extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -334,10 +343,10 @@ class ComponentbuilderModelSnippets extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -373,7 +382,8 @@ class ComponentbuilderModelSnippets extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && JFactory::getUser()->authorise('snippet.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('snippet.access', 'com_componentbuilder.snippet.' . (int) $item->id) && $user->authorise('snippet.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/templates.php b/admin/models/templates.php index c9696442d..5740d07c8 100644 --- a/admin/models/templates.php +++ b/admin/models/templates.php @@ -101,9 +101,15 @@ class ComponentbuilderModelTemplates extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && JFactory::getUser()->authorise('template.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && $user->authorise('template.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -239,6 +245,9 @@ class ComponentbuilderModelTemplates extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -246,10 +255,10 @@ class ComponentbuilderModelTemplates extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -285,7 +294,8 @@ class ComponentbuilderModelTemplates extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && JFactory::getUser()->authorise('template.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('template.access', 'com_componentbuilder.template.' . (int) $item->id) && $user->authorise('template.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/models/validation_rules.php b/admin/models/validation_rules.php index cc1a7e768..b932d8cf5 100644 --- a/admin/models/validation_rules.php +++ b/admin/models/validation_rules.php @@ -93,9 +93,15 @@ class ComponentbuilderModelValidation_rules extends JModelList // set values to display correctly. if (ComponentbuilderHelper::checkArray($items)) { + // Get the user object if not set. + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && JFactory::getUser()->authorise('validation_rule.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && $user->authorise('validation_rule.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); @@ -183,6 +189,9 @@ class ComponentbuilderModelValidation_rules extends JModelList /** * Method to get list export data. * + * @param array $pks The ids of the items to get + * @param JUser $user The user making the request + * * @return mixed An array of data items on success, false on failure. */ public function getExportData($pks, $user = null) @@ -190,10 +199,10 @@ class ComponentbuilderModelValidation_rules extends JModelList // setup the query if (ComponentbuilderHelper::checkArray($pks)) { - // Set a value to know this is exporting method. (USE IN CUSTOM CODE TO ALTER OUTCOME) + // Set a value to know this is export method. (USE IN CUSTOM CODE TO ALTER OUTCOME) $_export = true; // Get the user object if not set. - if (ComponentbuilderHelper::checkObject($user)) + if (!isset($user) || !ComponentbuilderHelper::checkObject($user)) { $user = JFactory::getUser(); } @@ -229,7 +238,8 @@ class ComponentbuilderModelValidation_rules extends JModelList { foreach ($items as $nr => &$item) { - $access = (JFactory::getUser()->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && JFactory::getUser()->authorise('validation_rule.access', 'com_componentbuilder')); + // Remove items the user can't access. + $access = ($user->authorise('validation_rule.access', 'com_componentbuilder.validation_rule.' . (int) $item->id) && $user->authorise('validation_rule.access', 'com_componentbuilder')); if (!$access) { unset($items[$nr]); diff --git a/admin/views/compiler/view.html.php b/admin/views/compiler/view.html.php index 25579ac97..547c2f7c9 100644 --- a/admin/views/compiler/view.html.php +++ b/admin/views/compiler/view.html.php @@ -53,7 +53,7 @@ class ComponentbuilderViewCompiler extends JViewLegacy // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new Exception(implode(PHP_EOL, $errors), 500); } parent::display($tpl); diff --git a/admin/views/get_snippets/view.html.php b/admin/views/get_snippets/view.html.php index 245f8d23f..2c291b66a 100644 --- a/admin/views/get_snippets/view.html.php +++ b/admin/views/get_snippets/view.html.php @@ -44,7 +44,7 @@ class ComponentbuilderViewGet_snippets extends JViewLegacy // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new Exception(implode(PHP_EOL, $errors), 500); } parent::display($tpl); diff --git a/componentbuilder.xml b/componentbuilder.xml index 742f61104..96a884659 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 4th September, 2019 + 5th September, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 89aefba5c..8f46b31e8 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -1826,7 +1826,7 @@ abstract class ComponentbuilderHelper $field = $db->loadObject(); // load the values form params $field->xml = json_decode($field->xml); - $field->type_name = self::safeString($field->type_name); + $field->type_name = self::safeTypeName($field->type_name); $load = true; // if category then name must be catid (only one per view) if ($field->type_name == 'category') @@ -5601,7 +5601,7 @@ abstract class ComponentbuilderHelper } } // check if there are any view values remaining - if (count($_result)) + if (count((array) $_result)) { $_result = json_encode($_result); $_result = array($_result); diff --git a/site/views/api/view.html.php b/site/views/api/view.html.php index 1260f7d3b..ac89d9ebd 100644 --- a/site/views/api/view.html.php +++ b/site/views/api/view.html.php @@ -40,7 +40,7 @@ class ComponentbuilderViewApi extends JViewLegacy // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new Exception(implode(PHP_EOL, $errors), 500); } parent::display($tpl);