diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php index 17263261056..5cbf34fd13c 100644 --- a/htdocs/bookmarks/fiche.php +++ b/htdocs/bookmarks/fiche.php @@ -28,12 +28,14 @@ require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; $langs->load("other"); -$action=GETPOST("action"); -$title=GETPOST("title"); -$url=GETPOST("url"); -$target=GETPOST("target"); -$userid=GETPOST("userid"); -$position=GETPOST("position"); +$id=GETPOST("id"); +$action=GETPOST("action","alpha"); +$title=GETPOST("title","alpha"); +$url=GETPOST("url","alpha"); +$target=GETPOST("target","alpha"); +$userid=GETPOST("userid","int"); +$position=GETPOST("position","int"); +$backtopage=GETPOST('backtopage','alpha'); /* @@ -42,10 +44,10 @@ $position=GETPOST("position"); if ($action == 'add' || $action == 'addproduct' || $action == 'update') { - if ($_POST["cancel"]) + if (GETPOST("cancel")) { - $urlsource=(! empty($_REQUEST["urlsource"]))?$_REQUEST["urlsource"]:((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php'); - header("Location: ".$urlsource); + if (empty($backtopage)) $backtopage=(GETPOST("urlsource")?GETPOST("urlsource"):((! empty($url))?$url:DOL_URL_ROOT.'/bookmarks/liste.php')); + header("Location: ".$backtopage); exit; } @@ -71,8 +73,8 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') if ($res > 0) { - $urlsource=! empty($_REQUEST["urlsource"])?urldecode($_REQUEST["urlsource"]):DOL_URL_ROOT.'/bookmarks/liste.php'; - header("Location: ".$urlsource); + if (empty($backtopage)) $backtopage=(GETPOST("urlsource")?GETPOST("urlsource"):DOL_URL_ROOT.'/bookmarks/liste.php'); + header("Location: ".$backtopage); exit; } else @@ -96,7 +98,7 @@ if ($action == 'add' || $action == 'addproduct' || $action == 'update') } } -if ($_GET["action"] == 'delete') +if ($action == 'delete') { $bookmark=new Bookmark($db); $bookmark->id=$_GET["bid"]; @@ -133,10 +135,10 @@ if ($action == 'create') * Fact bookmark creation mode */ - print '
'."\n"; + print ''."\n"; print ''; print ''; - + print_fiche_titre($langs->trans("NewBookmark")); dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark'); @@ -176,24 +178,25 @@ if ($action == 'create') } -if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) +if ($id > 0 && ! preg_match('/^add/i',$action)) { /* * Fact bookmark mode or visually edition */ $bookmark=new Bookmark($db); - $bookmark->fetch($_GET["id"]); + $bookmark->fetch($id); dol_fiche_head($head, $hselected, $langs->trans("Bookmark"),0,'bookmark'); - if ($_GET["action"] == 'edit') + if ($action == 'edit') { print ''; print ''; print ''; print ''; print ''; + print ''; } print ''; @@ -201,17 +204,17 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) print ''; print ''; print ''; print ''; print ''; @@ -254,9 +257,9 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) print '
'.$langs->trans("Ref").''.$bookmark->ref.'
'.$langs->trans("BookmarkTitle").''; - if ($_GET["action"] == 'edit') print 'title).'">'; + if ($action == 'edit') print 'title).'">'; else print $bookmark->title; print '
'.$langs->trans("UrlOrLink").''; - if ($_GET["action"] == 'edit') print 'url).'">'; + if ($action == 'edit') print 'url).'">'; else print 'target?' target="_blank"':'').'>'.$bookmark->url.''; print '
'.$langs->trans("BehaviourOnClick").''; - if ($_GET["action"] == 'edit') + if ($action == 'edit') { $liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); print $form->selectarray('target',$liste,isset($_POST["target"])?$_POST["target"]:$bookmark->target); @@ -224,7 +227,7 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) print '
'.$langs->trans("Owner").''; - if ($_GET["action"] == 'edit' && $user->admin) + if ($action == 'edit' && $user->admin) { $form->select_users(isset($_POST['userid'])?$_POST['userid']:($bookmark->fk_user?$bookmark->fk_user:''),'userid',1); } @@ -245,7 +248,7 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) // Position print '
'.$langs->trans("Position").''; - if ($_GET["action"] == 'edit') print 'position).'">'; + if ($action == 'edit') print 'position).'">'; else print $bookmark->position; print '
'; - if ($_GET["action"] == 'edit') print '
   
'; + if ($action == 'edit') print '
   
'; - if ($_GET["action"] == 'edit') print '
'; + if ($action == 'edit') print ''; dol_fiche_end(); @@ -264,13 +267,13 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) print "
\n"; // Edit - if ($user->rights->bookmark->creer && $_GET["action"] != 'edit') + if ($user->rights->bookmark->creer && $action != 'edit') { print " id."&action=edit\">".$langs->trans("Edit")."\n"; } // Remove - if ($user->rights->bookmark->supprimer && $_GET["action"] != 'edit') + if ($user->rights->bookmark->supprimer && $action != 'edit') { print " id."&action=delete\">".$langs->trans("Delete")."\n"; } @@ -279,8 +282,8 @@ if ($_GET["id"] > 0 && ! preg_match('/^add/i',$_GET["action"])) } -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/bookmarks/liste.php b/htdocs/bookmarks/liste.php index 8e3d0ea9e92..c9a6dff9ca2 100644 --- a/htdocs/bookmarks/liste.php +++ b/htdocs/bookmarks/liste.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005-2012 Laurent Destailleur * * 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 @@ -170,7 +170,11 @@ if ($resql) print ''.$obj->position.""; // Actions - print ''; + print ''; + if ($user->rights->bookmark->creer) + { + print "bid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()." "; + } if ($user->rights->bookmark->supprimer) { print "bid\">".img_delete()."";