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.

This commit is contained in:
2018-10-29 18:38:00 +02:00
parent 1e5fda0327
commit 6c4bab5ea9
58 changed files with 556 additions and 355 deletions

View File

@ -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)
{

View File

@ -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',

View File

@ -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;
}
}

View File

@ -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'] = '';

View File

@ -136,7 +136,11 @@
<option value="">
COM_COMPONENTBUILDER_ADMIN_FIELDS_DEFAULT</option>
<option value="1">
COM_COMPONENTBUILDER_ADMIN_FIELDS_SHOW_IN_LIST_VIEW</option>
COM_COMPONENTBUILDER_ADMIN_FIELDS_SHOW_IN_ALL_LIST_VIEWS</option>
<option value="3">
COM_COMPONENTBUILDER_ADMIN_FIELDS_ONLY_IN_ADMIN_LIST_VIEW</option>
<option value="4">
COM_COMPONENTBUILDER_ADMIN_FIELDS_ONLY_IN_LINKED_LIST_VIEWS</option>
<option value="2">
COM_COMPONENTBUILDER_ADMIN_FIELDS_NONE_DB</option>
</field>

View File

@ -427,6 +427,8 @@
COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITOWN</option>
<option value="core.edit.state">
COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITSTATE</option>
<option value="core.edit.access">
COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITACCESS</option>
<option value="core.edit.created_by">
COM_COMPONENTBUILDER_ADMIN_VIEW_COREEDITCREATED_BY</option>
<option value="core.edit.created">
@ -441,6 +443,8 @@
COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITOWN</option>
<option value="view.edit.state">
COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITSTATE</option>
<option value="view.edit.access">
COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITACCESS</option>
<option value="view.edit.created_by">
COM_COMPONENTBUILDER_ADMIN_VIEW_VIEWEDITCREATED_BY</option>
<option value="view.edit.created">

View File

@ -308,7 +308,8 @@ function usedin(functioName, ide) {
jQuery('#note-usedin-not').hide();
jQuery('#note-usedin-found').hide();
jQuery('#loading-usedin').show();
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l']; // if you update this, also update [customcode-codeUsedInHtmlNote]!
var targets = ['a','b','c','d','e','f','g','h','i','j','k','l']; // if you update this, also update (below 11) & [customcode-codeUsedInHtmlNote]!
var targetNumber = 11;
var run = 0;
var usedinChecker = setInterval(function(){
var target = targets[run];
@ -321,7 +322,7 @@ function usedin(functioName, ide) {
} else {
jQuery('#usedin-'+target).hide();
}
if (target === 'i') {
if (run == targetNumber) {
jQuery('#loading-usedin').hide();
if (found) {
jQuery('#note-usedin-found').show();
@ -330,7 +331,7 @@ function usedin(functioName, ide) {
}
}
});
if (run == 9) {
if (run == targetNumber) {
clearInterval(usedinChecker);
}
run++;

View File

@ -161,7 +161,6 @@
description="COM_COMPONENTBUILDER_DYNAMIC_GET_DB_TABLE_DESCRIPTION"
class="list_class"
multiple="false"
default=""
required="false"
button="false"
/>
@ -581,7 +580,6 @@
description="COM_COMPONENTBUILDER_DYNAMIC_GET_DB_TABLE_MAIN_DESCRIPTION"
class="list_class"
multiple="false"
default=""
required="true"
button="false"
/>

View File

@ -1385,7 +1385,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
$value = ComponentbuilderHelper::openValidBase64($item->{$key}, null);
}
elseif ('json' === $target['not_base64'][$key] && 'xml' === $key) // just for field search
elseif (isset($keys['not_base64'][$key]) && 'json' === $keys['not_base64'][$key] && 'xml' === $key) // just for field search
{
$value = json_decode($item->{$key});
}
@ -1394,11 +1394,11 @@ class ComponentbuilderModelJoomla_components extends JModelList
$value = $item->{$key};
}
// check if we should search for base64 string inside the text
if (isset($target['base64_search']) && isset($target['base64_search'][$key])
&& isset($target['base64_search'][$key]['start']) && strpos($value, $target['base64_search'][$key]['start']) !== false)
if (isset($keys['base64_search']) && isset($keys['base64_search'][$key])
&& isset($keys['base64_search'][$key]['start']) && strpos($value, $keys['base64_search'][$key]['start']) !== false)
{
// search and open the base64 strings
$this->searchOpenBase64($value, $target['base64_search'][$key]);
$this->searchOpenBase64($value, $keys['base64_search'][$key]);
}
// search the value to see if it has custom code
$codeArray = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=',']');
@ -1422,10 +1422,14 @@ class ComponentbuilderModelJoomla_components extends JModelList
}
elseif (ComponentbuilderHelper::checkString($func))
{
if ($funcID = ComponentbuilderHelper::getVar('custom_code', $func, 'function_name', 'id'))
if (($funcID = ComponentbuilderHelper::getVar('custom_code', $func, 'function_name', 'id')) !== false && is_numeric($funcID))
{
$this->setSmartIDs($funcID, 'custom_code');
}
else
{
// set a notice that custom code was not found
}
}
}
}
@ -1627,97 +1631,97 @@ class ComponentbuilderModelJoomla_components 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',