From f9f43ac105f9824e6b0b625b811377e46bafc8d9 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 13 Jun 2022 13:09:34 +0000 Subject: [PATCH 01/25] add layout feature --- require/function_layout.php | 136 ++++++++++++++++++++++++++++++++ require/function_table_html.php | 23 +++++- require/header.php | 1 + 3 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 require/function_layout.php diff --git a/require/function_layout.php b/require/function_layout.php new file mode 100644 index 000000000..248bda8ef --- /dev/null +++ b/require/function_layout.php @@ -0,0 +1,136 @@ +form_name = $form; + } + + + public function insertLayout($layout_name, $user, $cols) { + // check that we have everything before attempting to insert + if (!empty($cols) && !empty($layout_name) && !empty($user)) { + // check for a layout w/ same name or columns already existing for this user + $dupli_check = $this->checkLayout($layout_name, $user, $cols); + if (empty($dupli_check)) { + $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS) VALUES ('$layout_name', '$user', '".$this->form_name."', $cols)"; + $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); + + // check that layout was inserted + if ($result) { + msg_success("Layout '$layout_name' created"); + } else { + msg_error("Error creating layout '$layout_name'"); + } + + } else { + msg_error($dupli_check); + } + + } else { + msg_error("Please provide a layout name"); + } + } + + + public function getLayout($user, $layout_name) { + $query = "SELECT COLUMNS FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; + // error_log($query); + $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); + if ($result) { + $layout = mysqli_fetch_array($result); + return $layout; + } else { + return false; + } + } + + + public function deleteLayout() { + + } + + // will get layout to be displayed if any selected + show the layouts buttons + public function displayLayoutButtons($user, $current_tab) { + // error_log(print_r($current_tab, true)); + // if user selected a layout, get the correct columns + if (isset($current_tab) && $current_tab != 'Add new') { + $colus = $this->getLayout($_SESSION['OCS']['loggeduser'], $current_tab); + } elseif (isset($current_tab) && $current_tab == 'Add new') { + // redirect to ms_layouts page + $urls = $_SESSION['OCS']['url_service']; + $layout_url = $urls->getUrl('ms_layouts'); + //error_log($layout_url); + $url = "index.php?function=$layout_url&value=$this->form_name&tab=add"; + change_window($url); + } + + + // display as many buttons as there are layouts for this user + an extra button to add a new layout + $query = "SELECT * FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."'"; + $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); + $nb_layouts = mysqli_fetch_all($result, MYSQLI_ASSOC); + $layout_tabs = array(); + + foreach ($nb_layouts as $key => $value) { + $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; + } + array_push($layout_tabs, "Add new"); + $this->layout_tabs = $layout_tabs; + + + // loop through layout_tabs and display a link for each one + foreach ($layout_tabs as $key => $value) { + // display buttons ('add new' takes user to layouts page / others display correct layout of cols) + if ($value == 'Add new') { + echo ""; + } else { + echo ""; + } + + } + + return $colus; + } + + + // checking for duplicate layout (same user and same name and/or columns) + private function checkLayout($layout_name, $user, $cols) { + $query = "SELECT * FROM layouts WHERE USER = '$user' AND COLUMNS = $cols OR LAYOUT_NAME = '$layout_name'"; + $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); + if (mysqli_num_rows($result) > 0) { + $dupli = ("A layout with the same name or columns already exists for your user, please choose another name or update the existing one"); + } else { + $dupli = false; + } + return $dupli; + } + +} +?> \ No newline at end of file diff --git a/require/function_table_html.php b/require/function_table_html.php index d21ae25e6..a6d32d9be 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -275,8 +275,14 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list ?> " . $l->g(1380) . ""; - ?> + + echo "
"; + + // layouts + $layout = new Layout($option['table_name']); + $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout']); + ?> + $value){ - echo "
  • Date: Mon, 13 Jun 2022 13:40:12 +0000 Subject: [PATCH 03/25] add layout page to urls --- config/urls.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/urls.xml b/config/urls.xml index 129c09ba7..6d29cf0ea 100644 --- a/config/urls.xml +++ b/config/urls.xml @@ -328,4 +328,8 @@ admin_local_import ms_upload_file + + layouts + ms_layouts + From 4eb71b9a4816d1a49a6494ab0109fc87bb586ddb Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Tue, 14 Jun 2022 08:38:05 +0000 Subject: [PATCH 04/25] fix actions col --- require/function_table_html.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index 4a518acc0..492963501 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -254,7 +254,13 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list } ?> + displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'], $option['table_name']); + ?> @@ -268,6 +274,7 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list "; @@ -279,9 +286,6 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list echo "
    "; - // layouts - $layout = new Layout($option['table_name']); - $cols = $layout->displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout']); ?> @@ -399,6 +403,10 @@ function checkall() "columns": [ Date: Thu, 16 Jun 2022 12:54:46 +0000 Subject: [PATCH 05/25] add delete layout --- require/function_layout.php | 39 ++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/require/function_layout.php b/require/function_layout.php index 248bda8ef..f5b93f166 100644 --- a/require/function_layout.php +++ b/require/function_layout.php @@ -33,13 +33,13 @@ public function __construct($form) { } - public function insertLayout($layout_name, $user, $cols) { + public function insertLayout($layout_name, $layout_descr, $user, $cols) { // check that we have everything before attempting to insert if (!empty($cols) && !empty($layout_name) && !empty($user)) { // check for a layout w/ same name or columns already existing for this user $dupli_check = $this->checkLayout($layout_name, $user, $cols); if (empty($dupli_check)) { - $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS) VALUES ('$layout_name', '$user', '".$this->form_name."', $cols)"; + $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS, DESCRIPTION) VALUES ('$layout_name', '$user', '".$this->form_name."', $cols, '$layout_descr')"; $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); // check that layout was inserted @@ -51,6 +51,7 @@ public function insertLayout($layout_name, $user, $cols) { } else { msg_error($dupli_check); + return $dupli_check; } } else { @@ -61,7 +62,6 @@ public function insertLayout($layout_name, $user, $cols) { public function getLayout($user, $layout_name) { $query = "SELECT COLUMNS FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; - // error_log($query); $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); if ($result) { $layout = mysqli_fetch_array($result); @@ -72,23 +72,21 @@ public function getLayout($user, $layout_name) { } - public function deleteLayout() { - + public function deleteLayout($id) { + $query = "DELETE FROM layouts WHERE ID = '$id'"; + $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); + if ($result) { + msg_success("Layout deleted"); + } else { + msg_error("Error deleting layout"); + } } // will get layout to be displayed if any selected + show the layouts buttons - public function displayLayoutButtons($user, $current_tab) { - // error_log(print_r($current_tab, true)); + public function displayLayoutButtons($user, $current_tab, $table) { // if user selected a layout, get the correct columns if (isset($current_tab) && $current_tab != 'Add new') { $colus = $this->getLayout($_SESSION['OCS']['loggeduser'], $current_tab); - } elseif (isset($current_tab) && $current_tab == 'Add new') { - // redirect to ms_layouts page - $urls = $_SESSION['OCS']['url_service']; - $layout_url = $urls->getUrl('ms_layouts'); - //error_log($layout_url); - $url = "index.php?function=$layout_url&value=$this->form_name&tab=add"; - change_window($url); } @@ -109,7 +107,11 @@ public function displayLayoutButtons($user, $current_tab) { foreach ($layout_tabs as $key => $value) { // display buttons ('add new' takes user to layouts page / others display correct layout of cols) if ($value == 'Add new') { - echo ""; + // redirect to ms_layouts page + $urls = $_SESSION['OCS']['url_service']; + $layout_url = $urls->getUrl('ms_layouts'); + $url = "index.php?function=$layout_url&value=$table&tab=add"; + echo "$value"; } else { echo ""; } @@ -120,12 +122,13 @@ public function displayLayoutButtons($user, $current_tab) { } - // checking for duplicate layout (same user and same name and/or columns) + // checking for duplicate layout (same user and same name and/or columns for same table) private function checkLayout($layout_name, $user, $cols) { - $query = "SELECT * FROM layouts WHERE USER = '$user' AND COLUMNS = $cols OR LAYOUT_NAME = '$layout_name'"; + $query = "SELECT * FROM layouts WHERE USER = '$user' AND TABLE_NAME = '$this->form_name' AND (COLUMNS = $cols OR LAYOUT_NAME = '$layout_name')"; + //error_log($query); $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); if (mysqli_num_rows($result) > 0) { - $dupli = ("A layout with the same name or columns already exists for your user, please choose another name or update the existing one"); + $dupli = ("A layout with the same name or columns already exists for your user, please choose another name"); } else { $dupli = false; } From 8350fd835fd4d70bba9b777e249daa6842f935da Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Thu, 16 Jun 2022 12:55:57 +0000 Subject: [PATCH 06/25] add ms layouts page --- .../main_sections/ms_layouts/ms_layouts.php | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 plugins/main_sections/ms_layouts/ms_layouts.php diff --git a/plugins/main_sections/ms_layouts/ms_layouts.php b/plugins/main_sections/ms_layouts/ms_layouts.php new file mode 100644 index 000000000..31c28465d --- /dev/null +++ b/plugins/main_sections/ms_layouts/ms_layouts.php @@ -0,0 +1,111 @@ +insertLayout($protectedPost['LAYOUT_NAME'], $protectedPost['LAYOUT_DESCR'], $_SESSION['OCS']['loggeduser'], $_SESSION['OCS']['layout_cols']); + if (!empty($dupli)) { + unset($protectedPost['Valid_modif']); + } + +} + +// if no layout has been added yet and user did not delete layout : show the form +if ((isset($protectedGet['tab']) && $protectedGet['tab'] == 'add') && (!isset($protectedPost['Valid_modif'])) && (!isset($protectedPost['SUP_PROF']) && !isset($protectedPost['del_check'])) && !isset($protectedPost['show_list'])) { + echo open_form('layouts', '', '', 'form-horizontal'); + ?> +
    + +
    +
    +
    + + +
    +
    + deleteLayout($protectedPost['SUP_PROF']); + $tab_options['CACHE'] = 'RESET'; + } + + if (is_defined($protectedPost['del_check'])) { + $layout->deleteLayout($protectedPost['del_check']); + $tab_options['CACHE'] = 'RESET'; + } + $table_name = $form_name; + $tab_options['form_name'] = $form_name; + $tab_options['table_name'] = $table_name; + + $list_fields = array( + 'LAYOUT_NAME' => 'LAYOUT_NAME', + 'USER' => 'USER', + 'TABLE_NAME' => 'TABLE_NAME', + 'DESCRIPTION' => 'DESCRIPTION' + ); + $list_col_cant_del = array( + 'LAYOUT_NAME' => 'LAYOUT_NAME', + 'USER' => 'USER', + 'TABLE_NAME' => 'TABLE_NAME', + 'SUP' => 'SUP', + 'CHECK' => 'CHECK' + ); + + $list_fields['SUP'] = 'ID'; + $list_fields['CHECK'] = 'ID'; + + $default_fields = $list_fields; + $tab_options['FILTRE'] = $list_fields; + $queryDetails = "SELECT ID, LAYOUT_NAME, USER, TABLE_NAME, DESCRIPTION FROM `layouts`"; + + ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del); + $img['image/delete.png'] = $l->g(162); + del_selection($form_name); + echo close_form(); + +} + + +if (AJAX) { + ob_end_clean(); + tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options); +} \ No newline at end of file From 286f25a68c35796cb602f9885224b808a70a720e Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Thu, 16 Jun 2022 13:09:24 +0000 Subject: [PATCH 07/25] update table function --- require/function_table_html.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index 492963501..d1b4ab6bf 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -130,7 +130,6 @@ function xml_decode($txt) { */ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list_col_cant_del) { global $protectedPost, $l, $pages_refs; - //Translated name of the column $lbl_column = array("ACTIONS" => $l->g(1381), "CHECK" => ""); @@ -468,7 +467,9 @@ function checkall() } } else { + echo $cols[0]; + } ?> @@ -553,7 +554,8 @@ function checkall() Date: Thu, 16 Jun 2022 14:14:51 +0000 Subject: [PATCH 08/25] create table layouts --- files/update/7063.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 files/update/7063.sql diff --git a/files/update/7063.sql b/files/update/7063.sql new file mode 100644 index 000000000..b30b5daa1 --- /dev/null +++ b/files/update/7063.sql @@ -0,0 +1,10 @@ +-- Create layouts table +CREATE TABLE IF NOT EXISTS `layouts` ( + `ID` BIGINT NOT NULL AUTO_INCREMENT, + `LAYOUT_NAME` VARCHAR(255) NOT NULL, + `USER` VARCHAR(255) NOT NULL, + `TABLE_NAME` VARCHAR(255) NOT NULL, + `COLUMNS` TEXT NOT NULL, + `DESCRIPTION` VARCHAR(255) NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=UTF8; \ No newline at end of file From de0feae77226804192503920b895437963cd1dc7 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 17 Jun 2022 09:26:51 +0000 Subject: [PATCH 09/25] change process to use visible_col + add translations --- plugins/language/en_GB/en_GB.txt | 10 +++ plugins/language/fr_FR/fr_FR.txt | 9 +++ .../main_sections/ms_layouts/ms_layouts.php | 10 +-- require/function_layout.php | 71 ++++++++++--------- require/function_table_html.php | 31 +++----- 5 files changed, 72 insertions(+), 59 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index b0be1bdb2..4df2d90ba 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1827,3 +1827,13 @@ 9704 CAS Configuration 9800 Exclude archived computers from statistics, CVE inventory, all softwares count, computers per TAG count + +9900 Layouts +9901 Layout created +9902 Layout deleted +9903 Error creating layout +9904 Please check your input. Repeat the process if the problem persists. +9905 Error deleting layout +9906 A layout with the same name or columns already exists for your user, please choose another name or set of columns +9907 Manage layouts +9908 Show all layouts \ No newline at end of file diff --git a/plugins/language/fr_FR/fr_FR.txt b/plugins/language/fr_FR/fr_FR.txt index 7e2639c1f..a4a88c677 100644 --- a/plugins/language/fr_FR/fr_FR.txt +++ b/plugins/language/fr_FR/fr_FR.txt @@ -1824,3 +1824,12 @@ 9800 Exlure les machines archivées des Statistiques, de l'inventaire CVE, du compte de Tous les logiciels, du compte des machines par TAG +9900 Dispositions +9901 Disposition créée +9902 Disposition supprimée +9903 Erreur lors de la création de la disposition +9904 Veuillez vérifier votre entrée. Répétez le processus si le problème persiste. +9905 Erreur lors de la suppression de la disposition +9906 Une disposition avec le même nom ou les mêmes colonnes existe déjà pour votre utilisateur. Veuillez choisir un autre nom ou d'autres colonnes. +9907 Gestion des dispositions +9908 Afficher les dispositions \ No newline at end of file diff --git a/plugins/main_sections/ms_layouts/ms_layouts.php b/plugins/main_sections/ms_layouts/ms_layouts.php index 31c28465d..e01c0cf55 100644 --- a/plugins/main_sections/ms_layouts/ms_layouts.php +++ b/plugins/main_sections/ms_layouts/ms_layouts.php @@ -27,13 +27,14 @@ ob_start(); } -printEnTete('Manage layouts'); +printEnTete($l->g(9907)); $form_name = "layouts"; $layout = new Layout($protectedGet['value']); //ADD new layout -if (isset($protectedPost['Valid_modif']) && (!empty($_SESSION['OCS']['layout_cols']) || !empty($protectedPost['add_layout']) )){ - $dupli = $layout->insertLayout($protectedPost['LAYOUT_NAME'], $protectedPost['LAYOUT_DESCR'], $_SESSION['OCS']['loggeduser'], $_SESSION['OCS']['layout_cols']); +if (isset($protectedPost['Valid_modif']) && (!empty($_SESSION['OCS']['layout_cols']))){ + $dupli = $layout->insertLayout($protectedPost['LAYOUT_NAME'], $protectedPost['LAYOUT_DESCR'], $_SESSION['OCS']['loggeduser'], $_SESSION['OCS']['layout_cols'], $_SESSION['OCS']['layout_visib']); + // if dupli, user needs to be redirected to the form and not to the list if (!empty($dupli)) { unset($protectedPost['Valid_modif']); } @@ -53,7 +54,7 @@
    - +
    checkLayout($layout_name, $user, $cols); + $dupli_check = $this->checkLayout($layout_name, $user, $visib); if (empty($dupli_check)) { - $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS, DESCRIPTION) VALUES ('$layout_name', '$user', '".$this->form_name."', $cols, '$layout_descr')"; + $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS, DESCRIPTION, visible_col) VALUES ('$layout_name', '$user', '".$this->form_name."', '$cols', '$layout_descr', '$visib')"; + $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); // check that layout was inserted if ($result) { - msg_success("Layout '$layout_name' created"); + msg_success($l->g(9901)); } else { - msg_error("Error creating layout '$layout_name'"); + msg_error($l->g(9903)); } } else { @@ -55,13 +60,13 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols) { } } else { - msg_error("Please provide a layout name"); + msg_error($l->g(9904)); } } public function getLayout($user, $layout_name) { - $query = "SELECT COLUMNS FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; + $query = "SELECT COLUMNS, visible_col FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); if ($result) { $layout = mysqli_fetch_array($result); @@ -73,23 +78,24 @@ public function getLayout($user, $layout_name) { public function deleteLayout($id) { + global $l; $query = "DELETE FROM layouts WHERE ID = '$id'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); if ($result) { - msg_success("Layout deleted"); + msg_success($l->g(9902)); } else { - msg_error("Error deleting layout"); + msg_error($l->g(9905)); } } // will get layout to be displayed if any selected + show the layouts buttons public function displayLayoutButtons($user, $current_tab, $table) { + global $l; // if user selected a layout, get the correct columns if (isset($current_tab) && $current_tab != 'Add new') { $colus = $this->getLayout($_SESSION['OCS']['loggeduser'], $current_tab); } - // display as many buttons as there are layouts for this user + an extra button to add a new layout $query = "SELECT * FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); @@ -99,36 +105,37 @@ public function displayLayoutButtons($user, $current_tab, $table) { foreach ($nb_layouts as $key => $value) { $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; } - array_push($layout_tabs, "Add new"); - $this->layout_tabs = $layout_tabs; - - // loop through layout_tabs and display a link for each one + echo ''; return $colus; } // checking for duplicate layout (same user and same name and/or columns for same table) - private function checkLayout($layout_name, $user, $cols) { - $query = "SELECT * FROM layouts WHERE USER = '$user' AND TABLE_NAME = '$this->form_name' AND (COLUMNS = $cols OR LAYOUT_NAME = '$layout_name')"; - //error_log($query); + private function checkLayout($layout_name, $user, $visib) { + global $l; + $query = "SELECT * FROM layouts WHERE USER = '$user' AND TABLE_NAME = '$this->form_name' AND (visible_col = '$visib' OR LAYOUT_NAME = '$layout_name')"; $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); if (mysqli_num_rows($result) > 0) { - $dupli = ("A layout with the same name or columns already exists for your user, please choose another name"); + $dupli = $l->g(9906); } else { $dupli = false; } diff --git a/require/function_table_html.php b/require/function_table_html.php index d1b4ab6bf..9fb631344 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -254,11 +254,11 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list ?> displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'], $option['table_name']); + $columns = json_decode($cols['COLUMNS'], true) ?? $columns; + $visible_col = json_decode($cols['visible_col'], true) ?? $visible_col; ?> @@ -402,18 +402,11 @@ function checkall() "columns": [ $column) { if (!empty($visible_col)) { if ((in_array($index, $visible_col))) { @@ -445,8 +438,6 @@ function checkall() $key = $option['REPLACE_COLUMN_KEY'][$key]; } - $layout_cols .= "{'data' : '" . $key . "' , 'class':'" . $key . "', 'name':'" . $key . "', 'defaultContent': ' ', 'orderable': " . $orderable . ",'searchable': false, 'visible' : " . $visible . "},"; - echo "{'data' : '" . $key . "' , 'class':'" . $key . "', 'name':'" . $key . "', 'defaultContent': ' ', 'orderable': " . $orderable . ",'searchable': false, @@ -458,7 +449,6 @@ function checkall() if (!empty($option['REPLACE_COLUMN_KEY'][$key])) { $name = $option['REPLACE_COLUMN_KEY'][$key]; } - $layout_cols .= "{'data' : '" . $name . "' , 'class':'" . $name . "', 'name':'" . $column . "', 'defaultContent': ' ', 'orderable': " . $orderable . ", 'visible' : " . $visible . "},"; echo "{ 'data' : '" . $name . "' , 'class':'" . $name . "', 'name':'" . $column . "', 'defaultContent': ' ', @@ -466,12 +456,7 @@ function checkall() } } -} else { - echo $cols[0]; - - -} ?> ], //Translation @@ -554,8 +539,10 @@ function checkall() Date: Fri, 17 Jun 2022 09:49:05 +0000 Subject: [PATCH 10/25] add column to sql table --- files/update/7063.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/files/update/7063.sql b/files/update/7063.sql index b30b5daa1..99a617421 100644 --- a/files/update/7063.sql +++ b/files/update/7063.sql @@ -6,5 +6,6 @@ CREATE TABLE IF NOT EXISTS `layouts` ( `TABLE_NAME` VARCHAR(255) NOT NULL, `COLUMNS` TEXT NOT NULL, `DESCRIPTION` VARCHAR(255) NULL, + `VISIBLE_COL` TEXT NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=UTF8; \ No newline at end of file From 477a4532f405ce46a04359abc50359c96ee4a8ca Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 17 Jun 2022 09:49:56 +0000 Subject: [PATCH 11/25] missing translation --- plugins/language/en_GB/en_GB.txt | 3 ++- plugins/language/fr_FR/fr_FR.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/language/en_GB/en_GB.txt b/plugins/language/en_GB/en_GB.txt index 4df2d90ba..4f490dbb7 100755 --- a/plugins/language/en_GB/en_GB.txt +++ b/plugins/language/en_GB/en_GB.txt @@ -1836,4 +1836,5 @@ 9905 Error deleting layout 9906 A layout with the same name or columns already exists for your user, please choose another name or set of columns 9907 Manage layouts -9908 Show all layouts \ No newline at end of file +9908 Show all layouts +9909 Add new layout \ No newline at end of file diff --git a/plugins/language/fr_FR/fr_FR.txt b/plugins/language/fr_FR/fr_FR.txt index a4a88c677..9ff16429b 100644 --- a/plugins/language/fr_FR/fr_FR.txt +++ b/plugins/language/fr_FR/fr_FR.txt @@ -1832,4 +1832,5 @@ 9905 Erreur lors de la suppression de la disposition 9906 Une disposition avec le même nom ou les mêmes colonnes existe déjà pour votre utilisateur. Veuillez choisir un autre nom ou d'autres colonnes. 9907 Gestion des dispositions -9908 Afficher les dispositions \ No newline at end of file +9908 Afficher les dispositions +9909 Ajouter une disposition \ No newline at end of file From 7c304ae2145b355ef7ddefe12506cf3162982ba9 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 17 Jun 2022 09:51:25 +0000 Subject: [PATCH 12/25] update column name --- require/function_layout.php | 20 +++++++++++--------- require/function_table_html.php | 2 +- var.php | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/require/function_layout.php b/require/function_layout.php index 076698e07..7fb03aa8a 100644 --- a/require/function_layout.php +++ b/require/function_layout.php @@ -43,7 +43,7 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols, $visib) // check for a layout w/ same name or columns already existing for this user $dupli_check = $this->checkLayout($layout_name, $user, $visib); if (empty($dupli_check)) { - $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS, DESCRIPTION, visible_col) VALUES ('$layout_name', '$user', '".$this->form_name."', '$cols', '$layout_descr', '$visib')"; + $query = "INSERT INTO layouts (LAYOUT_NAME, USER, TABLE_NAME, COLUMNS, DESCRIPTION, VISIBLE_COL) VALUES ('$layout_name', '$user', '".$this->form_name."', '$cols', '$layout_descr', '$visib')"; $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); @@ -66,7 +66,7 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols, $visib) public function getLayout($user, $layout_name) { - $query = "SELECT COLUMNS, visible_col FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; + $query = "SELECT COLUMNS, VISIBLE_COL FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); if ($result) { $layout = mysqli_fetch_array($result); @@ -106,22 +106,24 @@ public function displayLayoutButtons($user, $current_tab, $table) { $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; } - echo ' diff --git a/var.php b/var.php index ab3120c08..d8a7596b5 100644 --- a/var.php +++ b/var.php @@ -73,7 +73,7 @@ /** * OCS' MySQL database version */ -define('GUI_VER', '7062'); +define('GUI_VER', '7063'); /** * GUI Version From 54f725f902aa52ab10df7dc5c24ddd820698733e Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 17 Jun 2022 12:05:15 +0000 Subject: [PATCH 13/25] fix warnings on tab options --- require/function_table_html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index d2a752fbc..da616a886 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -1949,7 +1949,7 @@ function tab_req($list_fields,$default_fields,$list_col_cant_del,$queryDetails,$ } $data = json_encode($tab_options['visible_col']); $customized=false; - if (count($tab_options['visible_col'])!=$visible){ + if (isset($tab_options['visible_col']) && count($tab_options['visible_col'])!=$visible){ $customized=true; setcookie($tab_options['table_name']."_col",$data,time()+31536000); } From 64926a73688f06159c45d92e9231927d55f04154 Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Fri, 17 Jun 2022 12:24:13 +0000 Subject: [PATCH 14/25] add spacing between show/hide and layouts --- require/function_table_html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/require/function_table_html.php b/require/function_table_html.php index da616a886..0a93d2d61 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -252,7 +252,7 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list } } ?> - +
    Date: Mon, 20 Jun 2022 08:48:13 +0000 Subject: [PATCH 15/25] no layouts on multisearch --- require/function_table_html.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/require/function_table_html.php b/require/function_table_html.php index 0a93d2d61..8efbe7b1b 100644 --- a/require/function_table_html.php +++ b/require/function_table_html.php @@ -254,11 +254,14 @@ function ajaxtab_entete_fixe($columns, $default_fields, $option = array(), $list ?>
    displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'], $option['table_name']); $columns = json_decode($cols['COLUMNS'], true) ?? $columns; $visible_col = json_decode($cols['VISIBLE_COL'], true) ?? $visible_col; + } ?> From 55fc63d5f01f8f2983088cc8e9e60d1de838169c Mon Sep 17 00:00:00 2001 From: Lea9250 Date: Mon, 20 Jun 2022 08:52:11 +0000 Subject: [PATCH 16/25] add checks --- .../main_sections/ms_layouts/ms_layouts.php | 2 +- require/function_layout.php | 24 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/plugins/main_sections/ms_layouts/ms_layouts.php b/plugins/main_sections/ms_layouts/ms_layouts.php index e01c0cf55..1bcd9b9db 100644 --- a/plugins/main_sections/ms_layouts/ms_layouts.php +++ b/plugins/main_sections/ms_layouts/ms_layouts.php @@ -64,7 +64,7 @@ } else { echo open_form('layouts', '', '', 'form-horizontal'); //delete layout - if ($protectedPost['SUP_PROF'] != '') { + if (isset($protectedPost['SUP_PROF']) && $protectedPost['SUP_PROF'] != '') { $layout->deleteLayout($protectedPost['SUP_PROF']); $tab_options['CACHE'] = 'RESET'; } diff --git a/require/function_layout.php b/require/function_layout.php index 7fb03aa8a..f09dec32f 100644 --- a/require/function_layout.php +++ b/require/function_layout.php @@ -48,7 +48,7 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols, $visib) $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); // check that layout was inserted - if ($result) { + if (isset($result) && !empty($result)) { msg_success($l->g(9901)); } else { msg_error($l->g(9903)); @@ -61,6 +61,7 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols, $visib) } else { msg_error($l->g(9904)); + return "wrong input"; } } @@ -68,7 +69,7 @@ public function insertLayout($layout_name, $layout_descr, $user, $cols, $visib) public function getLayout($user, $layout_name) { $query = "SELECT COLUMNS, VISIBLE_COL FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."' AND LAYOUT_NAME = '".$layout_name."'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); - if ($result) { + if (isset($result) && !empty($result)) { $layout = mysqli_fetch_array($result); return $layout; } else { @@ -81,7 +82,7 @@ public function deleteLayout($id) { global $l; $query = "DELETE FROM layouts WHERE ID = '$id'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["writeServer"]); - if ($result) { + if (isset($result) && !empty($result)) { msg_success($l->g(9902)); } else { msg_error($l->g(9905)); @@ -99,16 +100,18 @@ public function displayLayoutButtons($user, $current_tab, $table) { // display as many buttons as there are layouts for this user + an extra button to add a new layout $query = "SELECT * FROM layouts WHERE USER = '".$user."' AND TABLE_NAME = '".$this->form_name."'"; $result = mysql2_query_secure($query, $_SESSION['OCS']["readServer"]); - $nb_layouts = mysqli_fetch_all($result, MYSQLI_ASSOC); - $layout_tabs = array(); - foreach ($nb_layouts as $key => $value) { - $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; - } + if (isset($result) && !empty($result)) { + $nb_layouts = mysqli_fetch_all($result, MYSQLI_ASSOC); + $layout_tabs = array(); + foreach ($nb_layouts as $key => $value) { + $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; + } + } // loop through layout_tabs and display a link for each layout if any - if (sizeof($layout_tabs) > 0) { + if (isset($layout_tabs) && sizeof($layout_tabs) > 0) { echo ' + displayLayoutButtons($_SESSION['OCS']['loggeduser'], $protectedPost['layout'], $option['table_name']); + $visible_col = json_decode($cols['VISIBLE_COL'], true) ?? $visible_col; + } + ?> diff --git a/require/header.php b/require/header.php index 4145471b1..05a37297d 100644 --- a/require/header.php +++ b/require/header.php @@ -51,7 +51,7 @@ require_once('require/views/forms.php'); require_once('require/plugin/include.php'); require_once('require/history/History.php'); -require_once('require/function_layout.php'); +require_once('require/layouts/Layout.php'); if (isset($_SESSION['OCS']['CONF_RESET'])) { unset($_SESSION['OCS']['LOG_GUI']); diff --git a/require/function_layout.php b/require/layouts/Layout.php similarity index 84% rename from require/function_layout.php rename to require/layouts/Layout.php index c4e95b6e1..79f6403e5 100644 --- a/require/function_layout.php +++ b/require/layouts/Layout.php @@ -90,7 +90,7 @@ public function deleteLayout($id) { } } - // will get layout to be displayed if any selected + show the layouts buttons + // will get layout to be displayed if any selected + show the layouts select public function displayLayoutButtons($user, $current_tab, $table) { global $l; // if user selected a layout, get the correct columns @@ -110,23 +110,38 @@ public function displayLayoutButtons($user, $current_tab, $table) { $layout_tabs[$value['LAYOUT_NAME']] = $value['LAYOUT_NAME']; } } - echo ''; + echo "".$l->g(9909).""; return $colus; } From f523a3a5806df13627864df71866e1374f08e11e Mon Sep 17 00:00:00 2001 From: Charlene Auger Date: Wed, 22 Jun 2022 09:11:37 +0200 Subject: [PATCH 25/25] Remove debug error_log --- backend/AUTH/methode/local.php | 1 - plugins/main_sections/ms_dict/ms_dict.php | 1 - require/layouts/Layout.php | 2 -- 3 files changed, 4 deletions(-) diff --git a/backend/AUTH/methode/local.php b/backend/AUTH/methode/local.php index b281d7b71..5ea1ca55a 100755 --- a/backend/AUTH/methode/local.php +++ b/backend/AUTH/methode/local.php @@ -62,7 +62,6 @@ if(password_verify($mdp, $rowOp->PASSWD)) { require_once('require/function_users.php'); $update = updatePasswordMd5toHash($login, $mdp); - error_log(print_r($update, true)); if($update) { $login_status = true; } diff --git a/plugins/main_sections/ms_dict/ms_dict.php b/plugins/main_sections/ms_dict/ms_dict.php index 0944150ed..7cab9a514 100644 --- a/plugins/main_sections/ms_dict/ms_dict.php +++ b/plugins/main_sections/ms_dict/ms_dict.php @@ -166,7 +166,6 @@ $querydico .= $value . ','; } } - error_log($list_cat[$protectedPost['onglet_soft']]); $querydico = substr($querydico, 0, -1); $querydico .= " from dico_soft left join " . $table . " cache on dico_soft.extracted=cache.name where formatted='" . mysqli_real_escape_string($_SESSION['OCS']["readServer"], $list_cat[$protectedPost['onglet_soft']]) . "' " . $search_count . " group by EXTRACTED"; diff --git a/require/layouts/Layout.php b/require/layouts/Layout.php index 79f6403e5..63896b9a4 100644 --- a/require/layouts/Layout.php +++ b/require/layouts/Layout.php @@ -124,9 +124,7 @@ public function displayLayoutButtons($user, $current_tab, $table) { if (isset($current_tab) && $current_tab == $value) { echo " selected"; - error_log('selected'); }elseif(!isset($current_tab) && $value == '----'){ - error_log('not selected'); echo " selected"; } echo ">$value";