From e87e89262f97d780232eaec9652a1a0b0265b12f Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Sat, 3 Sep 2011 14:40:48 +0000 Subject: [PATCH] Qual: Uniformize code --- htdocs/bookmarks/admin/bookmark.php | 33 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/htdocs/bookmarks/admin/bookmark.php b/htdocs/bookmarks/admin/bookmark.php index 6acc2617520..995fa21af76 100644 --- a/htdocs/bookmarks/admin/bookmark.php +++ b/htdocs/bookmarks/admin/bookmark.php @@ -1,7 +1,8 @@ * Copyright (C) 2005-2009 Laurent Destailleur - * + * Copyright (C) 2011 Juanjo Menent + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -29,18 +30,25 @@ $langs->load("admin"); if (!$user->admin) accessforbidden(); +$action=GETPOST("action"); -if ($_POST["action"] == 'setvalue' && $user->admin) +if ($action == 'setvalue') { - $result=dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU",$_POST["BOOKMARKS_SHOW_IN_MENU"],'chaine',0,'',$conf->entity); - if ($result >= 0) - { - $mesg='
'.$langs->trans("SetupSaved").'
'; - } - else - { - dol_print_error($db); + $showmenu = GETPOST("BOOKMARKS_SHOW_IN_MENU"); + $res = dolibarr_set_const($db, "BOOKMARKS_SHOW_IN_MENU",$showmenu,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $db->commit(); + $mesg = "".$langs->trans("SetupSaved").""; } + else + { + $db->rollback(); + $mesg = "".$langs->trans("Error").""; + } } @@ -56,9 +64,6 @@ print_fiche_titre($langs->trans("BookmarkSetup"),$linkback,'setup'); print $langs->trans("BookmarkDesc")."
\n"; - -if ($mesg) print '
'.$mesg; - print '
'; print '
'; print ''; @@ -80,6 +85,8 @@ print ''; print ''; print '
'; +dol_htmloutput_mesg($mesg); + $db->close(); llxFooter();