Form\Generate update

- remove auto load _POST vars
- Update color settings to # leading 6/8 digit hex code
- remove any global variable calls/requests
- fix some isset/empty clean ups (isset + set = !empty)
- fix on delete of reference data that loaded data was not shown again
- fix on reference data save error that wrong data is still shown and not removed
This commit is contained in:
Clemens Schwaighofer
2023-01-10 11:22:04 +09:00
parent df2ae66942
commit 53813261fb
13 changed files with 212 additions and 137 deletions

View File

@@ -0,0 +1,25 @@
-- Fixes for column types
-- edit group
ALTER TABLE edit_group ALTER name TYPE VARCHAR;
-- edit language
ALTER TABLE edit_language ALTER short_name TYPE VARCHAR;
ALTER TABLE edit_language ALTER long_name TYPE VARCHAR;
ALTER TABLE edit_language ALTER iso_name TYPE VARCHAR;
-- edit menu group
ALTER TABLE edit_menu_group ALTER name TYPE VARCHAR;
ALTER TABLE edit_menu_group ALTER flag TYPE VARCHAR;
-- edit page
ALTER TABLE edit_page ALTER filename TYPE VARCHAR;
ALTER TABLE edit_page ALTER name TYPE VARCHAR;
-- edit query string
ALTER TABLE edit_query_string ALTER name TYPE VARCHAR;
ALTER TABLE edit_query_string ALTER value TYPE VARCHAR;
-- edit scheme
ALTER TABLE edit_scheme ALTER name TYPE VARCHAR;
ALTER TABLE edit_scheme ALTER header_color TYPE VARCHAR;
ALTER TABLE edit_scheme ALTER css_file TYPE VARCHAR;
ALTER TABLE edit_scheme ALTER template TYPE VARCHAR;
-- edit visible group
ALTER TABLE edit_visible_group ALTER name TYPE VARCHAR;
ALTER TABLE edit_visible_group ALTER flag TYPE VARCHAR;

View File

@@ -58,10 +58,6 @@ $l10n = new \CoreLibs\Language\L10n(
// flush and start // flush and start
ob_end_flush(); ob_end_flush();
// FIXME: only extract _POST data that is needed
// FIXME: update table_arrays reader to use other than $_GLOBALS
extract($_POST, EXTR_SKIP);
// init smarty and form class // init smarty and form class
$edit_base = new CoreLibs\Admin\EditBase(DB_CONFIG, $log, $l10n, $locale); $edit_base = new CoreLibs\Admin\EditBase(DB_CONFIG, $log, $l10n, $locale);
// creates edit pages and runs actions // creates edit pages and runs actions

View File

@@ -5,35 +5,36 @@ declare(strict_types=1);
$edit_access = [ $edit_access = [
'table_array' => [ 'table_array' => [
'edit_access_id' => [ 'edit_access_id' => [
'value' => $GLOBALS['edit_access_id'] ?? '', 'value' => $_POST['edit_access_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Access Group Name', 'output_name' => 'Access Group Name',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',
'error_check' => 'alphanumericspace|unique' 'error_check' => 'alphanumericspace|unique'
], ],
'description' => [ 'description' => [
'value' => $GLOBALS['description'] ?? '', 'value' => $_POST['description'] ?? '',
'output_name' => 'Description', 'output_name' => 'Description',
'type' => 'textarea' 'type' => 'textarea'
], ],
'color' => [ 'color' => [
'value' => $GLOBALS['color'] ?? '', 'value' => $_POST['color'] ?? '',
'output_name' => 'Color', 'output_name' => 'Color',
'mandatory' => 0, 'mandatory' => 0,
'type' => 'text', 'type' => 'text',
'size' => 6, 'size' => 10,
'length' => 6, 'length' => 9,
'error_check' => 'custom', 'error_check' => 'custom',
'error_regex' => "/[\dA-Fa-f]{6}/", // FIXME: update regex check for hex/rgb/hsl with color check class
'error_example' => 'F6A544' 'error_regex' => '/^#([\dA-Fa-f]{6}|[\dA-Fa-f]{8})$/',
'error_example' => '#F6A544'
], ],
'enabled' => [ 'enabled' => [
'value' => $GLOBALS['enabled'] ?? 0, 'value' => $_POST['enabled'] ?? 0,
'output_name' => 'Enabled', 'output_name' => 'Enabled',
'type' => 'binary', 'type' => 'binary',
'int' => 1, // OR 'bool' => 1 'int' => 1, // OR 'bool' => 1
@@ -43,7 +44,7 @@ $edit_access = [
], ],
], ],
'protected' => [ 'protected' => [
'value' => $GLOBALS['protected'] ?? 0, 'value' => $_POST['protected'] ?? 0,
'output_name' => 'Protected', 'output_name' => 'Protected',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -53,7 +54,7 @@ $edit_access = [
], ],
], ],
'additional_acl' => [ 'additional_acl' => [
'value' => $GLOBALS['additional_acl'] ?? '', 'value' => $_POST['additional_acl'] ?? '',
'output_name' => 'Additional ACL (as JSON)', 'output_name' => 'Additional ACL (as JSON)',
'type' => 'textarea', 'type' => 'textarea',
'error_check' => 'json', 'error_check' => 'json',

View File

@@ -5,12 +5,12 @@ declare(strict_types=1);
$edit_groups = [ $edit_groups = [
'table_array' => [ 'table_array' => [
'edit_group_id' => [ 'edit_group_id' => [
'value' => $GLOBALS['edit_group_id'] ?? '', 'value' => $_POST['edit_group_id'] ?? '',
'pk' => 1, 'pk' => 1,
'type' => 'hidden' 'type' => 'hidden'
], ],
'enabled' => [ 'enabled' => [
'value' => $GLOBALS['enabled'] ?? '', 'value' => $_POST['enabled'] ?? '',
'output_name' => 'Enabled', 'output_name' => 'Enabled',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -20,13 +20,13 @@ $edit_groups = [
], ],
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Group Name', 'output_name' => 'Group Name',
'type' => 'text', 'type' => 'text',
'mandatory' => 1 'mandatory' => 1
], ],
'edit_access_right_id' => [ 'edit_access_right_id' => [
'value' => $GLOBALS['edit_access_right_id'] ?? '', 'value' => $_POST['edit_access_right_id'] ?? '',
'output_name' => 'Group Level', 'output_name' => 'Group Level',
'mandatory' => 1, 'mandatory' => 1,
'int' => 1, 'int' => 1,
@@ -34,14 +34,14 @@ $edit_groups = [
'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' => [ 'edit_scheme_id' => [
'value' => $GLOBALS['edit_scheme_id'] ?? '', 'value' => $_POST['edit_scheme_id'] ?? '',
'output_name' => 'Group Scheme', 'output_name' => 'Group Scheme',
'int_null' => 1, 'int_null' => 1,
'type' => 'drop_down_db', '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' => [ 'additional_acl' => [
'value' => $GLOBALS['additional_acl'] ?? '', 'value' => $_POST['additional_acl'] ?? '',
'output_name' => 'Additional ACL (as JSON)', 'output_name' => 'Additional ACL (as JSON)',
'type' => 'textarea', 'type' => 'textarea',
'error_check' => 'json', 'error_check' => 'json',

View File

@@ -5,12 +5,12 @@ declare(strict_types=1);
$edit_languages = [ $edit_languages = [
'table_array' => [ 'table_array' => [
'edit_language_id' => [ 'edit_language_id' => [
'value' => $GLOBALS['edit_language_id'] ?? '', 'value' => $_POST['edit_language_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'short_name' => [ 'short_name' => [
'value' => $GLOBALS['short_name'] ?? '', 'value' => $_POST['short_name'] ?? '',
'output_name' => 'Language (short)', 'output_name' => 'Language (short)',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',
@@ -18,25 +18,25 @@ $edit_languages = [
'length' => 2 'length' => 2
], ],
'long_name' => [ 'long_name' => [
'value' => $GLOBALS['long_name'] ?? '', 'value' => $_POST['long_name'] ?? '',
'output_name' => 'Language (long)', 'output_name' => 'Language (long)',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',
'size' => 40 'size' => 40
], ],
'iso_name' => [ 'iso_name' => [
'value' => $GLOBALS['iso_name'] ?? '', 'value' => $_POST['iso_name'] ?? '',
'output_name' => 'ISO Code', 'output_name' => 'ISO Code',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text' 'type' => 'text'
], ],
'order_number' => [ 'order_number' => [
'value' => $GLOBALS['order_number'] ?? '', 'value' => $_POST['order_number'] ?? '',
'int' => 1, 'int' => 1,
'order' => 1 'order' => 1
], ],
'enabled' => [ 'enabled' => [
'value' => $GLOBALS['enabled'] ?? '', 'value' => $_POST['enabled'] ?? '',
'output_name' => 'Enabled', 'output_name' => 'Enabled',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -46,7 +46,7 @@ $edit_languages = [
], ],
], ],
'lang_default' => [ 'lang_default' => [
'value' => $GLOBALS['lang_default'] ?? '', 'value' => $_POST['lang_default'] ?? '',
'output_name' => 'Default Language', 'output_name' => 'Default Language',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',

View File

@@ -5,25 +5,25 @@ declare(strict_types=1);
$edit_menu_group = [ $edit_menu_group = [
'table_array' => [ 'table_array' => [
'edit_menu_group_id' => [ 'edit_menu_group_id' => [
'value' => $GLOBALS['edit_menu_group_id'] ?? '', 'value' => $_POST['edit_menu_group_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Group name', 'output_name' => 'Group name',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text' 'type' => 'text'
], ],
'flag' => [ 'flag' => [
'value' => $GLOBALS['flag'] ?? '', 'value' => $_POST['flag'] ?? '',
'output_name' => 'Flag', 'output_name' => 'Flag',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',
'error_check' => 'alphanumeric|unique' 'error_check' => 'alphanumeric|unique'
], ],
'order_number' => [ 'order_number' => [
'value' => $GLOBALS['order_number'] ?? '', 'value' => $_POST['order_number'] ?? '',
'output_name' => 'Group order', 'output_name' => 'Group order',
'type' => 'order', 'type' => 'order',
'int' => 1, 'int' => 1,

View File

@@ -5,40 +5,41 @@ declare(strict_types=1);
$edit_pages = [ $edit_pages = [
'table_array' => [ 'table_array' => [
'edit_page_id' => [ 'edit_page_id' => [
'value' => $GLOBALS['edit_page_id'] ?? '', 'value' => $_POST['edit_page_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'filename' => [ 'filename' => [
'value' => $GLOBALS['filename'] ?? '', 'value' => $_POST['filename'] ?? '',
'output_name' => 'Add File ...', 'output_name' => 'Add File ...',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'drop_down_db', 'type' => 'drop_down_db',
'query' => "SELECT DISTINCT temp_files.filename AS id, temp_files.folder || temp_files.filename AS name " 'query' => "SELECT DISTINCT temp_files.filename AS id, "
. "temp_files.folder || temp_files.filename AS name "
. "FROM temp_files " . "FROM temp_files "
. "LEFT JOIN edit_page ep ON temp_files.filename = ep.filename " . "LEFT JOIN edit_page ep ON temp_files.filename = ep.filename "
. "WHERE ep.filename IS NULL" . "WHERE ep.filename IS NULL"
], ],
'hostname' => [ 'hostname' => [
'value' => $GLOBALS['hostname'] ?? '', 'value' => $_POST['hostname'] ?? '',
'output_name' => 'Hostname or folder', 'output_name' => 'Hostname or folder',
'type' => 'text' 'type' => 'text'
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Page name', 'output_name' => 'Page name',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text' 'type' => 'text'
], ],
'order_number' => [ 'order_number' => [
'value' => $GLOBALS['order_number'] ?? '', 'value' => $_POST['order_number'] ?? '',
'output_name' => 'Page order', 'output_name' => 'Page order',
'type' => 'order', 'type' => 'order',
'int' => 1, 'int' => 1,
'order' => 1 'order' => 1
], ],
/* 'flag' => [ /* 'flag' => [
'value' => isset($GLOBALS['flag']) ? $GLOBALS['flag'] : '', 'value' => $_POST['flag']) ?? '',
'output_name' => 'Page Flag', 'output_name' => 'Page Flag',
'type' => 'drop_down_array', 'type' => 'drop_down_array',
'query' => [ 'query' => [
@@ -51,7 +52,7 @@ $edit_pages = [
], ],
],*/ ],*/
'online' => [ 'online' => [
'value' => $GLOBALS['online'] ?? '', 'value' => $_POST['online'] ?? '',
'output_name' => 'Online', 'output_name' => 'Online',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -61,7 +62,7 @@ $edit_pages = [
], ],
], ],
'menu' => [ 'menu' => [
'value' => $GLOBALS['menu'] ?? '', 'value' => $_POST['menu'] ?? '',
'output_name' => 'Menu', 'output_name' => 'Menu',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -71,7 +72,7 @@ $edit_pages = [
], ],
], ],
'popup' => [ 'popup' => [
'value' => $GLOBALS['popup'] ?? '', 'value' => $_POST['popup'] ?? '',
'output_name' => 'Popup', 'output_name' => 'Popup',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -81,7 +82,7 @@ $edit_pages = [
], ],
], ],
'popup_x' => [ 'popup_x' => [
'value' => $GLOBALS['popup_x'] ?? '', 'value' => $_POST['popup_x'] ?? '',
'output_name' => 'Popup Width', 'output_name' => 'Popup Width',
'int_null' => 1, 'int_null' => 1,
'type' => 'text', 'type' => 'text',
@@ -89,7 +90,7 @@ $edit_pages = [
'length' => 4 'length' => 4
], ],
'popup_y' => [ 'popup_y' => [
'value' => $GLOBALS['popup_y'] ?? '', 'value' => $_POST['popup_y'] ?? '',
'output_name' => 'Popup Height', 'output_name' => 'Popup Height',
'int_null' => 1, 'int_null' => 1,
'type' => 'text', 'type' => 'text',
@@ -97,7 +98,7 @@ $edit_pages = [
'length' => 4 'length' => 4
], ],
'content_alias_edit_page_id' => [ 'content_alias_edit_page_id' => [
'value' => $GLOBALS['content_alias_edit_page_id'] ?? '', 'value' => $_POST['content_alias_edit_page_id'] ?? '',
'output_name' => 'Content Alias Source', 'output_name' => 'Content Alias Source',
'int_null' => 1, 'int_null' => 1,
'type' => 'drop_down_db', 'type' => 'drop_down_db',
@@ -110,7 +111,7 @@ $edit_pages = [
'order_by' => 'order_number' 'order_by' => 'order_number'
// 'query' => "SELECT edit_page_id AS content_alias_edit_page_id, name ". // 'query' => "SELECT edit_page_id AS content_alias_edit_page_id, name ".
// "FROM edit_page ". // "FROM edit_page ".
// (isset($GLOBALS['edit_page_id']) ? " WHERE edit_page_id <> ".$GLOBALS['edit_page_id'] : "")." ". // (!empty($_POST['edit_page_id']) ? " WHERE edit_page_id <> ".$_POST['edit_page_id'] : "")." ".
// "ORDER BY order_number" // "ORDER BY order_number"
], ],
], ],
@@ -151,7 +152,7 @@ $edit_pages = [
'output_name' => 'Visible Groups (access)', 'output_name' => 'Visible Groups (access)',
'mandatory' => 1, 'mandatory' => 1,
'select_size' => 10, 'select_size' => 10,
'selected' => $GLOBALS['edit_visible_group_id'] ?? '', 'selected' => $_POST['edit_visible_group_id'] ?? '',
'query' => "SELECT edit_visible_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " 'query' => "SELECT edit_visible_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag "
. "FROM edit_visible_group ORDER BY name" . "FROM edit_visible_group ORDER BY name"
], ],
@@ -161,7 +162,7 @@ $edit_pages = [
'output_name' => 'Menu Groups (grouping)', 'output_name' => 'Menu Groups (grouping)',
'mandatory' => 1, 'mandatory' => 1,
'select_size' => 10, 'select_size' => 10,
'selected' => $GLOBALS['edit_menu_group_id'] ?? '', 'selected' => $_POST['edit_menu_group_id'] ?? '',
'query' => "SELECT edit_menu_group_id, 'Name: ' || name || ', ' || 'Flag: ' || flag " '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"
], ],

View File

@@ -5,29 +5,30 @@ declare(strict_types=1);
$edit_schemes = [ $edit_schemes = [
'table_array' => [ 'table_array' => [
'edit_scheme_id' => [ 'edit_scheme_id' => [
'value' => $GLOBALS['edit_scheme_id'] ?? '', 'value' => $_POST['edit_scheme_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Scheme Name', 'output_name' => 'Scheme Name',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text' 'type' => 'text'
], ],
'header_color' => [ 'header_color' => [
'value' => $GLOBALS['header_color'] ?? '', 'value' => $_POST['header_color'] ?? '',
'output_name' => 'Header Color', 'output_name' => 'Header Color',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',
'size' => 6, 'size' => 10,
'length' => 6, 'length' => 9,
'error_check' => 'custom', 'error_check' => 'custom',
'error_regex' => '/[\dA-Fa-f]{6}/', // FIXME: update regex check for hex/rgb/hsl with color check class
'error_example' => 'F6A544' 'error_regex' => '/^#([\dA-Fa-f]{6}|[\dA-Fa-f]{8})$/',
'error_example' => '#F6A544'
], ],
'enabled' => [ 'enabled' => [
'value' => $GLOBALS['enabled'] ?? '', 'value' => $_POST['enabled'] ?? '',
'output_name' => 'Enabled', 'output_name' => 'Enabled',
'int' => 1, 'int' => 1,
'type' => 'binary', 'type' => 'binary',
@@ -37,7 +38,7 @@ $edit_schemes = [
], ],
], ],
'template' => [ 'template' => [
'value' => $GLOBALS['template'] ?? '', 'value' => $_POST['template'] ?? '',
'output_name' => 'Template', 'output_name' => 'Template',
'type' => 'text' 'type' => 'text'
], ],

View File

@@ -5,13 +5,13 @@ declare(strict_types=1);
$edit_users = [ $edit_users = [
'table_array' => [ 'table_array' => [
'edit_user_id' => [ 'edit_user_id' => [
'value' => $GLOBALS['edit_user_id'] ?? '', 'value' => $_POST['edit_user_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1, 'pk' => 1,
'int' => 1 'int' => 1
], ],
'username' => [ 'username' => [
'value' => $GLOBALS['username'] ?? '', 'value' => $_POST['username'] ?? '',
'output_name' => 'Username', 'output_name' => 'Username',
'mandatory' => 1, 'mandatory' => 1,
'error_check' => 'unique|alphanumericextended', 'error_check' => 'unique|alphanumericextended',
@@ -22,9 +22,9 @@ $edit_users = [
'min_show_acl' => '-1', 'min_show_acl' => '-1',
], ],
'password' => [ 'password' => [
'value' => $GLOBALS['password'] ?? '', 'value' => $_POST['password'] ?? '',
'HIDDEN_value' => $GLOBALS['HIDDEN_password'] ?? '', 'HIDDEN_value' => $_POST['HIDDEN_password'] ?? '',
'CONFIRM_value' => $GLOBALS['CONFIRM_password'] ?? '', 'CONFIRM_value' => $_POST['CONFIRM_password'] ?? '',
'output_name' => 'Password', 'output_name' => 'Password',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'password', // later has to be password for encryption in database 'type' => 'password', // later has to be password for encryption in database
@@ -40,7 +40,7 @@ $edit_users = [
// password date when first insert and password is set, needs special field with connection to password // password date when first insert and password is set, needs special field with connection to password
// password reset force interval, if set, user needs to reset password after X time period // password reset force interval, if set, user needs to reset password after X time period
'password_change_interval' => [ 'password_change_interval' => [
'value' => $GLOBALS['password_change_interval'] ?? '', 'value' => $_POST['password_change_interval'] ?? '',
'output_name' => 'Password change interval', 'output_name' => 'Password change interval',
// can be any date length format. n Y/M/D [not H/M/S], only one set, no combination // can be any date length format. n Y/M/D [not H/M/S], only one set, no combination
'error_check' => 'intervalshort', 'error_check' => 'intervalshort',
@@ -52,7 +52,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'enabled' => [ 'enabled' => [
'value' => $GLOBALS['enabled'] ?? '', 'value' => $_POST['enabled'] ?? '',
'output_name' => 'Enabled', 'output_name' => 'Enabled',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -64,7 +64,7 @@ $edit_users = [
'min_show_acl' => '-1', 'min_show_acl' => '-1',
], ],
'deleted' => [ 'deleted' => [
'value' => $GLOBALS['deleted'] ?? '', 'value' => $_POST['deleted'] ?? '',
'output_name' => 'Deleted', 'output_name' => 'Deleted',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -76,7 +76,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'strict' => [ 'strict' => [
'value' => $GLOBALS['strict'] ?? '', 'value' => $_POST['strict'] ?? '',
'output_name' => 'Strict (Lock after errors)', 'output_name' => 'Strict (Lock after errors)',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -88,7 +88,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'locked' => [ 'locked' => [
'value' => $GLOBALS['locked'] ?? '', 'value' => $_POST['locked'] ?? '',
'output_name' => 'Locked (auto set if strict with errors)', 'output_name' => 'Locked (auto set if strict with errors)',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -100,7 +100,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'admin' => [ 'admin' => [
'value' => $GLOBALS['admin'] ?? '', 'value' => $_POST['admin'] ?? '',
'output_name' => 'Admin', 'output_name' => 'Admin',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -112,7 +112,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'debug' => [ 'debug' => [
'value' => $GLOBALS['debug'] ?? '', 'value' => $_POST['debug'] ?? '',
'output_name' => 'Debug', 'output_name' => 'Debug',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -124,7 +124,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'db_debug' => [ 'db_debug' => [
'value' => $GLOBALS['db_debug'] ?? '', 'value' => $_POST['db_debug'] ?? '',
'output_name' => 'DB Debug', 'output_name' => 'DB Debug',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -136,7 +136,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'email' => [ 'email' => [
'value' => $GLOBALS['email'] ?? '', 'value' => $_POST['email'] ?? '',
'output_name' => 'E-Mail', 'output_name' => 'E-Mail',
'type' => 'text', 'type' => 'text',
'error_check' => 'email', 'error_check' => 'email',
@@ -144,21 +144,21 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'last_name' => [ 'last_name' => [
'value' => $GLOBALS['last_name'] ?? '', 'value' => $_POST['last_name'] ?? '',
'output_name' => 'Last Name', 'output_name' => 'Last Name',
'type' => 'text', 'type' => 'text',
'min_edit_acl' => '100', 'min_edit_acl' => '100',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'first_name' => [ 'first_name' => [
'value' => $GLOBALS['first_name'] ?? '', 'value' => $_POST['first_name'] ?? '',
'output_name' => 'First Name', 'output_name' => 'First Name',
'type' => 'text', 'type' => 'text',
'min_edit_acl' => '100', 'min_edit_acl' => '100',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'lock_until' => [ 'lock_until' => [
'value' => $GLOBALS['lock_until'] ?? '', 'value' => $_POST['lock_until'] ?? '',
'output_name' => 'Lock account until', 'output_name' => 'Lock account until',
'type' => 'datetime', 'type' => 'datetime',
'error_check' => 'datetime', 'error_check' => 'datetime',
@@ -168,7 +168,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'lock_after' => [ 'lock_after' => [
'value' => $GLOBALS['lock_after'] ?? '', 'value' => $_POST['lock_after'] ?? '',
'output_name' => 'Lock account after', 'output_name' => 'Lock account after',
'type' => 'datetime', 'type' => 'datetime',
'error_check' => 'datetime', 'error_check' => 'datetime',
@@ -177,7 +177,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id' => [ 'login_user_id' => [
'value' => $GLOBALS['login_user_id'] ?? '', 'value' => $_POST['login_user_id'] ?? '',
'output_name' => '_GET/_POST loginUserId direct login ID', 'output_name' => '_GET/_POST loginUserId direct login ID',
'type' => 'text', 'type' => 'text',
'error_check' => 'unique|custom', 'error_check' => 'unique|custom',
@@ -187,20 +187,20 @@ $edit_users = [
], ],
'login_user_id_set_date' => [ 'login_user_id_set_date' => [
'output_name' => 'loginUserId set date', 'output_name' => 'loginUserId set date',
'value' => $GLOBALS['login_user_id_set_date'] ?? '', 'value' => $_POST['login_user_id_set_date'] ?? '',
'type' => 'view', 'type' => 'view',
'empty' => '-', 'empty' => '-',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id_last_revalidate' => [ 'login_user_id_last_revalidate' => [
'output_name' => 'loginUserId last revalidate date', 'output_name' => 'loginUserId last revalidate date',
'value' => $GLOBALS['login_user_id_last_revalidate'] ?? '', 'value' => $_POST['login_user_id_last_revalidate'] ?? '',
'type' => 'view', 'type' => 'view',
'empty' => '-', 'empty' => '-',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id_locked' => [ 'login_user_id_locked' => [
'value' => $GLOBALS['login_user_id_locked'] ?? '', 'value' => $_POST['login_user_id_locked'] ?? '',
'output_name' => 'loginUserId usage locked', 'output_name' => 'loginUserId usage locked',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -212,7 +212,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id_revalidate_after' => [ 'login_user_id_revalidate_after' => [
'value' => $GLOBALS['login_user_id_revalidate_after'] ?? '', 'value' => $_POST['login_user_id_revalidate_after'] ?? '',
'output_name' => 'loginUserId, User must login after n days', 'output_name' => 'loginUserId, User must login after n days',
'type' => 'text', 'type' => 'text',
'error_check' => 'intervalshort', 'error_check' => 'intervalshort',
@@ -223,7 +223,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id_valid_from' => [ 'login_user_id_valid_from' => [
'value' => $GLOBALS['login_user_id_valid_from'] ?? '', 'value' => $_POST['login_user_id_valid_from'] ?? '',
'output_name' => 'loginUserId valid from', 'output_name' => 'loginUserId valid from',
'type' => 'datetime', 'type' => 'datetime',
'error_check' => 'datetime', 'error_check' => 'datetime',
@@ -233,7 +233,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_user_id_valid_until' => [ 'login_user_id_valid_until' => [
'value' => $GLOBALS['login_user_id_valid_until'] ?? '', 'value' => $_POST['login_user_id_valid_until'] ?? '',
'output_name' => 'loginUserId valid until', 'output_name' => 'loginUserId valid until',
'type' => 'datetime', 'type' => 'datetime',
'error_check' => 'datetime', 'error_check' => 'datetime',
@@ -243,7 +243,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'edit_language_id' => [ 'edit_language_id' => [
'value' => $GLOBALS['edit_language_id'] ?? '', 'value' => $_POST['edit_language_id'] ?? '',
'output_name' => 'Language', 'output_name' => 'Language',
'mandatory' => 1, 'mandatory' => 1,
'int' => 1, 'int' => 1,
@@ -253,7 +253,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'edit_scheme_id' => [ 'edit_scheme_id' => [
'value' => $GLOBALS['edit_scheme_id'] ?? '', 'value' => $_POST['edit_scheme_id'] ?? '',
'output_name' => 'Scheme', 'output_name' => 'Scheme',
'int_null' => 1, 'int_null' => 1,
'type' => 'drop_down_db', 'type' => 'drop_down_db',
@@ -262,7 +262,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'edit_group_id' => [ 'edit_group_id' => [
'value' => $GLOBALS['edit_group_id'] ?? '', 'value' => $_POST['edit_group_id'] ?? '',
'output_name' => 'Group', 'output_name' => 'Group',
'int' => 1, 'int' => 1,
'type' => 'drop_down_db', 'type' => 'drop_down_db',
@@ -272,7 +272,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'edit_access_right_id' => [ 'edit_access_right_id' => [
'value' => $GLOBALS['edit_access_right_id'] ?? '', 'value' => $_POST['edit_access_right_id'] ?? '',
'output_name' => 'User Level', 'output_name' => 'User Level',
'mandatory' => 1, 'mandatory' => 1,
'int' => 1, 'int' => 1,
@@ -283,27 +283,27 @@ $edit_users = [
], ],
'login_error_count' => [ 'login_error_count' => [
'output_name' => 'Login error count', 'output_name' => 'Login error count',
'value' => $GLOBALS['login_error_count'] ?? '', 'value' => $_POST['login_error_count'] ?? '',
'type' => 'view', 'type' => 'view',
'empty' => '0', 'empty' => '0',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_error_date_last' => [ 'login_error_date_last' => [
'output_name' => 'Last login error', 'output_name' => 'Last login error',
'value' => $GLOBALS['login_error_date_liast'] ?? '', 'value' => $_POST['login_error_date_liast'] ?? '',
'type' => 'view', 'type' => 'view',
'empty' => '-', 'empty' => '-',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'login_error_date_first' => [ 'login_error_date_first' => [
'output_name' => 'First login error', 'output_name' => 'First login error',
'value' => $GLOBALS['login_error_date_first'] ?? '', 'value' => $_POST['login_error_date_first'] ?? '',
'type' => 'view', 'type' => 'view',
'empty' => '-', 'empty' => '-',
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'protected' => [ 'protected' => [
'value' => $GLOBALS['protected'] ?? '', 'value' => $_POST['protected'] ?? '',
'output_name' => 'Protected', 'output_name' => 'Protected',
'type' => 'binary', 'type' => 'binary',
'int' => 1, 'int' => 1,
@@ -315,7 +315,7 @@ $edit_users = [
'min_show_acl' => '100', 'min_show_acl' => '100',
], ],
'additional_acl' => [ 'additional_acl' => [
'value' => $GLOBALS['additional_acl'] ?? '', 'value' => $_POST['additional_acl'] ?? '',
'output_name' => 'Additional ACL (as JSON)', 'output_name' => 'Additional ACL (as JSON)',
'type' => 'textarea', 'type' => 'textarea',
'error_check' => 'json', 'error_check' => 'json',
@@ -331,10 +331,10 @@ $edit_users = [
// if base acl is not 90 only list enabled // if base acl is not 90 only list enabled
// if not admin flag, do not list admin flagged // if not admin flag, do not list admin flagged
. ( . (
!$GLOBALS['acl_admin'] ? !$_POST['acl_admin'] ?
"WHERE admin = 0 " "WHERE admin = 0 "
. ( . (
$GLOBALS['base_acl_level'] < 90 ? $_POST['base_acl_level'] < 90 ?
"AND enabled = 1 " : "AND enabled = 1 " :
"" ""
) )

View File

@@ -5,18 +5,18 @@ declare(strict_types=1);
$edit_visible_group = [ $edit_visible_group = [
'table_array' => [ 'table_array' => [
'edit_visible_group_id' => [ 'edit_visible_group_id' => [
'value' => $GLOBALS['edit_visible_group_id'] ?? '', 'value' => $_POST['edit_visible_group_id'] ?? '',
'type' => 'hidden', 'type' => 'hidden',
'pk' => 1 'pk' => 1
], ],
'name' => [ 'name' => [
'value' => $GLOBALS['name'] ?? '', 'value' => $_POST['name'] ?? '',
'output_name' => 'Group name', 'output_name' => 'Group name',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text' 'type' => 'text'
], ],
'flag' => [ 'flag' => [
'value' => $GLOBALS['flag'] ?? '', 'value' => $_POST['flag'] ?? '',
'output_name' => 'Flag', 'output_name' => 'Flag',
'mandatory' => 1, 'mandatory' => 1,
'type' => 'text', 'type' => 'text',

View File

@@ -677,9 +677,19 @@ class Login
$_SESSION['GROUP_ACL_TYPE'] = $res['group_type']; $_SESSION['GROUP_ACL_TYPE'] = $res['group_type'];
// deprecated TEMPLATE setting // deprecated TEMPLATE setting
$_SESSION['TEMPLATE'] = $res['template'] ? $res['template'] : ''; $_SESSION['TEMPLATE'] = $res['template'] ? $res['template'] : '';
$_SESSION['HEADER_COLOR'] = $res['second_header_color'] ? $_SESSION['HEADER_COLOR'] = !empty($res['second_header_color']) ?
$res['second_header_color'] : $res['second_header_color'] :
$res['first_header_color']; $res['first_header_color'];
// missing # before, this is for legacy data, will be deprecated
if (preg_match("/^[\dA-Fa-f]{6,8}$/", $_SESSION['HEADER_COLOR'])) {
$_SESSION['HEADER_COLOR'] = '#' . $_SESSION['HEADER_COLOR'];
}
// TODO: make sure that header color is valid:
// # + 6 hex
// # + 8 hex (alpha)
// rgb(), rgba(), hsl(), hsla()
// rgb: nnn.n for each
// hsl: nnn.n for first, nnn.n% for 2nd, 3rd
$_SESSION['LANG'] = $res['locale'] ?? 'en'; $_SESSION['LANG'] = $res['locale'] ?? 'en';
$_SESSION['DEFAULT_CHARSET'] = $res['encoding'] ?? 'UTF-8'; $_SESSION['DEFAULT_CHARSET'] = $res['encoding'] ?? 'UTF-8';
$_SESSION['DEFAULT_LOCALE'] = $_SESSION['LANG'] $_SESSION['DEFAULT_LOCALE'] = $_SESSION['LANG']

View File

@@ -12,7 +12,7 @@
* you don't have to write any SQL queries, worry over update/insert * you don't have to write any SQL queries, worry over update/insert
* *
* HISTORY: * HISTORY:
* 2019/9/11 (cs) error string 21->91, 22->92 for not overlapping with IO * 2019/9/11 (cs) error string 21->1021, 22->1022 for not overlapping with IO
* 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax * 2005/07/07 (cs) updated array class for postgres: set 0 & NULL if int field given, insert uses () values () syntax
* 2005/03/31 (cs) fixed the class call with all debug vars * 2005/03/31 (cs) fixed the class call with all debug vars
* 2003-03-10: error_ids where still wrong chagned 11->21 and 12->22 * 2003-03-10: error_ids where still wrong chagned 11->21 and 12->22
@@ -72,20 +72,24 @@ class ArrayIO extends \CoreLibs\DB\IO
// instance db_io class // instance db_io class
parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging()); parent::__construct($db_config, $log ?? new \CoreLibs\Debug\Logging());
// more error vars for this class // more error vars for this class
$this->error_string['91'] = 'No Primary Key given'; $this->error_string['1999'] = 'No table array or table name set';
$this->error_string['92'] = 'Could not run Array Query'; $this->error_string['1021'] = 'No Primary Key given';
$this->error_string['1022'] = 'Could not run Array Query';
$this->table_array = $table_array; $this->table_array = $table_array;
$this->table_name = $table_name; $this->table_name = $table_name;
// error abort if no table array or no table name
if (empty($table_array) || empty($table_name)) {
$this->__dbError(1999, false, 'MAJOR ERROR: Core settings missing');
}
// set primary key for given table_array // set primary key for given table_array
if (is_array($this->table_array)) { foreach ($this->table_array as $key => $value) {
foreach ($this->table_array as $key => $value) { if (!empty($value['pk'])) {
if (isset($value['pk'])) { $this->pk_name = $key;
$this->pk_name = $key;
}
} }
} // set pk_name IF table_array was given }
$this->dbArrayIOSetAcl($base_acl_level, $acl_admin); $this->dbArrayIOSetAcl($base_acl_level, $acl_admin);
} }
@@ -197,7 +201,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// if not set ... produce error // if not set ... produce error
if (!$this->table_array[$this->pk_name]['value']) { if (!$this->table_array[$this->pk_name]['value']) {
// if no PK found, error ... // if no PK found, error ...
$this->__dbError(91); $this->__dbError(1021);
return false; return false;
} else { } else {
return true; return true;
@@ -282,7 +286,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// if 0, error // if 0, error
$this->pk_id = null; $this->pk_id = null;
if (!$this->dbExec($q)) { if (!$this->dbExec($q)) {
$this->__dbError(92); $this->__dbError(1022);
} }
return $this->table_array; return $this->table_array;
} }
@@ -369,7 +373,7 @@ class ArrayIO extends \CoreLibs\DB\IO
// possible dbFetchArray errors ... // possible dbFetchArray errors ...
$this->pk_id = $this->table_array[$this->pk_name]['value']; $this->pk_id = $this->table_array[$this->pk_name]['value'];
} else { } else {
$this->__dbError(92); $this->__dbError(1022);
} }
return $this->table_array; return $this->table_array;
} }
@@ -631,7 +635,7 @@ class ArrayIO extends \CoreLibs\DB\IO
} }
// return success or not // return success or not
if (!$this->dbExec($q)) { if (!$this->dbExec($q)) {
$this->__dbError(92); $this->__dbError(1022);
} }
// set primary key // set primary key
if ($insert) { if ($insert) {

View File

@@ -307,19 +307,21 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
* @param \CoreLibs\Language\L10n|null $l10n l10n language class, null auto set * @param \CoreLibs\Language\L10n|null $l10n l10n language class, null auto set
* @param array<string,string>|null $locale locale array from ::setLocale, * @param array<string,string>|null $locale locale array from ::setLocale,
* null auto set * null auto set
* @param array<mixed>|null $table_arrays Override table array data
* instead of try to load from
* include file
*/ */
public function __construct( public function __construct(
array $db_config, array $db_config,
?\CoreLibs\Debug\Logging $log = null, ?\CoreLibs\Debug\Logging $log = null,
?\CoreLibs\Language\L10n $l10n = null, ?\CoreLibs\Language\L10n $l10n = null,
?array $locale = null ?array $locale = null,
?array $table_arrays = null,
) { ) {
// don't log per class // don't log per class
if ($log !== null) { if ($log !== null) {
$log->setLogPer('class', false); $log->setLogPer('class', false);
} }
// if set global table array variable
global $table_arrays;
// replace any non valid variable names // replace any non valid variable names
// TODO extract only alphanumeric and _ after . to _ replacement // TODO extract only alphanumeric and _ after . to _ replacement
$this->my_page_name = str_replace(['.'], '_', System::getPageName(System::NO_EXTENSION)); $this->my_page_name = str_replace(['.'], '_', System::getPageName(System::NO_EXTENSION));
@@ -346,15 +348,9 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// security settings // security settings
$this->base_acl_level = (int)$_SESSION['BASE_ACL_LEVEL']; $this->base_acl_level = (int)$_SESSION['BASE_ACL_LEVEL'];
$this->acl_admin = (int)$_SESSION['ADMIN']; $this->acl_admin = (int)$_SESSION['ADMIN'];
$GLOBALS['base_acl_level'] = $this->base_acl_level;
$GLOBALS['acl_admin'] = $this->acl_admin;
// first check if we have a in page override as $table_arrays[page name] // first check if we have a in page override as $table_arrays[page name]
if ( if (
/* isset($GLOBALS['table_arrays']) &&
is_array($GLOBALS['table_arrays']) &&
isset($GLOBALS['table_arrays'][System::getPageName(System::NO_EXTENSION)]) &&
is_array($GLOBALS['table_arrays'][System::getPageName(System::NO_EXTENSION)]) */
isset($table_arrays[System::getPageName(System::NO_EXTENSION)]) && isset($table_arrays[System::getPageName(System::NO_EXTENSION)]) &&
is_array($table_arrays[System::getPageName(System::NO_EXTENSION)]) is_array($table_arrays[System::getPageName(System::NO_EXTENSION)])
) { ) {
@@ -1480,7 +1476,8 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// $this->log->debug('edit_error', 'QS: <pre>' . print_r($_POST, true) . '</pre>'); // $this->log->debug('edit_error', 'QS: <pre>' . print_r($_POST, true) . '</pre>');
if (is_array($this->element_list)) { if (is_array($this->element_list)) {
// check the mandatory stuff // check the mandatory stuff
// if mandatory, check that at least on pk exists or if at least the mandatory field is filled // if mandatory, check that at least on pk exists or
// if at least the mandatory field is filled
foreach ($this->element_list as $table_name => $reference_array) { foreach ($this->element_list as $table_name => $reference_array) {
if (!is_array($reference_array)) { if (!is_array($reference_array)) {
$reference_array = []; $reference_array = [];
@@ -1520,7 +1517,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// . count($_POST[$prfx.$key]) . ' | M: $max'); // . count($_POST[$prfx.$key]) . ' | M: $max');
// $this->log->debug('edit_error_chk', 'K: ' . $_POST[$prfx.$key] . ' | ' . $_POST[$prfx.$key][0]); // $this->log->debug('edit_error_chk', 'K: ' . $_POST[$prfx.$key] . ' | ' . $_POST[$prfx.$key][0]);
} }
$this->log->debug('POST ARRAY', $this->log->prAr($_POST)); // $this->log->debug('POST ARRAY', $this->log->prAr($_POST));
// init variables before inner loop run // init variables before inner loop run
$mand_okay = 0; $mand_okay = 0;
$mand_name = ''; $mand_name = '';
@@ -1532,15 +1529,17 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
for ($i = 0; $i < $max; $i++) { for ($i = 0; $i < $max; $i++) {
// either one of the post pks is set, or the mandatory // either one of the post pks is set, or the mandatory
foreach ($reference_array['elements'] as $el_name => $data_array) { foreach ($reference_array['elements'] as $el_name => $data_array) {
if (isset($data_array['mandatory']) && $data_array['mandatory']) { if (
isset($data_array['mandatory']) &&
$data_array['mandatory']
) {
$mand_name = $data_array['output_name']; $mand_name = $data_array['output_name'];
} }
// check if there is a primary ket inside, so it is okay // check if there is a primary ket inside, so it is okay
if ( if (
isset($data_array['pk_id']) && isset($data_array['pk_id']) &&
count($_POST[$prfx . $el_name]) && count($_POST[$prfx . $el_name]) &&
isset($reference_array['mandatory']) && !empty($reference_array['mandatory'])
$reference_array['mandatory']
) { ) {
$mand_okay = 1; $mand_okay = 1;
} }
@@ -1551,15 +1550,14 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// . $_POST[$prfx . $el_name] . ' - ' . $reference_array['enable_name'] . ' - ' // . $_POST[$prfx . $el_name] . ' - ' . $reference_array['enable_name'] . ' - '
// . $_POST[$reference_array['enable_name']][$_POST[$prfx . $el_name][$i]]); // . $_POST[$reference_array['enable_name']][$_POST[$prfx . $el_name][$i]]);
if ( if (
isset($data_array['mandatory']) && !empty($data_array['mandatory']) &&
$data_array['mandatory'] && !empty($_POST[$prfx . $el_name][$i])
isset($_POST[$prfx . $el_name][$i]) &&
$_POST[$prfx . $el_name][$i]
) { ) {
$mand_okay = 1; $mand_okay = 1;
$row_okay[$i] = 1; $row_okay[$i] = 1;
} elseif ( } elseif (
!empty($data_array['type']) && $data_array['type'] == 'radio_group' && !empty($data_array['type']) &&
$data_array['type'] == 'radio_group' &&
!isset($_POST[$prfx . $el_name]) !isset($_POST[$prfx . $el_name])
) { ) {
// radio group and set where one not active // radio group and set where one not active
@@ -1567,20 +1565,22 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$row_okay[$_POST[$prfx . $el_name][$i] ?? 0] = 0; $row_okay[$_POST[$prfx . $el_name][$i] ?? 0] = 0;
$default_wrong[$_POST[$prfx . $el_name][$i] ?? 0] = 1; $default_wrong[$_POST[$prfx . $el_name][$i] ?? 0] = 1;
$error[$_POST[$prfx . $el_name][$i] ?? 0] = 1; $error[$_POST[$prfx . $el_name][$i] ?? 0] = 1;
} elseif (isset($_POST[$prfx . $el_name][$i]) && !isset($error[$i])) { } elseif (
isset($_POST[$prfx . $el_name][$i]) &&
!isset($error[$i])
) {
// $this->log->debug('edit_error_chk', '[$i]'); // $this->log->debug('edit_error_chk', '[$i]');
$element_set[$i] = 1; $element_set[$i] = 1;
$row_okay[$i] = 1; $row_okay[$i] = 1;
} elseif ( } elseif (
isset($data_array['mandatory']) && !empty($data_array['mandatory']) &&
$data_array['mandatory'] &&
!$_POST[$prfx . $el_name][$i] !$_POST[$prfx . $el_name][$i]
) { ) {
$row_okay[$i] = 0; $row_okay[$i] = 0;
} }
// do optional error checks like for normal fields // do optional error checks like for normal fields
// currently active: unique/alphanumeric // currently active: unique/alphanumeric
if (isset($data_array['error_check'])) { if (!empty($data_array['error_check'])) {
foreach (explode('|', $data_array['error_check']) as $error_check) { foreach (explode('|', $data_array['error_check']) as $error_check) {
switch ($error_check) { switch ($error_check) {
// check unique, check if field is filled and not same in _POST set // check unique, check if field is filled and not same in _POST set
@@ -1599,6 +1599,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$reference_array['output_name'], $reference_array['output_name'],
$i $i
); );
$_POST['ERROR'][$prfx][$i] = 1;
} }
break; break;
case 'alphanumericspace': case 'alphanumericspace':
@@ -1614,6 +1615,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
$reference_array['output_name'], $reference_array['output_name'],
$i $i
); );
$_POST['ERROR'][$prfx][$i] = 1;
} }
break; break;
} }
@@ -1625,8 +1627,7 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
// main mandatory is met -> error msg // main mandatory is met -> error msg
if ( if (
!$mand_okay && !$mand_okay &&
isset($reference_array['mandatory']) && !empty($reference_array['mandatory'])
$reference_array['mandatory']
) { ) {
$this->msg .= sprintf( $this->msg .= sprintf(
$this->l->__('You need to enter at least one data set for field <b>%s</b>!<br>'), $this->l->__('You need to enter at least one data set for field <b>%s</b>!<br>'),
@@ -2535,12 +2536,13 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
} }
// $this->log->debug('CFG QUERY', 'Q: ' . $q); // $this->log->debug('CFG QUERY', 'Q: ' . $q);
// only run if we have query strnig // only run if we have query strnig
$written_pos = [];
if (isset($q)) { if (isset($q)) {
$prfx = $data['prefix']; // short
$pos = 0; // position in while for overwrite if needed $pos = 0; // position in while for overwrite if needed
// read out the list and add the selected data if needed // read out the list and add the selected data if needed
while (is_array($res = $this->dbReturn($q))) { while (is_array($res = $this->dbReturn($q))) {
$_data = []; $_data = [];
$prfx = $data['prefix']; // short
// go through each res // go through each res
for ($i = 0, $i_max = count($q_select); $i < $i_max; $i++) { for ($i = 0, $i_max = count($q_select); $i < $i_max; $i++) {
// query select part, set to the element name // query select part, set to the element name
@@ -2570,13 +2572,48 @@ class Generate extends \CoreLibs\DB\Extended\ArrayIO
} }
$data['content'][] = $_data; $data['content'][] = $_data;
$data['pos'][] = [0 => $pos]; // this is for the checkboxes $data['pos'][] = [0 => $pos]; // this is for the checkboxes
$written_pos[] = $pos;
$pos++; // move up one $pos++; // move up one
// reset and unset before next run // reset and unset before next run
unset($_data); unset($_data);
} }
} }
// add lost error ones
$this->log->debug('ERROR', 'P: ' . $data['prefix'] . ', '
. $this->log->prAr($_POST['ERROR'][$data['prefix']] ?? []));
if ($this->error && !empty($_POST['ERROR'][$data['prefix']])) {
$prfx = $data['prefix']; // short
$_post_data = [];
// MAX entries defined via $data['pk_name'] entry (must exist)
$_max_pos = count($_POST[$data['pk_name']] ?? []);
// write all excte previous loaded @ $pos
foreach ($q_select as $_el_name) {
for ($_pos = 0; $_pos <= $_max_pos; $_pos++) {
// if not in data pos
if (!in_array($_pos, $written_pos)) {
$_post_data[$_pos][$prfx . $_el_name] =
$_POST[$prfx . $_el_name][$_pos] ?? '';
}
}
}
// only add if all fields in data are filled, else skip
// pk_name field is excluded of check
foreach ($_post_data as $_pos => $_data) {
$filled = false;
foreach ($_data as $_name => $_value) {
if ($_name != $data['pk_name'] && !empty($_value)) {
$filled = true;
}
}
if ($filled == true) {
$data['content'][] = $_data;
$data['pos'][] = [0 => $_pos];
}
}
}
// if this is normal single reference data check the content on the element count // if this is normal single reference data check the content on the element count
// if there is a max_empty is set, then fill up new elements (unfilled) until we reach max empty // if there is a max_empty is set, then fill up new elements (unfilled)
// until we reach max empty
if ( if (
/*isset($this->element_list[$table_name]['type']) && /*isset($this->element_list[$table_name]['type']) &&
$this->element_list[$table_name]['type'] == 'reference_data' &&*/ $this->element_list[$table_name]['type'] == 'reference_data' &&*/