From 44f37b7f74e1fcbfbbdf26036117d14404011abd Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 28 Feb 2023 10:31:34 +0900 Subject: [PATCH] Fix in EditUser Table Array query load for languages Also split all queries into multi line ones Fixes in Form\Generate for TableArray Interface location move Update EditBase to new and old edit schema (scheme) file name --- www/lib/CoreLibs/Admin/EditBase.php | 2 ++ www/lib/CoreLibs/Output/Form/Generate.php | 10 +++++----- .../Output/Form/TableArrays/EditAccess.php | 4 +++- .../Output/Form/TableArrays/EditGroups.php | 17 ++++++++++++---- .../Output/Form/TableArrays/EditMenuGroup.php | 4 +++- .../Output/Form/TableArrays/EditPages.php | 15 ++++++++++---- .../Output/Form/TableArrays/EditSchemas.php | 4 +++- .../Output/Form/TableArrays/EditUsers.php | 20 ++++++++++++++----- .../Form/TableArrays/EditVisibleGroup.php | 4 +++- 9 files changed, 58 insertions(+), 22 deletions(-) diff --git a/www/lib/CoreLibs/Admin/EditBase.php b/www/lib/CoreLibs/Admin/EditBase.php index 46a37a47..c84e159f 100644 --- a/www/lib/CoreLibs/Admin/EditBase.php +++ b/www/lib/CoreLibs/Admin/EditBase.php @@ -414,6 +414,8 @@ class EditBase $elements[] = $this->form->formCreateElement('additional_acl'); break; case 'edit_schemes': + // @deprecated Will be removed + case 'edit_schemas': $elements[] = $this->form->formCreateElement('enabled'); $elements[] = $this->form->formCreateElement('name'); $elements[] = $this->form->formCreateElement('header_color'); diff --git a/www/lib/CoreLibs/Output/Form/Generate.php b/www/lib/CoreLibs/Output/Form/Generate.php index d560e6fb..4ec98820 100644 --- a/www/lib/CoreLibs/Output/Form/Generate.php +++ b/www/lib/CoreLibs/Output/Form/Generate.php @@ -366,7 +366,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $config_array = $table_arrays[System::getPageName(1)]; } else { // primary try to load the class - /** @var \CoreLibs\Output\Form\TableArraysInterface|false $content_class */ + /** @var TableArrays\Interface\TableArraysInterface|false $content_class */ $content_class = $this->loadTableArray(); if (is_object($content_class)) { $config_array = $content_class->setTableArray(); @@ -468,9 +468,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO /** * load table array class based on my page name converted to camel case * class files are in \TableArrays folder in \Output\Form - * @return object|bool Return class object or false on failure + * @return TableArrays\Interface\TableArraysInterface|false Return class object or false on failure */ - private function loadTableArray() + private function loadTableArray(): TableArrays\Interface\TableArraysInterface|false { // note: it schould be Schemas but an original type made it to this // this file is kept for the old usage, new one should be EditSchemas @@ -489,7 +489,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $page_name_camel_case ); try { - /** @var \CoreLibs\Output\Form\TableArraysInterface|false $class */ + /** @var TableArrays\Interface\TableArraysInterface|false $class */ $class = new $class_string($this); } catch (\Throwable $t) { $this->log->debug('CLASS LOAD', 'Failed loading: ' . $class_string . ' => ' . $t->getMessage()); @@ -651,7 +651,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO $this->base_acl_level >= $this->security_level['new'] ) { if ($this->really_new == 'yes') { - $this->formUnsetTablearray(); + $this->formUnsetTableArray(); } else { $this->msg .= $this->l->__('You have to select the Checkbox for New!
'); $this->error = 2; diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php index 170046f9..3701e54c 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditAccess.php @@ -87,7 +87,9 @@ class EditAccess implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_access', - "load_query" => "SELECT edit_access_id, name FROM edit_access ORDER BY name", + "load_query" => "SELECT edit_access_id, name " + . "FROM edit_access " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php index e9008101..0ff66ebc 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditGroups.php @@ -55,14 +55,19 @@ class EditGroups implements Interface\TableArraysInterface 'mandatory' => 1, 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_scheme_id' => [ 'value' => $_POST['edit_scheme_id'] ?? '', 'output_name' => 'Group Scheme', 'int_null' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_scheme_id, name FROM edit_scheme WHERE enabled = 1 ORDER BY name" + 'query' => "SELECT edit_scheme_id, name " + . "FROM edit_scheme " + . "WHERE enabled = 1 " + . "ORDER BY name" ], 'additional_acl' => [ 'value' => $_POST['additional_acl'] ?? '', @@ -73,7 +78,9 @@ class EditGroups implements Interface\TableArraysInterface 'cols' => 60 ], ], - 'load_query' => "SELECT edit_group_id, name, enabled FROM edit_group ORDER BY name", + 'load_query' => "SELECT edit_group_id, name, enabled " + . "FROM edit_group " + . "ORDER BY name", 'table_name' => 'edit_group', 'show_fields' => [ [ @@ -115,7 +122,9 @@ class EditGroups implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'int' => 1, 'preset' => 1, // first of the select - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_page_id' => [ 'int' => 1, diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php index 6c327de7..48826bb8 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditMenuGroup.php @@ -55,7 +55,9 @@ class EditMenuGroup implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_menu_group', - 'load_query' => "SELECT edit_menu_group_id, name FROM edit_menu_group ORDER BY name", + 'load_query' => "SELECT edit_menu_group_id, name " + . "FROM edit_menu_group " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditPages.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditPages.php index a051a504..6ecd26e5 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditPages.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditPages.php @@ -140,7 +140,10 @@ class EditPages implements Interface\TableArraysInterface ], ], 'load_query' => "SELECT edit_page_id, " - . "CASE WHEN hostname IS NOT NULL THEN hostname ELSE ''::VARCHAR END || filename AS filename, " + . "CASE " + . "WHEN hostname IS NOT NULL THEN hostname " + . "ELSE ''::VARCHAR " + . "END || filename AS filename, " . "name, online, menu, popup " . "FROM edit_page " . "ORDER BY order_number", @@ -178,7 +181,8 @@ class EditPages implements Interface\TableArraysInterface 'select_size' => 10, 'selected' => $_POST['edit_visible_group_id'] ?? '', 'query' => "SELECT edit_visible_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " - . "FROM edit_visible_group ORDER BY name" + . "FROM edit_visible_group " + . "ORDER BY name" ], 'edit_menu_group' => [ 'table_name' => 'edit_page_menu_group', @@ -188,7 +192,8 @@ class EditPages implements Interface\TableArraysInterface 'select_size' => 10, 'selected' => $_POST['edit_menu_group_id'] ?? '', 'query' => "SELECT edit_menu_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " - . "FROM edit_menu_group ORDER BY order_number" + . "FROM edit_menu_group " + . "ORDER BY order_number" ], ], 'element_list' => [ @@ -259,7 +264,9 @@ class EditPages implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'int' => 1, 'preset' => 1, // first of the select - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_page_content_id' => [ 'type' => 'hidden', diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php index d91e14a1..8417ac1f 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditSchemas.php @@ -68,7 +68,9 @@ class EditSchemas implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_scheme', - 'load_query' => "SELECT edit_scheme_id, name, enabled FROM edit_scheme ORDER BY name", + 'load_query' => "SELECT edit_scheme_id, name, enabled " + . "FROM edit_scheme " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name' diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php index c3e9da2f..a85cb0e9 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditUsers.php @@ -274,7 +274,7 @@ class EditUsers implements Interface\TableArraysInterface 'type' => 'drop_down_db', 'query' => "SELECT edit_language_id, long_name " . "FROM edit_language " - . "WHERE enabled = 1" + . "WHERE enabled = 1 " . "ORDER BY order_number", 'min_edit_acl' => '100', 'min_show_acl' => '100', @@ -284,7 +284,10 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Scheme', 'int_null' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_scheme_id, name FROM edit_scheme WHERE enabled = 1 ORDER BY name", + 'query' => "SELECT edit_scheme_id, name " + . "FROM edit_scheme " + . "WHERE enabled = 1 " + . "ORDER BY name", 'min_edit_acl' => '100', 'min_show_acl' => '100', ], @@ -293,7 +296,10 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Group', 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_group_id, name FROM edit_group WHERE enabled = 1 ORDER BY name", + 'query' => "SELECT edit_group_id, name " + . "FROM edit_group " + . "WHERE enabled = 1 " + . "ORDER BY name", 'mandatory' => 1, 'min_edit_acl' => '100', 'min_show_acl' => '100', @@ -304,7 +310,9 @@ class EditUsers implements Interface\TableArraysInterface 'mandatory' => 1, 'int' => 1, 'type' => 'drop_down_db', - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level", + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level", 'min_edit_acl' => '100', 'min_show_acl' => '100', ], @@ -434,7 +442,9 @@ class EditUsers implements Interface\TableArraysInterface 'output_name' => 'Access Level', 'preset' => 1, // first of the select 'int' => 1, - 'query' => "SELECT edit_access_right_id, name FROM edit_access_right ORDER BY level" + 'query' => "SELECT edit_access_right_id, name " + . "FROM edit_access_right " + . "ORDER BY level" ], 'edit_default' => [ 'type' => 'radio_group', diff --git a/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php b/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php index a00c33d8..98a2f223 100644 --- a/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php +++ b/www/lib/CoreLibs/Output/Form/TableArrays/EditVisibleGroup.php @@ -48,7 +48,9 @@ class EditVisibleGroup implements Interface\TableArraysInterface ], ], 'table_name' => 'edit_visible_group', - 'load_query' => "SELECT edit_visible_group_id, name FROM edit_visible_group ORDER BY name", + 'load_query' => "SELECT edit_visible_group_id, name " + . "FROM edit_visible_group " + . "ORDER BY name", 'show_fields' => [ [ 'name' => 'name'