From 6c4bab5ea95f872100d6c0955c5f31ce22c95e17 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 29 Oct 2018 18:38:00 +0200 Subject: [PATCH] Resolved gh-323 so we can load fields only in the linked or admin list views or in both. Added the option to also add permission to access fields. Improved the checkArray method to return arry count value. Fixed issue in field permissions when the value is and array, field type can not be made hidden, but should instead just be removed. Fixed an issue in the code search methods to insure all areas are looked at, and search and export. --- README.md | 4 +- admin/README.txt | 4 +- admin/compiler/joomla_3/Helper.php | 6 +- admin/compiler/joomla_3/Helper_site.php | 6 +- admin/compiler/joomla_3/JTable.php | 2 +- admin/controllers/admin_view.php | 3 +- admin/helpers/compiler/a_Get.php | 238 +++++++++-------- admin/helpers/compiler/c_Fields.php | 27 +- admin/helpers/compiler/e_Interpretation.php | 239 ++++++++++++------ admin/helpers/componentbuilder.php | 38 ++- .../en-GB/en-GB.com_componentbuilder.ini | 10 +- admin/models/admin_view.php | 6 +- admin/models/ajax.php | 64 ++--- admin/models/fields/dbtables.php | 38 +-- admin/models/fieldtype.php | 5 +- admin/models/forms/admin_fields.xml | 6 +- admin/models/forms/admin_view.xml | 4 + admin/models/forms/custom_code.js | 7 +- admin/models/forms/dynamic_get.xml | 2 - admin/models/joomla_components.php | 78 +++--- admin/sql/install.mysql.utf8.sql | 4 +- admin/tables/admin_custom_tabs.php | 2 +- admin/tables/admin_fields.php | 2 +- admin/tables/admin_fields_conditions.php | 2 +- admin/tables/admin_fields_relations.php | 2 +- admin/tables/admin_view.php | 2 +- admin/tables/component_admin_views.php | 2 +- admin/tables/component_config.php | 2 +- admin/tables/component_custom_admin_menus.php | 2 +- admin/tables/component_custom_admin_views.php | 2 +- admin/tables/component_dashboard.php | 2 +- admin/tables/component_files_folders.php | 2 +- admin/tables/component_mysql_tweaks.php | 2 +- admin/tables/component_site_views.php | 2 +- admin/tables/component_updates.php | 2 +- admin/tables/custom_admin_view.php | 2 +- admin/tables/custom_code.php | 2 +- admin/tables/dynamic_get.php | 2 +- admin/tables/field.php | 2 +- admin/tables/fieldtype.php | 2 +- admin/tables/help_document.php | 2 +- admin/tables/joomla_component.php | 2 +- admin/tables/language.php | 2 +- admin/tables/language_translation.php | 2 +- admin/tables/layout.php | 2 +- admin/tables/library.php | 2 +- admin/tables/library_config.php | 2 +- admin/tables/library_files_folders_urls.php | 2 +- admin/tables/server.php | 2 +- admin/tables/site_view.php | 2 +- admin/tables/snippet.php | 2 +- admin/tables/snippet_type.php | 2 +- admin/tables/template.php | 2 +- admin/tables/validation_rule.php | 2 +- admin/views/admin_fields/tmpl/edit.php | 10 +- admin/views/admin_fields/view.html.php | 4 +- componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 38 ++- 58 files changed, 556 insertions(+), 355 deletions(-) diff --git a/README.md b/README.md index 3f09e23ff..c9e36b7b2 100644 --- a/README.md +++ b/README.md @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 7th October, 2018 ++ *Last Build*: 29th October, 2018 + *Version*: 2.9.7 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195701** ++ *Line count*: **195735** + *Field count*: **1087** + *File count*: **1277** + *Folder count*: **201** diff --git a/admin/README.txt b/admin/README.txt index 3f09e23ff..c9e36b7b2 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -125,11 +125,11 @@ Watch the [proposed development workflow](https://vdm.bz/proposed-development-wo + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 7th October, 2018 ++ *Last Build*: 29th October, 2018 + *Version*: 2.9.7 + *Copyright*: Copyright (C) 2015 - 2018 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **195701** ++ *Line count*: **195735** + *Field count*: **1087** + *File count*: **1277** + *Folder count*: **201** diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index 2913f37da..854e96267 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -854,11 +854,11 @@ abstract class ###Component###Helper * * @input array The array to check * - * @returns bool true on success + * @returns bool/int number of items in array on success **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count((array)$array) > 0) + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -872,7 +872,7 @@ abstract class ###Component###Helper } return self::checkArray($array, false); } - return true; + return $nr; } return false; } diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index db1f8c8f1..ae2ce5aad 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -846,11 +846,11 @@ abstract class ###Component###Helper * * @input array The array to check * - * @returns bool true on success + * @returns bool/int number of items in array on success **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count((array)$array) > 0) + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -864,7 +864,7 @@ abstract class ###Component###Helper } return self::checkArray($array, false); } - return true; + return $nr; } return false; } diff --git a/admin/compiler/joomla_3/JTable.php b/admin/compiler/joomla_3/JTable.php index 061b1410d..73304bb31 100644 --- a/admin/compiler/joomla_3/JTable.php +++ b/admin/compiler/joomla_3/JTable.php @@ -222,7 +222,7 @@ class ###Component###Table###View### extends JTable { // asset alread set so use saved rules $assetId = (int) $db->loadResult(); - return JAccess::getAssetRules($assetId); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) diff --git a/admin/controllers/admin_view.php b/admin/controllers/admin_view.php index d58bda581..f787a500f 100644 --- a/admin/controllers/admin_view.php +++ b/admin/controllers/admin_view.php @@ -328,7 +328,8 @@ class ComponentbuilderControllerAdmin_view extends JControllerForm $_tablesArray = array( 'admin_fields', 'admin_fields_conditions', - 'admin_fields_relations' + 'admin_fields_relations', + 'admin_custom_tabs' ); foreach($_tablesArray as $_updateTable) { diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index aa9873fae..b31869445 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -2713,7 +2713,7 @@ class Get return $field['type_name']; } // check that we have the poperties - if (ComponentbuilderHelper::checkArray($field['settings']->properties)) + if (isset($field['settings']) && ComponentbuilderHelper::checkObject($field['settings']) && isset($field['settings']->properties) && ComponentbuilderHelper::checkArray($field['settings']->properties)) { // search for own custom fields if (strpos($field['settings']->type_name, '@') !== false) @@ -4316,139 +4316,155 @@ class Get $counter = 'a'; // Create a new query object. $query = $this->db->getQuery(true); + // switch to onlu trigger the run of the query if we have tables to query + $runQuery = false; foreach ($tables as $table) { - if ($counter === 'a') + if (isset($table['table'])) { - // the main table fields - if (strpos($table['sourcemap'], PHP_EOL) !== false) + if ($counter === 'a') { - $fields = explode(PHP_EOL, $table['sourcemap']); - if (ComponentbuilderHelper::checkArray($fields)) + // the main table fields + if (strpos($table['sourcemap'], PHP_EOL) !== false) { - // reset array buckets - $sourceArray = array(); - $targetArray = array(); - foreach ($fields as $field) + $fields = explode(PHP_EOL, $table['sourcemap']); + if (ComponentbuilderHelper::checkArray($fields)) { - if (strpos($field, "=>") !== false) + // reset array buckets + $sourceArray = array(); + $targetArray = array(); + foreach ($fields as $field) { - list($source, $target) = explode("=>", $field); - $sourceArray[] = $counter . '.' . trim($source); - $targetArray[] = trim($target); + if (strpos($field, "=>") !== false) + { + list($source, $target) = explode("=>", $field); + $sourceArray[] = $counter . '.' . trim($source); + $targetArray[] = trim($target); + } } - } - if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray)) - { - // add to query - $query->select($this->db->quoteName($sourceArray, $targetArray)); - $query->from('#__' . $table['table'] . ' AS a'); - } - // we may need to filter the selection - if (isset($this->sqlTweak[$view_id]['where'])) - { - // add to query the where filter - $query->where('a.id IN (' . $this->sqlTweak[$view_id]['where'] . ')'); - } - } - } - } - else - { - // the other tables - if (strpos($table['sourcemap'], PHP_EOL) !== false) - { - $fields = explode(PHP_EOL, $table['sourcemap']); - if (ComponentbuilderHelper::checkArray($fields)) - { - // reset array buckets - $sourceArray = array(); - $targetArray = array(); - foreach ($fields as $field) - { - if (strpos($field, "=>") !== false) + if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray)) { - list($source, $target) = explode("=>", $field); - $sourceArray[] = $counter . '.' . trim($source); - $targetArray[] = trim($target); - } - if (strpos($field, "==") !== false) - { - list($aKey, $bKey) = explode("==", $field); // add to query - $query->join('LEFT', $this->db->quoteName('#__' . $table['table'], $counter) . ' ON (' . $this->db->quoteName('a.' . trim($aKey)) . ' = ' . $this->db->quoteName($counter . '.' . trim($bKey)) . ')'); + $query->select($this->db->quoteName($sourceArray, $targetArray)); + $query->from('#__' . $table['table'] . ' AS a'); + $runQuery = true; + } + // we may need to filter the selection + if (isset($this->sqlTweak[$view_id]['where'])) + { + // add to query the where filter + $query->where('a.id IN (' . $this->sqlTweak[$view_id]['where'] . ')'); } } - if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray)) - { - // add to query - $query->select($this->db->quoteName($sourceArray, $targetArray)); - } } } - } - $counter++; - } - // now get the data - $this->db->setQuery($query); - $this->db->execute(); - if ($this->db->getNumRows()) - { - // get the data - $data = $this->db->loadObjectList(); - // start building the MySql dump - $dump = "--"; - $dump .= PHP_EOL . "-- Dumping data for table `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "`"; - $dump .= PHP_EOL . "--"; - $dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "` ("; - foreach ($data as $line) - { - $comaSet = 0; - foreach ($line as $fieldName => $fieldValue) - { - if ($comaSet == 0) - { - $dump .= $this->db->quoteName($fieldName); - } - else - { - $dump .= ", " . $this->db->quoteName($fieldName); - } - $comaSet++; - } - break; - } - $dump .= ") VALUES"; - $coma = 0; - foreach ($data as $line) - { - if ($coma == 0) - { - $dump .= PHP_EOL . "("; - } else { - $dump .= "," . PHP_EOL . "("; - } - $comaSet = 0; - foreach ($line as $fieldName => $fieldValue) - { - if ($comaSet == 0) + // the other tables + if (strpos($table['sourcemap'], PHP_EOL) !== false) { - $dump .= $this->mysql_escape($fieldValue); + $fields = explode(PHP_EOL, $table['sourcemap']); + if (ComponentbuilderHelper::checkArray($fields)) + { + // reset array buckets + $sourceArray = array(); + $targetArray = array(); + foreach ($fields as $field) + { + if (strpos($field, "=>") !== false) + { + list($source, $target) = explode("=>", $field); + $sourceArray[] = $counter . '.' . trim($source); + $targetArray[] = trim($target); + } + if (strpos($field, "==") !== false) + { + list($aKey, $bKey) = explode("==", $field); + // add to query + $query->join('LEFT', $this->db->quoteName('#__' . $table['table'], $counter) . ' ON (' . $this->db->quoteName('a.' . trim($aKey)) . ' = ' . $this->db->quoteName($counter . '.' . trim($bKey)) . ')'); + } + } + if (ComponentbuilderHelper::checkArray($sourceArray) && ComponentbuilderHelper::checkArray($targetArray)) + { + // add to query + $query->select($this->db->quoteName($sourceArray, $targetArray)); + } + } + } + } + $counter++; + } + else + { + // see where + // var_dump($view); + // jexit(); + } + } + // check if we should run query + if ($runQuery) + { + // now get the data + $this->db->setQuery($query); + $this->db->execute(); + if ($this->db->getNumRows()) + { + // get the data + $data = $this->db->loadObjectList(); + // start building the MySql dump + $dump = "--"; + $dump .= PHP_EOL . "-- Dumping data for table `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "`"; + $dump .= PHP_EOL . "--"; + $dump .= PHP_EOL . PHP_EOL . "INSERT INTO `#__" . $this->bbb . "component" . $this->ddd . "_" . $view . "` ("; + foreach ($data as $line) + { + $comaSet = 0; + foreach ($line as $fieldName => $fieldValue) + { + if ($comaSet == 0) + { + $dump .= $this->db->quoteName($fieldName); + } + else + { + $dump .= ", " . $this->db->quoteName($fieldName); + } + $comaSet++; + } + break; + } + $dump .= ") VALUES"; + $coma = 0; + foreach ($data as $line) + { + if ($coma == 0) + { + $dump .= PHP_EOL . "("; } else { - $dump .= ", " . $this->mysql_escape($fieldValue); + $dump .= "," . PHP_EOL . "("; } - $comaSet++; + $comaSet = 0; + foreach ($line as $fieldName => $fieldValue) + { + if ($comaSet == 0) + { + $dump .= $this->mysql_escape($fieldValue); + } + else + { + $dump .= ", " . $this->mysql_escape($fieldValue); + } + $comaSet++; + } + $dump .= ")"; + $coma++; } - $dump .= ")"; - $coma++; + $dump .= ";"; + // return build dump query + return $dump; } - $dump .= ";"; - // return build dump query - return $dump; } } return false; diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 9a31387ff..c45d28f8c 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -2107,6 +2107,8 @@ class Fields extends Structure // setup a default field if (ComponentbuilderHelper::checkArray($field['settings']->properties)) { + // we need a deeper php code search tracker + $phpTracker = array(); foreach ($field['settings']->properties as $property) { // reset @@ -2155,6 +2157,8 @@ class Fields extends Structure $this->setDynamicValues(ComponentbuilderHelper::openValidBase64( ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"') )); + // load tracker + $phpTracker['type_' . $phpKey] = $phpKey; } elseif ($property['name'] === 'prime_php' && $setCustom) { @@ -2338,6 +2342,24 @@ class Fields extends Structure $fieldAttributes['default'] = $xmlValue; } } + // check if all php is loaded using the tracker + if (ComponentbuilderHelper::checkArray($phpTracker)) + { + // litle search validation + $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; + foreach ($phpTracker as $searchKey => $phpKey) + { + // we must search for more code in the xml just incase + foreach(range(2, 30) as $phpLine) + { + $get_ = $searchKey . '_' . $phpLine; + if (!isset($fieldAttributes['custom'][$phpKey][$phpLine]) && ($value = ComponentbuilderHelper::getValueFromXMLstring($field['settings']->xml, $get_, $confirmation)) !== $confirmation) + { + $fieldAttributes['custom'][$phpKey][$phpLine] = $this->setDynamicValues(ComponentbuilderHelper::openValidBase64($value)); + } + } + } + } // do some nice twigs beyond the default if (isset($fieldAttributes['name'])) { @@ -2460,7 +2482,7 @@ class Fields extends Structure } } // set list switch - $listSwitch = (isset($field['list']) && $field['list'] == 1); + $listSwitch = (isset($field['list']) && ($field['list'] == 1 || $field['list'] == 3 || $field['list'] == 4 )); // set list join $listJoin = (isset($this->listJoinBuilder[$view_name_list][(int) $field['field']])); // add history to this view @@ -2523,7 +2545,8 @@ class Fields extends Structure 'sort' => (isset($field['sort']) && $field['sort']) ? true : false, 'custom' => $custom, 'multiple' => $multiple, - 'options' => $options); + 'options' => $options, + 'target' => (int) $field['list']); } // build custom builder list if ($listSwitch || $listJoin) diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d496e21a2..53191cb53 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -4554,6 +4554,9 @@ class Interpretation extends Fields public function setMethodItemSave(&$view) { $script = ''; + // get component name + $Component = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh]; + $component = $this->fileContentStatic[$this->hhh . 'component' . $this->hhh]; // check if there was script added before modeling of data $script .= $this->getCustomScriptBuilder('php_before_save', $view, PHP_EOL . PHP_EOL); // turn array into JSON string @@ -4568,7 +4571,22 @@ class Interpretation extends Fields $script .= PHP_EOL . $this->_t(3) . "\$" . $jsonItem . "->loadArray(\$data['" . $jsonItem . "']);"; $script .= PHP_EOL . $this->_t(3) . "\$data['" . $jsonItem . "'] = (string) \$" . $jsonItem . ";"; $script .= PHP_EOL . $this->_t(2) . "}"; - $script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "']))"; + if (isset($this->permissionFields[$view]) && isset($this->permissionFields[$view][$jsonItem]) && ComponentbuilderHelper::checkArray($this->permissionFields[$view][$jsonItem])) + { + $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Also check permission since the value may be removed due to permissions"; + $script .= PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Then we do not want to clear it out, but simple ignore the empty " . $jsonItem; + $script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "'])"; + // only add permission that are available + foreach ($this->permissionFields[$view][$jsonItem] as $permission_option => $fieldType) + { + $script .= PHP_EOL . $this->_t(3) . "&& JFactory::getUser()->authorise('" . $view . "." . $permission_option . "." . $jsonItem . "', 'com_" . $component . "')"; + } + $script .= ")"; + } + else + { + $script .= PHP_EOL . $this->_t(2) . "elseif (!isset(\$data['" . $jsonItem . "']))"; + } $script .= PHP_EOL . $this->_t(2) . "{"; $script .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Set the empty " . $jsonItem . " to data"; $script .= PHP_EOL . $this->_t(3) . "\$data['" . $jsonItem . "'] = '';"; @@ -4600,7 +4618,6 @@ class Interpretation extends Fields } } // turn string into encrypted string - $Component = $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh]; foreach ($this->cryptionTypes as $cryptionType) { if (isset($this->{$cryptionType . 'EncryptionBuilder'}[$view]) && ComponentbuilderHelper::checkArray($this->{$cryptionType . 'EncryptionBuilder'}[$view])) @@ -6759,25 +6776,29 @@ class Interpretation extends Fields // start adding the dynamic foreach ($this->listBuilder[$viewName_list] as $item) { - // set some defaults - $customAdminViewButtons = ''; - // set the item default class - $itemClass = 'hidden-phone'; - // set the item row - $itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core); - // check if buttons was aready added - if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + // check if target is admin list + if (1 == $item['target'] || 3 == $item['target']) { - // get custom admin view buttons - $customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list); - // make sure the custom admin view buttons are only added once - $firstTimeBeingAdded = false; + // set some defaults + $customAdminViewButtons = ''; + // set the item default class + $itemClass = 'hidden-phone'; + // set the item row + $itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core); + // check if buttons was aready added + if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + { + // get custom admin view buttons + $customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list); + // make sure the custom admin view buttons are only added once + $firstTimeBeingAdded = false; + } + // add row to body + $body .= PHP_EOL . $this->_t(2) . "getListFieldClass($item['code'], $viewName_list, $itemClass) . "\">"; + $body .= $itemRow; + $body .= $customAdminViewButtons; + $body .= PHP_EOL . $this->_t(2) . ""; } - // add row to body - $body .= PHP_EOL . $this->_t(2) . "getListFieldClass($item['code'], $viewName_list, $itemClass) . "\">"; - $body .= $itemRow; - $body .= $customAdminViewButtons; - $body .= PHP_EOL . $this->_t(2) . ""; } // add the defaults if (!isset($this->fieldsNames[$viewName_single]['published'])) @@ -7253,30 +7274,34 @@ class Interpretation extends Fields // build the dynamic fields foreach ($this->listBuilder[$viewName_list] as $item) { - // check if we have an over-ride - if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + // check if target is admin list + if (1 == $item['target'] || 3 == $item['target']) { - $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; + // check if we have an over-ride + if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + { + $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; + } + // set the custom code + if (ComponentbuilderHelper::checkArray($item['custom'])) + { + $item['code'] = $item['code'] . '_' . $item['custom']['text']; + } + $class = 'nowrap hidden-phone'; + if ($item['link']) + { + $class = 'nowrap'; + } + $title = ""; + if ($item['sort']) + { + $title = "listDirn, \$this->listOrder); ?>"; + } + $head .= PHP_EOL . $this->_t(1) . ''; + $head .= PHP_EOL . $this->_t(3) . $title; + $head .= PHP_EOL . $this->_t(1) . ""; + $this->listColnrBuilder[$viewName_list] ++; } - // set the custom code - if (ComponentbuilderHelper::checkArray($item['custom'])) - { - $item['code'] = $item['code'] . '_' . $item['custom']['text']; - } - $class = 'nowrap hidden-phone'; - if ($item['link']) - { - $class = 'nowrap'; - } - $title = ""; - if ($item['sort']) - { - $title = "listDirn, \$this->listOrder); ?>"; - } - $head .= PHP_EOL . $this->_t(1) . ''; - $head .= PHP_EOL . $this->_t(3) . $title; - $head .= PHP_EOL . $this->_t(1) . ""; - $this->listColnrBuilder[$viewName_list] ++; } // set default if (!isset($this->fieldsNames[$viewName_single]['published'])) @@ -8212,27 +8237,31 @@ class Interpretation extends Fields // start adding the dynamic foreach ($this->listBuilder[$viewName_list] as $item) { - // set the ref - $ref = ''; - // set some defaults - $customAdminViewButtons = ''; - // set the item row - $itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, false, $ref, '$displayData->escape', '$user', $refview); - // check if buttons was aready added - if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + // check if target is linked list view + if (1 == $item['target'] || 4 == $item['target']) { - // get custom admin view buttons - $customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list, $ref); - // make sure the custom admin view buttons are only added once - $firstTimeBeingAdded = false; + // set the ref + $ref = ''; + // set some defaults + $customAdminViewButtons = ''; + // set the item row + $itemRow = $this->getListItemBuilder($item, $viewName_single, $viewName_list, $itemClass, $doNotEscape, $coreLoad, $core, false, $ref, '$displayData->escape', '$user', $refview); + // check if buttons was aready added + if ($firstTimeBeingAdded) // TODO we must improve this to allow more items to be targeted instead of just the first item :) + { + // get custom admin view buttons + $customAdminViewButtons = $this->getCustomAdminViewButtons($viewName_list, $ref); + // make sure the custom admin view buttons are only added once + $firstTimeBeingAdded = false; + } + // add row to body + $body .= PHP_EOL . $this->_t(2) . ""; + $body .= $itemRow; + $body .= $customAdminViewButtons; + $body .= PHP_EOL . $this->_t(2) . ""; + // increment counter + $counter++; } - // add row to body - $body .= PHP_EOL . $this->_t(2) . ""; - $body .= $itemRow; - $body .= $customAdminViewButtons; - $body .= PHP_EOL . $this->_t(2) . ""; - // increment counter - $counter++; } $counter = $counter + 2; $data_value = (3 == $this->footableVersion) ? 'data-sort-value' : 'data-value'; @@ -8397,31 +8426,35 @@ class Interpretation extends Fields // build the dynamic fields foreach ($this->listBuilder[$viewName_list] as $item) { - // check if we have an over-ride - if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + // check if target is linked list view + if (1 == $item['target'] || 4 == $item['target']) { - $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; - } - $setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"'; - if ($controller > 3) - { - $setin = (2 == $this->footableVersion) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"'; - } + // check if we have an over-ride + if (isset($this->listHeadOverRide[$viewName_list]) && ComponentbuilderHelper::checkArray($this->listHeadOverRide[$viewName_list]) && isset($this->listHeadOverRide[$viewName_list][$item['id']])) + { + $item['lang'] = $this->listHeadOverRide[$viewName_list][$item['id']]; + } + $setin = (2 == $this->footableVersion) ? ' data-hide="phone"' : ' data-breakpoints="xs sm"'; + if ($controller > 3) + { + $setin = (2 == $this->footableVersion) ? ' data-hide="phone,tablet"' : ' data-breakpoints="xs sm md"'; + } - if ($controller > 6) - { - $setin = (2 == $this->footableVersion) ? ' data-hide="all"' : ' data-breakpoints="all"'; - } + if ($controller > 6) + { + $setin = (2 == $this->footableVersion) ? ' data-hide="all"' : ' data-breakpoints="all"'; + } - if ($item['link'] && $firstLink) - { - $setin = (2 == $this->footableVersion) ? ' data-toggle="true"' : ''; - $firstLink = false; + if ($item['link'] && $firstLink) + { + $setin = (2 == $this->footableVersion) ? ' data-toggle="true"' : ''; + $firstLink = false; + } + $head .= PHP_EOL . $this->_t(2) . ""; + $head .= PHP_EOL . $this->_t(3) . ""; + $head .= PHP_EOL . $this->_t(2) . ""; + $controller++; } - $head .= PHP_EOL . $this->_t(2) . ""; - $head .= PHP_EOL . $this->_t(3) . ""; - $head .= PHP_EOL . $this->_t(2) . ""; - $controller++; } // set some V3 attr $data_hide = (2 == $this->footableVersion) ? 'data-hide="phone,tablet"' : 'data-breakpoints="xs sm md"'; @@ -11284,6 +11317,19 @@ class Interpretation extends Fields $allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields while saving."; $allow[] = $this->_t(3) . "\$form->setFieldAttribute('created', 'filter', 'unset');"; $allow[] = $this->_t(2) . "}"; + // check if the item has access permissions. + if ($coreLoad && isset($core['core.edit.access']) && isset($this->permissionBuilder[$core['core.edit.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.edit.access']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.edit.access']])) + { + $allow[] = $this->_t(2) . "//" . $this->setLine(__LINE__) . " Modify the form based on Edit Access 'access' controls."; + $allow[] = $this->_t(2) . "if (\$id != 0 && (!\$user->authorise('" . $core['core.edit.access'] . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$id))"; + $allow[] = $this->_t(3) . "|| (\$id == 0 && !\$user->authorise('" . $core['core.edit.access'] . "', 'com_" . $component . "')))"; + $allow[] = $this->_t(2) . "{"; + $allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields for display."; + $allow[] = $this->_t(3) . "\$form->setFieldAttribute('access', 'disabled', 'true');"; + $allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Disable fields while saving."; + $allow[] = $this->_t(3) . "\$form->setFieldAttribute('access', 'filter', 'unset');"; + $allow[] = $this->_t(2) . "}"; + } // handel the fields permissions if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single])) { @@ -11382,12 +11428,21 @@ class Interpretation extends Fields $allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " Make the field hidded."; $allow[] = $this->_t(3) . "\$form->setFieldAttribute('" . $fieldName . "', 'type', 'hidden');"; $allow[] = $this->_t(3) . "//" . $this->setLine(__LINE__) . " If there is no value continue."; - $allow[] = $this->_t(3) . "if (!\$form->getValue('" . $fieldName . "'))"; + $allow[] = $this->_t(3) . "if (!(\$val = \$form->getValue('" . $fieldName . "')))"; $allow[] = $this->_t(3) . "{"; $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Disable fields while saving."; $allow[] = $this->_t(4) . "\$form->setFieldAttribute('" . $fieldName . "', 'filter', 'unset');"; $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Disable fields while saving."; $allow[] = $this->_t(4) . "\$form->setFieldAttribute('" . $fieldName . "', 'required', 'false');"; + $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Make sure"; + $allow[] = $this->_t(4) . "\$form->setValue('" . $fieldName . "', null, '');"; + $allow[] = $this->_t(3) . "}"; + $allow[] = $this->_t(3) . "elseif (" . ucfirst($component) . "Helper::checkArray(\$val))"; + $allow[] = $this->_t(3) . "{"; + $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " We have to unset then (TODO)"; + $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Hiddend field can not handel array value"; + $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Even if we conver to json we get an error"; + $allow[] = $this->_t(4) . "\$form->removeField('" . $fieldName . "');"; $allow[] = $this->_t(3) . "}"; $allow[] = $this->_t(2) . "}"; } @@ -12336,6 +12391,8 @@ class Interpretation extends Fields // JSON_ARRAY_ENCODE $decode = 'json_decode'; $suffix_decode = ', true'; + // fallback on json + $item['method'] = 1; break; } @@ -12486,7 +12543,7 @@ class Interpretation extends Fields { if (!$export) { - // For thos we have not cached yet. + // For those we have not cached yet. $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) . "\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ");"; } @@ -15469,7 +15526,7 @@ function vdm_dkim() { // set the permission for this field $fieldView['action'] = 'view.' . $permission_option . '.' . $fieldName; $fieldView['implementation'] = '3'; - // check if persmissions was laready set + // check if persmissions was already set if (isset($view['settings']->permissions) && ComponentbuilderHelper::checkArray($view['settings']->permissions)) { array_push($view['settings']->permissions, $fieldView); @@ -15600,6 +15657,7 @@ function vdm_dkim() { $view['settings']->permissions[] = $versionView; } } + // add batch permissions if ($type === 'admin') { // set batch control @@ -15615,6 +15673,7 @@ function vdm_dkim() { $view['settings']->permissions[] = $batchView; } } + // load the permissions foreach ($view['settings']->permissions as $permission) { // set acction name @@ -15639,6 +15698,12 @@ function vdm_dkim() { array_shift($actionNameBuilder); $nameBuilder = trim(implode('___', $actionNameBuilder)); $customName = trim(implode(' ', $actionNameBuilder)); + // check if we have access set for this view (if not skip) + if ($nameBuilder === 'edit___access' && $type === 'admin' && (!isset($view['access']) || $view['access'] != 1)) + { + continue; + } + // build the names if ($type === 'admin') { $W_NameList = ComponentbuilderHelper::safeString($view['settings']->name_list, 'W'); @@ -15666,6 +15731,12 @@ function vdm_dkim() { // set edit description $permission['description'] = ' Allows the users in this group to edit ' . $w_NameList . ' created by them'; break; + case 'edit___access': + // set edit title + $permission['title'] = $W_NameList . ' Edit Access'; + // set edit description + $permission['description'] = ' Allows the users in this group to change the access of the ' . $w_NameList; + break; case 'edit___state': // set edit title $permission['title'] = $W_NameList . ' Edit State'; diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index ae86abcb3..b93caac06 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -686,6 +686,8 @@ abstract class ComponentbuilderHelper 'description' => $result->description); // number pointer $nr = 0; + // php tracker (we must try to load alteast 17 rows + $phpTracker = array(); // value to check since there are false and null values even 0 in the values returned $confirmation = '8qvZHoyuFYQqpj0YQbc6F3o5DhBlmS-_-a8pmCZfOVSfANjkmV5LG8pCdAY2JNYu6cB'; // set the headers @@ -701,6 +703,9 @@ abstract class ComponentbuilderHelper if (strpos($property['name'], 'type_php') !== false) { $addPHP = true; + // set the line number + $phpLine = (int) preg_replace('/[^0-9]/', '', $property['name']); + // set the key $phpKey = trim(preg_replace('/[0-9]+/', '', $property['name']), '_'); // start array if not already set if (!isset($field['php'][$phpKey])) @@ -708,6 +713,8 @@ abstract class ComponentbuilderHelper $field['php'][$phpKey] = array(); $field['php'][$phpKey]['value'] = array(); $field['php'][$phpKey]['desc'] = $property['description']; + // start tracker + $phpTracker[$phpKey] = 1; } } // was the settings for the property passed @@ -718,7 +725,8 @@ abstract class ComponentbuilderHelper // add the json values if ($addPHP) { - $field['php'][$phpKey]['value'][] = $settings[$property['name']]; + $field['php'][$phpKey]['value'][$phpLine] = $settings[$property['name']]; + $phpTracker[$phpKey]++; } else { @@ -732,7 +740,8 @@ abstract class ComponentbuilderHelper // add the json values if ($addPHP) { - $field['php'][$phpKey]['value'][] = ($confirmation !== $value) ? $value : $example; + $field['php'][$phpKey]['value'][$phpLine] = ($confirmation !== $value) ? $value : $example; + $phpTracker[$phpKey]++; } else { @@ -747,6 +756,25 @@ abstract class ComponentbuilderHelper // increment the number $nr++; } + // check if all php is loaded using the tracker + if (self::checkString($xml) && isset($phpTracker) && self::checkArray($phpTracker)) + { + foreach ($phpTracker as $phpKey => $start) + { + if ($start < 30) + { + // we must search for more code in the xml just incase + foreach(range(2, 30) as $t_nr) + { + $get_ = $phpKey . '_' . $t_nr; + if (!isset($field['php'][$phpKey]['value'][$t_nr]) && ($value = self::getValueFromXMLstring($xml, $get_, $confirmation)) !== $confirmation) + { + $field['php'][$phpKey]['value'][$t_nr] = $value; + } + } + } + } + } $field['values'] .= PHP_EOL . "/>"; $field['values_description'] .= ''; // return found field options @@ -5192,11 +5220,11 @@ abstract class ComponentbuilderHelper * * @input array The array to check * - * @returns bool true on success + * @returns bool/int number of items in array on success **/ public static function checkArray($array, $removeEmptyString = false) { - if (isset($array) && is_array($array) && count((array)$array) > 0) + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) { // also make sure the empty strings are removed if ($removeEmptyString) @@ -5210,7 +5238,7 @@ abstract class ComponentbuilderHelper } return self::checkArray($array, false); } - return true; + return $nr; } return false; } diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 1d75c498a..057d4adce 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -322,6 +322,8 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW="A New Admin Fields" COM_COMPONENTBUILDER_ADMIN_FIELDS_NONE_DB="None DB" COM_COMPONENTBUILDER_ADMIN_FIELDS_NOTE_ON_VIEWS_DESCRIPTION="id, asset_id, state, access, ordering, created_by, created, modified_by, modified, checked_out, checked_out_time, version, hits, metakey, metadesc, metadata (you don't need to add them again)
For more help please watch this tutorial." COM_COMPONENTBUILDER_ADMIN_FIELDS_NOTE_ON_VIEWS_LABEL="The following fields are added by default to all views." +COM_COMPONENTBUILDER_ADMIN_FIELDS_ONLY_IN_ADMIN_LIST_VIEW="Only in Admin List View" +COM_COMPONENTBUILDER_ADMIN_FIELDS_ONLY_IN_LINKED_LIST_VIEWS="Only in Linked List Views" COM_COMPONENTBUILDER_ADMIN_FIELDS_ORDERING_LABEL="Ordering" COM_COMPONENTBUILDER_ADMIN_FIELDS_ORDER_EDIT_DESCRIPTION="Order in relation to tab & alignment of admin and site." COM_COMPONENTBUILDER_ADMIN_FIELDS_ORDER_EDIT_LABEL="Order in Edit" @@ -385,7 +387,7 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_RIGHT_OF_TABS="Right of Tabs" COM_COMPONENTBUILDER_ADMIN_FIELDS_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Admin Fields to customise the alias." COM_COMPONENTBUILDER_ADMIN_FIELDS_SEARCH_DESCRIPTION="Select if the field is to be searchable in list view, if shown." COM_COMPONENTBUILDER_ADMIN_FIELDS_SEARCH_LABEL="Searchable" -COM_COMPONENTBUILDER_ADMIN_FIELDS_SHOW_IN_LIST_VIEW="Show in list view" +COM_COMPONENTBUILDER_ADMIN_FIELDS_SHOW_IN_ALL_LIST_VIEWS="Show in All List Views" COM_COMPONENTBUILDER_ADMIN_FIELDS_SORT_DESCRIPTION="Select if the field should be sortable in list view, if shown." COM_COMPONENTBUILDER_ADMIN_FIELDS_SORT_LABEL="Sortable" COM_COMPONENTBUILDER_ADMIN_FIELDS_STATUS="Status" @@ -614,6 +616,7 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_CONTRACT_TWO="Contract 2" COM_COMPONENTBUILDER_ADMIN_VIEW_CORECREATE="core.create" COM_COMPONENTBUILDER_ADMIN_VIEW_COREDELETE="core.delete" COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDIT="core.edit" +COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITACCESS="core.edit.access" COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITCREATED="core.edit.created" COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITCREATED_BY="core.edit.created_by" COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITOWN="core.edit.own" @@ -1324,6 +1327,7 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWACCESS="view.access" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWCREATE="view.create" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWDELETE="view.delete" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDIT="view.edit" +COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITACCESS="view.edit.access" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITCREATED="view.edit.created" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITCREATED_BY="view.edit.created_by" COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITOWN="view.edit.own" @@ -7016,12 +7020,14 @@ COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_CONDITIONS="The admin fields conditions" COM_COMPONENTBUILDER_THE_ADMIN_FIELDS_RELATIONS="The admin fields relations" COM_COMPONENTBUILDER_THE_AVAILABLE_VALIDATION_RULES_FOR_THE_VALIDATE_ATTRIBUTE_ARE="The available validation rules for the validate attribute are:" COM_COMPONENTBUILDER_THE_BNONE_DBB_OPTION_WILL_REMOVE_THIS_FIELD_FROM_BEING_SAVED_IN_THE_DATABASE="The None DB option will remove this field from being saved in the database." +COM_COMPONENTBUILDER_THE_BONLY_IN_ADMIN_LIST_VIEWB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW_NOT_TO_ANY_LINKED_VIEWS="The Only in Admin List View option will only Add this field to the admin list view, not to any linked views." +COM_COMPONENTBUILDER_THE_BONLY_IN_LINKED_LIST_VIEWSB_OPTION_WILL_ONLY_ADD_THIS_FIELD_TO_THE_LINKED_LIST_VIEW_IF_THIS_VIEW_GETS_LINKED_TO_OTHER_VIEW_NOT_TO_THIS_ADMIN_LIST_VIEW="The Only in Linked List Views option will only Add this field to the linked list view, if this view gets linked to other view, not to this admin list view." COM_COMPONENTBUILDER_THE_BPHPSECLIBNETSFTPB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The phpseclib\NET\SFTP library\class is not available! This library\class should have been added to your libraries/vdm_io/vendor folder. Please contact your system administrator for more info" COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_PATH_ON_BSB_SERVER="The %s file could not be moved to %s path on %s server." COM_COMPONENTBUILDER_THE_BSB_FILE_COULD_NOT_BE_MOVED_TO_BSB_SERVER="The %s file could not be moved to %s server." COM_COMPONENTBUILDER_THE_BSB_LIBRARYCLASS_IS_NOT_AVAILABLE_THIS_LIBRARYCLASS_SHOULD_HAVE_BEEN_ADDED_TO_YOUR_BLIBRARIESVDM_IOVENDORB_FOLDER_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR_FOR_MORE_INFO="The %s library\class is not available! This library\class should have been added to your libraries/vdm_io/vendor folder. Please contact your system administrator for more info!" COM_COMPONENTBUILDER_THE_BSB_LIBRARY_CAN_NOT_BE_DELETED_OR_THINGS_WILL_BREAK="The %s library can not be deleted, or things will break." -COM_COMPONENTBUILDER_THE_BSHOW_IN_LIST_VIEWB_OPTION_WILL_ADD_THIS_FIELD_TO_THE_ADMIN_LIST_VIEW="The Show in list view option will Add this field to the admin list view." +COM_COMPONENTBUILDER_THE_BSHOW_IN_ALL_LIST_VIEWSB_OPTION_WILL_ADD_THIS_FIELD_TO_ALL_LIST_VIEWS_ADMIN_AMP_LINKED="The Show in All List Views option will Add this field to all list views, admin & linked." COM_COMPONENTBUILDER_THE_COMPONENT_ADMIN_VIEWS="The component admin views" COM_COMPONENTBUILDER_THE_COMPONENT_CONFIG="The component config" COM_COMPONENTBUILDER_THE_COMPONENT_CUSTOM_ADMIN_MENUS="The component custom admin menus" diff --git a/admin/models/admin_view.php b/admin/models/admin_view.php index 186d3ba04..ec753ce76 100644 --- a/admin/models/admin_view.php +++ b/admin/models/admin_view.php @@ -770,7 +770,8 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $_tablesArray = array( 'admin_fields', 'admin_fields_conditions', - 'admin_fields_relations' + 'admin_fields_relations', + 'admin_custom_tabs' ); foreach($_tablesArray as $_updateTable) { @@ -811,7 +812,8 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $_tablesArray = array( 'admin_fields', 'admin_fields_conditions', - 'admin_fields_relations' + 'admin_fields_relations', + 'admin_custom_tabs' ); foreach($_tablesArray as $_updateTable) { diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 6a7a009b2..19d6e9aec 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -2180,97 +2180,97 @@ class ComponentbuilderModelAjax extends JModelList * @var array */ protected $codeSearchKeys = array( - // #__componentbuilder_joomla_component + // #__componentbuilder_joomla_component (a) 'joomla_component' => array( - 'search' => array('id', 'system_name', 'php_preflight_install','php_postflight_install', - 'php_preflight_update','php_postflight_update','php_method_uninstall', - 'php_helper_admin','php_admin_event','php_helper_both','php_helper_site', - 'php_site_event','javascript'), + 'search' => array('id', 'system_name', 'php_preflight_install', 'php_postflight_install', + 'php_preflight_update', 'php_postflight_update', 'php_method_uninstall', + 'php_helper_admin', 'php_admin_event', 'php_helper_both', 'php_helper_site', + 'php_site_event', 'javascript'), 'views' => 'joomla_components', 'not_base64' => array(), 'name' => 'system_name' ), - // #__componentbuilder_component_dashboard + // #__componentbuilder_component_dashboard (b) 'component_dashboard' => array( - 'search' => array('id', 'joomla_component', 'php_dashboard_methods','dashboard_tab'), + 'search' => array('id', 'joomla_component', 'php_dashboard_methods', 'dashboard_tab'), 'views' => 'components_dashboard', 'not_base64' => array('dashboard_tab' => 'json'), 'name' => 'joomla_component->id:joomla_component.system_name' ), - // #__componentbuilder_admin_view + // #__componentbuilder_admin_view (c) 'admin_view' => array( - 'search' => array('id', 'system_name', 'javascript_view_file','javascript_view_footer', - 'javascript_views_file','javascript_views_footer','html_import_view', - 'php_after_delete','php_after_publish','php_ajaxmethod','php_allowedit','php_batchcopy', - 'php_batchmove','php_before_delete','php_before_publish','php_before_save','php_controller', - 'php_controller_list','php_document','php_getitem','php_getitems','php_getitems_after_all', - 'php_getlistquery','php_import','php_import_display','php_import_ext','php_import_headers','php_getform', - 'php_import_save','php_import_setdata','php_model','php_model_list','php_postsavehook','php_save'), + 'search' => array('id', 'system_name', 'javascript_view_file', 'javascript_view_footer', + 'javascript_views_file', 'javascript_views_footer', 'html_import_view', + 'php_after_delete', 'php_after_publish', 'php_ajaxmethod', 'php_allowedit', 'php_batchcopy', + 'php_batchmove', 'php_before_delete', 'php_before_publish', 'php_before_save', 'php_controller', + 'php_controller_list', 'php_document', 'php_getitem', 'php_getitems', 'php_getitems_after_all', + 'php_getlistquery', 'php_import', 'php_import_display', 'php_import_ext', 'php_import_headers', 'php_getform', + 'php_import_save', 'php_import_setdata', 'php_model', 'php_model_list', 'php_postsavehook', 'php_save'), 'views' => 'admin_views', 'not_base64' => array(), 'name' => 'system_name' ), - // #__componentbuilder_admin_fields_relations + // #__componentbuilder_admin_fields_relations (d) 'admin_fields_relations' => array( 'search' => array('id', 'admin_view', 'addrelations'), 'views' => 'admins_fields_relations', 'not_base64' => array('addrelations' => 'json'), 'name' => 'admin_view->id:admin_view.system_name' ), - // #__componentbuilder_custom_admin_view + // #__componentbuilder_custom_admin_view (e) 'custom_admin_view' => array( - 'search' => array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document', - 'js_document','css_document','css','php_ajaxmethod','php_model','php_controller'), + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), 'views' => 'custom_admin_views', 'not_base64' => array(), 'name' => 'system_name' ), - // #__componentbuilder_site_view + // #__componentbuilder_site_view (f) 'site_view' => array( - 'search' => array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document', - 'js_document','css_document','css','php_ajaxmethod','php_model','php_controller'), + 'search' => array('id', 'system_name', 'default', 'php_view', 'php_jview', 'php_jview_display', 'php_document', + 'js_document', 'css_document', 'css', 'php_ajaxmethod', 'php_model', 'php_controller'), 'views' => 'site_views', 'not_base64' => array(), 'name' => 'system_name' ), - // #__componentbuilder_field + // #__componentbuilder_field (g) 'field' => array( - 'search' => array('id', 'name', 'xml','javascript_view_footer','javascript_views_footer'), + 'search' => array('id', 'name', 'xml', 'javascript_view_footer', 'javascript_views_footer'), 'views' => 'fields', 'not_base64' => array('xml' => 'json'), 'base64_search' => array('xml' => array('start' => 'type_php', '_start' => '="', 'end' => '"')), 'name' => 'name' ), - // #__componentbuilder_fieldtype + // #__componentbuilder_fieldtype (h) 'fieldtype' => array( 'search' => array('id', 'name', 'properties'), 'views' => 'fieldtypes', 'not_base64' => array('properties' => 'json'), 'name' => 'name' ), - // #__componentbuilder_dynamic_get + // #__componentbuilder_dynamic_get (i) 'dynamic_get' => array( - 'search' => array('id', 'name', 'php_before_getitem','php_after_getitem','php_before_getitems','php_after_getitems', + 'search' => array('id', 'name', 'php_before_getitem', 'php_after_getitem', 'php_before_getitems', 'php_after_getitems', 'php_getlistquery'), 'views' => 'dynamic_gets', 'not_base64' => array(), 'name' => 'name' ), - // #__componentbuilder_template + // #__componentbuilder_template (j) 'template' => array( - 'search' => array('id', 'name', 'php_view','template'), + 'search' => array('id', 'name', 'php_view', 'template'), 'views' => 'templates', 'not_base64' => array(), 'name' => 'name' ), - // #__componentbuilder_layout + // #__componentbuilder_layout (k) 'layout' => array( - 'search' => array('id', 'name', 'php_view','layout'), + 'search' => array('id', 'name', 'php_view', 'layout'), 'views' => 'layouts', 'not_base64' => array(), 'name' => 'name' ), - // #__componentbuilder_library + // #__componentbuilder_library (l) 'library' => array( 'search' => array('id', 'name', 'php_setdocument'), 'views' => 'libraries', diff --git a/admin/models/fields/dbtables.php b/admin/models/fields/dbtables.php index cd3653456..a1594c157 100644 --- a/admin/models/fields/dbtables.php +++ b/admin/models/fields/dbtables.php @@ -35,23 +35,27 @@ class JFormFieldDbtables extends JFormFieldList */ protected function getOptions() { - $db = JFactory::getDBO(); - $tables= $db->getTableList(); - $config = JFactory::getConfig(); - $options = array(); - $db = JFactory::getDBO(); $options[] = JHtml::_('select.option', '', 'Select an option'); - for ($i=0; $i < count($tables); $i++) - { - //only tables with primary key - $db->setQuery('SHOW FIELDS FROM `'.$tables[$i].'` WHERE LOWER( `Key` ) = \'pri\''); - if ($db->loadResult()) - { - $dbprefix = version_compare(JVERSION,'3.0','lt') ? $config->getValue('config.dbprefix') : $config->get('dbprefix'); $key = $i+1; - $options[$key] = new stdClass; - $options[$key]->value = str_replace($dbprefix, '', $tables[$i]); - $options[$key]->text = $tables[$i]; - } - } + // get db object + $db = JFactory::getDBO(); + // get all tables + $tables= $db->getTableList(); + // get config + $config = JFactory::getConfig(); + $dbprefix = version_compare(JVERSION,'3.0','lt') ? $config->getValue('config.dbprefix') : $config->get('dbprefix'); + $options = array(); + $options[] = JHtml::_('select.option', '', 'Select an option'); + for ($i=0; $i < count($tables); $i++) + { + //only tables with primary key + $db->setQuery('SHOW FIELDS FROM `'.$tables[$i].'` WHERE LOWER( `Key` ) = \'pri\''); + if ($db->loadResult()) + { + $key = $i+1; + $options[$key] = new stdClass; + $options[$key]->value = str_replace($dbprefix, '', $tables[$i]); + $options[$key]->text = $tables[$i]; + } + } return $options; } } diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index 5d0118887..4ebaaab40 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -1075,7 +1075,10 @@ class ComponentbuilderModelFieldtype extends JModelAdmin $properties->loadArray($data['properties']); $data['properties'] = (string) $properties; } - elseif (!isset($data['properties'])) + // Also check permission since the value may be removed due to permissions + // Then we do not want to clear it out, but simple ignore the empty properties + elseif (!isset($data['properties']) + && JFactory::getUser()->authorise('fieldtype.edit.properties', 'com_componentbuilder')) { // Set the empty properties to data $data['properties'] = ''; diff --git a/admin/models/forms/admin_fields.xml b/admin/models/forms/admin_fields.xml index 4c3bc5522..2948f6b46 100644 --- a/admin/models/forms/admin_fields.xml +++ b/admin/models/forms/admin_fields.xml @@ -136,7 +136,11 @@ + COM_COMPONENTBUILDER_ADMIN_FIELDS_SHOW_IN_ALL_LIST_VIEWS + + diff --git a/admin/models/forms/admin_view.xml b/admin/models/forms/admin_view.xml index b31ba9b01..ffefef0af 100644 --- a/admin/models/forms/admin_view.xml +++ b/admin/models/forms/admin_view.xml @@ -427,6 +427,8 @@ COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITOWN + +