Fix issue when delete a menu with submenu , remove properly all direct and indirect children
This commit is contained in:
parent
f4ebb0664e
commit
70383a2ca6
3 changed files with 21 additions and 4 deletions
|
|
@ -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)");
|
||||
?>
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -301,4 +301,7 @@ begin
|
|||
|
||||
end;
|
||||
$BODY$
|
||||
LANGUAGE plpgsql ;
|
||||
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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue