diff --git a/htdocs/bookmarks/fiche.php b/htdocs/bookmarks/fiche.php index 9d26c0eeba2..6414b119cc4 100644 --- a/htdocs/bookmarks/fiche.php +++ b/htdocs/bookmarks/fiche.php @@ -18,12 +18,12 @@ * * $Id$ * $Source$ - * */ /** - \file htdocs/comm/bookmark.php - \brief Page affichage des bookmarks + \file htdocs/bookmarks/fiche.php + \brief Page affichage/creation des bookmarks + \ingroup bookmark \version $Revision$ */ @@ -31,13 +31,22 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/bookmarks/bookmark.class.php"); +$langs->load("other"); + +$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$title=isset($_GET["title"])?$_GET["title"]:$_POST["title"]; +$url=isset($_GET["url"])?$_GET["url"]:$_POST["url"]; +$target=isset($_GET["target"])?$_GET["target"]:$_POST["target"]; + /* * Actions */ - -if ($_GET["action"] == 'add') + +if ($action == 'add') { + $mesg=''; + $bookmark=new Bookmark($db); $bookmark->fk_user=$user->id; if ($_GET["socid"]) // Lien vers fiche comm société @@ -47,27 +56,41 @@ if ($_GET["action"] == 'add') $societe->fetch($_GET["socid"]); $bookmark->fk_soc=$societe->id; $bookmark->url=DOL_URL_ROOT.'/comm/fiche.php?socidp='.$societe->id; - $bookmark->target=''; + $bookmark->target='0'; $bookmark->title=$societe->nom; } else { - $bookmark->url=$_GET["url"]; - $bookmark->target=$_GET["target"]; - $bookmark->title=$_GET["title"]; + if (! $title) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("BookmarkTitle")); + if (! $url) $mesg.=($mesg?'
':'').$langs->trans("ErrorFieldRequired",$langs->trans("UrlOrLink")); + + $bookmark->title=$title; + $bookmark->url=$url; + $bookmark->target=$target; } - $bookmark->favicon='xxx'; - - $res=$bookmark->create(); - if ($res > 0) + + if (! $mesg) { - $urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:$_SERVER["PHP_SELF"]; - header("Location: ".$urlsource); + $bookmark->favicon='xxx'; + + $res=$bookmark->create(); + if ($res > 0) + { + $urlsource=isset($_GET["urlsource"])?$_GET["urlsource"]:DOL_URL_ROOT.'/bookmarks/liste.php'; + header("Location: ".$urlsource); + } + else + { + $mesg='
'.$bookmark->error.'
'; + $action='create'; + } } else { - $mesg='
'.$bookmark->error.'
'; + $mesg='
'.$mesg.'
'; + $action='create'; } + } if ($_GET["action"] == 'delete') @@ -94,13 +117,76 @@ if ($_GET["action"] == 'delete') llxHeader(); -print_fiche_titre($langs->trans("Bookmarks")); - +$html=new Form($db); -print 'En construction'; +if ($action == 'create') +{ + /* + * Fiche bookmark en mode creation + */ + + print '
'."\n"; + print ''; + + print_fiche_titre($langs->trans("NewBookmark")); + + if ($mesg) print "$mesg
"; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("BookmarkTitle").''.$langs->trans("SetHereATitleForLink").'
'.$langs->trans("UrlOrLink").''.$langs->trans("UseAnExternalHttpLinkOrRelativeDolibarrLink").'
'.$langs->trans("BehaviourOnClick").''; + $liste=array(1=>$langs->trans("OpenANewWindow"),0=>$langs->trans("ReplaceWindow")); + $html->select_array('target',$liste,1); + print ''.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'
'; + + print '
'; +} + + +if ($_GET["id"] > 0) +{ + /* + * Fiche bookmark en mode edition + */ + $bookmark=new Bookmark($db); + $bookmark->fetch($_GET["id"]); + + + dolibarr_fiche_head($head, $hselected, $langs->trans("Bookmark")); + + print ''; + + print ''; + print ''; + print ''; + print '
'.$langs->trans("BookmarkTitle").''.$bookmark->title.'
'.$langs->trans("UrlOrLink").''; + print ''.$bookmark->url.'
'.$langs->trans("BehaviourOnClick").''; + if ($bookmark->target == 0) print $langs->trans("OpenANewWindow"); + if ($bookmark->target == 1) print $langs->trans("ReplaceWindow"); + print '
'; + + print "\n"; + + print "
\n"; + + // Supprimer + if ($user->rights->bookmark->supprimer) + { + print " id."&action=delete\">".$langs->trans("Delete")."\n"; + } + + print '
'; + +} $db->close(); + llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/bookmarks/liste.php b/htdocs/bookmarks/liste.php index 5fee4cb7a19..ab0306e4fca 100644 --- a/htdocs/bookmarks/liste.php +++ b/htdocs/bookmarks/liste.php @@ -22,6 +22,7 @@ /** \file htdocs/bookmarks/liste.php \brief Page affichage des bookmarks + \ingroup bookmark \version $Revision$ */ @@ -75,7 +76,7 @@ $sql = "SELECT b.fk_soc as idp, ".$db->pdate("b.dateb")." as dateb, b.rowid as b $sql.= " u.name, u.firstname, u.code"; $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b, ".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE b.fk_user=u.rowid"; -if (! $user->admin) $sql.= " AND b.fk_user = ".$user->id; +if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL)"; $sql.= " ORDER BY $sortfield $sortorder " . $db->plimit( $limit, $offset); $resql=$db->query($sql); @@ -89,8 +90,9 @@ if ($resql) print ""; //print " "; print_liste_field_titre($langs->trans("Id"),$_SERVER["PHP_SELF"],"bid","","",'align="left"',$sortfield); - print "".$langs->trans("Title").""; - print "".$langs->trans("Link").""; + print ''.$langs->trans("Title").""; + print ''.$langs->trans("Link").""; + print ''.$langs->trans("Target").""; print_liste_field_titre($langs->trans("Author"),$_SERVER["PHP_SELF"],"u.name","","","",$sortfield); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"b.dateb","","",'align="center"',$sortfield); print " "; @@ -137,20 +139,34 @@ if ($resql) // Url print ""; - if (! $lieninterne) print "url."\">"; + if (! $lieninterne) print 'target?' target="newlink"':'').'>'; print $lien; - if (! $lieninterne) print ""; + if (! $lieninterne) print ''; + print "\n"; + + // Target + print ''; + if ($obj->target == 0) print $langs->trans("BookmarkTargetReplaceWindowShort"); + if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort"); print "\n"; // Auteur - print "".img_object($langs->trans("ShowUser"),"user").' '.$obj->code."\n"; - + print '".img_object($langs->trans("ShowUser"),"user").' '.$obj->code."\n"; + // Date creation print ''.dolibarr_print_date($obj->dateb) .""; // Actions - print "bid\">".img_delete()."\n"; - + print ""; + if ($user->rights->bookmark->supprimer) + { + print "bid\">".img_delete().""; + } + else + { + print " "; + } + print ""; print "\n"; $i++; } diff --git a/htdocs/bookmarks/pre.inc.php b/htdocs/bookmarks/pre.inc.php index cb251141e56..b56f8cecf76 100644 --- a/htdocs/bookmarks/pre.inc.php +++ b/htdocs/bookmarks/pre.inc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2005 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 @@ -40,10 +40,13 @@ function llxHeader($head = "", $title = "") $menu = new Menu(); // Bookmarks - $menu->add(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("Bookmarks")); - $menu->add_submenu(DOL_URL_ROOT."/bookmarks/fiche.php?action=create", $langs->trans("NewBookmark")); - $menu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("List")); - + if ($conf->bookmark->enabled) + { + if ($user->rights->bookmark->lire) $menu->add(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("Bookmarks")); + if ($user->rights->bookmark->creer) $menu->add_submenu(DOL_URL_ROOT."/bookmarks/fiche.php?action=create", $langs->trans("NewBookmark")); + if ($user->rights->bookmark->lire) $menu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("List")); + } + left_menu($menu->liste); } ?> diff --git a/htdocs/includes/menus/barre_left/eldy.php b/htdocs/includes/menus/barre_left/eldy.php index 809a30ad355..5862075339b 100644 --- a/htdocs/includes/menus/barre_left/eldy.php +++ b/htdocs/includes/menus/barre_left/eldy.php @@ -545,11 +545,14 @@ class MenuLeft { $newmenu->add_submenu(DOL_URL_ROOT."/comm/mailing/liste.php?leftmenu=mailing", $langs->trans("List"), 1, $user->rights->mailing->lire); } - $langs->load("other"); - $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php?leftmenu=bookmarks", $langs->trans("Bookmarks"), 0, 1); - $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/fiche.php?action=create", $langs->trans("NewBookmark")); - $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("List")); - + if ($conf->bookmark->enabled) + { + $langs->load("other"); + $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php?leftmenu=bookmarks", $langs->trans("Bookmarks"), 0, $user->rights->bookmark->lire); + $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/fiche.php?action=create", $langs->trans("NewBookmark"), 1, $user->rights->bookmark->creer); + $newmenu->add_submenu(DOL_URL_ROOT."/bookmarks/liste.php", $langs->trans("List"), 1, $user->rights->bookmark->lire); + } + $newmenu->add_submenu(DOL_URL_ROOT."/exports/index.php?leftmenu=export",$langs->trans("Exports"),0,1); } diff --git a/htdocs/includes/modules/modBookmark.class.php b/htdocs/includes/modules/modBookmark.class.php index bbe51db2013..b3ad970f720 100644 --- a/htdocs/includes/modules/modBookmark.class.php +++ b/htdocs/includes/modules/modBookmark.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2005 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 @@ -21,13 +22,13 @@ /** \defgroup bookmark Module Bookmark - \brief Module pour gérer l'addon Bookmark + \brief Module pour gérer les Bookmarks */ /** \file htdocs/includes/modules/modBookmark.class.php \ingroup bookmark - \brief Fichier de description et activation du module Bookmark + \brief Fichier de description et activation du module Bookmarks */ include_once "DolibarrModules.class.php"; @@ -47,13 +48,13 @@ class modBookmark extends DolibarrModules function modBookmark($DB) { $this->db = $DB ; - $this->numero = 67 ; + $this->numero = 330; $this->family = "technic"; $this->name = "Bookmarks"; $this->description = "Gestion des Bookmarks"; $this->revision = explode(" ","$Revision$"); - $this->version = $this->revision[1]."(DEV)"; + $this->version = $this->revision[1]; $this->const_name = "MAIN_MODULE_BOOKMARK"; $this->const_config = MAIN_MODULE_BOOKMARK; @@ -79,6 +80,29 @@ class modBookmark extends DolibarrModules // Permissions $this->rights = array(); $this->rights_class = 'bookmark'; + $r=0; + + $r++; + $this->rights[$r][0] = 331; // id de la permission + $this->rights[$r][1] = 'Lire les bookmarks'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (déprécié à ce jour) + $this->rights[$r][3] = 1; // La permission est-elle une permission par défaut + $this->rights[$r][4] = 'lire'; + + $r++; + $this->rights[$r][0] = 332; // id de la permission + $this->rights[$r][1] = 'Creer/modifier les bookmarks'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (déprécié à ce jour) + $this->rights[$r][3] = 1; // La permission est-elle une permission par défaut + $this->rights[$r][4] = 'creer'; + + $r++; + $this->rights[$r][0] = 333; // id de la permission + $this->rights[$r][1] = 'Supprimer les bookmarks'; // libelle de la permission + $this->rights[$r][2] = 'r'; // type de la permission (déprécié à ce jour) + $this->rights[$r][3] = 1; // La permission est-elle une permission par défaut + $this->rights[$r][4] = 'supprimer'; + } /** diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 81594db5919..d66e6b6faaf 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -81,8 +81,6 @@ Module58Name=ClickToDial Module58Desc=ClickToDial integration Module59Name=Bookmark4u Module59Desc=Add function to generate Bookmark4u account from a Dolibarr account -Module67Name=Bookmarks -Module67Desc=Bookmarks' management Module70Name=Interventions Module70Desc=Interventions' management Module75Name=Trips @@ -103,6 +101,8 @@ Module310Name=Members Module310Desc=Foundation members management Module320Name=RSS Flux Module320Desc=Add RSS flux inside Dolibarr screen pages +Module330Name=Bookmarks +Module330Desc=Bookmarks' management Module400Name=Projects Module400Desc=Projects' management inside other modules Module410Name=Webcalendar @@ -185,6 +185,9 @@ Permission233=Delete supplier invoices Permission300=Read bar codes Permission301=Create/modify bar codes Permission302=Delete bar codes +Permission331=Read bookmarks +Permission332=Create/modify bookmarks +Permission333=Delete bookmarks Permission700=Read donations Permission701=Create/modify donations Permission702=Delete donations diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index 624b5e7d849..a034b69238a 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -25,4 +25,15 @@ Bookmark=Bookmark Bookmarks=Bookmarks NewBookmark=New bookmark ShowBookmark=Show bookmark -BookmarkThisPage=Bookmark this page \ No newline at end of file +BookmarkThisPage=Bookmark this page +OpenANewWindow=Open a new window +ReplaceWindow=Replace current window +BookmarkTargetNewWindowShort=New window +BookmarkTargetReplaceWindowShort=Current window +BookmarkTitle=Bookmark title +UrlOrLink=URL +BehaviourOnClick=Behaviour on click on URL +CreateBookmark=Create bookmark +SetHereATitleForLink=Set here a title for bookmark +UseAnExternalHttpLinkOrRelativeDolibarrLink=Use an external http URL or a relative Dolibarr URL +ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if page opened by link must appear on current or new window \ No newline at end of file diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 101838e2a9a..beb74e16dbc 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -81,8 +81,6 @@ Module58Name=ClickToDial Module58Desc=Intégration de ClickToDial Module59Name=Bookmark4u Module59Desc=Ajoute fonction pour générer un compte Bookmark4u depuis un compte Dolibarr -Module67Name=Bookmarks -Module67Desc=Gestion des bookmarks Module70Name=Interventions Module70Desc=Gestion des interventions Module75Name=Déplacements @@ -103,6 +101,8 @@ Module310Name=Adh Module310Desc=Gestion des adhérents d'une association Module320Name=Fils RSS Module320Desc=Ajout de fils d'informations RSS dans les écrans Dolibarr +Module330Name=Bookmarks +Module330Desc=Gestion des marque-pages Module400Name=Projets Module400Desc=Gestion des projets au sein des autres modules Module410Name=Webcalendar @@ -185,6 +185,9 @@ Permission233=Supprimer les factures fournisseurs Permission300=Consulter les codes barres Permission301=Créer/modifier les codes barres Permission302=Supprimer les codes barres +Permission331=Lire les bookmarks +Permission332=Créer/modifier les bookmarks +Permission333=Supprimer les bookmarks Permission700=Consulter les dons Permission701=Créer/modifier les dons Permission702=Supprimer les dons diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 38bc817a4cc..f07f89ee891 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -25,4 +25,15 @@ Bookmark=Marque page Bookmarks=Marque pages NewBookmark=Nouveau marque page ShowBookmark=Afficher marque page -BookmarkThisPage=Marquer cette page dans ces favoris \ No newline at end of file +BookmarkThisPage=Marquer cette page dans ces favoris +OpenANewWindow=Ouvrir une nouvelle fenêtre +ReplaceWindow=Remplacer fenêtre courante +BookmarkTargetNewWindowShort=Nouvelle fenêtre +BookmarkTargetReplaceWindowShort=Fenêtre courante +BookmarkTitle=Titre du marque page +UrlOrLink=URL +BehaviourOnClik=Comportement sur click de l'URL +CreateBookmark=Créer bookmark +SetHereATitleForLink=Saisir ici un titre pour le marque page +UseAnExternalHttpLinkOrRelativeDolibarrLink=Saisir une URL http externe ou une URL Dolibarr relative +ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choisir si le raccourci doit ouvrir la page dans une nouvelle fenêtre ou fenêtre courante \ No newline at end of file