[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 03/14: Fix issue when delete a menu with subm
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 03/14: Fix issue when delete a menu with submenu , remove properly all direct and indirect children |
Date: |
Wed, 28 Oct 2015 09:56:55 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 70383a2ca66b188cb0371c7389084571a63cee8c
Author: Dany De Bontridder <address@hidden>
Date: Sun Oct 25 18:11:45 2015 +0100
Fix issue when delete a menu with submenu , remove properly all direct and
indirect children
---
include/ajax/ajax_remove_submenu.php | 8 +++++++-
include/profile.inc.php | 12 ++++++++++--
sql/upgrade.sql | 5 ++++-
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/include/ajax/ajax_remove_submenu.php
b/include/ajax/ajax_remove_submenu.php
index 9247301..137896b 100644
--- a/include/ajax/ajax_remove_submenu.php
+++ b/include/ajax/ajax_remove_submenu.php
@@ -27,5 +27,11 @@ if ($g_user->check_module('CFGPRO')==0)
die();
$p_profile_menu_id=HtmlInput::default_value_get('p_profile_menu_id', 0);
if ( $p_profile_menu_id == 0 ||isNumber($p_profile_menu_id)==0) throw new
Exception(_('Donnée invalide'));
-$cn->exec_sql('delete from profile_menu where pm_id = $1 or
pm_id_dep=$1',array($p_profile_menu_id))
+// Delete menu + children
+$cn->exec_sql('delete from profile_menu where pm_id = $1 or
pm_id_dep=$1',array($p_profile_menu_id));
+
+// remove child without parent
+$cn->exec_sql("delete from profile_menu "
+ . " where pm_id_dep is not null "
+ . " and pm_id_dep not in (select pm_id from profile_menu)");
?>
\ No newline at end of file
diff --git a/include/profile.inc.php b/include/profile.inc.php
index e2c57da..5e98120 100644
--- a/include/profile.inc.php
+++ b/include/profile.inc.php
@@ -206,7 +206,7 @@ if (isset($_POST['delete_profil']))
}
}
//************************************
-// Modify the menu or delete it
+// Modify the menu
//************************************
if (isset($_POST['mod']))
{
@@ -345,7 +345,15 @@ if
(isset($_POST['add_menu'])||isset($_POST['add_impress']))
* if me_code_dep == -1, it means it is null
*/
$me_code_dep=($me_code_dep==-1)?null:$me_code_dep;
-
+
+ /*
+ * Do not insert twice the same menu
+ */
+ $duplicate = $cn->get_value(" select count(*) from profile_menu where "
+ . " pm_id_dep = $1 and me_code = $2",array($p_dep,$me_code));
+ if ( $duplicate > 0 ) {
+ throw new Exception(_('Doublon'));
+ }
$pm_default=(isset($pm_default))?1:0;
$cn->exec_sql("
insert into profile_menu
(me_code,me_code_dep,p_id,p_order,pm_default,p_type_display,pm_id_dep)
diff --git a/sql/upgrade.sql b/sql/upgrade.sql
index 298cfe8..a5fd965 100644
--- a/sql/upgrade.sql
+++ b/sql/upgrade.sql
@@ -301,4 +301,7 @@ begin
end;
$BODY$
-LANGUAGE plpgsql ;
\ No newline at end of file
+LANGUAGE plpgsql ;
+
+
+delete from profile_menu where pm_id_dep is not null and pm_id_dep not in
(select pm_id from profile_menu);
\ No newline at end of file
- [Noalyss-commit] [noalyss] branch master updated (08827e1 -> a3fd1a9), Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 01/14: Protect $_POST variable, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 03/14: Fix issue when delete a menu with submenu , remove properly all direct and indirect children,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 07/14: Sort of the ledger in search, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 08/14: Bug : in follow-up , error in security can_add_action, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 02/14: Reinforce and Protect ajax, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 05/14: Select has a new attribute : size, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 10/14: Bug : in follow-up , error in security can_add_action, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 11/14: Bug : in export card, the textarea was not exported in CSV properly, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 12/14: Bug : in export card, the textarea was not exported in CSV properly, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 06/14: Select has already undocumented rowsize attribute , changes reversed, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 09/14: Bug : in follow-up , error in security can_add_action, Dany De Bontridder, 2015/10/28
- [Noalyss-commit] [noalyss] 14/14: indent, Dany De Bontridder, 2015/10/28